T O P I C R E V I E W |
tib |
Posted - 01/11/2002 : 10:12:14 AM What I can do is: label -s -sa -n start "Press here to start"; // create label; start.text$="Press here to stop"; // change label text; start.x=1000; // x position label; start.y=1000; // y position label; start.color=2; // set color; start.script=1; // change text label to button;
I can also run this button by start.run();
But how can I assign a script via script to this button? I expected something like start.script.text$="type -b Hello"; But I haven't found anything so far...
Thanks for any suggestions, Tilman. |
5 L A T E S T R E P L I E S (Newest First) |
Mike Buess |
Posted - 01/13/2002 : 11:21:15 AM Hi Tilman,
Yes, it looks like this approach is tailor-made for your situation. As for creating 100 sections, I was going to leave that up to you.
I think your suggestion about "scriptable" scripts is a good one. There have been a number of times where it would have made my life easier. Whether or not semicolons would be a problem depends on how it was implemented. I rather doubt if it would be too hard to avoid such problems, but I'm not an Origin developer.
There may indeed be a connection between this problem and your "add path stamp..." topic. It also resembles the previous Expressing strings between { } topic, although the issues involved may be very different.
Mike Buess Origin WebRing Member |
tib |
Posted - 01/13/2002 : 07:18:57 AM Yes, Mike, this way works. I didn't remember the "this.text$" property. In my special case this works even simpler. Since my buttons just return the x and y position of the button in the matrix.
Like you proposed... [Main] %A=this.text$; // use as button text 00 ... 99; XPOS=int($(A)/10); // extract x position; YPOS=mod($(A),10); // extract y position;
Then, I actually do not need these 100 sections. [B00] xpos=0; ypos=0; . . [B99] xpos=9; ypos=9;
BTW, how did you want to create these 100 sections? By hand?
I'm still convinced that a way like below would be much simpler and more flexible and would open up new ways of user interaction.
loop (xx,0,9) { loop (yy,0,9) { label -s -n B$(xx)$(yy) $(xx)$(yy); // create label with text; B$(xx)$(yy).script=1; // change to button; B$(xx)$(yy).x=...; // x-position of button in window, same for y; B$(xx)$(yy).script.text$="XPOS=$(xx); YPOS=$(yy);"; // assign script text; }; };
Would the semicolons in the text be problematic? Maybe this is connected to an other problem which I also had, that it seems to be impossible via script to link a text label to variables. See posting "Adding a path stamp by script?". |
Mike Buess |
Posted - 01/12/2002 : 08:34:09 AM Just assign different text to each button and have the script run a different command based on the button text.
// script in start button control label run.section(MyScript,Main);
// save start button from script window draw -n start -f save %Ystart.ogo
// recreate 100 times, label and position each // you'll have to add something to define x and y for each button loop (ii,1,100) { draw -n s$(ii) -f read %Ystart.ogo; s$(ii).text$=s$(ii); s$(ii).x=x; s$(ii).y=y; };
// Myscript.ogs - this is the script that each button runs [Main] %A=this.text$; run.section(,%A);
[s1] -- button #1 commands --
[s2] -- button #2 commands -- . . . [s100] -- button #100 commands --
Note: It's even simpler if you have OriginPro, in which you can create objects with multiple buttons.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/12/2002 08:38:23
Edited by - Mike Buess on 01/12/2002 08:40:59
Edited by - Mike Buess on 01/12/2002 09:07:08 |
tib |
Posted - 01/11/2002 : 10:50:07 PM Mike, thank you, but your method is OK for one and the same button. But I wanted to create 100 buttons (even more) arranged in a 10x10 matrix, where each button when pressed returns different values to variables and triggers an according action. So, I wanted to avoid creating 100 buttons and change the script text by hand. But obviously, I have to do so... Maybe there's an other solution to this problem?  Tilman. |
Mike Buess |
Posted - 01/11/2002 : 11:44:40 AM You can't assign an object's script with LabTalk. It has to be typed manually in the Label Control. One alternative is to create the button, add the script and save it as an OGO file.
draw -n start -f save %Ystart.ogo;
Then you can add it to any window you want with
draw -n start -f read %Ystart.ogo;
I use this method frequently.
Mike Buess Origin WebRing Member |
|
|