1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
\ Information NEWAPP is a skeletal program that allows users to quickly develop a DOS application. It provides often needed tasks including error handling, command-line parsing, file operations, buffered I/O, help screen, number and string functions. NEWAPP comprises two parts: NEWAPP.SCR skeletal application program DOSLIB.SCR function support library \ Load - main screen empty forth definitions decimal application warning on : TITLE ." NEWAPP version 0.0 2017-01-17" cr ; cr .( Compiling: ) title 2 load cr .( Save to disk? ) y/n [if] \ reserve @ pad + 256 + limit s0 @ - + set-limit turnkey program NEWAPP [then] \ Load - defaults variable RESERVE 0 reserve ! \ reserved memory tally defer ?BREAK ' noop is ?break \ break check off defer SET-IO ' bios-io is set-io \ default console mode defer ONERROR ' noop is onerror \ reset on-error handler defer ONSTART ' noop is onstart \ startup initialization blk @ 1+ #screens 1- thru \ load electives & application ' (?break) is ?break \ enable user break \ ' dos-io is set-io \ enable console redirection ' deloutfile +is onerror \ delete outfile on error \ wrtchk off \ disable overwrite check \ Electives 1 fload DOSLIB \ DOSLIB library _Errors \ error handler _Inout1 \ number output _Inout2 \ string & number input \ _Compare1 \ basic compare _String1 \ basic strings \ _String2 \ extra strings _Parsing1 \ command-line parsing \ _Parsing2 \ command-line parsing _Fileprims \ file primitives _Files \ default files _Bufinfile \ buffered input file _Bufoutfile \ buffered output file \\ Electives _Dos1 \ dosver dta _Dos2 \ ctl-brk int _Disk \ disk _Memory \ memory allocate _Timedate1 \ time/date _Timedate2 \ time/date _Timepack \ time/date packing _Filematch \ file find first/next _Filestamp \ file stamp/attribute _Diskdir \ directory _Env \ environment _Exec \ exec prog/command _Video1 \ textcolor attrib cursor _Video2 \ mode page \\ Electives _Timing1 \ timer _Timing2 \ delay _Device1 \ 8087 cpu keybd \ Help screen - HELP : HELP ( -- ) dos-io cr cr title cr ." Use: NEWAPP [options] file[.TXT] [file[.DOC]]" cr cr ." -A set A option" cr ." -B set B option" cr ." -Cn set C option using numeric argument (1-10)" cr \ Help screen - HELP cr ." default: list program defaults here" cr cr ." Insert a brief description of program here." cr ." The HELP screen should be invoked when a program" cr ." is unable to proceed due to fatal user error." set-io error1 ; \ Variables variable A-VAR \ variable B-VAR \ 1 value C-VAL \ \ (SETOPTION) \ Set options : (SETOPTION) ( a u char -- a u ) upcase [char] A of A-VAR on end [char] B of B-VAR off end [char] C of 1 10 /numrange to C-VAL end badoption ; ' (setoption) is setoption \ (PARSEFILENAME) \ Parse filenames : (PARSEFILENAME) ( -- ) argv 0= if help then s" TXT" +ext infile setname argv 0= if infile filename -path -ext then s" DOC" +ext outfile setname ; ' (parsefilename) is parsefilename \ (RUN) \ Run application : (RUN) ( -- ) cr ." infile: " infile .file r/o openinfile cr ." outfile: " outfile .file r/w makeoutfile cr ( perform the application tasks ) begin readchar while writechar repeat \ a sample application closefiles ; \ DEFAULTS \ Set application defaults : DEFAULTS ( -- ) ; defaults \ RUN PROGRAM \ Run application with error handling : RUN ( -- ) ['] (run) catch ?dup if >r onerror r> throw then ; \ Main : PROGRAM ( -- ) onstart \ startup initialization set-io \ set console mode defaults \ set defaults cr title \ show application name cmdtail parsecmd \ process command-line run \ run application cr ." done" \ show success ; |