Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpl-opus!hpnmdla!darrylo From: darrylo@hpnmdla.HP.COM (Darryl Okahata) Newsgroups: comp.sys.handhelds Subject: Unix-link PATH searching for the HP-48SX Message-ID: <1570006@hpnmdla.HP.COM> Date: 11 Jul 90 20:20:39 GMT Organization: HP Network Measurements Div, Santa Rosa, CA Lines: 106 Here is yet another method for accessing programs in other directories. It introduces the concept of a Unix-like "PATH" variable, which gives a list of directories to search. This program, called "EXEC", works just like Jan Christiaan van Winkel's (jc@atcmp.nl) SVC function, except that it will search multiple paths. You enter the arguments to your function on the stack, enter the name of your function (e.g., 'MYFUNC'), and then execute "EXEC". To use it, you need a variable called "EXECPATH" in the HOME directory, and this variable should contain a list of directory paths (in list form). For example, one possible value for EXECPATH could be: { { SYS } { ETC } { ETC ETC } HOME { } } This causes EXEC to search the following directories for functions: { SYS } { ETC } { ETC ETC } HOME the current working directory Note that HOME does not have to be in a list (for that matter, directory paths with only one name do not have to be in a list, but it makes it easier to debug). Also note that placing HOME in this list is redundant; as everything searches HOME, HOME should never be placed in this list. Notes/problems: 1. EXECPATH does not necessarily come from the HOME directory. Strange things will happen if EXECPATH resides in the "current directory" or in one of the directories given by EXECPATH. 2. The name "EXECPATH" is too long. It should be shortened to save time and space. 3. EXEC is slow. The overhead in using EXEC is at least 0.1 sec (I don't know what the overhead in using SVS is, however). The actual overhead depends on how large and complex your EXECPATH happens to be. EXEC should be rewritten in assembly language. It should, perhaps, keep more things on the stack and not in local variables. 4. EXEC is big (240 bytes). 5. If "{ }" is not contained in the EXECPATH list, the current working directory will not be searched. 6. Some people will want to remove the code that handles "{ }" (searches the current working directory). This will increase speed and decrease program size. To do this, replace the lines that say: IF DUP SIZE 0 == THEN DROP cwd END EVAL with: EVAL 7. Searching HOME is redundant. -- Darryl Okahata UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo Internet: darrylo%hpnmd@hp-sde.sde.hp.com DISCLAIMER: this message is the author's personal opinion and does not constitute the support, opinion or policy of Hewlett-Packard or of the little green men that have been following him all day. =============================================================================== Store the following in a variable called "EXEC" in the HOME directory. Checksum: #19683d ------------------------------------------------------------------------------- %%HP: T(3)A(D)F(.); \<< PATH EXECPATH SIZE 1 \-> cwd end i \<< DO EXECPATH i GET IF DUP SIZE 0 == THEN DROP cwd END EVAL IF IFERR RCL 1 THEN IF 'i' INCR end > THEN cwd EVAL " :NOT FOUND" + DOERR END 0 0 END THEN cwd EVAL EVAL 1 END UNTIL END \>> \>>