05-16-2003, 01:05 AM
I've noticed some of the code posted here contains explicit path information, or else files need to be loaded in a particular directory to be accessable when the program is run.
1 pretty good way to prevent paths from needing to be hard-wired while allowing the user to hunt for their files is with code like this:
where 3 was menu item that said something like "change directory".
Once the path is identified, the user can type his filename using a different menuitem.
However...this is still clunky. When I write a program that I want to open a file, I find it easier to simply use the COMMAND$, then compile the program before using it. That way, you can simply drag-n-drop the file from windows onto the executable to launch the program with the dropped file as the target. This makes it *much* easier to use.
The code looks something like this:
(caution...this is not actual code subs not included...just an example)
Note the inclusion of the filehandling routine...this is to make the code usable from within the interpreter...if you don't include this, then the code is only usable in its compiled form.
Just a thought...does anyone else use the drag-n-drop method?
Are there easier ways to get path info?
Thanks
This doesn't work if you have a bunch of data files...in this case, it's easiest to use relative addressing and put the files in a directory where the exe is located...
1 pretty good way to prevent paths from needing to be hard-wired while allowing the user to hunt for their files is with code like this:
Code:
CASE "3"
PRINT
DO
SHELL "cd" 'to print the 'pwd'
PRINT "Enter DOS command or <Q>uit "
INPUT DOS$
IF LCASE$(DOS$) = "q" THEN EXIT DO
COLOR 15
SHELL DOS$
LOOP
Once the path is identified, the user can type his filename using a different menuitem.
However...this is still clunky. When I write a program that I want to open a file, I find it easier to simply use the COMMAND$, then compile the program before using it. That way, you can simply drag-n-drop the file from windows onto the executable to launch the program with the dropped file as the target. This makes it *much* easier to use.
The code looks something like this:
Code:
CALL commandhandler (needfile%) 'checks if COMMAND$ contains data
fullfilein$=COMMAND$
IF needfile%=1 THEN
CALL filesmenu (fullfilein$) 'get a name (with option to change path) if command$ contains no data
ENDIF
CALL pathparser (fullfilein$, path$, root$, extension$)
OPEN path$+root$+extension$ FOR BINARY AS 1
OPEN path$+root$+".tmp" FOR BINARY AS 2
(caution...this is not actual code subs not included...just an example)
Note the inclusion of the filehandling routine...this is to make the code usable from within the interpreter...if you don't include this, then the code is only usable in its compiled form.
Just a thought...does anyone else use the drag-n-drop method?
Are there easier ways to get path info?
Thanks
This doesn't work if you have a bunch of data files...in this case, it's easiest to use relative addressing and put the files in a directory where the exe is located...