Source language: Translate to:

FilePath problems

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

FilePath problems

Postby Leos » Mon Sep 29, 2014 6:23 pm

Hi,
I have a problem:
If i use the 'RUN' command with this file, i have no problems

Run "c:\test\mymusic.mp3"

But, with this file i got the message 'file not found'

Run "c:\te % st\mymusic.mp3"

I know that the problem is in the special character "%". I got the same problem using nom 'standart' characters, like '&' '#' and others...
Any easy solution, please?

Thank you
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Re: FilePath problems

Postby Gaev » Mon Sep 29, 2014 8:22 pm

Leos:

Did you try ...
Code: Select all
Run "!c:\te % st\mymusic.mp3" "parameters" "options" "subroutine" "variable"

... i.e. with ! before the c:\te % st\mymusic.mp3
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: FilePath problems

Postby Leos » Tue Sep 30, 2014 3:38 am

Hi Gaev,
In this case this solution "!" do not result.
I think that the solution is to replace the character '%' (and all the others non 'standard', like 'ã' , '&' , ...) by its code, but I'm not really an easy way to do it ...
best regards tu you.

.....
Your tip is useful in many cases; this is an example:

Run 'C:\1000+3\myfile.doc'
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Re: FilePath problems

Postby Gaev » Tue Sep 30, 2014 5:03 am

Leos:

I think that the solution is to replace the character '%' (and all the others non 'standard', like 'ã' , '&' , ...) by its code, but I'm not really an easy way to do it ...

I tried this ...
Code: Select all
Run "C:\gk\te % st\abcd.txt" "" "Normal" "" ""

... and it opened the file under notepad.exe

The ascii code for % is 37 ... so I tried this ...
Code: Select all
Run "C:\gk\te [#37] st\abcd.txt" "" "Normal" "" ""

... and it also opened the file under notepad.exe

You might want to make sure that the folder name has exactly one space before and after the % sign.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: FilePath problems

Postby Leos » Tue Sep 30, 2014 7:37 am

it results with other characters...
May be the solution is a function to replace all the string ocurrency with non standart characters...

something like that:

StrReplace "[MyString]" "%" "[#37]" "[MyString]" ""
StrReplace "[MyString]" "_" "[#95]" "[MyString]" ""

...
Thank you
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Re: FilePath problems

Postby Leos » Wed Oct 01, 2014 12:13 pm

I did the function but with the comma character "," do not works!!!
Stranger still:
This works, and open the text file:

RUN "C:\teste,2~2\file.txt"

This, do not works!!!
(it was supposed to open the folder)

RUN "C:\teste,2~2\"

Any solution, please?
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Re: FilePath problems

Postby David de Argentina » Wed Oct 01, 2014 2:41 pm

Try to replace the LongFileName with the ShortFileName.

LongFileNames does not work in all cases.

My 0.01

David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: FilePath problems

Postby Leos » Wed Oct 01, 2014 3:55 pm

Hi, David
In this case i don´t think that is the problem...

It just does'nt works with any folder with a 'comma' ',' in the folder's name...

Do you have any simple way to have the shortname? (I did it with 'Dir /x')

Thanks
Best regards to you
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal

Re: FilePath problems

Postby David de Argentina » Wed Oct 01, 2014 8:31 pm

Save this as a VbScript function.

Code: Select all
publication.nbSetVar "[%2]", CreateObject("Scripting.FileSystemObject").GetFile("[%1]").ShortPath


Code: Select all
Parameters:

[%1] = Long FileName, text
[%2] = Return Var, variable


My (15x) devaluated cent,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: FilePath problems

Postby Leos » Thu Oct 02, 2014 7:19 am

Hi, David

IT WORKS!!!

Thank you very mutch!!! :mrgreen:


My devalueted EuroCent!!!
(which is currently worse than yours :) )
User avatar
Leos
 
Posts: 178
Joined: Mon Apr 04, 2005 11:13 am
Location: Coimbra, Portugal


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 1 guest