home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxcp290.zip
/
CP290.RXX
< prev
next >
Wrap
Text File
|
1996-02-15
|
20KB
|
600 lines
/*-----------------------------------------------------------------------------+
| |
| REXX source code listing for DrRexx application: |
| E:\drdialog\examples\CP290.res |
| |
| File last modified on: 02/15/96 at: 03:41pm |
| Listing produced on: 02/15/96 at: 03:41pm |
| |
+-----------------------------------------------------------------------------*/
SIGNAL ON SYNTAX
SIGNAL ON HALT
SIGNAL INIT
RETURN:
SIGNAL VALUE DrRexxEvent()
L1:
EXIT -1
L2:
INTERPRET DrRexxInterpret()
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: RxCP290 |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: RxCP290 (DIALOG) */
RxCP290_Exit:
rc = RxCloseCP290(CP290)
exit 0
SIGNAL RETURN
RxCP290_Init:
call RxFuncAdd 'SysLoadFuncs', 'REXXUtil', 'SysLoadFuncs'
call SysLoadFuncs
call RxFuncAdd 'RxLoadFuncsCP290', 'RxCP290', 'RxLoadFuncsCP290'
call RxLoadFuncsCP290
comport = SysIni('USER','RXCP290','COMPORT')
if Left(comport,3) <> "COM" then
do
comport = "COM2"
rc = SysIni('USER','RXCP290','COMPORT', 'COM2')
end
CP290 = ''
rc = RxInitCP290(comport, 'CP290')
events. = 0
eventpages. = 0
filename = ""
i = 0
initpage = RxCP290.BigNote.Add(0,"F","InitDialog","Init", , )
dirpage = RxCP290.BigNote.Add(initpage,"N","DirControlDialog","Direct",,)
eventpages.0 = RxCP290.BigNote.Add(dirpage,"N","EventDialog","Event "0,,0)
SIGNAL RETURN
/* Event handlers for: BigNote (NOTEBOOK) */
RxCP290_BigNote_Select:
page = RxCP290.BigNote.Select()
do i = 0 to 127
if eventpages.i = page then leave
end
if i < 128 then do
rc = EventDialog.Eventno.Text(i)
if events.i.0 <> 0 then do
rc = EventDialog.EventMod.Select(events.i.5.1)
rc = EventDialog.EventLevel.Select(events.i.7)
rc = EventDialog.EventHr.Select(events.i.3)
rc = EventDialog.EventMin.Select(events.i.4)
rc = EventDialog.MonBut.Select(0)
rc = EventDialog.TueBut.Select(0)
rc = EventDialog.WedBut.Select(0)
rc = EventDialog.ThuBut.Select(0)
rc = EventDialog.FriBut.Select(0)
rc = EventDialog.SatBut.Select(0)
rc = EventDialog.SunBut.Select(0)
do j = 1 to events.i.2.0
if events.i.2.j = "MON" then
rc = EventDialog.MonBut.Select(1)
if events.i.2.j = "TUE" then
rc = EventDialog.TueBut.Select(1)
if events.i.2.j = "WED" then
rc = EventDialog.WedBut.Select(1)
if events.i.2.j = "THU" then
rc = EventDialog.ThuBut.Select(1)
if events.i.2.j = "FRI" then
rc = EventDialog.FriBut.Select(1)
if events.i.2.j = "SAT" then
rc = EventDialog.SatBut.Select(1)
if events.i.2.j = "SUN" then
rc = EventDialog.SunBut.Select(1)
end
do j = 1 to 16
if events.i.6 = D2C(j+64) then leave
end
rc = EventDialog.EventHcode.Select(j)
if events.i.1 = "NORMAL" then
rc = EventDialog.EventMode.Select(1)
if events.i.1 = "SECURITY" then
rc = EventDialog.EventMode.Select(2)
if events.i.1 = "TODAY" then
rc = EventDialog.EventMode.Select(3)
if events.i.1 = "TOMORROW" then
rc = EventDialog.EventMode.Select(4)
if events.i.1 = "CLEAR" then
rc = EventDialog.EventMode.Select(5)
if events.i.8 = "ON" then
rc = EventDialog.Eventfunc.Select(1)
if events.i.8 = "OFF" then
rc = EventDialog.Eventfunc.Select(2)
if events.i.8 = "DIM" then
rc = EventDialog.Eventfunc.Select(3)
end
else do
rc = EventDialog.EventFunc.Select(1)
rc = EventDialog.EventLevel.Select(0)
rc = EventDialog.EventHr.Select(0)
rc = EventDialog.EventMin.Select(0)
rc = EventDialog.EventMode.Select(1)
rc = EventDialog.EventMod.Select(1)
rc = EventDialog.EventHcode.Select(1)
rc = EventDialog.MonBut.Select(0)
rc = EventDialog.TueBut.Select(0)
rc = EventDialog.WedBut.Select(0)
rc = EventDialog.ThuBut.Select(0)
rc = EventDialog.FriBut.Select(0)
rc = EventDialog.SatBut.Select(0)
rc = EventDialog.SunBut.Select(0)
end
end
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Menu handlers for dialog: RxCP290 |
| |
+-----------------------------------------------------------------------------*/
/* File */
/* New */
/* - Action: */
events. = 0
do i = 0 to 127
if eventpages.i <> 0 then
rc = RxCP290.BigNote.Delete(eventpages.i)
eventpages.i = 0
end
eventpages.0 = RxCP290.BigNote.Add(0,"L","EventDialog","Event "0,,0)
rc = RxCP290.Text("X-10 Controller - New")
SIGNAL RETURN
/* Open */
/* - Action: */
filename = FilePrompt("*.EVT",,,"O")
events. = 0
do i = 0 to 127
if eventpages.i <> 0 then
rc = RxCP290.BigNote.Delete(eventpages.i)
eventpages.i = 0
end
call linein filename, ,0
do i = 0 to 127
events.i.0 = linein(filename)
if events.i.0 = 1 then
do
events.i.1 = linein(filename)
events.i.2.0 = linein(filename)
do j = 1 to events.i.2.0
events.i.2.j = linein(filename)
end
events.i.3 = linein(filename)
events.i.4 = linein(filename)
events.i.5.0 = linein(filename)
Do j = 1 to events.i.5.0
events.i.5.j = linein(filename)
end
events.i.6 = linein(filename)
events.i.7 = linein(filename)
events.i.8 = linein(filename)
end
end
do i = 0 to 127
if events.i.0 <> 0 then
eventpages.i = RxCP290.BigNote.Add(0,"L","EventDialog","Event "i,,i)
end
rc = RxCP290.Text("X-10 Controller - "filename)
SIGNAL RETURN
/* ---------- (Disabled) */
/* Save */
/* - Action: */
if filename = "" then
filename = FilePrompt("*.EVT",,,"S")
call lineout filename, ,1
do i=0 to 127
call lineout filename, events.i.0
if events.i.0 = 1 then
Do
call lineout filename, events.i.1
call lineout filename, events.i.2.0
Do j = 1 to events.i.2.0
call lineout filename, events.i.2.j
end
call lineout filename, events.i.3
call lineout filename, events.i.4
call lineout filename, events.i.5.0
Do j = 1 to events.i.5.0
call lineout filename, events.i.5.j
end
call lineout filename, events.i.6
call lineout filename, events.i.7
call lineout filename, events.i.8
end
end
call lineout filename
SIGNAL RETURN
/* Save as */
/* - Action: */
filename = FilePrompt("*.EVT",,,"S")
call lineout filename, ,1
do i=0 to 127
call lineout filename, events.i.0
if events.i.0 = 1 then
Do
call lineout filename, events.i.1
call lineout filename, events.i.2.0
Do j = 1 to events.i.2.0
call lineout filename, events.i.2.j
end
call lineout filename, events.i.3
call lineout filename, events.i.4
call lineout filename, events.i.5.0
Do j = 1 to events.i.5.0
call lineout filename, events.i.5.j
end
call lineout filename, events.i.6
call lineout filename, events.i.7
call lineout filename, events.i.8
end
end
call lineout filename
SIGNAL RETURN
/* ---------- (Disabled) */
/* Quit */
/* - Action: */
rc = RxCP290.close()
SIGNAL RETURN
/* Events */
/* New Event */
/* - Action: */
i = 0
do while eventpages.i <> 0
i = i + 1
end
prev = i-1
if prev = -1 then
eventpages.i = RxCP290.BigNote.Add(dirpage,"N","EventDialog","Event "i,,i)
else
eventpages.i = RxCP290.BigNote.Add(eventpages.prev,"N","EventDialog","Event "i,,i)
SIGNAL RETURN
/* Del Event */
/* - Action: */
page = RxCP290.BigNote.Select()
do i = 0 to 127
if eventpages.i = page then Leave
end
do j = 0 to 8
events.i.j = 0
if j = 2 then
events.i.j.0 = 0
if j = 5 then
events.i.j.0 = 0
end
eventpages.i = 0
rc = RxCP290.BigNote.Delete(page)
SIGNAL RETURN
/* GetEvents */
/* - Action: */
events. = 0
do i = 0 to 127
if eventpages.i <> 0 then
rc = RxCP290.BigNote.Delete(eventpages.i)
eventpages.i = 0
end
Do until rc = 0
rc = RxCmdUploadCP290(CP290,'result')
end
rc = RxGetEventsCP290(CP290, 'events')
if rc = -1 then
rc = ErrorDialog("Communications Error With CP290")
else
do i = 0 to 127
if events.i.0 \= 0 then
eventpages.i = RxCP290.BigNote.Add(0,"L","EventDialog","Event "i,,i)
end
SIGNAL RETURN
/* StoreEvents */
/* - Action: */
Do until rc = 0
rc = RxCmdUploadCP290(CP290,'result')
end
rc = RxGetTimeCP290(CP290, 'thc')
if rc = -1 then
do
rc = ErrorDialog("Communications Error With CP290")
Signal RETURN
end
rc = RxSetHcodeCP290(CP290,thc.4)
if rc = -1 then
do
rc = ErrorDialog("Communications Error With CP290")
Signal RETURN
end
do i = 0 to 127
if events.i.0 \= 0 then
do
rc = RxDwnLdEvtCP290(CP290,i,'events.i')
if rc = -1 then
do
rc = ErrorDialog("Communications Error With CP290")
i = 128
end
end
end
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: InitDialog |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: C305 (PUSHBUTTON) */
InitDialog_C305_Click:
Do until rc = 0
rc = RxCmdUploadCP290(CP290,'result')
end
rc = RxSetTimeCP290(CP290)
if rc = -1 then
rc = ErrorDialog("Communications Error With CP290")
SIGNAL RETURN
/* Event handlers for: C304 (PUSHBUTTON) */
InitDialog_C304_Click:
ind = InitDialog.SetHcode.select()
hc = SetHcd.ind
Do until rc = 0
rc = RxCmdUploadCP290(CP290,'result')
end
rc = RxSetHcodeCP290(CP290, hc)
if rc = -1 then
rc = ErrorDialog("Communications Error With CP290")
SIGNAL RETURN
/* Event handlers for: SetHcode (SPINBUTTON) */
InitDialog_SetHcode_Init:
SetHcd.0 = 16
do j = 1 to 16
SetHcd.j = D2C(j+64)
end
rc = InitDialog.SetHcode.Range('SetHcd')
SIGNAL RETURN
/* Event handlers for: InitButton (PUSHBUTTON) */
InitDialog_InitButton_Click:
com = InitDialog.ComPort.Select()
com = port.com
if CP290 <> "" then
rc = RxCloseCP290(CP290)
rc = RxInitCP290(com, "CP290")
if rc <> 0 then
rc = ErrorDialog("Error Opening Commmunications Port "com)
rc = SysIni('USER','RXCP290','COMPORT', com)
SIGNAL RETURN
/* Event handlers for: ComPort (SPINBUTTON) */
InitDialog_ComPort_Init:
port.0 = 4
port.1 = "COM1"
port.2 = "COM2"
port.3 = "COM3"
port.4 = "COM4"
call InitDialog.ComPort.Range "Port"
do j = 1 to 4
if comport = port.j then
rc = InitDialog.ComPort.Select(j)
end
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: EventDialog |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: EventDialog (DIALOG) */
EventDialog_Init:
EvtHcode.0 = 16
do j = 1 to 16
EvtHcode.j = D2C(64 +j)
end
EvtMode.0 = 5
EvtMode.1 = "NORMAL"
EvtMode.2 = "SECURITY"
EvtMode.3 = "TODAY"
EvtMode.4 = "TOMORROW"
EvtMode.5 = "CLEAR"
EvtFunc.0 = 3
EvtFunc.1 = "ON"
EvtFunc.2 = "OFF"
EvtFunc.3 = "DIM"
rc = EventDialog.EventHcode.Range('EvtHcode')
rc = EventDialog.EventMode.Range('EvtMode')
rc = EventDialog.Eventfunc.Range('Evtfunc')
rc = EventDialog.EventMod.Range(1,16)
rc = EventDialog.EventHr.Range(0,23)
rc = EventDialog.EventMin.Range(0,59)
rc = EventDialog.EventLevel.Range(15)
SIGNAL RETURN
EventDialog_Open:
page = RxCP290.BigNote.Select()
evt = RxCP290.BigNote.Item(page, "D")
rc = EventDialog.Eventno.Text(evt)
SIGNAL RETURN
/* Event handlers for: EnterButton (PUSHBUTTON) */
EventDialog_EnterButton_Click:
evt = EventDialog.EventNo.Text()
events.evt.0 = 1
in = EventDialog.EventMode.Select()
events.evt.1 = EvtMode.in
events.evt.5.0 = 1
events.evt.5.1 = EventDialog.EventMod.Select()
events.evt.3 = EventDialog.EventHr.Select()
events.evt.4 = EventDialog.EventMin.Select()
in = 0
if EventDialog.MonBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "MON"
end
if EventDialog.TueBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "TUE"
end
if EventDialog.WedBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "WED"
end
if EventDialog.ThuBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "THU"
end
if EventDialog.FriBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "FRI"
end
if EventDialog.SatBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "SAT"
end
if EventDialog.SunBut.Select() = 1 then
do
in = in + 1
events.evt.2.in = "SUN"
end
events.evt.2.0 = in
in = EventDialog.EventHcode.Select()
events.evt.6 = EvtHcode.in
events.evt.7 = EventDialog.EventLevel.Select()
in = EventDialog.EventFunc.Select()
events.evt.8 = Evtfunc.in
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: DirControlDialog |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: DirControlDialog (DIALOG) */
DirControlDialog_Init:
housecode.0 = 16
module.0 = 16
do j = 1 to 16
housecode.j = D2C(j+64)
module.j = j
end
rc = DirControlDialog.DirHcode.Range('housecode')
rc = DirControlDialog.DirMod.Range('module')
rc = DirControlDialog.DirOn.Select(1)
rc = DirControlDialog.DirOff.Select(0)
rc = DirControlDialog.DirDim.Select(0)
rc = DirControlDialog.DirLevel.Range(15,0,15,0)
SIGNAL RETURN
/* Event handlers for: DirExe (PUSHBUTTON) */
DirControlDialog_DirExe_Click:
hcode = DirControlDialog.DirHcode.Select()
hcode = housecode.hcode
module = DirControlDialog.DirMod.Select()
if DirControlDialog.DirOn.Select() = 1 then
func = "ON"
if DirControlDialog.DirOff.Select() = 1 then
func = "OFF"
if DirControlDialog.DirDim.Select() = 1 then
func = "DIM"
dim = DirControlDialog.DirLevel.Select()
Do until rc = 0
rc = RxCmdUploadCP290(CP290,'result')
end
rc = RxDirCmdCP290(CP290, dim, func, hcode, module)
if rc = -1 then
do
rc = ErrorDialog("Communications Error With CP290")
rc = 20
end
do while rc < 5
rc = RxCmdUploadCP290(CP290, 'result')
end
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: errdlg |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: errbut (PUSHBUTTON) */
errdlg_errbut_Click:
rc = errdlg.Close()
return 0
SIGNAL RETURN
/* Event handlers for: errmsg (TEXTBOX) */
errdlg_errmsg_Init:
rc= errdlg.errmsg.Text(msg)
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Global procedures: |
| |
+-----------------------------------------------------------------------------*/
ErrorDialog:
ErrorDialog: procedure
parse arg msg
Return ModalFor('errdlg')
/*-----------------------------------------------------------------------------+
| |
| Default initialization: |
| |
+-----------------------------------------------------------------------------*/
INIT:
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Default error handlers: |
| |
+-----------------------------------------------------------------------------*/
SYNTAX:
SAY 'SYNTAX ERROR:' errortext( rc ) 'in:'
SAY sourceline( sigl )
SIGNAL ON SYNTAX
SIGNAL RETURN
HALT:
SAY 'HALT occurred in:'
SAY sourceline( sigl )
SIGNAL ON HALT
SIGNAL RETURN