[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - relative paths in scripts

relative paths in scripts

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

relative paths in scripts

Postby alfred » Tue Sep 14, 2010 1:03 pm

Does anybody know how to write correct a relative path in a script? An absolute path (for example: J:\download\Barca2\bfacs\bfacs.exe) works- how could I make this path relative?

Barca has no encryption, I want to encrypt my mail folders. This works with a script, calling the encryption-program. But the path has to be relative, in order to work portable!
alfred
Poco Tourist
 
Posts: 16
Joined: Mon Sep 13, 2010 8:54 am

Postby MarkB » Thu Sep 16, 2010 12:35 am

But the path has to be relative...

Which path? The path to the encryption program? The Execute command requires that the application name be either a fully qualified file name or in the Windows search path.

"Relative" implies that the script has knowledge of a base path. If so, build the full name from it. For example,
Code: Select all
Set $filename ""
AddStrings $filename $path "bfacs.exe"
Execute $filename


Do the same if one of PocoScript's system variables gives the path.

A third option is to have your script search through a list of possible locations (fully qualified file names), for example,
Code: Select all
I:\download\Barca2\bfacs\bfacs.exe
J:\download\Barca2\bfacs\bfacs.exe
K:\download\Barca2\bfacs\bfacs.exe

for the correct one using FileExists.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby alfred » Thu Sep 16, 2010 1:26 am

Thank you!

Your third option is not applicable. I run Barca on PC in a directory, which I synchronize to my flashdrive. The directories on PC and flashdrive are different. Moreover, the driveletter could from D:\ to Z:\

I will try the base path. Are there apt scripts in the "Skripts"-section for download as example for using this base path? There are so many scripts.....
alfred
Poco Tourist
 
Posts: 16
Joined: Mon Sep 13, 2010 8:54 am

Postby MarkB » Thu Sep 16, 2010 4:03 am

We're not understanding each other. A relative path is a mere convenience. A system that supports relative paths, such as MS-DOS and HTML, understands both a fully qualified file name (e.g., http://www.yahoo.com/images/joe.jpg) and a partial file name (e.g., images/joe.jpg) where the working directory (http://www.yahoo.com/) is implied. This working directory is explicitly supplied beforehand in the script or is a default. Without a working directory, support for relative paths is of no help to you. With a working directory, you don't need a relative path.

Am I right in thinking that your problem is that the working directory is an unknown?
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby alfred » Thu Sep 16, 2010 4:35 am

Well..... the working directory is partly unknown. On PC it is for example J:\a\b\c\portable\Barca, and on the flash drive it is [unknown driveletter]\portable\Barca.
So, I think, the working directory is \portable\Barca or just \Barca.

So, how can I set \portable\Barca as working directory in the script?

I simply want to call a program from Barca with a script. One click, and the program (in the Barca directory (\portable\Barca or \Barca - opens), indifferent form which computer I run Barca.

I am new to this program, and I don´t know, how to tell Barca this working directory. I just modified the "calculator" script, delivered with barca, and this works with absolute paths and any program.

I would appriciate, if you could tell me the code for the working path.

Thank you very much!
alfred
Poco Tourist
 
Posts: 16
Joined: Mon Sep 13, 2010 8:54 am

Postby MarkB » Thu Sep 16, 2010 8:06 am

Sorry. Can't help you. If it were me, the PocoScript would be a one-liner that calls an AutoIt script that finds the program and runs it.
Code: Select all
;  AutoIt script
;  The array $a will contain a list of removable drives -- drive letter and colon.
;  $a[0] = no. of removable drives.
;  Drive a:\ is removable; CD-ROM is not
$a = DriveGetDrive("REMOVABLE")
If @error Then
   MsgBox(48, @ScriptName, "DriveGetDrive() failed")
Else
   For $i = 1 To $a[0]
      If $a[$i] <> "a:" And DriveStatus($a[$i]) = "READY" Then
         If FileExists($a[$i] & "\Toolkit_MAB\Txt2Jpg.exe") Then
            Run($a[$i] & "\Toolkit_MAB\Txt2Jpg.exe")
            ExitLoop
         EndIf
      EndIf
   Next
EndIf
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 0 guests

cron