Make your own free website on Tripod.com
 
 
 Tips & Trix
Dynamically Create Batch Files based on user input

Home
PUBz
Grafx Pax
Tips & Trix
Neo-Linx
Neo-Talk
Neo-Filez
Search NeoDezign
 
 
 

 


By using various button styles and the FileWrite command you can create DOS Batch files. You can then have your Neo-app run the BAT file to do various tasks.

The downside is you have to contend with the ugly old DOS screen that pops up. The upside is that, as you know, there are lots of DOS commands. This, in some cases, could potentially add a bit more power to your app. 

As you might guess, this example is just the tip of the iceberg. This is just a simple GUI for a "dir" command...

Here, I have created a set of Option buttons that act as File Filters. *.TXT, *.DOC, *.EXE and *.BMP. The variable is [filter]. 

The Text Entry box is for a Path statement and stored in the variable [path]. End the statement with a trailing backslash "\". 

(Or better yet, look at the string and determine if the "\" is there or not. If it's not, then append it to the string.)

StrLen "[path]" "[pathlen]"
SubStr "[path]" "[pathlen]" "1" "[lastchar]"
If "[lastchar]" "<>" "\"
SetVar "[path]" "[path]\"
EndIf
The "Next >" button does most of the work.
FileWrite "[path]list.bat" "1" "dir [filter] /b > list.txt"
DOSCommand "[path]list.bat" "" "Normal"
GotoNextPage
The FileWrite command creates a BAT file in the folder designated by the user. It could look something like this...
dir c:\windows\*.txt /b > list.txt
(the "/b" is for a bare list)
 


The down arrow button action first reads all of the list.txt file and stores it in the variable [list]. Then from that, build a menu with MenuEx. In turn, the selection number is stored in the variable [menuselect]. Lastly, FileRead the line number of list.txt as chosen from the [menuselect] 
 

FileRead "[path]list.txt" "all" "list"
MenuEx "26" "62" "[list]" "menuselect"
FileRead "[path]list.txt" "[menuselect]" "[file]"
The List button opens a TextWindow of the list.txt file and finally, the Open button performs a DOSCommand on the file launching the associated program to open the file.
DOSCommand "[path][file]" "" "Normal"


Download this PUB

There are a lot more possibilities!