home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------ */
-
- /* console.rexx */
-
- /* ------------------------------------------------------------ */
-
- /* miscellaneous definitions... */
-
-
- g.TRUE=1; g.FALSE=0; g.CR='0D'x; g.BACKSPACE='08'x
-
- g.SPACE='20'x; g.APPROX='7E'x; g.ESC='1B'x; g.CSI='9b'x
-
- g.BACKGROUND = g.CSI||'3e'x||'32'x||'6d'x
-
- g.CELL_COLOUR = g.CSI||'34'x||'32'x||'6d'x
-
- g.INVERSE_ON = g.CSI||'37'x||'6d'x /* inverse video style command */
-
- g.INVERSE_OFF = g.CSI||'32'x||'37'x||'6d'x /* inverse off command */
-
- g.ITALIC_ON = g.CSI||'33'x||'6d'x /* italic text style command */
-
- g.ITALIC_OFF = g.CSI||'32'x||'33'x||'6d'x /* italic off command */
-
- g.BOLD_ON = g.CSI||'31'x||'6d'x /* bold text style command */
-
- g.BOLD_OFF = g.CSI||'32'x||'32'x||'6d'x /* bold off command */
-
- g.UNDERSCORE_ON = g.CSI||'34'x||'6d'x /* underscore text style command */
-
- g.UNDERSCORE_OFF = g.CSI||'32'x||'34'X||'6d'x /* underscore off command */
-
- g.TITLE1 = g.BOLD_ON||'I N C O M E - S U M M A R Y'||g.BOLD_OFF
-
- g.TITLE2 = g.ITALIC_ON||'Press ESCape to clear form or exit program'||g.ITALIC_OFF
-
- g.PROCESS_EXISTING = 'PROCESS THIS DATA SET (Y/N)? '
-
- g.PROCESS_NEW = 'PROCESS NEW SET OF DATA(Y/N)? '
-
- g.TOTAL = g.BOLD_ON||'TOTAL £'||g.BOLD_OFF
-
- g.TOTAL_R=35
-
- g.TOTAL_C=28
-
- g.PROCESS_PROMPT_R = 38
-
- g.PROCESS_PROMPT_C = 4
-
- g.GENERAL_C=4
-
- g.CLEAR = ' '
-
- g.CLEAR_TOTAL = ' '
-
-
- /* Data table for the form display... */
-
-
- f.FIELD_COUNT=12
-
- f.1.name='Amount for January: £'; f.1.r=10; f.1.c=4; f.1.l=8
-
- f.2.name='Amount for February: £'; f.2.r=12; f.2.c=4; f.2.l=8
-
- f.3.name='Amount for March: £'; f.3.r=14; f.3.c=4; f.3.l=8
-
- f.4.name='Amount for April: £'; f.4.r=16; f.4.c=4; f.4.l=8
-
- f.5.name='Amount for May: £'; f.5.r=18; f.5.c=4; f.5.l=8
-
- f.6.name='Amount for June: £'; f.6.r=20; f.6.c=4; f.6.l=8
-
- f.7.name='Amount for July: £'; f.7.r=22; f.7.c=4; f.7.l=8
-
- f.8.name='Amount for August: £'; f.8.r=24; f.8.c=4; f.8.l=8
-
- f.9.name='Amount for September: £'; f.9.r=26; f.9.c=4; f.9.l=8
-
- f.10.name='Amount for October: £'; f.10.r=28; f.10.c=4; f.10.l=8
-
- f.11.name='Amount for November: £'; f.11.r=30; f.11.c=4; f.11.l=8
-
- f.12.name='Amount for December: £'; f.12.r=32; f.12.c=4; f.12.l=8
-
- reply$. = ''
-
- /* ------------------------------------------------------------ */
-
- /* start main code by opening window and displaying form... */
-
- call Open(window,'RAW:40/40/430/330/console.rexx')
-
- call Writech(window,g.BACKGROUND||g.CELL_COLOUR)
-
- call WriteToConsoleWindow(window,2,g.GENERAL_C,g.TITLE1)
-
- call WriteToConsoleWindow(window,6,g.GENERAL_C,g.TITLE2)
-
- call WriteToConsoleWindow(window,g.TOTAL_R,g.GENERAL_C,g.TOTAL)
-
- call DisplayConsoleWindow(window)
-
-
- /* now collect data... */
-
- exit_flag=g.FALSE /* force entry into loop */
-
- do while ~exit_flag
-
- call ClearConsoleWindow(window)
-
- if ReadConsoleWindow(window) then
-
- do
-
- call WriteToConsoleWindow(window,g.PROCESS_PROMPT_R,g.PROCESS_PROMPT_C,g.PROCESS_EXISTING)
-
- x$=Readch(window,1)
-
- if Upper(x$)=='Y' then call ProcessData()
-
- end
-
- call WriteToConsoleWindow(window,g.PROCESS_PROMPT_R,g.PROCESS_PROMPT_C,g.PROCESS_NEW)
-
- x$=Readch(window,1)
-
- if Upper(x$)=='N' then exit_flag=g.TRUE
-
- else do
-
- call WriteToConsoleWindow(window,g.PROCESS_PROMPT_R,g.PROCESS_PROMPT_C,g.CLEAR)
-
- call WriteToConsoleWindow(window,g.TOTAL_R,g.TOTAL_C,g.CLEAR_TOTAL)
-
- end
- end
-
- call Close(window)
-
- exit /* logical program end */
-
-
- /* ------------------------------------------------------------ */
-
- /* Here you can do whatever you like but for this example
- we are just adding the entered reply fields together and
- displaying the total amount (ignoring any invalid,
- ie non-numeric, entries)... */
-
- ProcessData: Procedure expose f. g. reply$.
-
- total=0
-
- do i=1 to f.FIELD_COUNT
-
- if DataType(reply$.i,'Numeric') then total=total+reply$.i
-
- end
-
- call WriteToConsoleWindow(window,g.TOTAL_R,g.TOTAL_C,total)
-
- return
-
- /* ------------------------------------------------------------ */
-
- DisplayConsoleWindow: Procedure expose f. g.
-
- parse arg window
-
- do i=1 to f.FIELD_COUNT
-
- call WriteToConsoleWindow(window,f.i.r,f.i.c,f.i.name)
-
- end
-
- return
-
- /* ------------------------------------------------------------ */
-
- ClearConsoleWindow: Procedure expose f. g.
-
- parse arg window
-
- do i=1 to f.FIELD_COUNT
-
- call InitialiseInputField(window,f.i.r,f.i.c+Length(f.i.name)+1,f.i.l)
-
- end
-
- return
-
- /* ------------------------------------------------------------ */
-
- ReadConsoleWindow: Procedure expose f. g. reply$.
-
- parse arg window
-
- data_ok_flag=g.TRUE
-
- do i=1 to f.FIELD_COUNT
-
- reply$.i=ReadFromConsoleWindow(window,f.i.r,f.i.c+Length(f.i.name)+1,f.i.l);
-
- if reply$.i==g.ESC then
-
- do
-
- i=f.FIELD_COUNT
-
- data_ok_flag=g.FALSE
-
- end
- end
-
- return data_ok_flag
-
- /* ------------------------------------------------------------ */
-
- WriteToConsoleWindow: Procedure expose g.
-
- parse arg window,r,c,text$
-
- call Writech(window,g.CSI||r||'3B'x||c||'48'x)
-
- call Writech(window,text$)
-
- return
-
- /* ------------------------------------------------------------ */
-
- ReadFromConsoleWindow: Procedure expose g.
-
- parse arg window,r,c,count
-
- input_string$=''
-
- i=0 /* loop counter */
-
- x$=''
-
- call Writech(window,g.CSI||r||'3B'x||c||'48'x) /* position cursor */
-
- do while x$~==g.CR
-
- if i<count+1 then do
-
- select
-
- when x$==g.CSI then
-
- do
-
- call Readch(window,1)
-
- x$=Readch(window,1)
-
- end
-
-
- when x$==g.BACKSPACE & i>1 then
-
- do
-
- i=i-1
-
- Writech(window,x$||'.'x$)
-
- input_string$=Left(input_string$,Length(input_string$)-1)
-
- x$=Readch(window,1)
-
- end
-
-
- when x$==g.ESC then
-
- do
-
- input_string$=g.ESC
-
- x$=g.CR
-
- end
-
-
- when x$>=g.SPACE & x$<g.APPROX then
-
- do
-
- i=i+1
-
- Writech(window,x$)
-
- input_string$=input_string$||x$
-
- x$=Readch(window,1)
-
- end
-
-
- otherwise x$=Readch(window,1)
-
-
- end /* case-select end */
-
- end /* if-then end */
-
- else x$=g.CR
-
- end /* do-while loop end */
-
- return input_string$
-
- /* ------------------------------------------------------------ */
-
- InitialiseInputField: Procedure expose g.
-
- parse arg window,r,c,count
-
- call Writech(window,g.CSI||r||'3B'x||c||'48'x) /* position cursor */
-
- call Writech(window,Copies('.',count))
-
- return
-
- /* ------------------------------------------------------------ */
-