Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / About paths

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. About paths
#7570
Posted by: Jeff Glatt 2005-11-24 11:45:03 Last edited by: Jeff Glatt 2007-06-15 07:35:59 (Total edited 1 time)
After dealing with people putting data files, DLLs, EXEs, and scripts in various places and then saying that they're getting error messages about things not being found (because people aren't specifying full paths), I've decided to enforce a more restrictive policy toward paths.

(Most of these problems likely arise from presenting a file dialog without the 'DIR' option. That causes the current directory to be changed to whatever directory the user browses. With the current directory constantly changing, you need to specify full paths. It is bad programming practice not to do so. But by adopting a more restrictive policy, I believe the need for full paths can be avoided).

First of all, Reginald must be installed via its installer. The installer properly sets up the file association, and registry, so that scripts can be started by double-clicking, and also add-on DLLs can be found. Scripts, as well as EXEs you create with RPC, can then be placed anywhere on the system.

Secondly, add-on DLLs (but not Macro DLLs) must always be installed in Reginald's directory. The add-on installers automatically do this.

Third, all object scripts, child scripts, icons, bitmaps, and macro DLLs must be put in the same directory as the scripts that use them. If "main.rex" uses an icon named "myicon.ico" and creates an object from "MyScript.rex", then all 3 items must be in the same directory.




I've also adopted a "naming policy" for child scripts and macro DLLs. Child scripts should be named with a .REX or .REXX extension. When calling the script, add the extension to the name:
myscript.rex()
Macro DLLs should be named with a DLL extension. When loading the DLL, do not add the DLL extension:
/* Load MyMacros.dll */
MACRO mymacros
When creating an object from a script in a macro DLL, again, do not add the DLL extension:
createobject("MyMacros", "Object1", 1)



As far as data files are concerned, you should always specify a full path.

For a data file that is temporary (ie, will be created when the script runs, and deleted when the script ends), use the temp directory. For example, to create the full path for a data file named "myfile.dat":
filename = SEARCHPATH("%TEMP%") || "myfile.dat"
For a data file that is to be shared by all users running that script, you should create your own directory in the Program Files directory, and place the data file there. You can get the Program Files directory via SEARCHPATH(). If you install your script onto a computer, you should also install there.

For a data file that is to be used only by the one user running the script (ie, each user will have his own version of the data file), then create it in a per-user directory. One approach would be to put it in his "My Documents" folder (or in a sub-folder you create there). Again SEARCHPATH("%DOCS%") will get you that path. Do not put per-user data files in Program Files, the same directory as the script, or the "current directory". That's bad programming practice on a multi-user OS.
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-2-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0