home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
wp_dtp
/
proan111.lha
/
AutoMenu.ProANSI
< prev
next >
Wrap
Text File
|
1992-05-28
|
8KB
|
374 lines
/*
* file : AutoMenu.ProANSI
* auteur: Marcel Offermans
* $VER: AutoMenu.ProANSI V1.02 (28.5.92)
*
* Copyright © 1992 Marcel Offermans (Sillysoft)
*
* Dit programma is bedoeld om het genereren van `standaard' menu's te
* vereenvoudigen. Je maakt de menu definities aan in een soort script
* en dat script `voer' je dan aan dit programma, dat het omzet in de
* gewenste schermen. Die schermen worden dan automatisch gesaved naar
* de van te voren aangegeven files. Je roept dit programma als volgt
* aan (vanuit een Shell):
*
* 1> rx AutoMenu.ProANSI <scriptfile>
*
* Waarbij je voor die scriptfile natuurlijk je eigen script invult.
* Dat is alles. Volgens mij gaat het niet veel eenvoudiger.
*
* Het programma kan eenvoudig uitgebreid worden omdat je de parser
* niet hoeft aan te passen als je een nieuw commando toevoegt. Je
* kunt dus volstaan met het toevoegen van het commando, en de parser
* zal het automatisch herkennen.
*
* NOTE TO ENGLISH SPEAKING USERS:
*
* If you don't understand dutch I will be happy to help you with this
* program. Unfortunately I don't have time to translate everything into
* english at the moment.
*
* - Marcel
*/
/* Stuur commando's naar ProANSI, onze host. */
address 'REXX_ProANSI'
/* We willen ook graag antwoord terug hebben. */
options results
/* Lees het commando achter AUTOMENU, de naam van de scriptfile. */
parse arg menufile
/* Als die filenaam niet opgegeven was, geef dan een melding uit. */
if (menufile == '') then
do
say
say 'AutoMenu.ProANSI, Copyright © 1992 Marcel Offermans (Sillysoft)'
say 'Usage: rx AutoMenu.ProANSI FILENAME/A'
say
exit 5
end
/* Als de filenaam niet bestaat, protesteren we ook. */
if (exists(menufile) ~= 1) then
do
say 'Error finding ' || menufile || ', please check path & spelling.'
exit 10
end
/* Nu openen we de file, en `ontleden' we hem in commando's. */
if (open('fin', menufile, 'Read') == 0) then
do
/* Dat ging blijkbaar niet?! */
say
say 'Error opening ' || menufile || '. The file is available, but I'
say 'cannot open it, check if some other task has it open.'
say
/* exit with returncode FAIL */
exit 20
end
/* Nu eerst een paar globale var. van een default waarde voorzien. */
menutitel = 'Menu'
menufcol = 9
menubcol = 4
menualign = 'center'
menux = 5
menuxsize = 70
menuy = 2
itemfcol = 15
itembcol = 4
itemx = 10
itemxsize = 60
itemy = 5
itemalign = 'left'
hotkeyfcol = 11
hotkeybcol = 0
bracketfcol = 9
bracketbcol = 0
bracketopen = '['
bracketclose = ']'
nrofcolumns = 1
boxfcol = 12
boxbcol = 0
/* `Tijdelijke' waarden, zoals tellers e.d. */
itemnum = 0
/* Lees de file regel voor regel. */
instring = readln('fin')
/* Net zolang tot we een lege regel tegenkomen. */
do while (~eof('fin'))
/* Verwijder eventueel commentaar achteraan de regel. */
parse var instring command ';' comment
/* Kijk of er dan nog een commando overblijft. */
if (length(command) > 0) then
do
/* Ontleed het commando in commando en argumenten. */
parse var command cmd par
/* Als dat lukte, dan voeren we het commando uit. */
if (length(cmd) > 0) then
do
interpret 'call ' || cmd || '(par)'
end
end
/* Lees de volgende regel uit de file. */
instring = readln('fin')
end
/* Sluit de file. */
close('fin')
/* Verlaat het programma. */
exit 0
/*************************************************************************\
* *
* Hieronder volgen de commando's die door automenu herkend worden als *
* scriptcommando's. Deze lijst is zonder meer uit te breiden met alle *
* mogelijke commando's, want de dispatcher hierboven kan het niet sche- *
* len of/welke commando's er bestaan. Hij stopt gewoon als hij iets *
* tegenkomt wat niet bestaat. *
* *
* Als je zelf commando's toevoegt, dan zou ik die graag ook krijgen, *
* zodat ook anderen daarvan kunnen profiteren, en omdat je dan een *
* beetje een standaard aan kunt houden. Ik hoop hierbij op een ieders *
* medewerking. *
* *
* Marcel *
* *
\*************************************************************************/
menu:
parse arg titel
itemnum = 0
parse var titel naam
menutitel = strip(naam,'b')
'set_pos' menux menuy
'select_col' menufcol menubcol
if (menualign == 'center') then
do
'print_string' Center(menutitel, menuxsize)
end
if (menualign == 'left') then
do
'print_string' Left(menutitel, menuxsize)
end
return
menuoptions:
parse arg titel
parse var titel fcol bcol align x xs y
if ((align ~= 'left') & (align ~= 'center')) then
do
say 'Unsupported menu align parameter (' || align || ').'
return
end
menualign = align
if ((fcol >= 0) & (fcol <= 15)) then
do
menufcol = fcol
end
if ((bcol >= 0) & (bcol <= 7)) then
do
menubcol = bcol
end
if ((x >= 0) & (x <= 79)) then
do
menux = x
end
if ((xs >= 0) & (xs <= 79)) then
do
menuxsize = xs
end
if ((y >= 0) & (y <= 60)) then
do
menuy = y
end
return
single_box:
arg xmin, ymin, xmax, ymax
'set_pos' xmin ymin
if ((xmax <= xmin) || (ymax <= ymin)) then
do
return
end
/* Maak een string met lengte xmax-xmin */
topline = 'da'x || Copies('c4'x, xmax-xmin-1) || 'bf'x
'print_string' topline
do y = ymin+1 to ymax-1
'set_pos' xmin y
'print_string' 'b3'x
'set_pos' xmax y
'print_string' 'b3'x
end
'set_pos' xmin ymax
/* Maak een string met lengte xmax-xmin */
bottomline = 'c0'x || Copies('c4'x, xmax-xmin-1) || 'd9'x
'print_string' bottomline
return
/*
Een nieuw item toevoegen aan een menu.
*/
item:
parse arg hotkey naam
/* kijk of het een leeg item was, want dan zijn we snel klaar */
if (length(naam) == 0) then
do
itemnum = itemnum + 1
return
end
xp = (itemnum - nrofcolumns * trunc(itemnum / nrofcolumns)) * trunc(itemxsize / nrofcolumns)
xs = trunc(itemxsize / nrofcolumns)
yp = trunc(itemnum / nrofcolumns)
'set_pos' (itemx + xp) (itemy + yp)
'select_col' bracketfcol bracketbcol
'print_string' bracketopen
'select_col' hotkeyfcol hotkeybcol
'print_string' hotkey
'select_col' bracketfcol bracketbcol
'print_string' bracketclose || ' '
'select_col' itemfcol itembcol
naam = strip(naam,'b')
rest = xs - 3 - length(hotkey)
if (itemalign == 'center') then
do
'print_string' Center(naam, rest)
end
if (itemalign == 'left') then
do
'print_string' Left(naam, rest)
end
itemnum = itemnum + 1
return
itemoptions:
parse arg titel
parse var titel fcol bcol align x xs y cols
if ~((align ~= 'left') & (align ~= 'center')) then
do
itemalign = align
end
if ((fcol >= 0) & (fcol <= 15)) then
do
itemfcol = fcol
end
if ((bcol >= 0) & (bcol <= 7)) then
do
itembcol = bcol
end
if ((x >= 0) & (x <= 79)) then
do
itemx = x
end
if ((xs >= 0) & (xs <= 79)) then
do
itemxsize = xs
end
if ((y >= 0) & (y <= 60)) then
do
itemy = y
end
if ((cols >= 1) & (cols <= 10)) then
do
nrofcolumns = cols
end
return
boxitems:
'select_col' boxfcol boxbcol
call single_box(itemx-2,itemy-1,itemx+itemxsize+1,itemy+trunc((itemnum + (nrofcolumns - 1)) / nrofcolumns))
return
boxmenu:
'select_col' boxfcol boxbcol
call single_box(menux-2,menuy-1,menux+menuxsize+1,menuy+1)
return
save:
parse arg titel
parse var titel mode filenaam
filenaam = strip(filenaam,'b')
mode = strip(mode,'b')
if (mode == 'ascii') then
do
'save_ascii' filenaam
end
if (mode == 'ansi') then
do
'save_ansi' filenaam
end
if (mode == 'anim') then
do
'save_ansi_anim' filenaam
end
return
/* load a (background) picture */
loadpic:
parse arg filename
filename = strip(filename)
'include_file' filename
return
/* change hotkey colors */
hotkeyoptions:
parse arg fc bc bfc bbc bopen bclose
if ((bc >= 0) & (bc <= 7)) then
hotkeybcol = bc
if ((fc >= 0) & (fc <= 15)) then
hotkeyfcol = fc
if ((bbc >= 0) & (bbc <= 7)) then
bracketbcol = bbc
if ((bfc >= 0) & (bfc <= 15)) then
bracketfcol = bfc
if (bopen != '') then
bracketopen = bopen
if (bclose != '') then
bracketclose = bclose
return
newmenu:
'new'
return