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

annekin

Germany
Posts

Posted - 03/05/2006 :  5:56:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.G
Operating System:Win XP

Hi

I have a plotted graph from which I need the user to select the relevant data range. Since there can be more than one relevant data range I put the whole selection procedure in 'while'loop. Like this:

var=1;zahl=0;
for ( ;var >0;) //while loop
{
dotool 4;// data selector tool
def pointproc {
zahl=zahl+1;
getstring (peak name) C1s;
peak_Name[zahl]$=%B;
%A=xof(%C);
peak_Emin[zahl]=%A[mks1];
peak_Emax[zahl]=%A[mks2];
getyesno (add range?) var;
done=1;
};
for (done=0; done ==0; ) {sec -p .05}; // Wait until done=1
};

For the first data range this works fine. But if I want to add a second range I get the same values as before even though I moved the data markers.

Any suggestion why this doesn´t work?

Best regards,

Anita

Laurie

USA
404 Posts

Posted - 03/06/2006 :  2:33:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Anita,

It is because your PointProc macro is missing the 'dotool 0;' command.

Below is an alternative solution. I define another macro within the Pointproc macro, and in this way, avoid the need of the 'sec -p' to pause the code from running. The GetYesNo command will set the value of the 'done' variable to 1 if the user clicks Yes

dotool 4;
def pointproc {
mks1=; //output value of left marker
dotool 0;
getyesno (Add Range?) done;
if(done==1)
{
def newrange {
dotool 4;
def pointproc {
mks1=;
dotool 0;
getyesno (Add Range?) done;
if(done==1) newrange;
};
};
newrange;
}
};



The code could also look like this:

def newrange {
dotool 4;
def pointproc {
mks1=;
dotool 0;
getyesno (Add Range?) done;
if(done==1) newrange;
};
};
dotool 4;
def pointproc {
mks1=;
dotool 0;
getyesno (Add Range?) done;
if(done==1) newrange;
};


Newrange could also be a section of code in an OGS file instead of a macro. In the PointProc macro definition, you'd replace newrange; with run.section(myOGSfile.ogs,newrange);.

-Laurie
OriginLab Technical Support
Go to Top of Page

annekin

Germany
Posts

Posted - 03/07/2006 :  02:54:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Laurie for your advice.

The script now works. But still I need the
for (done=0; done ==0; ) {sec -p .05};
waiting loop because otherwise the rest of the script continues without waiting for the input data. I don't know how else to put the rest of the script on hold until the data selection is finished.

There is also one more minor problem. When the data selector tool is first called, the data markers are visible but I still see the point selector symbol and I can't move the data markers. Only when I change to another window and then back to this graph window everything is as it should be. After that it works also for all other calls of the data selector tools.
I suspect it has something to do with the data markers assuming positions saved before. Because when I switch between the left and right data marker by using the arrow keys, the red crosses indicating the marker positions take some weird positions in the middle of the graph window but nowhere near the curve.
doc -uw and plot -c doesn't seem to help either.

Best regards,
Anita
Go to Top of Page

Laurie

USA
404 Posts

Posted - 03/13/2006 :  2:22:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Anita,

If you rewrite your code as follows, you will not need to use the sec -p command to wait:

zahl=1;
def newrange {


dotool 4;

def pointproc {
zahl++;
getstring (peak name) C1s;
peak_Name[zahl]$=%B;
%A=xof(%C);
peak_Emin[zahl]=%A[mks1];
peak_Emax[zahl]=%A[mks2];

dotool 0;

getyesno (Add Range?) done;

if(done==1) newrange;

};

};

dotool 4;

def pointproc {

getstring (peak name) C1s;
peak_Name[zahl]$=%B;
%A=xof(%C);
peak_Emin[zahl]=%A[mks1];
peak_Emax[zahl]=%A[mks2];

dotool 0;

getyesno (Add Range?) done;

if(done==1) newrange;

};


OriginLab Technical Support
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