home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #3
/
amigamamagazinepolishissue1998.iso
/
bazy
/
intra2_17
/
rexx
/
demo1.irx
< prev
next >
Wrap
Text File
|
1994-02-22
|
4KB
|
164 lines
/* INTRA_demo1.irx by Frank Maesen */
/* $VER: INTRA_demo1.irx 1.1 (22.2.1994) */
/* Example Arexx program for controlling INTRA by Bart Vanhaeren */
NL = '0a'x
OPTIONS RESULTS
IF POS('rexxsupport.library',SHOW('libs'))=0 THEN
nill=ADDLIB('rexxsupport.library',0,-30,0)
IF POS('INTRAREXX', SHOW('PORTS'))=0 THEN DO
SAY "*** Start INTRA first !!!"
EXIT(0)
END
ADDRESS (TRIM(SUBSTR(SHOW('PORTS'),POS('INTRAREXX',SHOW('PORTS')),12)))
SCREENTOFRONT
REQUESTNOTIFY PROMPT "ARexx script start ..."
INVOICES
IF RC=0 THEN DO
REQUESTRESPONSE PROMPT """Close current file ?!?"""
IF RC>0 THEN DO
REQUESTNOTIFY PROMPT "Quitting ARexx script ..."
EXIT(0)
END
ELSE CLOSE
END
filelist=SHOWDIR('RAM:','File')
DO i=1 TO WORDS(filelist)
IF WORD(filelist,i)='TestDemo.intra' THEN DO
REQUESTRESPONSE PROMPT """Overwrite old demofile ?!?"""
IF RESULT=1 THEN LEAVE
ELSE DO
REQUESTNOTIFY PROMPT "Quitting ARexx script ..."
EXIT(0)
END
END
END
NEW FILENAME "RAM:TestDemo.intra"
IF RC~=0 THEN DO
REQUESTNOTIFY PROMPT "Couldn't create file for demo !!!"
REQUESTNOTIFY PROMPT "Quitting ARexx script ..."
EXIT(0)
END
DO i=1 TO 25
ADD
SETDATA DATE i"-01-"49+i*2 AMOUNT RANDOM(0, 1000)+RANDOM(100, 1000) TRADER """BETAtestings Inc.""" DESCRIPTION """Testobject" i""""
REWRITE i
END
REQUESTNOTIFY PROMPT "Just created 25 invoices."
REQUESTRESPONSE PROMPT """Calculate total of invoices ?!?"""
IF RESULT=1 THEN DO
total=0
DO i=1 TO 25
READ i
GETDATA AMOUNT
PARSE VAR RESULT '"'RESULT'"' nill
total=total+RESULT
END
REQUESTNOTIFY PROMPT "Total amount: "||total
END
number=RANDOM(0,26)
REQUESTRESPONSE PROMPT """Search the amount for ""Testobject "||number||""" ?!?"""
IF RESULT=1 THEN DO
POSITION BOF
DO i=1 TO 25
GETDATA DESCRIPTION
IF RESULT="""Testobject "||number"""" THEN DO
GETDATA AMOUNT
REQUESTNOTIFY PROMPT "Testobject "||number||" = "||RESULT
LEAVE
END
NEXT
END
END
REQUESTRESPONSE PROMPT """Wanna know which version you're running of INTRA ?!?"""
IF RESULT = 1 THEN DO
VERSION
PARSE VAR RESULT nil RESULT
REQUESTNOTIFY PROMPT RESULT
END
REQUESTRESPONSE PROMPT """Change all EVEN invoices from trader ?!?"""
IF RESULT = 1 THEN DO
REQUESTSTRING PROMPT """Enter new trader""" DEFAULT """Trader ????"""
IF RC~=0 THEN BREAK
ELSE DO
name=RESULT
DO i=25 TO 2 BY -1
READ i
IF i // 2 = 0 THEN DO
SETDATA TRADER name
REWRITE i
END
PREVIOUS
END
END
END
records='25'
REQUESTRESPONSE PROMPT """Open another INTRA file to play with ?!?"""
IF RESULT = 1 THEN DO
CLOSE
OPEN
IF RC~=0 THEN DO
REQUESTNOTIFY PROMPT "Dummy, why do you select thing you don't mean !!!"
OPEN FILENAME "RAM:TestDemo.intra"
END
ELSE DO
INVOICES
records=RESULT
REQUESTNOTIFY PROMPT "File contains "||RESULT||" records."
END
END
REQUESTRESPONSE PROMPT """Search the highest amount of all invoices ?!?"""
IF RESULT=1 THEN DO
POSITION BOF
GETDATA AMOUNT
PARSE VAR RESULT '"'RESULT'"' nill
number=RESULT '1'
DO i=2 TO records
READ i
GETDATA AMOUNT
PARSE VAR RESULT '"'RESULT'"' nill
IF RESULT > WORD(number,1) THEN number=RESULT i
END
READ WORD(number,2)
REQUESTNOTIFY PROMPT "HIGHEST amount : "||WORD(number,1)||", INVOICE : "||WORD(number,2)
END
REQUESTSTRING PROMPT """Calculate total of which month ???""" DEFAULT "01-93"
IF RC=0 THEN DO
info=RESULT
total=0
INVOICES
DO i=1 TO RESULT
READ i
GETDATA DATE AMOUNT
PARSE VAR RESULT '"'dat'"' '"'val'"' nill
IF RIGHT(dat,5) = info THEN total = total + val
END
IF total~=0 THEN REQUESTNOTIFY PROMPT "Total amount for 'XX-"info "=" total"'"
ELSE REQUESTNOTIFY PROMPT "Didn't find any amount for 'XX-"info"'"
END
ELSE IF RC=10 THEN REQUESTNOTIFY PROMPT "Reqtools is not available"
CLOSE
REQUESTRESPONSE PROMPT """Delete RAM:TestDemo.intra (demofile) ?!?"""
IF RESULT=1 THEN DELETE FILENAME """RAM:TestDemo.intra""" FORCE
REQUESTNOTIFY PROMPT "ARexx script is done ..."
EXIT(0)