home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / OS2 / GPHER161.ZIP / GETFNAME.GPH next >
Text File  |  1994-02-09  |  1KB  |  36 lines

  1. /* Return a reasonable filename */
  2. Parse arg type plustype, host, port, title, selstr, candidate, reason
  3.  
  4.  
  5. /* Parse the candidate file into directory and file: */
  6. candidate = translate(candidate,'/','\')
  7. last = lastpos('/', candidate)
  8. if last > 0 then
  9.   do
  10.   last = last + 1
  11.   parse var candidate path =(last) tail
  12.   end
  13. else
  14.   do
  15.   path = ''
  16.   tail = candidate
  17.   end
  18.  
  19. /* Now, parse the selection string into directory and file. */
  20. selstr = translate(selstr, '/', '\:')
  21. last = lastpos('/', selstr)
  22. selstr = substr(selstr, last+1)
  23.  
  24. /* If we're being called to advise the user, build a candidate
  25.    filename from the path and the selection string.  Note that
  26.    there's no guarantee that the resulting filename is actually
  27.    valid -- for example, on a FAT system, it should be constrained
  28.    to 8.3 format, and it's not. */
  29. if (reason='PROMPT') then
  30.   return path || selstr
  31.  
  32. /* If we're being called for a GIF file, always use the same
  33.    filename. */
  34. if (type = 'g') then
  35.   return path || 'work.gif'
  36.