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
 FindFiles and maximum string length
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

JokerOne

Germany
58 Posts

Posted - 06/16/2016 :  03:13:29 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 9.1 and Service Release (Select Help-->About Origin):
Operating System: Win 7

Hello everybody,

I am using FindFiles followed by a fileimport-loop to get a larger number of files imported to Origin automatically.

While this usually works fine I experience crashes of Origin, when the number of files become large and/or the folder+filenames of the files are long (e.g. 200 characters per file and 150 files).

I assume, that the crashes is due too a limit in a string length

findFiles path:=filepath$ fname:=filesinpath;

thus the string "filesinpath$" cannot be set correctly?

Is my assumption correct and if so, what is the maximum string length?

Thank you!

Chris D

428 Posts

Posted - 06/16/2016 :  09:31:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

We can create a simple script to test the maximum allow length of a string variable in LabTalk by creating a loop and adding a character to a string for every iteration. Below I will do 10,000 iterations and then test length of generated string:

string str$;
for (int ii = 1; ii <= 10000; ii++)
{
	str$ += "X";
}
str.GetLength()=;


That should output:
str.GetLength()=8191


You also have to take into account the delimiters between each returned file name (CRLF) which is 2 characters.

Perhaps you are going to have to take a more complex approach.

Thanks,
Chris Drozdowski
Originlab Technical Support
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/20/2016 :  8:05:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Maybe you can set addpath:=0 to get only the name of the files and not the full path, since you have the path in filepath$ to begin with.

I also tested and found the resulting string variable can hold much more then 8191 characters. I don't have a folder with more files, but here is what I found using a folder with Origin source code:

string results$;
string sPath$="D:\dev\Source\vc32\OKern96\";
findFiles path:=sPath$ ext:="*.*" addpath:=1 fname:=results$;
results.GetLength()=;
int nn = results.GetNumTokens(CRLF);
nn=;


I got the following print out
quote:

results.GetLength()=33590
nn=781


So 781 files with full path taking up 33590 bytes and I don't see a crash. I did not try this in 9.1 though.

CP
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/20/2016 :  9:08:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi Chris,

In your test about with str$+="X"; the 8191 limit has nothing to do with string variables themselves, but rather with the LabTalk assignment. Basically, any LabTalk expression involving '=' has a buffer that is 8192 in size, so the transfer from Right-Hand-Side to Left-Hand-Side will be limited to the 1st 8191 characters. If the LabTalk statements are not involving '=', then the bigger string can work perfectly fine.

CP
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