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
 Forum for Origin C
 Missing LabTalk variables and Lt_get_var
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 10/11/2006 :  5:00:30 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR6
Operating System: Win2000

Hi,

With LabTalk I'll routinely check if a variable has been set eg by
if(setvar!=0/0) {...}
This is really useful!

With OC though I come across a problem..

The following code illustrates what I would like to use :

void CheckVar(string strvar)
{
double outdouble;
LT_get_var(strvar, &outdouble);
out_double("Val : =", outdouble);
}


If I now check a variable which hasn't been set eg
CheckVar(NotSet) The value 0 is displayed, yet in LabTalk CheckVar=-- ie missing value.

To get the CheckVar function to behave as expected I have to set NotSet=0/0 first then the value '--' ie NANUM is correctly displayed. This sortof defeats the purpose and I'm not happy with what's going on. Can someone please explain and say if it's a bug or not?

Cheers,

Pete

Deanna

China
Posts

Posted - 10/11/2006 :  10:18:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Peter.

The return value of LT_get_var() function might work better in checking if a Labtalk variable has been set.

It is explained in the file utilities.h that the return value will be TRUE if lpcszLabTalkVarName is a LabTalk variable, and FALSE if it is not for the function:
BOOL LT_get_var(LPCSTR lpcszLabTalkVarName, double * lpdbResult); // Get LabTalk variable value


I think the code can be rewritten as:

void CheckVar(string strvar)
{
double outdouble;
bool bRet = LT_get_var(strvar, &outdouble);
if (bRet) out_double("Val : =", outdouble);
else out_str("This variable has not been set");
}



Deanna
OriginLab Technical Services
Go to Top of Page

peter.cook

UK
356 Posts

Posted - 10/18/2006 :  10:29:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,

Belated thanks - this works for me!

Cheers,

Pete



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