PDA

View Full Version : Syntax Help/Check


abnrange
02-12-2009, 08:26 PM
Hello,

I have a button and on click I would like it to get the user name and display in a dialog. I have this code but something is missing (User.User). Thanks

name = System.GetUserInfo();
Dialog.TimedMessage("Please Wait", "User information is being logged for security purposes. You are logged as"..name..".", 4000, MB_ICONINFORMATION);

Dermot
02-12-2009, 08:48 PM
System.GetUserInfo() returns a table. The help file is an amazing thing. With a single click you would have had seen that, and how the returned table is indexed.

abnrange
02-12-2009, 08:53 PM
I did look at the help first. I don't understand how to table User.User

I was able to get this to work to output to a label. I thought it would be similiar to a dialog.

name = System.GetUserInfo();
Label.SetText("UserInfo1", User.User);


Sorry, Still learning...

abnrange
02-12-2009, 08:57 PM
I figured it out Thanks

name = System.GetUserInfo();
name1 = (User.User);
Dialog.TimedMessage("Please Wait", "User infromation is being logged for security purposes. You are logged as "..name1..".", 4000, MB_ICONINFORMATION);

Dermot
02-12-2009, 09:01 PM
From the help, this is what System.GetUserInfo() returns.

RegOwner
string
The registered owner of the system. If this information cannot be determined, an empty string will be returned.

RegOrganization
string
The organization of the registered owner of the system. If this information cannot be determined, an empty string will be returned.

IsAdmin
boolean
Whether the current user is logged into Windows NT/2000/XP/Vista with Administrator permissions. True will be returned if the user has administrator permissions and false if they do not. On non-NT operating systems, true will always be returned. If this information cannot be determined, false will be returned.

Note: On Windows Vista, with UAC enabled, administrators are logged in with standard user privileges with the ability to elevate. This will determine if the user has already been elevated to the full access token. See Running On Windows Vista for more information.

IsVistaAdminLimitedToken
boolean
Returns True if the current user on Windows Vista (only) is part of the administrator's group, but only contains a standard user access token (has not been elevated to full administrator privileges). False is returned if UAC (User Account Control) is off, or if the user has already been elevated. For all non-Vista operating systems, the result will be the same as the normal administrator check IsAdmin as mentioned above.

There is no User field. You can't just makeup fields. If it is not listed in the help file then it does not exist. The table returned by System.GetLANInfo () does have a User field.

name = System.GetLANInfo();
Label.SetText("UserInfo1", name.User);

Dermot
02-12-2009, 09:07 PM
I figured it out Thanks

name = System.GetUserInfo();
name1 = (User.User);
Dialog.TimedMessage("Please Wait", "User infromation is being logged for security purposes. You are logged as "..name1..".", 4000, MB_ICONINFORMATION);

That does not work. What is User.User?

abnrange
02-12-2009, 09:58 PM
Not sure where User.User comes from but it does works. I used it in other projects. I think it came from Mina. See attached image...

-- Get User and LAN info to displaying 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);

Dermot
02-12-2009, 10:26 PM
Using that code like you posted does not work. You must have other code elsewhere that defines the table User.

This is not being used at all in your code.
name = System.GetUserInfo();

Desrat
02-13-2009, 04:48 AM
the screenshot shows he's using LanInfo not UserInfo command

ShadowUK
02-13-2009, 05:23 AM
Doesn't matter. The point is that (User.User) is not defined.

abnrange
02-13-2009, 07:24 AM
On Preload there is this code. I did not know that this code directly effected the code on the button - Sorry for the confusion - still learning coding! Thanks for the help.


--------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);

name1 = System.GetUserInfo();
Label.SetText("UserInfo2", User.User);