/* Filter for formatting Prospect data. Change log: 12-25-99 - Change HTMLDATA to be the filename to prevent Rexx clause from exceeding limit 12-20-99 - Improve performance by removing PIPE from the change 12-15-99 - Prevent | and / from causing problems, improve performance 07-01-99 - Oh great. back to this again. Made it faster yet again as well as able to handle very large pieces of data STMK 07-27-98 - Tweaked to use multistream pipes... Faster. STMK 07-26-98 - Discovered no other marketable skills. Bought new monitor. Returned to work. STMK 07-23-98 - Shot computer. Quit in frustration. STMK 07-20-98 - Created. STMK USAGE: The formatting of the cells at the HTML to respond with are passed as a single argument. The SQL information is passed via the incoming pipe. CELLFORM FORMAT: "Name;Size-Name;Size-Name;Size", ie, "Project;30-Name;15" would specify the first field named 'Project' which is 30 characters long, the second field named 'Name' which is 15 characters long. HTMLDATA FORMAT: The HTMLDATA is passed in the same argument as the CELLFORM format. It must be seperated from the CELLFORM by the string %&%. HTMLDATA itself may be any string literal. It is parsed against the names given in CELLFORM and replaces all instances of $() with the data of that cell. (This is now the FN of a file that contains this info, w/ ft=RESPON) EXAMPLE: CELLDATA = 'Name;15-Date;8-Notes;100' HTMLDATA = 'Name $(NAME)
' , 'Date $(DATE)
' , 'Notes $(NOTES)
' 'CALLPIPE sql SELECT * FROM MYDB | ', 'stempros 'CELLDATA'%&%'HTMLDATA' |:*' */ parse arg CELLPAD /* Multistage to seperate cellpad from htmldata, then parse cellpad * into the tmp stem for later translation */ 'CALLPIPE (name stempros01 endchar ?)' , 'var CELLPAD | split string /%&%/ | a: drop 1' , '| var FNHTMLDATA', '?', 'a: | tokenize /-/ | nlocate /-/ | stem tmp.' /* Would you like some... D E A T H with your MULTISTREAM PIPELINE!? AHAHAHAHAHAHAHAHAHAHAH */ "CALLPIPE (name stempros02) <" fnhtmldata "RESPON |" , "join * | var htmldata" /* Parse the celldata into nme and len */ len.0 = tmp.0 /* each stem item describes a field */ do z = 1 to tmp.0 /* See, isn't parse var cool? Everyone say 'Thank You Mr. Faust!' */ /* THAAANNNKKK YOUU MISTTEERRR FAUUUSSSTT! */ parse var tmp.z nme.z ';' len.z ynme.z = '$('||nme.z||')' xnme.z = 'X' || c2x(ynme.z) end /* tmp.0 */ /* Calc the actual offsets */ off.1 = 1 do i = 2 to len.0 x = i-1 off.i = off.x+len.x end /* do while */ /* Get our data from the SQL CGI call */ do Forever 'READTO RAWDATA' if (rc ^= 0) then leave do i = 1 to len.0 parsed.i = strip(substr(rawdata, off.i, len.i)) xparsed.i = 'X' || c2x(parsed.i) end /* do len */ parsed.0 = len.0 /* LOCHTMLDATA = HTMLDATA do i = 1 to len.0 'CALLPIPE (name stempros02)' , 'var LOCHTMLDATA |' , 'change 'xnme.i xparsed.i '|' , 'var LOCHTMLDATA' If rc <> 0 Then do Say 'rc=' rc 'i=' i say 'nme' nme.i 'parsed('parsed.i')' end /* rc */ end /* Changeloop */ */ LOCHTMLDATA = HTMLDATA do i = 1 to len.0 p = pos(ynme.i,lochtmldata) do while p > 0 Parse var lochtmldata first (ynme.i) second lochtmldata = first || parsed.i || second If second = '' Then do Say 'Empty' i nme.i tmp.i lochtmldata = first end p = pos(ynme.i,lochtmldata) end /* while */ end /* Changeloop */ 'OUTPUT' lochtmldata end /* do forever */ exit