Last active
August 29, 2015 14:14
-
-
Save phpdave/902debb703aadbe53b07 to your computer and use it in GitHub Desktop.
CL Program that takes in a Filename and passes it to PHP-CLI in the PASE environment (IBM i)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*************** Beginning of data ******************************************** | |
PGM PARM(&FILENAME) | |
/* VARS */ | |
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(80) | |
DCL VAR(&PHPCLIPATH) TYPE(*CHAR) LEN(128) | |
/* VARS FOR TRIM */ | |
DCL VAR(&LEN) TYPE(*DEC) LEN(2 0) | |
DCL VAR(&NULL) TYPE(*CHAR) LEN(128) VALUE(X'00') /*TERMINATE VAR WITH NULL */ | |
DCL VAR(&NULL1) TYPE(*CHAR) LEN(1) VALUE(X'00') | |
DCL VAR(&CHR15) TYPE(*CHAR) LEN(15) | |
DCL VAR(&CURCHAR) TYPE(*CHAR) LEN(1) | |
/* SET VARS */ | |
RTVDTAARA DTAARA(MYLIB/PHPCLIPATH) RTNVAR(&PHPCLIPATH) | |
CHGVAR VAR(&PHPCLIPATH) VALUE(&PHPCLIPATH *TCAT &NULL) | |
/* TRIM THAT FILENAME AND NULL TERMINATE */ | |
CHGVAR &LEN 80 | |
CHGVAR &CURCHAR %SST(&FILENAME &LEN 1) | |
LOOP: IF (&LEN > 1 & (&CURCHAR=' ' | &CURCHAR=&NULL1)) (DO) | |
CHGVAR &LEN VALUE(&LEN - 1) | |
CHGVAR &CURCHAR %SST(&FILENAME &LEN 1) | |
GOTO LOOP | |
ENDDO | |
CHGVAR &CHR15 &LEN | |
SNDPGMMSG ('THE LENGTH IS' |> &CHR15) | |
CHGVAR &FILENAME VALUE(%SST(&FILENAME 1 &LEN) *TCAT &NULL) | |
SNDPGMMSG ('FILENAME IS' |> &FILENAME) | |
CHGJOB LOG(4 00 *SECLVL) LOGCLPGM(*YES) | |
/* RUN */ | |
CALL QP2SHELL PARM(&PHPCLIPATH &FILENAME) | |
ENDPGM | |
****************** End of data *********************************************** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment