====================================================
;CHOICE.LXB // The semicolon is the LXB comment marker.
screensetup // LXB command to put the palmtop in graphics mode
upper *ext %1 // Gets commandline arguments (%1 and %2) ,
upper *fqn %2 // converts them to uppercase and stores them in
// LXB global variables.
goto @ext@ // Jump to the section of the code that deals with
// files that have the extension stored in @ext@
;--------------------------------------------------------
;Global subroutines:can be used by several types of files
;--------------------------------------------------------
:WIN //A label for a subroutine
screensetup Choices for @fqn@ //Show the name of the file
RETURN //at the top of the screen.
:1MNT
winopen 280 80 360 110 One //"One Moment" message in a
windisplay 10 1 2 Moment //small two-line window
RETURN
:SELECT //Pick a new file with the
//extension given in @ext@
Dirbrowse *aFile *.@ext@ Choose a different *.@ext@ file
//Dirbrowse puts a directory
//browser on the screen. It lets
//you select different drives,
//directories and only those files
//with the extension in @ext@. Once
//you've picked a file, its name
//will be stored in the *aFile
//variable.
if "@afile@" == "" goto skip //Test for the case when no file
//was selected otherwise goto :SKIP.
set *fqn @aFile@ //Copy the @aFile@ variable to the
//*fqn variable for further use.
:SKIP
goto @ext@ //Return to sender...
;---------------------
;Compressed files menu
;---------------------
:LZH
:ZIP
gosub win // execute ":WIN"
menu "&List all files" "&Test all files" "&View a text file" "&Extract a file" "&Pick a New File" &Quit
onerrorgoto end list@ext@ test@ext@ view@ext@ extract@ext@ select end
// "menu" is a LXB command.
// If a menu item is more than one
// word, enclose it in quotes.
// Use "&" before any "hot key".
// "onerrorgoto" is a LXB command.
// The first choice should be a way
// to exit via the ESC key. The second
// option refers to the first item in
// the menu list; the third option
// refers to the second item in the
// list and so on. All items refer to
// the routines below except for
// "Pick a New File" which refers to
// the ":SELECT" routine shown above.
// NOTE: you can concatenate an LXB
// variable to another word as in
// "list@ext@" (Neat feature!)
:LISTLZH // CHOICES to show a list of files
:LISTZIP // in a compressed file....
gosub 1MNT // run the ":1MNT" subroutine
if "@ext@" == "LZH" lha l /n @fqn@ >filelist
// i.e. if the extension is "LZH"
// run the LHA program on the
// given .LZH file (shown as @fqn@)
// and send the list to a file called
// "filelist" using the DOS I/O
// redirection operator ( > ).
if "@ext@" == "ZIP" fv @fqn@ >filelist
// If the extension is .ZIP, use
// Vernon Buerg's FV.COM program to
// send a list of files to the
// "filelist" file.
FileDisplay filelist // "FileDisplay" is a LXB command
// that displays any text file in
// an onscreen window.
del filelist // Erase the filelist file when
// you're done with it.
goto @ext@ // Loop back to the start of the
// Menu routine.
:TESTLZH // Routines to test the integrity
:TESTZIP // of a compressed file.
gosub 1MNT
if "@ext@" == "ZIP" goto ziptest
// If the extension is ZIP jump to the
// next section, otherwise set the
screenrestore // screen to text mode
lha t @fqn@ // Use the LHA program to test the
// .LZH file and show it on the screen.
pause
screensetup // Set graphics mode.
goto @ext@ // Loop back to the menu.
:ZIPTEST
pkunzip -t @fqn@ > filelist // Send the test results to
// "filelist" and
FileDisplay filelist // display the results.
del filelist
goto @ext@ // Loop back
:VIEWLZH // Routines to view a single file
:VIEWZIP // in a compressed file.
input *vufile "Which file? "
// "input" is a LXB command that
// asks for the name of a file and
// stores the name in a LXB variable
// I named *vufile.
if "@vufile@" == "" goto @ext@ // Test for no input
// otherwise...
gosub 1MNT
if "@ext@" == "LZH" lha e /n @fqn@ @vufile@
if "@ext@" == "ZIP" pkunzip -e @fqn@ @vufile@ >nul
// Extract the vufile from the
// compressed file.
Filedisplay @vufile@ // Display the file.
del @vufile@ // Erase the temporary file.
set *vufile "" // Reset the *vufile variable
goto @ext@
:EXTRACTLZH // File extraction routines
:EXTRACTZIP
input *vufile "Which file? "
if "@vufile@" == "" goto @ext@
gosub 1mnt
if "@ext@" == "LZH" lha x /n @fqn@ @vufile@
if "@ext@" == "ZIP" pkunzip -e @fqn@ @vufile@
// The extraction process will
// clutter the display, so
screenrestore // switch in and out of text mode
screensetup // to refresh the screen.
goto @ext@
:END
screenrestore //Restore the screen and stop
stop