PDA

View Full Version : Different behavior with _SourceFolder variable


rknol
09-20-2005, 08:43 AM
After compressing my old AMS5 project into a web/email executable, several scripts do no longer work.
In my scripts I often use the variable _SourceFolder. Building the project into a web/email executable, this variabele points to the temporary directory, i.e. the directory where the executable is uncompressed.
Is there a way to still get the _SourceFolder variable point to the path of the executable (autorun.exe) in stead of to the uncompressed executable?

Roel Knol
KMO Development BV

Brett
09-20-2005, 09:26 AM
There is a way to do this.

From the Help file:

Tip: Occasionally you may need the location your compressed executable was launched from. For this reason a command line argument is passed into your AutoPlay application in the form: SFXSOURCE:SFE EXE NAME where "SFE EXE NAME" is the full path to the compressed executable. For example, "SFXSOURCE:C:\Temp\launcher.exe". In your AutoPlay application you can access this command line argument using the Global Variable _CommandLineArgs. If any command line arguments are passed to the compressed executable, they will also be passed into the AutoPlay application.

SFESourceFolder = "";
for i, strArg in _CommandLineArgs do
if(String.Find(strArg,"SFXSOURCE") ~= -1)then
local nStrLen = String.Length(strArg);
local strFullFileName = String.Right(strArg,nStrLen-10);
local tblPathParts = String.SplitPath(strFullFileName);
SFESourceFolder = tblPathParts.Drive..tblPathParts.Folder;
SFESourceFolder = String.TrimRight(SFESourceFolder,"\\");
end
end

Dialog.Message("SFESourceFolder",SFESourceFolder);

rknol
09-20-2005, 09:55 AM
Great, thanks!

Roel