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
 Path error, possible conflict with symbols
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 08/05/2020 :  4:42:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Windows 10

Hello,

I am trying to import files from a certain path and I am encountering the error "Invalid file path!", even if the path is correct.

To try to check where the error is found, I typed:
string strPath$ = "D:\Samples\";
path$= strPath$;
findFolders; 
int n = folder.GetNumTokens(CRLF);	
type "$(n) subfolders found";
type path$;
string TempFol$ = folder.GetToken(1, CRLF)$;
path$ = strPath$ + "\" + TempFol$;	
findFolders; 	
int nn = folder.GetNumTokens(CRLF); 	
type "$(nn) subfolders found";
type path$;
TempFol$ =;
string dscFol$ = folder.GetToken(1, CRLF)$;
path$ = strPath$ + "\" + TempFol$ + "\" + dscFol$; 
findFolders;
int nnn = folder.GetNumTokens(CRLF);
type "$(nnn) subfolders found";
type path$;
dscFol$ =;
string ZnFol$ = folder.GetToken(1, CRLF)$; 
path$ = strPath$ + "\" + TempFol$ + "\" + dscFol$ + "\" + ZnFol$ + "\Data\New";
findFolders;
int nnnn = folder.GetNumTokens(CRLF);
type "$(nnnn) subfolders found";
type path$;
ZnFol$ = ;


And it returned:

3 subfolders found
D:\Samples
4 subfolders found
D:\Samples\3000°C
3000°C
4 subfolders found
D:\Samples\3000°C\DSC1
DSC1
0 subfolders found
D:\Samples\3000°C\DSC1 ---This is incomplete; should be D:\Samples\3000°C\DSC1\0.50%\Data\New
0.50% ---This is correct


While it retrieves all folder names correctly (even the last one), it won't get the whole path from the last folder. I suspect it has something to do either with "." or with "%", but the workarounds I tried did not work.

Is there any way I can get the correct path for folders that include these symbols?

Thank you.

Edited by - Clairekun on 08/06/2020 7:19:43 PM

Clairekun

Germany
175 Posts

Posted - 08/06/2020 :  7:19:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I dug a bit further and I discovered it has nothing to do with symbols or path length.

I tried setting the first path to inner subdirectories and execute less lines.

a. If the initial path is D:\Samples\3000°C\DSC1\, and I run the code up to TempFol$ =; , the text returned is correct:
4 subfolders found
D:\Samples\3000°C\DSC1
DSC1
0 subfolders found
D:\Samples\3000°C\DSC1\0.50%
0.50%


b. If I take the initial path 1 step backwards, that is, D:\Samples\3000°C\, and try to run the code up to dscFol$ =; , I get the same result as my first post:
4 subfolders found
D:\Samples\3000°C
3000°C
4 subfolders found
D:\Samples\3000°C\DSC1
DSC1
0 subfolders found
D:\Samples\3000°C\DSC1 ---This is incomplete; should be D:\Samples\3000°C\DSC1\0.50%
0.50% ---This is correct


I thought maybe there was a maximum of strings you could concatenate in a path, but I have used 3 appended strings before with no problem whatsoever.

On the other hand:
c. If I set the initial path to D:\Samples\3000°C\DSC1\0.50%\, and simply write:
string strPath$ = "D:\Samples\3000°C\DSC1\0.50%\";
path$= strPath$;
type path$;


D:\Samples\3000°C\DSC1 ---This is incomplete; should be D:\Samples\3000°C\DSC1\0.50%


Is there anything obvious I'm missing here? Why is it not working?

Edited by - Clairekun on 08/06/2020 7:21:33 PM
Go to Top of Page

Castiel

343 Posts

Posted - 08/07/2020 :  02:25:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Clairekun

Hello,

I dug a bit further and I discovered it has nothing to do with symbols or path length.

I tried setting the first path to inner subdirectories and execute less lines.

a. If the initial path is D:\Samples\3000°C\DSC1\, and I run the code up to TempFol$ =; , the text returned is correct:
4 subfolders found
D:\Samples\3000°C\DSC1
DSC1
0 subfolders found
D:\Samples\3000°C\DSC1\0.50%
0.50%


b. If I take the initial path 1 step backwards, that is, D:\Samples\3000°C\, and try to run the code up to dscFol$ =; , I get the same result as my first post:
4 subfolders found
D:\Samples\3000°C
3000°C
4 subfolders found
D:\Samples\3000°C\DSC1
DSC1
0 subfolders found
D:\Samples\3000°C\DSC1 ---This is incomplete; should be D:\Samples\3000°C\DSC1\0.50%
0.50% ---This is correct


I thought maybe there was a maximum of strings you could concatenate in a path, but I have used 3 appended strings before with no problem whatsoever.

On the other hand:
c. If I set the initial path to D:\Samples\3000°C\DSC1\0.50%\, and simply write:
string strPath$ = "D:\Samples\3000°C\DSC1\0.50%\";
path$= strPath$;
type path$;


D:\Samples\3000°C\DSC1 ---This is incomplete; should be D:\Samples\3000°C\DSC1\0.50%


Is there anything obvious I'm missing here? Why is it not working?



type -v path$



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 08/07/2020 :  09:31:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, although I could finally solve it myself. In my original code, every GetToken string was inside a for {} command, so there was a loop for every subfolder.

There was some conflict identifying which path was called everytime; what I did was assign each path to a differently named string, and the problem vanished. I was lazy and didn't want to name every single thing, but in the end it makes everything clearer.
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