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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Multiple ASCII Import / %Z

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kaiouu Posted - 10/10/2005 : 10:24:24 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: Windows 2000

Hi,

I'm using a worksheet script like follows to display the header lines of the imported ascii-Files in a worksheet-Label(with the respective System Variables):

page.info.user.variables.L1V1$=%[%Z,@1];
page.info.user.variables.L2V1$=%[%Z,@2];
page.info.user.variables.L3V1$=%[%Z,@3];
page.info.user.variables.L4V1$=%[%Z,@4];
page.info.user.variables.L5V1$=%[%Z,@5];

Since the Number of headerlines in the ascii-files is not fixed, I don't use the import wizard.
This works fine if I import single ascii files.
However, if I use the Multiple ascii-file import dialog, all the imported Files get the header-lines from the first imported file.
The question is, how I can avoid this, and get the headerlines in the system variables with the multiple ascii import.

Thanks,
Kai
6   L A T E S T    R E P L I E S    (Newest First)
kaiouu Posted - 10/13/2005 : 02:59:07 AM
Hi Mike,

to 2: This works, and now my import script is doing what I want.

to 1: Yes, this is the property I meant. I admit, that this isn't the most important feature, it would just be nice if one could adjust this value to not have so much white space, as is i.e. the case with only one header line and a gap of 100.

Thanks, Kai
Mike Buess Posted - 10/12/2005 : 04:14:21 AM
1. Do you mean Format > Worksheet > Worksheet Measurement > Gap From Top? I don't think there is a corresponding labtalk property. I suggest you use a wks template with a fixed gap.

2. If you're using the LabTalk method then this will work...

nLines=5;
page.info.add(User);
page.info.User.addSection(Variables);
loop (i,1,nLines) {
page.info.user.variables.L$(i)V1$=%[%Z, @i];
};

If you're using the LabTalk + OC method...

nLines=5;
loop (i,1,nLines) {
%L=L$(i)V1;
%A=%[%Z, @i];
setUserVar %L %A;
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/12/2005 04:16:04 AM

Edited by - Mike Buess on 10/12/2005 4:23:35 PM
kaiouu Posted - 10/12/2005 : 03:30:01 AM
Hi Mike,

now it works...
I've two other questions:
Since I sometimes have only a few header lines, (and I display these above the columns) it would be nice to adjust the property gap from top of the worksheet display control menu from the script. Is this possible?
And is it possible to access the LnV1$ variables with an indices n (like an array)? Then I could run a loop depending of the number of the header lines.

Thanks a lot,

Kai
Mike Buess Posted - 10/10/2005 : 12:34:11 PM
Hi Kai,

Add the following in the spot marked for page.info commands in my previous script...

page.info.add(User);
page.info.User.addSection(Variables);
page.info.user.variables.L1V1$=%[%Z, @1];
page.info.user.variables.L2V1$=%[%Z, @2];
page.info.user.variables.L3V1$=%[%Z, @3];
page.info.user.variables.L4V1$=%[%Z, @4];
page.info.user.variables.L5V1$=%[%Z, @5];

...FYI, you can view info storage for the active window by entering page.info.= in the script window.

...The OriginC function between the hash marks makes it slightly easier to store variables to page.info because it adds the necessary storage sections automatically. If you are unfamiliar with OriginC see my second post in the following topic for instructions on adding it to your workspace...

http://www.originlab.com/forum/topic.asp?TOPIC_ID=4248

If you find the function useful you can drag your C-file to CodeBuilder's System folder where it will be compiled on startup.

###############################################
void setUserVar(string strName, string strValue)
{
Page pg = Project.Pages();
page_set_info_var_value(pg, strName, strValue, "User.Variables");
}
###############################################

To use the function in labtalk replace the lines at the top of this post with the following...

%A=%[%Z, @1]; setUserVar L1V1 %A;
%A=%[%Z, @2]; setUserVar L2V1 %A;
etc.

Unfortunately, setUserVar L1V1 %[%Z, @1] does not work even if you quote the %[] expression.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/10/2005 12:36:38 PM

Edited by - Mike Buess on 10/10/2005 12:40:07 PM

Edited by - Mike Buess on 10/10/2005 1:31:24 PM
kaiouu Posted - 10/10/2005 : 12:23:26 PM
Hi Mike,

Thanks for the fast reply. I tried your code, but unfortunately the problems remains.
In the script-Window %Z is displayed correctly in each run of the loop, so this part is o.k.
I also tried to relink the label in the worksheet (In the label the reference it is written as %(%H,@W,$L1V1) )
to the variables, but it didn't help, so I guess that the wrong variable is assigned in the script execution. I tried to write it like %H!page.info.user.variables.L1V1$=... but it didn't work either.

Regards, Kaiouu
Mike Buess Posted - 10/10/2005 : 10:49:15 AM
Hi Kai,

A scripted import based on the one below should work. If you use a custom wks template substitute its name for Origin in win -t D Origin.

FDlog.dlgName$="Import Multiple ASCII";
FDlog.useGroup(ASCII);
if( FDlog.MultiOpen()==0/0 ) return;
for(i=1;i<=fdlog.multiopen.count;i++) {
fdlog.get(A,i);
win -t D Origin;
open -w %A;
%Z=;
// add your page.info commands here
};

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000