The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Get Current Username using LabTalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

alexisb2000

USA
7 Posts

Posted - 01/05/2009 :  5:58:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and SR (Select Help-->About Origin):
Operating System:

Is there a way to use LabTalk to get the current network username? For example, from MS-Access, I can use the following code to get the network username:
strusername = Environ("USERNAME")

Is there such a function in LabTalk? I need to get to a specific folder using this username and want to avoid hard-coding.

Thanks for your help.
Alexis

rlewis

Canada
253 Posts

Posted - 01/05/2009 :  6:40:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To my knowledge, not with LabTalk ....
However there is an OriginC function "GetUserName" that will do the trick
Go to Top of Page

alexisb2000

USA
7 Posts

Posted - 01/05/2009 :  8:05:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your response. I know this is a long shot but is there a way to embed one Origin C function in a LabTalk program? My program is running fine in LabTalk. I just need to get the network username programmatically.

Thanks,
Alexis
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 01/05/2009 :  10:07:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Under Origin 8.0 you can do something like the following ..
(a) Open the CodeBuilder workspace
(b) Create an ?????.C file (File New in the Codebuilder menu)
(c) Copy the origin C function below to the new origin C file created
(d) Add the file to the CB workspace (Right ckick System AddFiles)
(e) Compile the Origin C file (Tools Build in the CodeBuilder menu)


	string fnGetUserName()
	{
	     char szUserName[MAX_PATH];
    	     DWORD dwSize = MAX_PATH;
    	     if (GetUserName(szUserName, &dwSize)==true)
    	     {
    		string strTemp(szUserName);
    		strTemp.TrimLeft();
    		strTemp.TrimRight();
    		return (strTemp);
    	     }
    	     return ("");
	}


Under Origin 8.0 this should compile without error.
Once this is done you can then open the Origin script window
and use LT commands like

"%P=fnGetUserName()$" to retreive the username


Go to Top of Page

alexisb2000

USA
7 Posts

Posted - 01/06/2009 :  2:33:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
rlewis,
Thank you for taking the time to explain this to me. I am new to Origin programming and hoped there would be a way to do what you said. The steps you described worked perfectly and helped me to finalize my program.

Regards,
Alexis
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000