home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
345.lha
/
snap_v1.4
/
startsnap.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1990-02-13
|
13KB
|
524 lines
/* Arexx script to help people with Snap arguments */
signal on error
if ~show('l', "rexxarplib.library") then do
check = addlib('rexxsupport.library',0,-30,0)
check = addlib('rexxmathlib.library',0,-30,0)
check = addlib('rexxarplib.library',0,-30,0)
end
if ~exists("fonts:helvetica/15") then do
say "Actually I need font 'Helvetica 15', but I'll try anyway."
end
bool.0 = 'OFF'; bool.1 = 'ON'
/* Fix window dimensions */
screen.width = ScreenCols()
screen.height = ScreenRows()
window.width = 530
window.height = 200
window.leftedge = (screen.width-window.width)/2
window.topedge = (screen.height-window.height)/2
/* Set up a host */
parse version 'V' vers .
signal on syntax
call stop(SNAPHOST)
syntax:
if vers > 1.06 then
address AREXX "'call CreateHost(SNAPHOST, SNAPPORT)'"
else
"runwsh >nil:" "'call CreateHost(SNAPHOST, SNAPPORT)'"
/*
* Wait for a while until host is ready.
*/
do for 50 while ~show('Ports','SNAPHOST')
call delay 10 /* 200 ms */
end
call SetReqColor(SNAPHOST, BLOCKPEN, 1)
call SetReqColor(SNAPHOST, DETAILPEN, 0)
/*
* Open the window
*/
window.idcmp = 'CLOSEWINDOW+GADGETUP+RAWKEY'
window.flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
title = "Setup tool for Snap"
call OpenWindow(SNAPHOST, window.leftedge, window.topedge, window.width, ,
window.height, window.idcmp, window.flags, title)
call ModifyHost(SNAPHOST, RAWKEY, "RAWKEY %c")
if exists("fonts:Helvetica/15") then do
call SetFont(SNAPHOST, "Helvetica.font", 15)
end
signal dotext
/* --- Start of texts ---
" Please hold on..." 5 20 60 ""
"Priority:" 5 40 6 "Input handler priority."
"Insert key:" 215 60 9 "Key used with Left Amiga to insert."
"Window key:" 215 80 9 "Key used with Left Amiga to open control window."
"Char delay:" 215 100 9 "Delay after each inserted character"
"Line delay:" 215 120 9 "Delay after each inserted newline."
"Bit mask:" 215 140 9 "Bit planes to draw selection frame into."
"Starting unit:" 215 160 9 "Unit in which to start snapping."
"Prepend:" 5 180 6 "Characters added in front of each line in modified inserts."
"Append:" 215 180 6 "Characters added at the end of each line in modified inserts."
"Selection frame pattern:" 345 40 19 "Pattern used for crawling dots in selection frame."
"Text qualifier:" 5 60 11 "Qualifier used when snapping characters."
"Gfx qualifier:" 110 60 11 "Qualifier used when snapping graphics."
EOT
--- End of texts --- */
dotext:
textlines = sigl+1
call SetReqColor(SNAPHOST, 'BOXPEN', 0)
call SetReqColor(SNAPHOST, 'SHADOWPEN', 0)
call SetAPen(SNAPHOST, 1)
do i=1 while sourceline(textlines+i) ~= "EOT"
parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
call AddGadget(SNAPHOST, x, y, 'HLP'i, copies(' ',w), "HELP "help)
end
call SetReqColor(SNAPHOST, 'BOXPEN', 2)
call SetReqColor(SNAPHOST, 'SHADOWPEN', 3)
do i=1 while sourceline(textlines+i) ~= "EOT"
parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
call Move(SNAPHOST, x, y+10); call Text(SNAPHOST, text)
end
/* Set up some nice gadgets */
x = 65
do i=51 for 5
call AddGadget(SNAPHOST, x, 40, 'PR'i, ''i'', 'PRIORITY 'i); x = x+27
end
inscode.1 = 23; inscode.2 = 15; inscode.3 = 34
inskey.1 = 'I'; inskey.2 = 'Y'; inskey.3 = 'V'
x = 300
do i=1 for 3
call AddGadget(SNAPHOST, x, 60, 'INS'i, inskey.i, 'INSKEY 'i); x = x+20
end
cwcode.1 = 17; cwcode.2 = 51; cwcode.3 = 24
cwkey.1 = 'W'; cwkey.2 = 'C'; cwkey.3 = 'O'
x = 300
do i=1 for 3
call AddGadget(SNAPHOST, x, 80, 'CW'i, cwkey.i, 'CWKEY 'i); x = x+20
end
x = 300
do i=0 for 3
call AddGadget(SNAPHOST, x, 100, 'CDL'i, i, 'CDELAY 'i); x = x+20
end
x = 300
do i=0 for 3
call AddGadget(SNAPHOST, x, 120, 'LDL'i, i, 'LDELAY 'i); x = x+20
end
x = 300
do i=0 for 3
call AddGadget(SNAPHOST, x, 140, 'MSK'i, i, 'MASK 'i); x = x+20
end
call AddGadget(SNAPHOST, 300, 160, 'UNT'0, "Frame", 'UNIT 0')
call AddGadget(SNAPHOST, 350, 160, 'UNT'1, "Char ", 'UNIT 1')
call AddGadget(SNAPHOST, 365, 60, 'XERX', 'Immediate insert', 'XEROX')
call AddGadget(SNAPHOST, 365, 80, 'JOIN', 'Join long lines ', 'JOIN')
call AddGadget(SNAPHOST, 365, 100, 'PTCH', 'Early patch ', 'PATCH')
call AddGadget(SNAPHOST, 365, 120, 'USCR', 'True underscore ', 'UNDERSCORE')
call AddGadget(SNAPHOST, 70, 180, 'PREP', "> ", 'PREP %g', 128)
call AddGadget(SNAPHOST, 280, 180, 'APP', "", 'APP %g', 128)
call SetReqColor(SNAPHOST, 'SHADOWPEN', 0L)
y = 18
do i=0 for 16
call AddGadget(SNAPHOST, 510, y, 'PAT'i, ' ', 'PATTERN 'i); y = y+11
end
call SetReqColor(SNAPHOST, 'SHADOWPEN', 3L)
bit.1 = 0; desc.1 = 'Left Shift '
bit.2 = 1; desc.2 = 'Right Shift'
bit.3 = 3; desc.3 = 'Control '
bit.4 = 4; desc.4 = 'Left Alt '
bit.5 = 5; desc.5 = 'Right Alt '
bit.6 = 6; desc.6 = 'Left Amiga '
bit.7 = 7; desc.7 = 'Right Amiga'
y = 75
do i=1 for 7
call AddGadget(SNAPHOST, 5, y, 'TQ'i, desc.i, 'TEXTQUAL 'i)
call AddGadget(SNAPHOST, 110, y, 'GQ'i, desc.i, 'GFXQUAL 'i)
y = y+15
end
call AddGadget(SNAPHOST, 430, 172, 'APPLY', ' Apply\settings', 'APPLY')
/* Open our host port */
call openport(SNAPPORT)
start:
call ShowText(" Setting defaults...")
pri = 51; call SetGadget(SNAPHOST, 'PR51', 'ON')
textqual = '0040'x; call SetGadget(SNAPHOST, 'TQ6', 'ON')
gfxqual = '0080'x; call SetGadget(SNAPHOST, 'GQ7', 'ON')
inskey = 1; call SetGadget(SNAPHOST, 'INS1', 'ON')
cwkey = 1; call SetGadget(SNAPHOST, 'CW1', 'ON')
cdelay = 0; call SetGadget(SNAPHOST, 'CDL0', 'ON')
ldelay = 0; call SetGadget(SNAPHOST, 'LDL0', 'ON')
pattern = '7777'x;
do i=0 for 16
if bittst(pattern,i) then call SetGadget(SNAPHOST, 'PAT'i, 'ON')
end
unit = 0; call SetGadget(SNAPHOST, 'UNT0', 'ON')
xerox = 0
patch = 0
join = 0
underscore = 1; call SetGadget(SNAPHOST, 'USCR', 'ON')
planes = '00'x
call ShowText(" Select options. Click here for help.")
help.1 = "Click text (eg 'Priority') for help. Click here for more help."
help.2 = "Close window for correct command line. Click for more."
help.3 = "Click 'Apply settings' to reconfigure Snap."
maxhelp = 3
keycmd. = ""
keycmd.95 = "HELP"; keycmd.25 = "PRIORITY"; keycmd.16 = "CLOSEWINDOW"
keycmd.23 = "INSKEY"; keycmd.51 = "CDELAY"; keycmd.40 = "LDELAY"
keycmd.33 = "UNIT"; keycmd.32 = "APPLY"
main:
quitflag = 0
helpnum = 1
loop:
if quitflag~=0 then signal done
call waitpkt(SNAPPORT)
p = getpkt(SNAPPORT)
if p == NULL() then signal loop
cmd = getarg(p)
call reply(p, 0)
docmd:
parse var cmd item val .
signal value item
closewindow:
quitflag = 1
signal loop
rawkey:
cmd = keycmd.val
if cmd ~= "" then do
signal docmd
end
signal loop
help:
parse var cmd item help
if help="" then do
call showtext(help.helpnum)
helpnum = helpnum+1
if helpnum>maxhelp then helpnum = 1
end
else do
call showtext(help)
end
signal loop
priority:
if val="" then do
val = pri+1
if val>55 then val = 51
end
pri = val
do i=51 for 5
call setgadget(SNAPHOST, 'PR'i, 'OFF')
end
call setgadget(SNAPHOST, 'PR'pri, 'ON')
signal loop
inskey:
if val="" then do
val = inskey+1
if val>3 then val = 1
end
inskey = val
do i=1 for 3
call setgadget(SNAPHOST, 'INS'i, 'OFF')
end
call setgadget(SNAPHOST, 'INS'val, 'ON')
signal loop
cwkey:
if val="" then do
val = cwkey+1
if val>3 then val = 1
end
cwkey = val
do i=1 for 3
call setgadget(SNAPHOST, 'CW'i, 'OFF')
end
call setgadget(SNAPHOST, 'CW'val, 'ON')
signal loop
cdelay:
if val="" then do
val = cdelay+1
if val>2 then val = 0
end
cdelay = val
do i=0 for 3
call setgadget(SNAPHOST, 'CDL'i, 'OFF')
end
call setgadget(SNAPHOST, 'CDL'val, 'ON')
signal loop
ldelay:
if val="" then do
val = ldelay+1
if val>2 then val = 0
end
ldelay = val
do i=0 for 3
call setgadget(SNAPHOST, 'LDL'i, 'OFF')
end
call setgadget(SNAPHOST, 'LDL'val, 'ON')
signal loop
unit:
if val="" then do
val = 1-unit
end
unit = val
call setgadget(SNAPHOST, 'UNT0', 'OFF')
call setgadget(SNAPHOST, 'UNT1', 'OFF')
call setgadget(SNAPHOST, 'UNT'unit, 'ON')
signal loop
pattern:
pattern = bitchg(pattern,val)
temp = bittst(pattern,val)
call setgadget(SNAPHOST, 'PAT'val, bool.temp)
signal loop
mask:
planes = bitchg(planes,val)
temp = bittst(planes,val)
call setgadget(SNAPHOST, 'MSK'val, bool.temp)
signal loop
prep:
parse var cmd . ' ' prepend
signal loop
app:
parse var cmd . ' ' append
signal loop
textqual:
if bittst(textqual,bit.val) then do
textqual = bitclr(textqual,bit.val)
call setgadget(SNAPHOST, 'TQ'val, 'OFF')
end
else do
call setgadget(SNAPHOST, 'GQ'val, 'OFF')
gfxqual = bitclr(gfxqual,bit.val)
textqual = bitset(textqual,bit.val)
call setgadget(SNAPHOST, 'TQ'val, 'ON')
end
signal loop
gfxqual:
if bittst(gfxqual,bit.val) then do
gfxqual = bitclr(gfxqual,bit.val)
call setgadget(SNAPHOST, 'GQ'val, 'OFF')
end
else do
call setgadget(SNAPHOST, 'TQ'val, 'OFF')
textqual = bitclr(textqual,bit.val)
gfxqual = bitset(gfxqual,bit.val)
call setgadget(SNAPHOST, 'GQ'val, 'ON')
end
signal loop
xerox:
xerox = 1-xerox
call setgadget(SNAPHOST, 'XERX', bool.xerox)
signal loop
join:
join = 1-join
call setgadget(SNAPHOST, 'JOIN', bool.join)
signal loop
patch:
patch = 1-patch
call setgadget(SNAPHOST, 'PTCH', bool.patch)
signal loop
underscore:
underscore = 1-underscore
call setgadget(SNAPHOST, 'USCR', bool.underscore)
signal loop
apply:
quitflag = 2
signal loop
done:
call ReadGadget(SNAPHOST, 'PREP')
call waitpkt(SNAPPORT)
getprep:
p = getpkt(SNAPPORT)
if p == NULL() then signal getprep
cmd = getarg(p)
call reply(p, 0)
parse var cmd . ' ' prepend
call ReadGadget(SNAPHOST, 'APP')
call waitpkt(SNAPPORT)
getapp:
p = getpkt(SNAPPORT)
if p == NULL() then signal getapp
cmd = getarg(p)
call reply(p, 0)
parse var cmd . ' ' append
if c2d(textqual)=0 then do
call ShowText("No text qualifier specified!")
signal main
end
else if c2d(gfxqual)=0 then do
call ShowText("No graphics qualifier specified!")
signal main
end
unixargs = ""
amigaargs = ""
if pri~=51 then do
unixargs = unixargs "-p"pri
amigaargs = amigaargs "priority" pri
end
if textqual~='0040'x then do
unixargs = unixargs "-t"c2x(textqual)
amigaargs = amigaargs "textqual" c2x(textqual)
end
if gfxqual~='0080'x then do
unixargs = unixargs "-g"c2x(gfxqual)
amigaargs = amigaargs "gfxqual" c2x(gfxqual)
end
if inskey.inskey~='I' then do
unixargs = unixargs "-i"inscode.inskey
amigaargs = amigaargs "insertkey" inscode.inskey
end
if cwkey.cwkey~='W' then do
unixargs = unixargs "-w"cwcode.cwkey
amigaargs = amigaargs "cwkey" cwcode.cwkey
end
if prepend~="> " then do
unixargs = unixargs "-P" '"'||prepend||'"'
amigaargs = amigaargs "prepend" '"'||prepend||'"'
end
if append~="" then do
unixargs = unixargs "-A" '"'append'"'
amigaargs = amigaargs "append" '"'append'"'
end
if cdelay~=0 then do
unixargs = unixargs "-c"cdelay
amigaargs = amigaargs "chardelay" cdelay
end
if ldelay~=0 then do
unixargs = unixargs "-l"ldelay
amigaargs = amigaargs "linedelay" ldelay
end
if pattern~='7777'x then do
unixargs = unixargs "-a"c2x(pattern)
amigaargs = amigaargs "crawlptrn" c2x(pattern)
end
if xerox then do
unixargs = unixargs "-x"
amigaargs = amigaargs "XEROX"
end
if patch then do
unixargs = unixargs "-e"
amigaargs = amigaargs "EARLYPATCH"
end
if underscore then do
unixargs = unixargs "-r"
amigaargs = amigaargs "TRUEUNDERSCORE"
end
if join then do
unixargs = unixargs "-j"
amigaargs = amigaargs "JOINLONG"
end
if unit~=0 then do
unixargs = unixargs "-u"unit
amigaargs = amigaargs "startunit" unit
end
if planes~='00'x then do
unixargs = unixargs "-b"c2x(planes)
amigaargs = amigaargs "planemask" c2x(planes)
end
snapcmd = "snap"
if quitflag=1 then do
say snapcmd || unixargs
if amigaargs ~= unixargs then do
say "or"
say snapcmd || amigaargs
end
end
else do
if ~exists("snap") & ~exists("c:snap") then do
snapcmd = GetFile(50, 50, "sys:", "", "Find Snap for me")
if word(statef(snapcmd),1) ~= 'FILE' then do
snapcmd = snapcmd'snap'
end
end
if exists(snapcmd) then do
address command snapcmd unixargs
end
else do
call ShowText("Snap not found.")
signal main
end
end
error:
call Stop(SNAPHOST)
exit
showtext: procedure expose SNAPHOST
parse arg text
call SetAPen(SNAPHOST, 0)
call RectFill(SNAPHOST, 5, 15, 490, 35)
call SetAPen(SNAPHOST, 1)
call Move(SNAPHOST, 5, 30)
call Text(SNAPHOST, text)
return