Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534

    Post Global Path Solution

    I think I've done it!

    I have been wanting to call the AutoPlay folder as well as the folder from where the exe is run.

    As you may already know, this can be a bit difficult as you have to change the code depending on whether the program is compiled, not-compiled, compiled to an exe, compiled to the hard drive etc.

    All these require different code to call the AP folder and the exe folder. well, not anymore. The variable names can be found in the "Global Actions.afg" file. The variable that stores the path to the folder wherein the exe is run is called, plainly "exefolder".

    I have tested this to be used with un-compiled projects and projects compiled to an exe and to a hard drive folder. This code has been tested to work with no command line arguments and with external command line arguments.

    My brain is melting right now so I may have missed something, let me know if you find a bug.

    Enjoy!
    ~CS.
    Last edited by Centauri Soldier; 09-07-2009 at 04:22 PM.

  2. #2
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    My thread of inspiration by the way:
    http://www.indigorose.com/forums/showthread.php?t=25295

  3. #3
    Join Date
    May 2006
    Posts
    5,380
    i did make a suggestion ages ago for a global variable _EXEFolder to hold the path of the sfx exe, but it never made it to the table!
    Open your eyes to Narcissism, Don't let her destroy your life!!

  4. #4
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    Ok, I read over my post and noticed i forgot to include an example. No need to post a project but here's the idea.

    I have a project that gets compiled as an exe. The folder that contains the exe needs to have a subfolder in it called "Projects" (next to the exe file). I need to be able to read and write from/to this folder (as well as access the AutoPlay folder inside the exe file). Since I need to test the project before it's compiled, I need the code to work before and after I compile the project without having to alter it.

    This code causes the variable "exefolder" to store the path to the folder where the exe is REGARDLESS of the status of my project (compiled or uncomplied). This is what makes the code so handy; you never again have to find the AutoPlay folder or the exe folder no matter where your project is or if it is compiled or not. The variables will always take you to the right place before and after compilation. I hope I was a bit clearer this time.
    Last edited by Centauri Soldier; 11-01-2008 at 02:19 PM.

  5. #5
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534

    Post

    Found a serious bug in the code...here's the revised code

    Code:
    --===========================================================================
    --========================== GLOBAL PATH SECTION ============================
    --===========================================================================
    if Table.Count(_CommandLineArgs) == 0 then
    
    _AutoPlay = _SourceFolder.."\\AutoPlay";
    _ExeFolder = _SourceFolder;
    _Audio = _AutoPlay.."\\Audio";
    _Buttons = _AutoPlay.."\\Buttons";
    _Docs = _AutoPlay.."\\Docs";
    _Flash = _AutoPlay.."\\Flash";
    _Fonts = _AutoPlay.."\\Fonts";
    _Icons = _AutoPlay.."\\Icons";
    _Images = _AutoPlay.."\\Images";
    _Plugins = _AutoPlay.."\\Plugins";
    _Scripts = _AutoPlay.."\\Scripts";
    _TempAPFolder = _AutoPlay.."\\Temp";
    _Videos = _AutoPlay.."\\Videos";
    
    elseif Table.Count(_CommandLineArgs) > 0 then 
    
    sSourcePath = _CommandLineArgs[Table.Count(_CommandLineArgs)];
    
    iSourcePathFound = String.Find(sSourcePath, "SFXSOURCE:", 1, false);
    
    	if iSourcePathFound ~= -1 then
    	sTempPath = _CommandLineArgs[Table.Count(_CommandLineArgs)];
    	_SourceFolder = String.Replace(sTempPath, "SFXSOURCE:", "", false);
    	
    		for x = 1, 2 do
    		iAPFolderLength = String.Length(_SourceFolder);
    		iErasePoint = String.ReverseFind(_SourceFolder, "\\", false);
    		sTempExeFolder = String.Left(_SourceFolder, iAPFolderLength - (iAPFolderLength - iErasePoint) - 1);
    		end
    
    		_ExeFolder = sTempExeFolder;
    		_AutoPlay = "AutoPlay";
    		_Audio = _AutoPlay.."\\Audio";
    		_Buttons = _AutoPlay.."\\Buttons";
    		_Docs = _AutoPlay.."\\Docs";
    		_Flash = _AutoPlay.."\\Flash";
    		_Fonts = _AutoPlay.."\\Fonts";
    		_Icons = _AutoPlay.."\\Icons";
    		_Images = _AutoPlay.."\\Images";
    		_Plugins = _AutoPlay.."\\Plugins";
    		_Scripts = _AutoPlay.."\\Scripts";
    		_TempAPFolder = _AutoPlay.."\\Temp";
    		_Videos = _AutoPlay.."\\Videos";
    		
    		
    	elseif intSourcePathFound == -1 then
    	_ExeFolder = _SourceFolder;
    	_AutoPlay = _SourceFolder.."\\AutoPlay";
    	_Audio = _AutoPlay.."\\Audio";
    	_Buttons = _AutoPlay.."\\Buttons";
    	_Docs = _AutoPlay.."\\Docs";
    	_Flash = _AutoPlay.."\\Flash";
    	_Fonts = _AutoPlay.."\\Fonts";
    	_Icons = _AutoPlay.."\\Icons";
    	_Images = _AutoPlay.."\\Images";
    	_Plugins = _AutoPlay.."\\Plugins";
    	_Scripts = _AutoPlay.."\\Scripts";
    	_TempAPFolder = _AutoPlay.."\\Temp";
    	_Videos = _AutoPlay.."\\Videos";
    	end
    	
    end
    
    
    
    if not Folder.DoesExist(_TempAPFolder) then
    Folder.Create(_TempAPFolder);
    end
    --===========================================================================
    --========================== GLOBAL PATH SECTION END ========================
    --===========================================================================
    Just put this into your On Startup section or run it On Startup from an external script (which is what I do);

  6. #6
    Join Date
    Jun 2008
    Posts
    108
    This little function detects in which mode (Web-exe, Harddrive-folder etc.) and where the program is running.
    You can use the returned values to access the other folders, like docs etc.
    Just put it in the global funktions tab and call it in Actions on startup.

    Code:
    function fnDetectMode(runexe)
    	resFile = File.Run(runexe, "", "", SW_SHOWNORMAL, false);
    		if _CommandLineArgs[1] ~= nil then
    			ModeStrPath = String.Replace(_CommandLineArgs[1], "SFXSOURCE:", "", true);
    		else
    			ModeStrPath = _SourceFolder.."\\".._SourceFilename;
    		end
    		mode_path = String.SplitPath(ModeStrPath);
    	return mode_path;
    	--[[
    	Now you can access the parameters of the path with
    		mode_path.Drive
    		mode_path.Folder
    		mode_path.Filename
    		mode_path.Extension
    	--]]
    	end

Similar Threads

  1. InstallDirDlg Path Issue
    By kcfischer in forum MSI Factory 2.0 Suggestions
    Replies: 0
    Last Post: 05-13-2008, 08:37 AM
  2. How to set DB File Path "Help"
    By mjmfgm in forum AutoPlay Media Studio 7.5
    Replies: 0
    Last Post: 01-11-2008, 11:57 AM
  3. How do I add to my PATH statement at install?
    By Tnygaard in forum Setup Factory 6.0
    Replies: 3
    Last Post: 05-27-2002, 01:38 AM
  4. PATH environment variable
    By RDodson in forum Setup Factory 6.0
    Replies: 4
    Last Post: 02-27-2002, 12:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts