Example 9.18. ARG with source string named in Rexx program invocation
/* ARG with source string named in Rexx program invocation */ /* Program name is PALETTE. Specify 2 primary colors (yellow, */ /* red, blue) on call. Assume call is: palette red blue */ arg var1 var2 /* Assigns: var1="RED"; var2="BLUE" */ If var1<>"RED" & var1<>"YELLOW" & var1<>"BLUE" then signal err If var2<>"RED" & var2<>"YELLOW" & var2<>"BLUE" then signal err total=length(var1)+length(var2) SELECT; When total=7 then new="purple" When total=9 then new="orange" When total=10 then new="green" Otherwise new=var1 /* entered duplicates */ END Say new; exit /* Displays: "purple" */ Err: say 'Input error--color is not "red" or "blue" or "yellow"'; exit
Example 9.19. PARSE LINEIN
parse linein "a=" num1 "c=" num2 /* Assume: 8 and 9 */ sum=num1+num2 /* Enter: a=8 b=9 as input */ say sum /* Displays: "17" */
Example 9.20. PARSE PULL
PUSH "80 7" /* Puts data on queue */ parse pull fourscore seven /* Assigns: fourscore="80"; seven="7" */ SAY fourscore+seven /* Displays: "87" */
Example 9.21. PARSE SOURCE
parse source sysname . Say sysname /* Possibly Displays: */ /* "Windows" */