home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / MISC.REX < prev    next >
OS/2 REXX Batch file  |  1994-01-22  |  2KB  |  55 lines

  1. /* #include <misc.rex> */
  2.  
  3. MakeFileName: procedure
  4.    /**
  5.    ***  This will make a file name from the string passed.  In the case of
  6.    ***  HPFS, the name is left pretty much alone.  In the case of FAT, the
  7.    ***  1st 8 chars are returned, which has a good chance of not being
  8.    ***  unique.
  9.    **/
  10.  
  11.    parse arg FileSystem,string
  12.  
  13.    string = strip(string)
  14.    if FileSystem = 'HPFS' then
  15.       Name = translate(string, '!!...!---+', '"\/:*?|<>-&')
  16.    else
  17.       Name = left(translate(string, '___________', '"\/:*?|<>-&'), 8)
  18.    return Name
  19.  
  20.  
  21. GetHilbertIni: procedure
  22.    /**
  23.    ***  This will find the INI file that contains profile information.
  24.    **/
  25.  
  26.    /* Look for an environment variable first */
  27.  
  28.    IniFile = value('Hilbert.Ini',,"OS2ENVIRONMENT")
  29.    if IniFile = '' then
  30.       IniFile = SysSearchPath("DPATH","Hilbert.Ini")
  31.    if IniFile = '' then
  32.       do
  33.       This = ThisDirectory()
  34.       if Exists(This"\Hilbert.Ini") then
  35.          IniFile = This"\Hilbert.Ini"
  36.       end
  37.    if IniFile = '' then
  38.       call Error 2002,1,"Hilbert.Ini"
  39.    return IniFile
  40.  
  41. GetUniqueKey: procedure
  42.    /**
  43.    ***  This will return a unique numeric key to the caller.  This should be
  44.    ***  a systemwide critical section, but there's no way to do that in
  45.    ***  standard REXX, so we will hope for the best.
  46.    **/
  47.  
  48.    parse arg IniFile
  49.  
  50.    IniValue = SysIni(IniFile,'Global','Unique Key')
  51.    if datatype(IniValue,'Numeric') <> 1 then IniValue = 0
  52.    IniValue = IniValue + 1
  53.    code = SysIni(IniFile,'Global','Unique Key',IniValue)
  54.    return IniValue
  55.