xlate
Richard Kreiss
rkreiss at verizon.net
Tue Feb 19 15:35:10 PST 2013
> -----Original Message-----
> From: filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com
> [mailto:filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com] On
> Behalf Of Kenneth Brody
> Sent: Tuesday, February 19, 2013 6:10 PM
> To: GCC Consulting
> Cc: filepro-list at lists.celestial.com
> Subject: Re: xlate
>
> On 2/19/2013 5:56 PM, GCC Consulting wrote:
> [...]
> > I considered using xlate to remove the blank space:
> >
> > QQ=xlate(ab," ","");ab=qq
> >
> > I used a msgbox to show the value of ab and the space had been removed.
> > However, the parsing now completely fails. Anyone have any idea why
> > once xlate has been executed, my program fails but without it,
> > everything works as programmed.
> [...]
>
> 1) DDW
>
> 2) You have an error on line 42.
>
> --
> Kenneth Brody
Ken,
I realize you would like to see the code involved so here it is. Note that
when mt is set to 0, it is not added to the array rdata, This array is
mapped to real fields.
postit:'******************************:'* read the returned data from this
file and parse it:
:'* for the necessary information:'* check first to see that this is
actually an XML file:
:'* and not a curl error message:':
::declare
cfile,ifile,rdrive,file,line1(6,.0),line2(6,.0),line3(6,.0),tdif(6,.0),tag,s
ee,newtag:
::declare
rcsp,rtime,rref,rerror,rordernum,rmessage,rcode,rtdate,rscore,rauthresponse,
rapproved,ravs:
::declare isvalue,IDorder(8,rjzero):
::ab(1024,*):
::ct(2,.0)="0":
::rdrive=getenv("PFDATA"):
::bs=chr("92"):
::ifile=rdrive{bs{Folder{bs{freturn:
::aa=open(ifile):
:aa lt "0":BEEP;ERRORBOX "(94)Autherization File Not Found\nSj
#\r"<1<"\r\nRecord #\r"<@rn<"\r";exit:
:'allow additional time for response before reading file:sleep "500":
:'length of line read:xx=read(aa,ab):
:ab = "":MSGBOX "No Data";END:
::qq(1024,*)=xlate(ab," ","");ab=qq;msgbox ab:
readit:'process the data read in:':
:ct lt "30":ct=ct+"1";GOSUB get_tag:
:'get start of tag:line1=instr(ab,"<"):
:mid(tag,"2","1")="?" 'set ending
location:ac=mid(ab,len(tag)+"1",xx);ab=ac;GOTO readit:
:line2 = "":line2=instr(ab,">"):
:'set length of tag:tdif=(line2-line1):
:'get start of tag end - length of value:line3=instr(ab,"</")-(tdif+"1"):
:'get start of tag end - length of value:newtag=instr(ab,"</")+tdif:
nomatch:mid(ab,line2+"1","2") = "</" 'start of tag
close:ac=mid(ab,(line2*"2")+"2",xx);ab=ac:
:nomatch:GOTO clearit:
:mid(ab,line1+"1",line2-"2") = tag:ac=mid(ab,line2+"1",line3-"1"):
:ac = "" and ct = "14":GOTO make_ad:
:ac = "" and ct lt "30":GOTO clearit:
make_ad::ad=mid(ab,newtag+"2",xx);ab=ad:
:mt gt "0" 'set array value & field value:rdata[mt]=ac;display:
:ct = "30" 'read all of the tags & now process them:GOTO itsdone:
clearit:'reset ab for next read and clear previous
values:line1="";line2="";line3="";ac="";ad="";mt="";GOTO readit:
::end:
itsdone:'************************************************************:'*
check approval and set status field and post if approved:
:'close xml file and test file:ax=close(aa);bx=close(bb):
::'batch_num=bat_num:
:'reset each time transaction processed:'date_last_processed=@t4:
:'StatusMsg = "" and 22 ne "":'STATUS="0";flag="0";processed="3";GOTO
chk_fst:
:StatusMsg = "FRAUD" and submitted le
"2":CCP_STATUS="3";flag="3";processed="3";GOTO chk_fst:
:StatusMsg = "DECLINED" and submitted le
"2":CCP_STATUS="2";flag="5";processed="3";GOTO chk_fst:
:StatusMsg = "DECLINED" and submitted ge "3":CCP_STATUS="5";flag =
"6";processed="3";GOTO chk_fst:
:StatusMsg ne "APPROVED":CCP_STATUS="5";flag = "7";processed="3";GOTO
chk_fst:
:StatusMsg = "approved" and respCode = "00":CCP_STATUS="6";processed="3":
:'renewal ge "1":'post_status="0";GOTO postpay:
appro_1:'renewal = "":'GOTO chk_fst:
chk_fst::END:
get_tag:'*************************************************************:'*
set tag name:
:ct = "1":tag="<?xml version=\"1.0\"
encoding=\"UTF-8\"?><Response><NewOrderResp><IndustryType></IndustryType>";m
t="0";RETURN:
:ct = "2":tag="MessageType";mt(2,.0)="0";RETURN:
:ct = "3":tag="MerchantId";mt="0";RETURN:
:ct = "4":tag="TerminalId";mt="0";RETURN:
:ct = "5":tag="CardBrand";mt="0";RETURN:
:ct = "6":tag="AccountNum";mt="0";RETURN:
:ct = "7":tag="OrderId";mt="0";RETURN:
:ct = "8":tag="TxRefNum";mt="1";RETURN:
:ct = "9":tag="TxRefIdx";mt="2";RETURN:
:ct = "10":tag="ProcStatus";mt="3";RETURN:
:ct = "11":tag="ApprovalStatus";mt="4";RETURN:
:ct = "12":tag="RespCode";mt="5";RETURN:
:ct = "13":tag="AVSRespCode";mt="6";RETURN:
:ct = "14" 'skip this tag:tag="CVV2RespCode";mt="0";RETURN:
:ct= "15":tag="AuthCode";mt="7";RETURN:
:ct = "16" 'skip these tag:tag = "RecurringAdviceCd";mt="0";RETURN:
:ct = "17" 'skip these tag:tag = "CAVVRespCode";mt="0";RETURN:
:ct = "18":tag="StatusMsg";mt="8";RETURN:
:ct = "19":tag="RespMsg";mt="0";RETURN:
:ct = "20":tag="HostRespCode";mt="9";RETURN:
:ct = "21":tag="HostAVSRespCode";mt="10";RETURN:
:ct = "22":tag="HostVV2RespCode";mt="0";RETURN:
:ct = "23":tag="CustomerRefNum";mt="0";RETURN:
:ct = "24":tag="CustomerName";mt="0";RETURN:
:ct = "25":tag="ProfileProcStatus";mt="0";Return:
:ct = "26":tag="Customer ProfileMessage";mt="0";Return:
:ct = "27":tag="RespTime";mt="11":
::return:
::END:
Richard
More information about the Filepro-list
mailing list