PDA

View Full Version : File Equates reference?



LCSims
13-03-2012, 04:48
Continuing my discovery of programming in the 21st Century style, I was moving a small program from another form of BASIC into thinBASIC. It gathers a directory listing of files and one of the areas I wanted to add to the program was testing file names and their length. Since the file naming must be pretty uniform, I am looking for a slightly longer file name and marking an output file when encountered. As an avid reader of the help file, I came across the File Equates that are available. Of interest were the "%Path_File" and "%Path_Ext", but there was no further guidance in the help as to how they are used, nor could I find anything in checking some of the sample scripts.

So if I may ask, does anyone have a line or two of how these are coded? My attempts at using them like this were not successful; variable1 = %Path_File (variable2). Variable2 is a read of the full system path and file name. Both variables were setup as String.

Thank you for any insight, as it will help in future coding. For now I've just used an old fashioned "brute force" methodology, which means more more work in most cases.

Lance

Petr Schreiber
13-03-2012, 09:35
Hi Lance,

you were very close. Equates in general serve as helpers for commands.
The equates you mention are used by command FILE_PathSplit. To find the relevant commands, just open the help file, click on the "Find" tab, and enter the name of equate - related topics will pop up.

Here is little example of usage:


Uses "File" ' -- For file related functions
Uses "Console" ' -- To print something to console

String sMyFullPathToFile = "C:\MyFolder\MyFile.txt"
String sPathPart

PrintL "Tested path to file:"
PrintL sMyFullPathToFile
PrintL

' -- Returns just the path
sPathPart = FILE_PathSplit(sMyFullPathToFile, %PATH_ROOTPATH)
PrintL "%PATH_ROOTPATH:"
PrintL sPathPart
PrintL

' -- Returns just the filename
sPathPart = FILE_PathSplit(sMyFullPathToFile, %PATH_FILE)
PrintL "%PATH_FILE:"
PrintL sPathPart
PrintL

' -- Returns just the path
sPathPart = FILE_PathSplit(sMyFullPathToFile, %PATH_EXT)
PrintL "%PATH_EXT"
PrintL sPathPart
PrintL

PrintL
PrintL "Press any key to quit..."

WaitKey


Petr
Petr

LCSims
13-03-2012, 21:54
Hello Petr,

I see it's right where it should be in the help file, but wasn't one of the topics I had checked out. The explanation and your sample has turned the light on for me, Thank You!

I also read the thread about your work involving the robot. Most impressive!

Lance