home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
run.zip
/
run.RXX
< prev
next >
Wrap
Text File
|
2000-01-26
|
18KB
|
624 lines
/*-----------------------------------------------------------------------------+
| |
| REXX source code listing for DrRexx application: |
| J:\drdi\projects\run\run.RES |
| |
| File last modified on: 01/23/00 at: 03:16pm |
| Listing produced on: 01/26/00 at: 02:45pm |
| |
+-----------------------------------------------------------------------------*/
SIGNAL ON SYNTAX
SIGNAL ON HALT
SIGNAL INIT
RETURN:
SIGNAL VALUE DrRexxEvent()
L1:
EXIT -1
L2:
INTERPRET DrRexxInterpret()
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: D100 |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: D100 (DIALOG) */
D100_Init:
/* author= J. Pedone (jpedone@flash.net) */
/* Load REXX UTIL functions */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call sysloadfuncs
/* Get current working directory */
parse arg pworkdir
If pworkdir = '' Then Do
pworkdir=Directory()
End
/* check for root */
If LastPos('\',pworkdir) <> Length(pworkdir) Then Do
pworkdir=pworkdir||'\'
End
/* get current work directory */
cworkdir=directory()
If LastPos('\',cworkdir) <> Length(cworkdir) Then Do
cworkdir=cworkdir||'\'
End
/* set up some defaults */
file_found = ''
history=''
internetProg=''
oldD100=1
/* get vars for ftp and web browser */
call iniFunctions 'read,'||pworkdir||'run.ini , browsers; WEB Browser;, browsers; FTP Browser;'
internetProg.0=iniValues.0
Do n = 1 to 2
internetProg.n = iniValues.n
End
call check_internet
/* get history from run.ini */
Call get_data
/* display the last command */
rc = D100.prog_list.Select(1,'Select')
SIGNAL RETURN
/* Event handlers for: Browse_push (PUSHBUTTON) */
D100_Browse_push_Click:
/* Get file */
browse = FilePrompt('*.*','Browse',ok,'Open')
/* Put it in the run box */
rc = D100.prog_list.Text(browse)
SIGNAL RETURN
/* Event handlers for: ok_push (PUSHBUTTON) */
D100_ok_push_Click:
/* reorder history and run prog */
call run_prog
SIGNAL RETURN
/* Event handlers for: prog_list (COMBOBOX) */
D100_prog_list_Enter:
call run_prog
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Menu handlers for dialog: D100 |
| |
+-----------------------------------------------------------------------------*/
/* Browsers */
/* - Label: Internet */
/* - Action: */
call internet
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: error_dialog |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: error_ok (PUSHBUTTON) */
error_dialog_error_ok_Click:
/* close error dialog */
rc=error_dialog.close()
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Event handlers for dialog: browser_setup |
| |
+-----------------------------------------------------------------------------*/
/* Event handlers for: browser_setup (DIALOG) */
browser_setup_Init:
/* fill in the boxes */
rc = browser_setup.web_browser.Text(internetProg.1)
rc = browser_setup.ftp_browser.Text(internetProg.2)
/* give the ok button the focus */
CALL browser_setup.browser_ok_push.Focus
SIGNAL RETURN
/* Event handlers for: browser_cancel_push (PUSHBUTTON) */
browser_setup_browser_cancel_push_Click:
/* close error dialog */
rc=browser_setup.close()
SIGNAL RETURN
/* Event handlers for: browser_ok_push (PUSHBUTTON) */
browser_setup_browser_ok_push_Click:
/* save browser data */
internetProg.1 = browser_setup.web_browser.Text()
internetProg.2 = browser_setup.ftp_browser.Text()
/* write out the browser info */
call iniFunctions 'set,'||pworkdir||'run.ini , browsers;WEB Browser;'||internetprog.1||',browsers; FTP Browser;'||internetprog.2
rc = browser_setup.close()
call check_internet
SIGNAL RETURN
/* Event handlers for: prog2_push (PUSHBUTTON) */
browser_setup_prog2_push_Click:
/* get the ftp browser */
internetProgTemp2 = FilePrompt('*.exe','FTP Browser',ok,'Open')
/* put it in the box */
rc = browser_setup.ftp_browser.Text(internetProgTemp2)
SIGNAL RETURN
/* Event handlers for: Prog1_push (PUSHBUTTON) */
browser_setup_Prog1_push_Click:
/* get the web browser */
internetProgTemp1 = FilePrompt('*.exe','Web Browser',ok,'Open')
/* put it in the box */
rc = browser_setup.web_browser.Text(internetProgTemp1)
SIGNAL RETURN
/*-----------------------------------------------------------------------------+
| |
| Global procedures: |
| |
+-----------------------------------------------------------------------------*/
iniFunctions:
/* INI File functions */
/* Called as:
iniFunctions file [,application name; key name; value]
Examples:
iniFunctions set, test.ini , paths; download; f:\temp, paths; upload; f:\dragen\download, paths; program root; f:\dragen
iniFunctions get apps, test.ini
The values will be stored in appNames stem variable
iniFunctions get keys, test.ini , paths
The values will be stored in keyNames stem variable
iniFunctions read, test.ini , paths; download;, paths; upload;, paths; program root;
The values will be stored in iniValues stem variable
iniFunctions delete app,test.ini , paths;;
iniFunctions delete,test.ini , paths; download;
*/
parse arg function ',' file ',' appAndKeysAndData
Parse upper var function function
function = Strip(function)
file = Strip(file)
appAndKeysAndData = Strip(appAndKeysAndData)
x=0
Do while appAndKeysAndData > ''
x=x+1
parse var appAndKeysAndData app ';' key ';' data ',' .
app.0 = x
app.x = Strip(app)
key.0 = x
key.x = Strip(key)
data.0 = x
data.x = Strip(data)
parse var appAndKeysAndData . ',' appAndKeysAndData
End
Select
When function = 'SET' Then Do
Do x = 1 to app.0
rc=sysini(file,app.x,key.x,data.x)
End
End /* when do */
When function = 'READ' Then Do
Drop iniValues
Do x = 1 to app.0
iniValues.0=x
iniValues.x=sysini(file,app.x,key.x)
If iniValues.x = 'ERROR:' Then Do
iniValues.x = ''
End
End
End /* when do */
When function = 'DELETE' Then Do
Do x = 1 to app.0
rc=sysini(file,app.x,key.x,'DELETE:')
End
End /* when do */
When function = 'DELETE APP' Then Do
Do x = 1 to app.0
rc=sysini(file,app.x,'DELETE:')
End
End /* when do */
When function = 'GET KEYS' Then Do
Drop keyNames
Do x = 1 to app.0
rc=sysini(file,app.x,'ALL:',keyNames)
End
End /* when do */
When function = 'GET APPS' Then Do
Drop appNames
rc=sysini(file,'ALL:',appNames)
End /* when do */
Otherwise Do
Return 1
end /* Otherwise */
end /* select */
RETURN
check_internet:
/* check for existance of internet programs */
internetProg.1=strip(internetProg.1,B)
internetProg.2=strip(internetProg.2,B)
Do n = 1 to 2
parse upper var internetProg.n prog .
drive_part=FileSpec('Drive',prog)
Select
When prog = '' Then Do
call not_found
call internet
Return
End
When drive_part='' Then Do
prog=SysSearchPath('Path',prog)
if prog='' Then Do
Call not_found
Call internet
Return
End
End /* when */
Otherwise Do
Call SysFileTree prog, 'file', 'F'
If file.0 = 0 Then Do
Call not_found
call internet
Return
End
End /* otherwise */
End /* select */
parse caseless var internetProg.n . parm
internetProg.n = prog||' '||parm
End
/* write out the browser info */
call iniFunctions 'set,'||pworkdir||'run.ini ,' ||,
'browsers ; WEB Browser ; '||internetprog.1||',' ||,
'browsers ; FTP Browser ; '||internetprog.2
RETURN
internet:
/* open the browser setup dialog */
rc=browser_setup.open()
call browser_setup.show
RETURN
not_found:
/* the requested prog was not found */
rc = D100.Visible(oldD100)
rc=error_dialog.open()
call error_dialog.show
RETURN
save_history:
/* save the history list */
Call iniFunctions 'set,'||pworkdir||'run.ini, ' ||,
'history ; history1 ; '||history.1||', '||,
'history ; history2 ; '||history.2||', '||,
'history ; history3 ; '||history.3||', '||,
'history ; history4 ; '||history.4||', '||,
'history ; history5 ; '||history.5||', '||,
'history ; history6 ; '||history.6||', '||,
'history ; history7 ; '||history.7||', '||,
'history ; history8 ; '||history.8||', '||,
'history ; history9 ; '||history.9||', '||,
'history ; history10 ; '||history.10
RETURN
history:
/* strip blanks */
do n = 1 to 10
history.n = strip(history.n,'B')
end
/* rebuild history list */
Select
When D100.prog_list.Text()=history.10 Then Do
historytemp=history.1
history.1=history.10
history.10=history.9
history.9=history.8
history.8=history.7
history.7=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.9 Then Do
historytemp=history.1
history.1=history.9
history.9=history.8
history.8=history.7
history.7=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.8 Then Do
historytemp=history.1
history.1=history.8
history.8=history.7
history.7=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.7 Then Do
historytemp=history.1
history.1=history.7
history.7=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.6 Then Do
historytemp=history.1
history.1=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.5 Then Do
historytemp=history.1
history.1=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.4 Then Do
historytemp=history.1
history.1=history.4
history.4=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.3 Then Do
historytemp=history.1
history.1=history.3
history.3=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.2 Then Do
historytemp=history.1
history.1=history.2
history.2=historytemp
return
End
When D100.prog_list.Text()=history.1 Then Do
return
End
Otherwise Do
history.10=history.9
history.9=history.8
history.8=history.7
history.7=history.6
history.6=history.5
history.5=history.4
history.4=history.3
history.3=history.2
history.2=history.1
history.1=D100.prog_list.Text()
End
End
RETURN
run_prog:
/* hide the dialog */
oldD100 = D100.Visible(0)
/* reorder the history */
call history
/* run the program */
/* check for internet stuff */
firstFour = SubStr(D100.prog_list.text(),1,4)
parse upper var firstFour firstFour .
if firstFour = 'HTTP' | firstFour = 'WWW.' | firstFour = 'FTP:' | firstFour = 'FTP.' then do
objectID = '<JWP_RUN_TEMP>'
title = 'Browser'
class = 'WPProgram'
location = '<WP_NOWHERE>'
If firstFour='HTTP' | firstFour = 'WWW.' Then Do
parse caseless var internetProg.1 prog parm
setup = 'EXENAME='prog';' || ,
'PARAMETERS='parm||' '||D100.prog_list.text()';' || ,
'OBJECTID=' || objectID || ';' || ,
'CONCURRENTVIEW=YES' || ';'
End
If firstFour='FTP:' | firstFour = 'FTP.' Then Do
parse caseless var internetProg.2 prog parm
setup = 'EXENAME='prog';' || ,
'PARAMETERS='parm||' '||D100.prog_list.text()';' || ,
'OBJECTID=' || objectID || ';'|| ,
'CONCURRENTVIEW=YES' || ';'
End
rc = D100.close()
rc = SysCreateObject( class, title, location, setup, 'U' )
rc = SysOpenObject(objectID,0,1)
call save_history
exit 0
End
/* check for a blank entry */
fileToRun=D100.prog_list.text()
fileToRun = strip(fileToRun,'B')
if fileToRun = '' Then Do
Exit 1
End
/* set up for exe, com, cmd or bat (in order) */
run.0 = 6
parse var fileToRun run.1 .
run.2 = run.1||'.exe'
run.3 = run.1||'.com'
run.4 = run.1||'.cmd'
run.5 = run.1||'.bat'
run.6 = fileToRun
/* Change relative to absolute */
parse upper var fileToRun drive_part .
drive_part=FileSpec('Drive',drive_part)
Do i = 1 to 5
If drive_part=' ' Then Do
fileToRun=SysSearchPath('Path',run.i)
End
If fileToRun \= '' then leave
End
/* check to see if it exists */
Call SysFileTree fileToRun, 'file', 'F'
If file.0 = 0 Then Do
Call not_found
Return
End
/* set up the extension */
parse upper var fileToRun '.' test
/* run it */
Select
/* non-executable */
When test \= 'EXE' & test \= 'COM' & test \= 'CMD' & test \= 'BAT' & test \= '' Then Do
call sysOpenObject fileToRun,'Default','True'
call sysOpenObject fileToRun,'Default','True'
call save_history
exit 0
End
/* Executable */
When test = 'EXE' | test = 'COM' | test = 'CMD' | test = 'BAT' Then Do
parse var run.6 . parms
parse var fileToRun fileToRun .
objectID = '<JWP_RUN_TEMP>'
title = 'Run - '||fileToRun
class = 'WPProgram'
location = '<WP_NOWHERE>'
setup = 'EXENAME='fileToRun';' || ,
'PARAMETERS='||parms';' || ,
'OBJECTID=' || objectID || ';'|| ,
'CONCURRENTVIEW=YES' || ';' ,
'WORKDIR='||cworkdir||';'
rc = D100.close()
rc = SysCreateObject( class, title, location, setup, 'R' )
rc = SysOpenObject(objectID,0,1)
rc = SysOpenObject(objectID,0,1)
call save_history
exit 0
End
/* File not found */
Otherwise Do
call not_found
End
End
RETURN
get_data:
/* read it in and add the contents to the combo box */
Call iniFunctions 'read,'||pworkdir||'run.ini,' ||,
'history ; history1 ; ,' ||,
'history ; history2 ; ,' ||,
'history ; history3 ; ,' ||,
'history ; history4 ; ,' ||,
'history ; history5 ; ,' ||,
'history ; history6 ; ,' ||,
'history ; history7 ; ,' ||,
'history ; history8 ; ,' ||,
'history ; history9 ; ,' ||,
'history ; history10 ; '
Do n = 1 to 10
history.n = iniValues.n
rc = D100.prog_list.Add(history.n,n)
End
RETURN
/*-----------------------------------------------------------------------------+
| |
| 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