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
 FindFiles and maximum string length

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
JokerOne Posted - 06/16/2016 : 03:13:29 AM
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!
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 06/20/2016 : 9:08:11 PM
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
cpyang Posted - 06/20/2016 : 8:05:16 PM
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
Chris D Posted - 06/16/2016 : 09:31:50 AM
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

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