/*REXX*/ /*TRACE I*/ /*--- SUB ----------------------------- 2005 - Mark McDonald --------------- This macro allows you to 'SUBMIT' the currently edit code for execution by typing SUB on the Command line. SUB determines how to execute the code based on the file extension i.e. ".html" Is currently Setup to work with: .ASM - Assembler - Sent to System OS (assumes there is a .com or .exe) .BAT - Batch(DOS) - Sent to OS command interpreter .c - C - Sent to SPFSE C interpreter .cs - C - Sent to System OS (assumes there is a .com or .exe) .CMD - REXX - Sent to PCDOS REXX Interpreter .FTP - FTP Script - Sent to Windows ftp engine .GIF - GIF Graphic - Sent to Internet Explorer .HTM - Sends page to Internet Explorer .HTML - Sends page to Internet Explorer .ISP - SPFPC/PRO REXX Editor Exec - Sent to SPFPC/PRO Interpreter .JPG - JPEG Graphic - Sent to Internet Explorer .JPEG - JPEG Graphic - Sent to Internet Explorer .JS - Javascript - Sent to Internet Explorer .LBS - Liberty BASIC - Sent to Liberty BASIC IDE .MBS - MBASIC Interpreter .PAN - SPF/PCv3/4/5 ISPF Panels - Sent to SPFPC/SPFPRO .PBS - PowerBasic 3.5 - Sent to OS (assumes there is .com or .exe) .PBC - PowerBasic Concole Compiler (assumes there is .exe) .PDB - Palm Doc Book - Sent to DOCREADER .PDF - PDF Documents - Sent to Internet Explorer .PHP - PHP - Calls installed php windows engine .PRG - dBASE - Sent to dBase Interpreter .REX - REXX - Sent to OOREXX Interpreter .REXX - REXX - Sent to OOREXX Interpreter .RRX - REGINA REXX Interpreter .SWF - ShockWave Flash - Sent to Internet Explorer .SPF - SPPPC/PRO REXX Macro - Sent to SPFPC/PRO Interpreter .ZBS - ZBASIC Interpiler(32 Bit Software) - Sent to OS (Assumes .COM) This SPFPRO/SPFPCv4 macro can be used by non-REXX integrated editors such as SPF/PC, SPFSE, SPFLite, XE. I suggest creating a batch program and passing parms to it. Example: @ECHO OFF REM ------------------------------------------------------------------- REM Call SUB.SPF - Presumes SUB.BAT is in command path somewhere REM ------------------------------------------------------------------- H:\U\PCDOS\REXX.EXE H:\U\SPFPC40\MACROS\SUB.SPF %1 %2 Examples: SPF/PC: TSO SUB c:\path\index.html SPFSE: You can use a User commnad or see SUB.C on SPF my web page. XE: DOS SUB c:\path\index.html This macro will work with OOREXX/R4 if you delete or comment out the SPF REXX specific code which would cause it to abort when scanned as OOREXX can not ignore the ISREDIT commands in SPF REXX. ----------------------------------------------------------------------------------------*/ /*--- Determine Drive Letter SUB.SPF is Executing From i.e. C: ---*/ TSDRV = "C:" ;/*XDETSDRV() */ /*--- Determine IF SPFPRO, SPFPC v4.x or Stand-alone REXX Interpreter ---*/ TSPFL = XDETREXX(); TSPF = WORD(TSPFL,1) /*--- Determine Path of Browser for Interpreter ---*/ IF (TSPF = 0 | TSPF = 1 | TSPF = 4 )THEN TBROWSER = TSDRV"\U\IE.EXE" /* USE FOR SPC/PC 4.x or Stand Alone REXX Interpreter*/ IF (TSPF = 5 | TSPF = 6 | TSPF = 7 )THEN TBROWSER = TSDRC"\Program Files\Internet Explorer\IEXPLORE.EXE " /*--- Set vars ---*/ TZBASIC = TSDRV'\U\BASIC\ZB-32.COM' ;/*ZBASIC*/ TMFBASIC = TSDRV'\U\BASIC\MFBASIC\MFBASIC.EXE' ;/*MBASIC*/ TDBASE = TSDRV'\U\DBASE\DBASE ' ;/*dBASE Interpreter*/ TDOCREADER = TSDRV'\U\DOCREADER.EXE ' ;/*PALM DOCReader*/ TJBASIC = TSDRV'\U\BASIC\JBASIC\JBASIC.EXE ' ;/*JUST BASIC Interpreter*/ TLBASIC = TSDRV'\U\BASIC\LIBERTY\LIBERTY.EXE -R ' ;/*LIBERTY BASIC Interpreter*/ TOOREXX = TSDRV'\U\REXX\OOREXX\rexx.exe ' ;/*OOREXX Interpreter*/ TR4 = TSDRV'\U\REXX\R4\R4.EXE' ;/*R4 REXX Interpreter*/ TREXX = TSDRV'\U\REXX\PCDOS\REXX.EXE ' ;/*Classic REXX Interpreter*/ TRRX = TSDRV'\U\REXX\REGINA\REGINA.EXE ' ;/*32 Bit Regina REXX Interpreter*/ TSPFSE = TSDRV'\E\SPFSE\Graphic\Bin /S' ;/*SPFSE C Interpreter*/ TPHP = TSDRV'\U\PHP\php.bat 'TSDRV' ' ;/*PHP Interpreter*/ /*--- This Section for SPFPRO/SPFPCv3/4 Only ---*/ IF (TSPF = 4 | TSPF = 5) THEN DO 'ISREDIT MACRO(PARMS)' 'ISREDIT (FILENAME) = DATASET' FULLNAME = TRANSLATE(FILENAME) 'ISREDIT (MEMBER) = MEMBER' 'ISREDIT (MODIFIED) = DATA_CHANGED' IF (MODIFIED=YES) THEN 'ISREDIT SAVE' END /*-- Retrieve Passed Prams if not SPFPRO/SPFPC REXX ---*/ IF (TSPF = 0 | TSPF = 1 | TSPF = 6 | TSPF = 7) THEN DO PARSE UPPER ARG PARM1 PARMS FULLNAME = PARM1 END /*--- Breakout Filespec Info ---*/ RNAME = FULLNAME FULLNAME = TRANSLATE(FULLNAME) MEMNAME = SUBSTR(FULLNAME,1,POS('.',FULLNAME) -1) MEMNAME = SUBSTR(MEMNAME,LASTPOS('\',MEMNAME)+1) TNAME = TRANSLATE(FILENAME,' ','\') EXENAME = SUBSTR(FULLNAME,1,LASTPOS('.',FULLNAME)-1) /*--- Get Extenstion of File Name ---*/ EXNT = TRANSLATE(SUBSTR(FULLNAME,POS('.',FULLNAME)+1,3)) /*--- Remove Source Extension From File Name ---*/ EXE = SUBSTR(FULLNAME,1,POS('.',FULLNAME) -1) /*--- Use Local Web Server Instead of Internet? ---*/ IF POS("\HTDOCS\",RNAME,1) > 0 THEN DO SP = POS("\HTDOCS\",RNAME,1) SP = SP + 8 FULLNAME = SUBSTR(RNAME,SP) TCMD = TBROWSER' HTTP://127.0.0.1/'FULLNAME SIGNAL TEXEC END /*--- Use internet browser to display? ---*/ IF POS(EXNT,"HTA") > 0 THEN DO TCMD = 'START /B MSHTA 'FULLNAME SIGNAL TEXEC END /*--- Need Internet Browser to run ---*/ IF POS(EXNT,"HTA HTML HTM PDF SWF JS JPG JPEG GIF") > 0 THEN DO TCMD = 'START /B IEXPLORE ' FULLNAME SIGNAL TEXEC END /*--- PHP? ---*/ IF EXNT = "PHP" THEN DO TCMD = "C:\U\PHP\PHP.EXE "FULLNAME" "PARMS" > C:\TEMP\RDOS.HTM ;" TCMD = TCMD" START /B IEXPLORE C:\TEMP\RDOS.HTM" CALL RDOS TCMD EXIT END /*---Just BASIC (JBS) Runtime? ---*/ IF EXNT = "JBS" THEN DO TCMD = TJBASIC' 'FULLNAME SIGNAL TEXEC END /*--- Liberty BASIC (LBS) Runtime? ---*/ IF EXNT = "LBS" THEN DO TCMD = TLBASIC' 'FULLNAME SIGNAL TEXEC END /*--- SPFSE C Macro? ---*/ IF (EXNT = "C" | EXNT = "DLG" ) & (TSPF = 4 | TSPF = 5 | TSPF = 6 | TSPF = 7) THEN DO TCMD = TSPFSE''MEMBER SIGNAL TEXEC END /*--- Classic REX? (PCDOS REXX) ---*/ IF EXNT = 'CMD' THEN DO TCMD = TREXX' 'FULLNAME' 'PARMS SIGNAL TEXEC END /*--- R4 --------- WIN ---*/ IF EXNT = 'REX' THEN DO TCMD = TR4' 'FULLNAME' 'PARMS TCMD = "START CMD.EXE C:\U\R4\R4.EXE "TCMD CALL RDOS TCMD SIGNAL EEXIT END /*--- Display a SPFPC 3/4/5 Panel ---*/ IF (EXNT = 'PAN' & (TSPF = 4 | TSPF = 5)) THEN DO 'ISPEXEC DISPLAY PANEL('MEMNAME')' EXIT 0 END /*--- Palm Doc? ---*/ IF EXNT = 'PDB' THEN DO TCMD = TDOCREADER' 'FULLNAME SIGNAL TEXEC END /*--- (MFBASIC) ---*/ IF EXNT = "MBS" THEN DO TCMD = TMFBASIC' 'FULLNAME SIGNAL TEXEC END /*--- Power Basic Console Compiler? ---*/ IF EXNT = "PBC" THEN DO TCMD = FULLNAME".EXE "PARMS SIGNAL TEXEC END /*--- Executing a compiled program such as ZBASIC, PowerBasic(DOS), C, ASM? ---*/ IF POS(EXNT,'ZBS PBS CS ASM BAS',1) > 0 THEN DO TCMD = EXENAME' 'PARMS SIGNAL TEXEC END /*--- Regina REXX? ---*/ IF (EXNT = 'RRX') THEN DO TCMD = TRRX' 'FILENAME' 'PARMS SIGNAL TEXEC END /*--- OOREXX Program? ---*/ IF (EXNT = 'RX' | EXNT = 'REXX') THEN DO TCMD = TOOREXX' 'FILENAME' 'PARMS SIGNAL TEXEC END /*--- Executing a DOS Batch Program? ---*/ IF EXNT = 'BAT' THEN DO TCMD = 'START /B CMD /C 'FULLNAME' 'PARMS SIGNAL TEXEC END /*--- Executing a FTP Script ---*/ IF EXNT = 'FTP' THEN DO TCMD = 'FTP -s:'FILENAME SIGNAL TEXEC END /*--- Execute a Visual BASIC Module? ---*/ IF EXNT = 'VBS' THEN DO TCMD = 'C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VB98\VB6.EXE 'FULLNAME' /runexit' IF WORDS(PARMS) > 0 THEN TCMD = TCMD ' /cmd' SIGNAL TEXEC END /*--- Executing a SPFPC REXX Program? -- This section will not work with OOREXX Comment it out ---*/ IF (TSPF = 4 | TSPF = 5) THEN DO IF EXNT = 'SPF' THEN DO FULLNAME PARMS EXIT END IF EXNT = 'ISP' THEN DO ADDRESS ISPEXEC 'select cmd('MEMNAME') parm('PARMS')' ADDRESS ISREDIT EXIT END END /*--- Executing a dBASE II/III/IV Program? ---*/ IF EXNT = 'PRG' THEN DO TCMD = TDBASE' 'FILENAME' 'PARMS SIGNAL TEXEC END /*--- Execute TCMD Command --*/ EEXIT: EXIT /*-- Pass Command to OS --------------------------------------------------*/ TEXEC: IF TSPF = 0 THEN ADDRESS COMMAND TCMD /*DOSREXX*/ IF (TSPF = 4 | TSPF = 5) THEN ADDRESS SYSTEM TCMD /*SPFPC4/SPFPRO - Delete if using OOREXX*/ IF TSPF = 1 | TSPF = 6 THEN TCMD /*R4/OOREXX*/ IF TSPF = 7 THEN ADDRESS SYSTEM TCMD /*OOREXX*/ EXIT 0 /*-- Determine Source Path ----------------------------------*/ XDETSDRV: PROCEDURE PARSE SOURCE ENV TYPE NAME TSDRV = LEFT(NAME,2) RETURN (TSDRV) /*----------------------------------------------------------- Determines Version of REXX Interpreter -------------------------------------------------------------*/ XDETREXX: PROCEDURE parse version name level date1 date2 date3 /*--- Use this section to display REXX Interpreter Info ---*/ /* SAY name; SAY level; SAY date1; SAY date2; SAY date3; EXIT */ /*-- Determine which REXX interpreter is being used ---*/ TSPF = 0 /* Using a stand-alone REXX Interpreter DOSREXX*/ IF name = "REXXSAA" & date3 = "1994" THEN TSPF = '0 'name /* Using PCDOS REXX*/ IF name = "REXX-r4" THEN TSPF = '1 'name /* Using R4 */ IF name = "REXXPC88" & date3 = "1987" THEN TSPF = '2 'name /* Using REXXIBM (1987)*/ IF name = "REXX/Personal" & date3 = "1992" THEN TSPF = '3 'name /* Using Personal REXX v4*/ IF name = "REXX/2" & date3 = "1995" THEN TSPF = '4 'name /* Using SPFPC v4 */ IF name = "REXX/2" & date3 = "1996" THEN TSPF = '5 'name /* Using SPFPRO */ IF LEFT(name,11) = "REXX-ooRexx" THEN TSPF = '6 'name /* Using OOREXX */ IF LEFT(name,11) = "REXX-Regina" THEN TSPF = '7 'name /* Using Regina */ /*say name;parse pull z */ RETURN (TSPF) /*--------------------------------------------------------------- RDOS - Builds Batch File To Execute OS Commands REQUIRES EXISTENCE OF C:\TEMP XWORDS XWORD XLATE UNXLATE Commands Separated by ; CMD = "IF EXIST C:\TEMP\RDOS.TXT DEL C:\TEMP\RDOS.TXT;" CMD = CMD"ECHO Gathing data...;" CMD = CMD"CALL DIR C:\SPFPRO\MACROS\*.* /N /ON > C:\TEMP\RDOS.TXT;" CMD = CMD"START IEXPLORE C:\TEMP\RDOS.TXT" CALL RDOS CMD EXIT ---------------------------------------------------------------*/ RDOS: PROCEDURE PARSE ARG CMD /*--- Build Semi-Unique Result File Name ---*/ TBAT = "C:\TEMP\RDOS.BAT" /*--- Build Batch File ---*/ T = LINEOUT(TBAT,"@ECHO OFF",1) /*Turn off Command Echo*/ TCNT = XWORDS(CMD,";") /*Det # OS Commands*/ DO CNT = 1 TO TCNT /*Loop Through Commands*/ TCMD = XWORD(CMD,CNT,";") /*Extract OS Command*/ T = LINEOUT(TBAT,TCMD) /*Write to Batch File*/ END T = LINEOUT(TBAT,'EXIT') /*Tell Batch to End*/ T = LINEOUT(TBAT) /*Close C:\TEMP\RDOS.BAT*/ /*--- Execute Batch Program ---*/ ADDRESS SYSTEM TBAT /*Execute Batch File*/ RETURN /*---------------------------------------------------------------*/ XWORDS: PROCEDURE PARSE ARG X, XDL X = XLATE(X,XDL) NWRDS = WORDS(X) RETURN (NWRDS) /*---------------------------------------------------------------*/ XWORD: PROCEDURE PARSE ARG X, N ,XDL IF N > XWORDS(X,XDL) THEN RETURN ("") X = XLATE(X,XDL) X = WORD(X,N) X = XUNLATE(X) RETURN (X) /*---------------------------------------------------------------*/ XLATE: PROCEDURE PARSE ARG X, XDL X = TRANSLATE(X,D2C(253)," ") X = TRANSLATE(X," ",XDL) RETURN (X) /*---------------------------------------------------------------*/ XUNLATE: PROCEDURE PARSE ARG X X = TRANSLATE(X," ",D2C(253)) RETURN (X) /*---------------------------------------------------------------*/ /* Removes Leftmost n characters */ /* T = XTRIML("--ONE",2) returns "ONE" */ /*---------------------------------------------------------------*/ XTRIML: PROCEDURE PARSE ARG X, N IF LENGTH(X) - 1 >= N THEN XR = RIGHT(X,LENGTH(X) - N) ELSE XR = X RETURN (XR)