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
 How to refer to the long name?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

circumvent

Posts

Posted - 04/16/2010 :  8:44:58 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0SR3
Operating System:Vista

I am wondering how to refer to the long name when I save a file. Basically I am importing a file, delete some rows and columns, then save the worksheet to a new file with same file name but different extension. Everything works well except the saved name is the short name. Can anyone help? In addition, is it possible to upgrade the code and make it more flexible?

getfile -m *.txt;
loop (ii,1,count)
{
//Open one data file
fdlog.Get(A,ii);
impasc fname:="%A";
del col(3);del col(2); //Any easier way to delete these two columns? I have to delete the third col first.
range bb=col(1)[700:1340];// 1340 is the end of the row
mark -d bb;
range bb=col(1)[1:300];
mark -d bb; //Again, any easier way to delete the rows? I want to keep the rows between 300 and 700
wks.export.cntrl=2;
save -wh %H %H.cut// How to refer to the long name of the current worksheet?

}

larry_lan

China
Posts

Posted - 04/22/2010 :  06:11:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

1> To delete several columns, you can use range. Such as

range rr = col(1, 3);
del rr;


2> You can output the selected data range only. See the wks.export for more information. (Try wks.export.c1, wks.export.c2, wks.export.r1, wks.export.r2)

3> Use page.longname$ to refer to a windows longname. Such as:

save -wh %H c:\%(page.longname$).txt;

Thanks
Larry

Edited by - larry_lan on 04/22/2010 06:11:46 AM
Go to Top of Page

circumvent

Posts

Posted - 04/22/2010 :  3:20:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Larry.

A quick question: how to get part of the long name?

The file is xxxxx.txt and now it save as xxxx.txt.txt


In old version %[%A,'.'] will return the value left to '.'

Do we have better functions to operate strings?




Edited by - circumvent on 04/22/2010 3:23:09 PM
Go to Top of Page

larry_lan

China
Posts

Posted - 04/23/2010 :  12:17:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

How about the gettoken method of string variable?

something like:

string str$ = page.longname$;
string title$ = str.GetToken(1, ".")$


Thanks
Larry

Edited by - larry_lan on 04/23/2010 12:51:13 AM
Go to Top of Page

circumvent

Posts

Posted - 04/23/2010 :  2:21:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Larry.

The string function works well.

By the way, have you test that the following statements work in your computer?

range rr = col(1, 3);
del rr;

it does not work in my case. Basically, I created 5 columns in a worksheet

1) range rr = col(1, 3);
del rr;

//nothing happen

2) del col(1)
//works as expected

3) del col(1,2)
//only delete col(1)

4) range rr=col(1);
del rr;
//works as expected


I guess rr=col(1,3) has problems. So how to refer to many columns at the same time?

Edited by - circumvent on 04/23/2010 2:21:57 PM
Go to Top of Page

vincenth

30 Posts

Posted - 04/28/2010 :  10:33:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The statements

range rr=col(1,3);
del rr;

Should delete columns 1 and 3, but not column 2. This worked for me in 8.0/SR3, so I'm not sure what is going wrong there.

To delete a several contiguous columns, say, columns 3-5 in the active worksheet, try the following:

range rr=3:5;
del rr;

If you are dealing with some other worksheet (not the active worksheet) in the project, use the entire range notation, for example:

range rr=[Book2]Sheet1!3:5;
del rr;

The LabTalk Scripting documentation was improved for Origin 8.1, and you can view the new information (most of it relevant for 8.0) on our wiki:

http://wiki.originlab.com/~originla/wiki/index.php?title=Category:LabTalk_Programming

Specifically, the page on range notation:

http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Range_Notation

Hope this helps.

Vince
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