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
 xfunction dlgfile and space character in path
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hgibhar

Germany
12 Posts

Posted - 11/23/2012 :  09:09:25 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.6 and Service Release 3
Operating System: win7 prof 32bit

Hello,

my fdlog problem remains to exist. However, I changed to the x-function dlgFile. There is a problem with white spaces in the directory name. I have a file in a directory (which contains a space):

d:\holger\gamma_origin\teste leerzeichen\g0016835.dat

I want to make some work with this file.

My test script is:

//x-function for multiopen
dlgFile title:="Open Gamma Files" group:="*.dat" multi:=1 init:="d:\holger\gamma_origin\teste leerzeichen";

string files$ = fname$; //save result file name list
int count=files.GetNumTokens(CRLF);
type files$;
type fname$;
count=;


The response of the x-function is:

D:\holger\gamma_origin este leerzeichen\g0016835.dat

Hence, the result string skipped the character \t an origin is not able to open this file! This seems to me to be a severe problem, because the number of files is determined by the GetNumTokens function (see example).

So, what to do now???

Thanks for any hint.

Holger

hgibhar

Germany
12 Posts

Posted - 11/23/2012 :  10:36:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is a new aspect: if I put the result of dlgfile into a %variable,
the two characters are sustained:

%M=fname$;
%M=;

The result is:
D:\holger\gamma_origin\teste leerzeichen\g0016836.dat

It is unclear to me.

Holger
Go to Top of Page

hgibhar

Germany
12 Posts

Posted - 11/23/2012 :  10:54:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I extendend for tests the script:

[test]
//x-function for multiopen
dlgFile title:="Open Gamma Files" group:="*.dat" multi:=1 init:="d:\holger\gamma_origin\teste leerzeichen";

string files$ = fname$; //save result file name list
int count=files.GetNumTokens(CRLF);
//Choose only one file, hence count = 1
count=;

int index=0;
string testtoken$;

//look how much tokens there
for(index=1;index <= 2; index++)
{
testtoken$=fname.GetToken(index)$;
type testtoken$;
}

//compare with % variable
%M=fname$;
%M=;
for(index=1;index <= 4; index++)
{
type %[%M,#index];
}


See the results:

count=1
D:\holger\gamma_origin este
leerzeichen\g0016834.dat
D:\holger\gamma_origin\teste leerzeichen\g0016834.dat
D:\holger\gamma_origin este
leerzeichen\g0016834.dat

Only one file was choosen; nevertheless there are 2 tokens as result of dlgfile and the first token lost \t.
The printout of %M yields the correct path, but the tokens are wrong, too.

Thanks for help.

Holger
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/24/2012 :  05:42:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The type command will interpret \t as TAB by default. To preven this, use type -v text instead. I tried with a path like you had with the following and the result is correct:


dlgfile group:="*.dat" multi:=1;
type -v fname$;
string files$ = fname$;
int count=files.GetNumTokens(CRLF);
count=;


CP
Go to Top of Page

hgibhar

Germany
12 Posts

Posted - 11/26/2012 :  10:35:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear CP,

thank you very much for your reply. I knew the verbose parameter -v, but as I thought about your reply and the line "GetNumToken(CRLF)", I found my mistake:

It seems to me, that the filenames of dlgFile (as multiopen dialog) are separated by CRLF. Hence, the loop over all tokens must be done with CRLF:

nn$=fname.GetToken(ii,CRLF)$;

This, I did not thought of. If nothing is given as separator, any white character is used as separator, and this breaks the (path-)filenames to wrong tokens.

Now, it works

Holger

Edited by - hgibhar on 11/26/2012 10:38:08 AM
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