Tv ReqFile

From TVPaintWiki
Revision as of 10:26, 21 May 2010 by Madsjuul (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<<<George<<<Command Reference<<<<George Commands Interface


  tv_ReqFile "title|path|name|extension"

Opens a file requester. The arguments for this command use the form: "title|path|name|extension". This string must be written between double quotes. Each argument is separated from the next by the "|" (pipe) character. These arguments may contain spaces. The title argument is the title of the file selector, in other words the text that is displayed in the title bar (for example "Save an image"). The path argument is the access path to the directory for which the contents are displayed by the selector (for example "C:\TVPaint\Images"). The name argument is the text that appears in the Selector Name field by default (for example "LOGO.JPG"). The extension argument is a pattern that determines the file type displayed in the selector (for example "*.jpg"). This command returns the complete path and filename of the selected file, or "Cancel" if the user clicked on Cancel or OK without selecting a file.


Examples

Remember File Path

tv_ReadUserString fileRequest 0 
PARSE result path
tv_ReqFile "Request A File|"path"||"
PARSE result path
last = LastPos(path,"\")
dir = LeftString(path,last-1)
tv_writeUserString fileRequest 0 dir
FUNCTION LastPos(string,car)
 pos = LEN(string)
  WHILE ((CMP(CHAR(string,pos),car) == 0) && (pos > 0))
    pos = pos-1
  END
 RETURN pos
END
FUNCTION LeftString(string,number)
 LOCAL size
  size = LEN(string)
  IF (number > 0)
   IF (number > size)
    number = size
   END
   RETURN CUT(string,1,number)
  END
  RETURN 0
END