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
 Getnumber
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Belsinga

Netherlands
28 Posts

Posted - 06/22/2010 :  04:07:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8E
Operating System: Win XP

Hello (again),

I am working on a dialog box in Labview, but I do not know how to use the selected variable. (The following script returns only a blank line). How can I use the selected value from P?

Regards,

*********************************
i = 8;
%P = "000 010 030 050 100 200 300 400";

getnumber (Sample1) i:P
(Filter Type);
type $(Sample1);

Penn

China
644 Posts

Posted - 06/22/2010 :  04:47:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The return value is the index of the selected item. To get the item value in your issue, you can use the switch command.

For example:

i = 8;
%P = "000 010 030 050 100 200 300 400";

getnumber (Sample1) i:P
(Filter Type);
type $(i); 

switch (i)
{
	case 1:
		type "000";
		break;
	case 2:
		type "010";
		break;
	case 3:
		type "030";
		break;
	case 4:
		type "050";
		break;
	case 5:
		type "100";
		break;
	case 6:
		type "200";
		break;
	case 7:
		type "300";
		break;
	case 8:
		type "400";
		break;
}


Penn
Go to Top of Page

Belsinga

Netherlands
28 Posts

Posted - 06/22/2010 :  05:45:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK thanks,

Is it possible to type a generic string instead of "Sample1", e.g. the name of the sample that is in the filename?
Go to Top of Page

Belsinga

Netherlands
28 Posts

Posted - 06/22/2010 :  10:24:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
And yet another question regarding the "switch" statement:

If I define a variable inside a case:{}, how can I access it later on?
Go to Top of Page

Penn

China
644 Posts

Posted - 06/22/2010 :  10:49:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you have renamed the workbook or worksheet with the data file name when you import data, you can use the %H string register to get the active window title or wks.name$ to get the worksheet name.

getnumber (%H) i:P (Filter Type);

or

getnumber (%(wks.name$)) i:P (Filter Type);

Also, you can use the string defined by yourself.

string myStr$ = "MySample";
getnumber (%(myStr$)) i:P (Filter Type);


For accessing the variable defined inside case:{}, The "later on" means outside the "switch"? If so, with the braces for each case, you need to use the @global to force global scope.

switch (i)
{
	case 1:
	{  // in braces
		@global = 1;  // begin global scope
		string str = "string defined in case 1";
		@global = 0;  // end global scope
		type "000";
		break;
	}
	case 2:
	{	.
		.
	        .
	}
        // other cases...	
}
str$ = ;  // can get the string defined in case 1


Penn
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