home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMIGA PD 1
/
AMIGA-PD-1.iso
/
Programme_zum_Heft
/
Anwendungen
/
Kurztests
/
IR-Master
/
ARexx
/
switch_on&off.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-10-13
|
7KB
|
276 lines
/*****
Record.rexx
Sinn:
TV um eine bestimmte Uhrzeit
einschalten, bestimmtes Programm
einstellen und wieder um eine bestimmte
Uhrzeit abschalten.
Purpose:
Switch on TV at a given time, select
channel, switch off at a different time.
-------------
this script needs:
AmigaDOS commands: requestchoice, requestfile (shipped with OS3.0)
Selfmade commands: getstring, getnumber (shipped with ir-master)
libs : req.library (shipped with ir-master)
*****/
cr = d2c(10) /* ascii return */
/***********
Initialize this 3 variables to your project's needs
***********/
power_on = "1" /* How to switch on the tv set */
power_off= "Power" /* How to switch off the tv set */
mute = "mute" /* if you wnat to switch off volume on startup */
/* otherwise enter "" to ignore this option */
/**********
This is initialized by the script
***********/
port_name = "" /* The project's port */
channel = "" /* The desired channel */
start_at = "" /* Start at ?? o'clock */
stop_at = "" /* Stop at ?? o'clock */
/************
Do not edit the program as long as you do not
have experience in this
************/
options results
again_project:
call message "Welcome to RECORD.REXX V1.0*N*N© 1994 by Michael Watzl*N*NPlease select a Project..."
call getfile
file = result
if file = "" then do
if ask("Again?") then call again_project
exit 5
end
else
do
/* Extract port name by file name */
port_name = file
if pos( ":",port_name ) > 0 then port_name = right( port_name , length( port_name ) - lastpos(":",port_name))
if pos( "/",port_name ) > 0 then port_name = right( port_name , length( port_name ) - lastpos("/",port_name))
port_name = left( port_name , length(port_name)-4 )"_rexx"
/* ask for the missing parameters */
again_channel:
call message "Enter channel..."
call getnumber
channel = result
if channel = "" then do
if ask("Again?") then call again_channel
exit 5
end
else
do
again_start:
call message "Enter Start time...*N*NFormat: hh:mm"
call getstring
start_at = result
call valid start_at
if ~result then do
if ask( "Again?" ) then call again_start
exit 5
end
else
do
again_stop:
call message "Enter stop time...*N*NFormat: hh:mm"
call getstring
stop_at = result
call valid stop_at
if ~result then do
if ask("Again?") then call again_stop
exit 5
end
else
do
/*
* All data is now entered...
*/
msg = "Confirm please *N*N"
msg = msg||"Port : "port_name"*N"
msg = msg||"Channel : "channel "*N"
msg = msg||"Start : "start_at "*N"
msg = msg||"Stop : "stop_at "*N"
call ask msg
if ~result then do
if ask( "Again (all)?") then call again_project
exit 5
end
else
do
/*
* start the runner
*/
address command 'run >nil: ir-runner "'file'"'
address command 'wait 1'
if ~show(p,port_name) then do
if ask("Can't locate IR-Runner or project...*N*NStart again?") then call again_project
exit 5
end
else
do
address value port_name
/*
* Now the IR-Runner is activated with the correct project
* Ready to send commands
*/
/* Wait for start time */
say "Waiting until "start_at
address command 'wait until 'start_at
say "Switch on tv and wait some time"
'IR_SEND $'power_on
address command 'wait 1'
if mute ~= "" then do
'IR_SEND $'mute /* switch off volume */
end
address command 'wait 4'
say "Select channel "channel
do i=1 to length( channel )
'IR_Send $'substr( channel , i , 1 )
address command 'wait 1'
end
say "Wait 'till "stop_at
address command 'wait until 'stop_at
say "Switch off and quit.."
'IR_SEND $'power
'IR_QUIT'
end
end
end
end
end
end
exit 0
/*
* Invoke a filerequester and return selected file
*/
getfile:
address command
'requestfile >t:selected TITLE="IRM-Projekt auswählen" ACCEPTPATTERN="#?.IRM" NOICONS'
if rc >0 then return ""
if open( fh , 't:selected' , "R" ) then do
line = readln(fh)
line = compress( line , d2c(34) )
call close( fh )
'delete t:selected quiet'
end
else do
line = ""
end
address
return line
/*
* Invoke a (self programmed) numberrequester and return number
*/
getnumber:
address command
'getnumber >t:number'
if rc >0 then return ""
if open( fh , 't:number' , "R" ) then do
line = readln( fh )
call close( fh )
'delete t:number quiet'
end
else do
line = ""
end
address
return line
/*
* Invoke a (self programmed) stringrequester and return string
*/
getstring:
address command
'getstring >t:string'
if rc >0 then return ""
if open( fh , 't:string' , "R" ) then do
line = readln( fh )
call close( fh )
'delete t:string quiet'
end
else do
line = ""
end
address
return line
/*
* simple message for the user
*/
message:
arg string
address command
'requestchoice >nil: body="'string'" title=Request gadgets=ok'
address
return
/*
* check validity of timestring
*/
valid:
arg time
res = 1
if length(time) ~= 5 then res = 0
if substr(time,3,1) ~= ":" then res = 0
if datatype( substr(time,1,2)) ~= NUM then res = 0
if datatype( substr(time,4,2)) ~= NUM then res = 0
return res
/*
* ask user and return result
*/
ask:
arg string
address command
'requestchoice >t:select body="'string'" title=Request gadgets=ok|cancel'
if open( fh , "t:select" , "R" ) then do
line = readln( fh )
call close( fh )
address command 'delete "t:select" quiet'
end
else
do
line = 0
end
return line