Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 11 of 11

Thread: Code Check

  1. #1
    Join Date
    Feb 2006
    Posts
    346

    Code Check

    Hello,

    I have an image in my project that I want to change out depending on user name. I did not want to imput the full user name - just limit to the first 4 or 5 letters. Then, If not WELL or ITAD then use this image. Is there a better way to do this. The below code does not work with error; Line 5: Argument must be of type String. Any help would be great - Thanks


    Code:
    --Get user name
    NAME = System.GetUserInfo(); 
    NAME1 = (NAME.User);
    
    -- (2) Narrow Result to the first 4 letters
    NAME1 = String.Mid(NAME1, 1, 4);
    
    -- (3) Compare and change image
    if NAME1 == "well" then      Image.Load("Image16", "AutoPlay\\Images\\User.png");
                                   
    elseif NAME1 == "itad" then  Image.Load("Image16", "AutoPlay\\Images\\Secuty-agent.png");
                                   
    elseif NAME1 == "" then       Image.Load("Image16", "AutoPlay\\Images\\People.png");
    end

  2. #2
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    One way would be to set up your abbreviated name and images in a table where name one associates to images1 , etc.

    Code:
    tblNames={"well","itad"}
    tblMax=Table.Count(tblNames)
    tblImages={"User.png","Secuty-agent.png"}
    
    for x = 1, tblMax do
    	if NAME1 == tblNames[x] then
    		Image.Load("Image16", "AutoPlay\\Images\\"..tblImages[x])
    		Image.SetVisible("Image16", true)
    	else
                    Image.Load("Image16", "AutoPlay\\Images\\default.png")
    		Image.SetVisible("Image16", true)	
    	end
    end
    hth

    PS:

    NAME.User is not a valid return parameter from System.GetUserInfo maybe try .RegOwner...
    Last edited by holtgrewe; 02-17-2009 at 09:38 AM. Reason: PS

  3. #3
    Join Date
    Feb 2006
    Posts
    346
    Thanks for the quick reply - I tried your code but was not able to make it work. Is there something missing??? Thanks again.

  4. #4
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    Yeah, check the PS in my message - The code works, but not with NAME.User (Where did you find that?)...

  5. #5
    Join Date
    Feb 2006
    Posts
    346
    Okay this is were I get confused. I tried modifying a code that I already have working (see code below). I seem to get confused on using the right syntax. I looked at AMS help - still confused. I guess the right question to ask is how would you do it? We use Novell Client . I was trying to get the username ie; ITADMIN (itad) if = itad then load this image etc.. I got the below code from Mina sometime back. Thanks again...

    I have this code that currently works on a button

    Code:
    -- Get User and LAN info to dispaly in a dialog--
    name = System.GetUserInfo(); 
    name1 = (User.User);
    
    LANINFO = System.GetLANInfo();
    LAN = (LANINFO.Host);
    
    name2 = name1.." and computer station "..LAN
    
    Dialog.Message("Status", "Your user information is being logged for security purposes only.\r\n\r\nYou are being logged as user "..name2..".", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    Thno On Preload I have this code
    Code:
    --------write to log file------
    LANINFO = System.GetLANInfo();
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", LANINFO.Host.."\r\n", true);  
    
    name = System.GetUserInfo(); 
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", name.RegOwner.."\r\n", true);
    
    IPinfo = System.GetLANInfo();
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", IPinfo.IP.."\r\n", true);
    
    User = System.GetLANInfo();
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", User.User.."\r\n", true)
    
    result = System.GetDate(DATE_FMT_US);
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", result.."\r\n", true)
    
    result1 = System.GetTime(TIME_FMT_MIL);
    TextFile.WriteFromString("AutoPlay\\Docs\\Logs\\HomeLog.dat", result1.."\r\n", true)
    
    --------------------------------------------------------------Display User info --------------------------
    
    name1 = System.GetUserInfo(); 
    Label.SetText("UserInfo1", User.User);
    
    LANINFO = System.GetLANInfo();
    Label.SetText("LanInfo", LANINFO.Host);

  6. #6
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    http://www.indigorose.com/forums/sho...ight=User.User

    If you can find out what User.User is and where it comes from in your project, the rest should be easy...

    If it's possible to post that project I'm certain someone can help...

  7. #7
    Join Date
    Feb 2006
    Posts
    346
    I attached a sample project with the code User.User.

    Still unable to figure out how to change the image by username.

    Thanks again!
    Attached Files

  8. #8
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    I don't see how some of that is working. I would open a ticket with IR. The way User.User is being used, and appears to be working, it seems you have been using some undocumented resources.

    Sorry I can't be of further assistance.

  9. #9
    Join Date
    Feb 2006
    Posts
    346
    Thanks for your time.

  10. #10
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    We have gone through this with him just last week. User.User is defined else where.

    Also you don't need to call System.GetLANInfo() over and over. Once is enough. Just access the different table values returned.

    As I told you last week, name = System.GetUserInfo() is not being used at all. The whole thing is a mess and very confusing.
    Dermot

    I am so out of here

  11. #11
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    Without complicating things any further, if you place this on your (button/image) on-click, it should work with what you currently have.

    Code:
    Get User and LAN info to diaply in a dialog--
    name = System.GetUserInfo(); 
    name1 = (User.User);
    
    LANINFO = System.GetLANInfo();
    LAN = (LANINFO.Host);
    
    name2 = name1.." and computer station "..LAN
    
    Dialog.Message("Status", "Your user information is being logged for security purposes only.\r\n\r\nYou are being logged as user "..name2..".", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    if String.Left(name1,4) == 'abcd' then 
    	Image.Load("Image16", "AutoPlay\\Images\\abcdefghi.PNG")
    --elseif etc...	
    end

Similar Threads

  1. Code Check requested? (re. FTP)
    By mystica in forum AutoPlay Media Studio 7.5
    Replies: 3
    Last Post: 09-29-2008, 01:52 AM
  2. Article: Using Authenticode Code Signing Certificates
    By Ted Sullivan in forum Setup Factory 8.0 Examples
    Replies: 4
    Last Post: 10-31-2007, 09:03 AM
  3. New Check Boxes on Preload code
    By civil78 in forum Setup Factory 7.0
    Replies: 3
    Last Post: 03-16-2006, 09:57 AM
  4. Need a code that will check for installed programs.
    By Quantrac in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 02-07-2005, 12:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts