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
 Adding Panel or Dialog Box after Click a Button
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wenghua

USA
3 Posts

Posted - 10/01/2002 :  5:51:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I am a user of Orign 7. I need to create a panel for button to do custom function on active worksheet, my problem is I don't know how to create a panel(having some check boxes or input box to request information form user) after user click a button using Orign 7. When I took a look at the Programming Guide for Orign 7, I didn't find it. Is there anybody knows how to do it? Or only OrignPro has this feature. Thanks a lot.

Tracy

Mike Buess

USA
3037 Posts

Posted - 10/01/2002 :  6:30:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Panels such as you describe are called UIM objects and you need OriginPro to create them. However, the Labtalk getnumber command opens a dialog with as many as six different inputs that can be edit boxes for entering numbers or strings, check boxes or drop-down lists.

Mike Buess
Origin WebRing Member
Go to Top of Page

wenghua

USA
3 Posts

Posted - 10/02/2002 :  12:07:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike:

Thank you for your quick response. When I take a look at the getnumber command in LabTalk reference, there is a example for the use of this command:
%A = enter name;
i = 1;
j = 1;
k = 0;
%B = "line1 line2 line3"; // drop down list with three entries

getn
(X Minimum) MyVar // a variable
(my boolean) k:2s // show remaining items if k = 1 (checked)
(my list) i:B // use %B as the list items
(Color) j:@C // color list, init j = 1
(Your Name) %%A // %% to preserve %A for holding the name
(Title of this dialog); // end of getnumber

I don't understand this example and I also don't know how to call and use this routine. Could you explain a little more to me. Thanks a lot!
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 10/02/2002 :  1:59:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Until Originlab provide an Origin C version of the GetNumber function in labtalk, it is quite combersome to call this labtalk function from Origin C, but I have provided an example here. You will need to put the following code in a file called test.c and put this file inside the Origin C folder.

void dd(string str, double xmin, int i, int j, int k)
{
LT_set_str("%A", str);

LT_set_var("i",i);
LT_set_var("j",j);
LT_set_var("k",k);
LT_set_var("MyVar", xmin);
printf("On input, Xmin=%f, i=%d, j=%d, k=%d, str=%s\n", xmin, i,j,k,str);
// can use __FILE__ to find this file name, but
// we will just hard code it here to be a file called test.c inside
// OriginC subfolder
if(!LT_execute("run.section(%YOriginC\\test.c,GetNum)"))
{
out_str("User Cancel");
return;
}
double db_i, db_j, db_k;
LT_get_var("MyVar", &xmin);
LT_get_var("i",&db_i); // must use double to receive value from labtalk
LT_get_var("j",&db_j);
LT_get_var("k",&db_k);
char szTemp[100];
LT_get_str("%A", szTemp, 100);


printf("On output, Xmin=%f, i=%d, j=%d, k=%d, str=%s\n", xmin, (int)db_i,(int)db_j,(int)db_k,szTemp);

}

// this is a trick to call LabTalk section inside a C file
#ifdef _JUNK
// section name must match run.section
[GetNum]

%B = "line1 line2 line3"; // drop down list with three entries

getn
(X Minimum) MyVar
(my boolean) k:2s
(my list) i:B
(Color) j:@C
(Your Name) %%A
(Title of this dialog);
return 0;
#endif //_JUNK



You can then compile this and type into script window
dd "some text" 5.7 1 1 1;

CP


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/02/2002 :  2:15:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Tracy,

I had problems too when I just copied the script from the help file and pasted it in the script window. So I'll edit it a little and remove the comments.

The following lines just initialize the variables. Copy them to your script window, hilite all six lines and press Enter.

%A = enter name;
i = 1;
j = 1;
k = 1;
MyVar = 2;
%B = "line1 line2 line3";

The next lines launch the getnumber command...

getn
(my variable) MyVar
(my boolean) k:2s
(my list) i:B
(Color) j:@C
(Your Name) %%A
(Title of this dialog);

Once again, hilite all seven lines and press enter to launch the dialog below.



1> Whatever is in the my variable box becomes the new value of MyVar when the dialog is OK'd.
2> The value of k is determined by whether or not my boolean is checked on OK. (checked: k=1, unchecked: k=0) Also, the lines beneath are only shown when my boolean is checked.
3> my (drop-down) list contains the three tokens in the string %B. The line chosen by the user determines the new value of i. (line2 sets i=2) The actual string chosen by the user can be obtained with

%L=%[%B,#i];
%L=line2 // if i=2

4> @C is a system string variable containing the names on Origin's color pallete. The choice determines the value of j.
5> The string entered in the Your Name box is assigned to the string variable %A.

That's a rather brief summary, but I hope it will get you started.

Mike Buess
Origin WebRing Member
Go to Top of Page

wenghua

USA
3 Posts

Posted - 10/02/2002 :  3:05:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot! It helps a lot.
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