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
 file - c with string variables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

marcel1992

Germany
12 Posts

Posted - 07/19/2021 :  06:33:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2021 9.8.0.200
Operating System: Win 10 pro 64bit

Hello together, I like to copy a file to another location.
After using the labtalk manual I found "file -c".
I tried this with some .txt files and it worked great.
Now I like to copy some .tdms files and the location (in and out) should be a string variable but it seems that this doesn't work. Some ideas why? Is there a better way copying files to another destination?
Thanks in advance

YimingChen

1666 Posts

Posted - 07/19/2021 :  10:45:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Would you please attach the script that you used? I couldn't reproduce the issue.

James
Go to Top of Page

marcel1992

Germany
12 Posts

Posted - 07/20/2021 :  03:46:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello James, thanks for your reply.
In general I used:
file -c C:\User\Test1\Test.txt C:\User\Test2\Test.txt

After this is tried:
String dest1$ = "C:\User\Test1\Test.txt"
String dest2$ = "C:\User\Test2\Test.txt"
file -c dest1$ dest2$
but this doesn't work.
Syntax issue?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/20/2021 :  8:55:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This LT command was very old, way before LT string variables were introduced and apparently we failed to update it, we will do it for upcoming Origin 2022, for now, use the % substitution, see below:

string str1$="C:\temp\test1\test.txt";
string str2$="C:\temp\test2\test.txt";
type -v "copying from [%(str1$)] to [%(str2$)]";
@ERR=0;
file -c "%(str1$)" "%(str2$)";
@ERR=;//from system GetLastError if CopyFile failed.


Please make sure you have write access to the destination as c:\Users\ typically is not writable.

See also

https://www.originlab.com/doc/LabTalk/guide/Substitution-Notation#.25.28_.29_Substitution

CP
Go to Top of Page

marcel1992

Germany
12 Posts

Posted - 07/21/2021 :  08:33:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello cpyang
this works perfect, thanks for the solution.
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