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

razva

Germany
Posts

Posted - 08/30/2006 :  6:40:02 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): originpro 7.5 SR5
Operating System:Win XP SP2

Hi.
I want to create a script in labtalk to extract the value in a certain column at a certain row position. or better value in a certain row corresponding to a given X value.
The value extracted to be then exported to a notepad file (or result window) together with the label of the datasheet the value had been extracted from.
This script should be applied for all datasheets in the current folder, not for the entire project.
It should not be so difficult such a script but I cannot manage to make it work as it should beand I am a little bit in a hurry.

thank you

Deanna

China
Posts

Posted - 08/30/2006 :  10:06:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi.

To output to a notes window or the result log, you can refer to the type object in the Labtalk Language Reference.

To loop over the worksheets in the current folder, you can use
doc -ef w {...}.

The following script creates a notes window, searches through all the worksheets in the current folder for all the x values that is equal to 3, and then outputs the value in the second column in the same row. The X values are assumed to be in the first column of each worksheet. I think you can modify this script to suit your need.


//Create a notes window with the title ExtractResult
window -n n ExtractResult;

//Set the notes window as the current output window.
type.notes$=ExtractResult;
old = type.redirection;
type.redirection = 2;
type "Extractiong result:";

doc -ef w
{ //loop over all the worksheets in current folder
nrow=wks.maxRows; //The maximum row index number that contains a value

for (ii=1; ii<nrow; ii++) //loop over the rows
{
%a=%(%h, 1, $(ii));
if (%a==3)
{
type %h; //Type the name of the worksheet
type $(%(%h, 2, $(ii))); //Type the corresponding value in column 2
};
};
};

type.redirection = old; //Restore the output window




Deanna
OriginLab GZ Office

Edited by - Deanna on 08/30/2006 10:09:25 PM
Go to Top of Page

razva

Germany
Posts

Posted - 09/13/2006 :  04:06:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you so much for your help.
I am sorry for this late reply.
I have modified the script to match my needs and it works perfectly, except for the cases when the value I am gathering from column no. 2 is negative.
Another problem which might be related with the one above mentioned is that the label of the workseets in not completely shown when displaying the result (only some couple of characters are missing)

the modified script i am using now is the following:

window -n n ExtractResult;

//Set the notes window as the current output window.
type.notes$=ExtractResult;
old = type.redirection;
type.redirection = 2;
type "Extractiong result:";

doc -ef w
{ //loop over all the worksheets in current folder
nrow=wks.maxRows; //The maximum row index number that contains a value

for (ii=1; ii<nrow; ii++) //loop over the rows
{
%a=%(%h, 1, $(ii));
if (%a==1520)
{
type %h; //Type the name of the worksheet
type $(%(%h, 2, $(ii))); //Type the corresponding value in column 2
%j=page.label$; //get the label of the current worksheet
type %j; // type the label into the result window
type "";
};
};
};

type.redirection = old; //Restore the output window
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/13/2006 :  05:24:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Use quotation marks... type "$(%(%h, 2, $(ii)))";
quote:
Another problem which might be related with the one above mentioned is that the label of the workseets in not completely shown when displaying the result (only some couple of characters are missing)


Most LabTalk letter variables can hold no more than 260 characters. (Exception is %Z which holds approx. 8k characters.) Perhaps the labels are truncated. Try %Z=page.label$ instead.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/13/2006 05:50:35 AM
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