• The CompuBBS code (3/4)

    From SPP@21:1/5 to All on Mon Jul 26 22:47:40 2021
    [continued from previous message]

    +"," +oshort +"," +ommid +","
    +opa+","+oflags+", ," +odisplay +","
    +right(awhen,3) +"," +oclearing+",D"

    do write with w

    aflag = .T.

    endif

    tecount = tecount + 1

    eshares = min( LEAVES , mmax )

    oleaves = oleaves - eshares

    mmax = mmax - eshares

    ofilled = ofilled + eshares

    tmatch = tmatch + 1

    w = left( awhen , 5 ) +",E," +str( SEQ ,9,0)
    +"," +PORT +"," +USER +"," +TOKEN +"," +BUY_SELL
    +", " +str(eshares,6,0) +"," +str(tmatch,9,0)
    +"," +ostock +"," +str(PRICE,11,4) +"," +str(
    recno() ,8,0) +", 0," +SHORT +"," +MMID +","
    +PA+"," +ommid+",A," +DISPLAY +","
    +right(awhen,3) +"," +CLEARING+",D"

    do write with w

    w = left( awhen , 5 ) +",E," +str(tseq,9,0) +","
    +oport+"," +ouser +"," +otoken +"," +obuy_sell
    +", " +str(eshares,6,0) +"," +str(tmatch,9,0)
    +"," +ostock +"," +str(PRICE,11,4) +","
    +str(tlocate,8,0) +", 0," +oshort +"," +ommid
    +"," +opa+","+MMID+",R," +odisplay +","
    +right(awhen,3) +"," +oclearing+",D"

    do write with w

    dleaves = LEAVES - eshares

    if dleaves <= 0 && Dead record?

    replace LEAVES with 0 , SEQ with
    tnextdead tnextdead = recno()

    else

    replace LEAVES with dleaves , FILLED
    with FILLED + eshares

    endif

    enddo

    endif

    if oleaves > 0 && any non-executed shares left?

    if otif = 0 && Fill or kill, so cancel leaves

    if !aflag && did we not make an A message yet?

    w = left( awhen , 5 ) +",A,"
    +str(tseq,9,0) +"," +oport+"," +ouser
    +"," +otoken +"," +obuy_sell +", "
    +str(oshares,6,0) +", " +str(omin,6,0)
    +"," +ostock +"," +str(oprice,11,4) +","
    +str(tlocate,8,0)+ "," +str(otif,5,0)
    +"," +oshort +"," +ommid +","
    +opa+","+oflags+", ," +odisplay +","
    +right(awhen,3) +"," +oclearing+",D" do
    write with w

    endif

    w = left( awhen , 5 ) +",X," +str(tseq,9,0) +","
    +oport+"," +ouser +"," +otoken +"," +obuy_sell
    +", " +str(oleaves,6,0) +", 0," +ostock +","
    +str(oprice,11,4) +"," +str(tlocate,8,0)+ ", 0,"
    +oshort +"," +ommid +"," +opa+",#IOC, ,"
    +odisplay +"," +right(awhen,3) +","
    +oclearing+",D" do write with w

    oleaves = 0

    else

    if !aflag && did we not make an A message yet?

    w = left( awhen , 5 ) +",A,"
    +str(tseq,9,0) +"," +oport+"," +ouser
    +"," +otoken +"," +obuy_sell +", "
    +str(oshares,6,0) +", " +str(omin,6,0)
    +"," +ostock +"," +str(oprice,11,4) +","
    +str(tlocate,8,0) +"," +str(otif,5,0)
    +"," +oshort +"," +ommid +","
    +opa+","+oflags+",B," +odisplay +","
    +right(awhen,3) +"," +oclearing+",D"

    else

    w = left( awhen , 5 ) +",B,"
    +str(tseq,9,0) +"," +oport+"," +ouser
    +"," +otoken +"," +obuy_sell +", "
    +str(oleaves,6,0) +", 0," +ostock +","
    +str(oprice,11,4) +"," +str(tlocate,8,0)
    +"," +str(otif,5,0) +"," +oshort +","
    +ommid +"," +opa+", , ," +odisplay +","
    +right(awhen,3) +"," +oclearing+",D"

    endif

    do write with w

    endif && otif == 0

    endif && oleaves > 0

    if oleaves > 0 && Still open?

    goto tlocate

    replace ; PORT with oport,; USER with ouser,; TOKEN with
    otoken,; BUY_SELL with obuy_sell,; LEAVES with
    oleaves,; STOCK with ostock,; PRICE with
    oprice,; SHORT with oshort,; MMID with ommid,;
    PA with opa,; DISPLAY with odisplay,; CLEARING
    with oclearing,; FILLED with ofilled,; SEQ with
    tseq

    else && leaves = 0 (add current order to deadlist)

    goto tlocate replace SEQ with tnextdead tnextdead =
    recno()

    endif && oleaves > 0

    return

    ****** Enter Report adds a type R line to the file ****** Enter order
    assumes ostock and obuy_sell are the right length.

    proc enter2report

    parameter

    oport,ouser,otoken,obuy_sell,oshares,ostock,oprice,oshort,ommid,opa,oreport,oclearing,ocontra

    tseq = tseq + 1

    tmatch = tmatch + 1

    mwhen = str( tnow , 9 , 3)

    w = left( mwhen , 5 ) + ",R,"+str(tseq,9,0) +"," +oPORT+","
    +oUSER+"," +oTOKEN+"," +oBUY_SELL +",
    "+str(oshares,6,0)+","+str(tmatch,9,0)+","
    +oSTOCK+","+str(oprice,11,4)+",00000000,

    0,"+oSHORT+","+oMMID+","+oPA+","+ocontra+","+oreport+",R,"+right(mwhen, 3)+","+oCLEARING+",D"

    do write with w

    return


    ****** Enter Reject adds a type J line to the file

    proc enter2reject

    parameter oport,ouser,otoken,otype,oreason

    tseq = tseq + 1

    *** Leaves MUST be 0 or it might be included in the match!

    mwhen = str( tnow , 9 , 3)

    w = left( mwhen , 5 ) + ",J," +str(tseq,9,0) +"," +oport+","
    +ouser +"," +otoken+"," +otype+", 0, 0, , 0.0000,00000000, 0, ,
    , , ," +oreason +",N,"+right(mwhen,3)+", ,D"

    do write with w

    return


    ****** Enter break adds a type C line to the file

    proc enterbreak

    parameter oseq, oport , ouser, otoken, obuy_sell, oshares,
    omatch, ostock, oprice, ommid, oreason, omisc, oclearing ,
    oshort

    if oseq > tseq .or. oseq < 1

    ? time()+" Bad SEQ in Break! OSEQ="+str(oseq,9,0)+"
    RECS="+str( tseq, 9,0)

    return

    endif

    if oshares <= 0

    ? time()+" Jerk boy BREAK zero shares
    SEQ="+str(oseq,9,0)

    return

    endif

    if oprice <= 0

    ? time()+" Jerk boy BREAK zero price SEQ="+str(oseq,9,0)

    return

    endif

    if ! omisc $ "AR"

    ? time()+" Invalid A/R BREAK MISC="+omisc+"
    SEQ="+str(oseq,9,0)

    return

    endif

    mwhen = str( tnow , 9 , 3)

    w = left( mwhen , 5 ) + ",C,"+str(oseq,9,0) +"," +oPORT+","
    +oUSER+"," +oTOKEN+"," +oBUY_SELL +",
    "+str(oshares,6,0)+","+str(omatch,9,0)+","
    +oSTOCK+","+str(oprice,11,4)+",00000000, 0,"+oshort+","+oMMID+",
    ,"+oreason +","+omisc+", ,"+right(mwhen,3)+","+oCLEARING+",D"

    do write with w

    return


    ****** Enter maint adds a type M line to the file


    *** SHORTTYPE ***** N - No short sale checks ***** B - Bidtick test
    ***** L - Lasttrade test

    *** BLOCKSUB - Block subscriber only orders? ***** B - Block ***** N -
    No block

    *** CENTER ***** Q - NASDAQ ***** L - LISTED

    proc entermaint

    parameter
    oport,ouser,otoken,ostock,oshorttype,oblocksub,ocenter,omisc

    if ! oshorttype $ "NBL"

    ? time()+" Bad SHORTTYPE="+oshorttype+" STOCK="+ostock

    return

    endif

    if !oblocksub $ "BN" ? time()+" Bad BLOCKSUB="+oblocksub+"
    STOCK="+ostock

    return endif

    if !ocenter $ "QL" ? time()+" Bad CENTER="+ocenter+"
    STOCK="+ostock

    return endif

    if len( omisc ) # 4 ? time()+" Bad omisc len!"+omisc return
    endif

    for eml = 1 to 4

    emb = substr( omisc , eml , 1 )

    if !isalpha( emb ) .and. emb # " "

    ? time()+" Bad omisc letter!"+omisc return

    endif

    endfor

    awhen = str( tnow , 9 , 3 )

    w = left( awhen , 5 ) +",M, 0,"+oport+","+ouser+","+otoken+",S,
    0, 0," +ostock +", 0.0000,00000000, 0,"+oshorttype+", ,
    ,"+omisc+","+ocenter+","+oblocksub+"," +right(awhen,3) +", , "

    do write with w

    return

    *** STATE - Trading state ***** T - Trading ***** H - Halted

    proc enterstate

    parameter oport,ouser,otoken,ostock,ostate

    if !ostate $ "TH" ? time()+" Bad STATE="+ostate+" STOCK="+ostock

    return endif

    awhen = str( tnow , 9 , 3 )

    w = left( awhen , 5 ) +",M, 0,"+oport+","+ouser+","+otoken+",T,
    0, 0," +ostock +", 0.0000,00000000, 0, , , , ,"+ostate+", ,"
    +right(awhen,3) +", , "

    do write with w

    return

    *** Enter account configures an OUCH account

    proc enteraccount

    parameter oaccount,opassword,otest,otrusted, othresh,
    osscheck,oiflag, odefault

    if !otest$"TN"

    ? time()+" Bad TEST flag in enteraccount:"+otest return

    endif

    if !otrusted$"TN"

    ? time()+" Bad TRUSTED flag in enteraccount:"+otrusted
    return

    endif

    if !osscheck$"YN"

    ? time()+" Bad SSCHECK flag in enteraccount:"+osscheck
    return

    endif

    if !oiflag$"IN"

    ? time()+" Bad IFLAG flag in enteraccount:"+oiflag
    return

    endif

    if len( opassword ) # 10 ? time()+" Bad opassword
    len!"+opassword return
    endif

    for eml = 1 to 10

    emb = substr( opassword , eml , 1 )

    if !isalpha( emb ) .and. !isdigit( emb) .and. emb # " "
    .and. emb # "!" .and. emb # "#"

    ? time()+" Bad opassword
    letter!"+opassword+":"+str(eml) return

    endif

    endfor


    if len( oaccount ) # 6 ? time()+" Bad oaccount len!"+oaccount
    return
    endif

    for eml = 1 to 6

    emb = substr( oaccount , eml , 1 )

    if !isalpha( emb ) .and. !isdigit( emb ) .and. emb # " "

    ? time()+" Bad oaccount
    letter!"+oaccount+":"+str(eml) return

    endif

    endfor

    if len( odefault ) # 4 ? time()+" Bad odefault len!"+odefault
    return
    endif

    for eml = 1 to 4

    emb = substr( odefault , eml , 1 )

    if !isalpha( emb ) .and. !isdigit( emb) .and. emb # " "

    ? time()+" Bad odefault letter!"+odefault
    +":"+str(eml) return

    endif

    endfor

    awhen = str( tnow , 9 , 3 )

    w = left( awhen , 5 ) +",M, 0,"+oaccount+",
    ,"+opassword+",A,"+str(othresh,9,0)+", 0, , 0.0000,00000000,
    0,"+osscheck+","+odefault +", ,"+otest+ " "+ otrusted +"
    ,"+oiflag+", ," +right(awhen,3) +", , "

    do write with w

    return


    *** Enter firm configures an OUCH account for clearing

    proc enterfirm

    parameter oaccount,ommid,oclearing

    if !oclearing$"AIQRN"

    ? time()+" Bad clearing in enterfirm:"+oclearing return

    endif

    if len( ommid ) # 4 ? time()+" Bad ommid len!"+ommid return
    endif

    for eml = 1 to 4

    emb = substr( ommid , eml , 1 )

    if !isalpha( emb ) .and. !isdigit( emb) .and. emb # " "

    ? time()+" Bad ommid letter!"+ommid+":"+str(eml)
    return

    endif

    endfor

    if len( oaccount ) # 6 ? time()+" Bad oaccount len!"+oaccount
    return
    endif

    for eml = 1 to 6

    emb = substr( oaccount , eml , 1 )

    if !isalpha( emb ) .and. !isdigit( emb ) .and. emb # " "

    ? time()+" Bad oaccount
    letter!"+oaccount+":"+str(eml) return

    endif

    endfor


    awhen = str( tnow , 9 , 3 )

    w = left( awhen , 5 ) +",M, 0,"+oaccount+", , ,F, 0, 0, ,
    0.0000,00000000, 0, ,"+ ommid +", , , , ," +right(awhen,3)
    +","+oclearing+", "

    do write with w

    return

    proc new2cancel

    parameter olocate,oseq,oshares,ocontra && Contra indeicates
    reason for cancel

    if olocate <= 0 .or. olocate > reccount()

    ? time()+" CANCEL LOCATE OUT OF BOUNDS " +str( olocate ,
    8 , 0)+ " SEQ=" +str(oseq,8,0)

    return 0

    endif

    goto olocate

    if oseq # SEQ

    *** ? time()+" CANCEL OUT OF DATE " +str( olocate , 8 , 0)+ " SEQ=" +str(oseq,8,0)

    ttoolate = ttoolate + 1

    return 0

    endif

    if LEAVES <= oshares

    ttoolate = ttoolate + 1

    return

    endif

    xshares = LEAVES - oshares

    do mwrite with "X", SEQ , xshares , PRICE , ocontra , " " , 0 ,
    recno()

    txcount = txcount + 1

    dleaves = LEAVES - xshares

    if dleaves <=0

    && Must set LEAVES to zero to pull order from indexes

    replace LEAVES with 0 , SEQ with tnextdead tnextdead =
    recno()

    else

    replace LEAVES with dleaves

    endif

    return


    ****** Cancel Order takes a locator and a SEQ number ****** passed
    shares in new intedned order size ****** returns number of shares
    canceled and leaves record pointer on order canceled.

    proc i2cancel

    parameter olocate,oseq,oshares,ocontra && Contra indeicates
    reason for cancel


    if olocate <= 0 .or. olocate > reccount()

    ? time()+" CANCEL LOCATE OUT OF BOUNDS " +str( olocate ,
    8 , 0)+ " SEQ=" +str(oseq,8,0)

    return 0

    endif

    goto olocate

    if oseq # SEQ

    *** ? time()+" CANCEL OUT OF DATE " +str( olocate , 8 , 0)+ " SEQ=" +str(oseq,8,0)

    ttoolate = ttoolate + 1

    return 0

    endif

    msize = LEAVES + FILLED && Current size of order

    if oshares >= msize

    *** ? time()+" INTENEDED CANCEL BIGGER THAN ORDER SHARES="+str( oshares,
    6 , 0 )+" REASON="+ocontra

    return 0

    endif

    xshares = msize - oshares && HOwmany do we have to cancel to get
    from current size to new size?

    if xshares > LEAVES && Don't cancel more than are open

    xshares = LEAVES

    endif

    if xshares = 0

    ttoolate = ttoolate + 1

    return 0

    endif

    do mwrite with "X", SEQ , xshares , PRICE , ocontra , " " , 0 ,
    recno()

    txcount = txcount + 1

    dleaves = LEAVES - xshares

    if dleaves <=0

    && Must set LEAVES to zero to pull order from indexes

    replace LEAVES with 0 , SEQ with tnextdead tnextdead =
    recno()

    else

    replace LEAVES with dleaves

    endif

    return xshares


    proc initstatus activate window status @ 0,1 SAY "Orders:" @ 0,27 SAY
    "Executions:" @ 0,52 SAY "Cancels:" activate window ticker
    return

    proc showstatus activate window status @ 0,11 SAY tseq PICTURE
    "##,###,###" @ 0,38 SAY tmatch PICTURE "##,###,###" @ 0,60 SAY
    txcount PICTURE "##,###,###" activate window ticker
    return

    proc processtcpip

    param ptm

    tcommand = substr( ptm , 1 , 1 )

    if geom

    ? time()+" Command recieved after EOM:"+tcommand return

    endif

    do case

    case tcommand = "H"

    tport = substr( ptm , 2 , 6 )

    if !seek( tport , "SOURCES" )

    insert into SOURCES values ( tport , 1 )

    endif

    tinseq = val(substr( ptm , 73, 9 ) )

    if tinseq # SOURCES.SEQ

    if tinseq < SOURCES.SEQ

    *** ? time()+" Duped inseq "+tport+" Expected:"+str( SOURCES.SEQ , 9,
    0)+" Got:"+str( tinseq , 9 , 0 )
    return

    endif

    do alert with "Gapped inseq "+tport+"
    Expected:"+str( SOURCES.SEQ , 9, 0)+"
    Got:"+str( tinseq , 9 , 0 )

    endif

    tuser = substr( ptm , 8 , 4 ) ttoken = substr(
    ptm , 12 , 10 ) tbuy_sell = substr( ptm , 22 , 1
    ) tshares = val( substr( ptm , 23 , 6 ) ) tmin =
    val( substr( ptm , 29 , 6 ) ) tstock = substr(
    ptm , 35 , 6 ) tprice = val( substr( ptm , 41 ,
    11 ) ) ttif = val( substr( ptm , 52 , 5 ) )
    tdisplay = substr( ptm , 57 , 1 ) tshort =
    substr( ptm , 58 , 1 ) tpa = substr( ptm , 59 ,
    1 ) tmmid = substr( ptm , 60 , 4 ) tclearing =
    substr( ptm , 64 , 1 ) tflags = substr( ptm , 65
    , 4 )

    if tbuy_sell = "B"

    xshort = " "

    else

    if tbuy_sell # "S"

    ? time()+" Bad buy_sell
    "+tbuy_sell+" port="+tport

    return

    endif

    do case case tshort = "Y" xshort = "S"

    case tshort = "S" xshort = "S"

    case tshort = "N" xshort = "L"

    case tshort = "L" xshort = "L"

    case tshort = "E" xshort = "E"

    otherwise xshort = "?"

    endcase

    endif

    if tshares <= 0

    ? time()+" Jerk boy zero shares TOKEN "
    +tport+"-" +tuser+"-" +ttoken

    return

    endif

    if tshares >= 1000000

    ? time()+" Jerk boy million shares TOKEN
    " +tport+"-" +tuser+"-" +ttoken

    return

    endif


    if tprice <= 0

    ? time()+" Jerk boy zero price TOKEN "
    +tport+"-" +tuser+"-" +ttoken

    return

    endif


    if tprice >= 1000000

    ? time()+" Jerk boy million price TOKEN
    " +tport+"-" +tuser+"-" +ttoken

    return

    endif


    if ! tclearing $ "AIQOR"

    ? time()+" Jerk boy strange clearing >"
    +tclearing+"< TOKEN " +tport+"-"
    +tuser+"-" +ttoken

    return

    endif


    if ! tdisplay $ "YNLRP"

    ? time()+" Jerk boy strange display >"
    +tdisplay+"< TOKEN " +tport+"-"
    +tuser+"-" +ttoken

    return

    endif

    if (tdisplay = "R" .or. tdisplay = "P" ) .and.
    ttif > 0

    ? time()+" Jerk boy R or P or Q display
    with nonzero tif >" +str(ttif,5,0)+"<
    TOKEN " +tport+"-"+tuser+"-"+ttoken

    return

    endif

    if !gaccept

    ? time()+" Trade ignored outside SOD-EOD
    time "+tport+"-" +tuser+"-" +ttoken

    return

    endif

    if tclearing = "A"

    if !gactaccept

    ? time()+" ACT trade ignored
    outside ACT time " +tport+"-"
    +tuser+"-" +ttoken

    return

    endif

    endif


    select SOURCES replace SEQ with tinseq + 1
    select ISLAND

    do enter2order with tport , tuser , ttoken ,
    tbuy_sell , tshares , tstock , tprice , ttif ,
    xshort , tmmid , tpa , tdisplay , tmin ,
    tclearing , tflags

    case tcommand = "L"

    tolocate = val( substr( ptm , 2 , 8 ) ) toseq =
    val( substr( ptm , 10 , 9 ) ) tshares = val(
    substr( ptm , 19 , 6 ) ) treason = substr( ptm ,
    25 , 1 )

    do case case treason = "A" xreason = "#USR" case
    treason = "B"
    xreason = "#TME" case treason =
    "C"
    xreason = "#HLT" case treason =
    "D"
    xreason = "#SUP" case treason =
    "E"
    xreason = "#DNT" case treason =
    "F"
    xreason = "#MBL"

    otherwise xreason = "#USR" endcase

    do new2cancel with tolocate , toseq , tshares ,
    xreason

    case tcommand = "I"

    tport = substr( ptm , 2 , 6 )


    if !seek( tport , "SOURCES" )

    insert into SOURCES values ( tport , 1 )

    endif

    tinseq = val( substr( ptm , 24 , 9 ) )

    if tinseq # SOURCES.SEQ

    if tinseq < SOURCES.SEQ

    *** ? time()+" Duped REJ inseq "+tport+" Expected:"+str( SOURCES.SEQ ,
    9, 0)+" Got:"+str( tinseq , 9 ,
    0 ) return

    endif

    do alert with "Gapped REJ inseq
    "+tport+" Expected:"+str( SOURCES.SEQ ,
    9, 0)+" Got:"+str( tinseq , 9 , 0 )

    endif


    tuser = substr( ptm , 8 , 4 ) ttoken = substr(
    ptm , 12 , 10 ) ttype = substr( ptm , 22 , 1 )
    treason = substr( ptm , 23 , 1 )

    do enter2reject with tport , tuser , ttoken ,
    ttype , treason

    select SOURCES replace SEQ with tinseq + 1
    select ISLAND

    case tcommand = "Z"

    tolocate = val( substr( ptm , 2 , 8 ) ) toseq =
    val( substr( ptm , 10 , 9 ) ) tshares = val(
    substr( ptm , 19 , 6 ) ) treason = substr( ptm ,
    25 , 1 )

    do case case treason = "A" xreason = "#USR" case
    treason = "B"
    xreason = "#TME" case treason =
    "C"
    xreason = "#HLT" case treason =
    "D"
    xreason = "#SUP" case treason =
    "E"
    xreason = "#DNT" case treason =
    "F"
    xreason = "#MBL"

    otherwise xreason = "#USR" endcase


    =i2cancel( tolocate , toseq , tshares , xreason
    )

    case tcommand = "S"

    tport = substr( ptm , 2 , 6 )

    if !seek( tport , "SOURCES" )

    insert into SOURCES values ( tport , 1 )

    endif

    tinseq = val(substr( ptm , 58 , 9 ) )

    if tinseq # SOURCES.SEQ

    if tinseq < SOURCES.SEQ

    *** ? time()+" Duped REP inseq "+tport+" Expected:"+str( SOURCES.SEQ ,
    9, 0)+" Got:"+str( tinseq , 9 ,
    0 ) return

    endif

    do alert with "Gapped REP inseq
    "+tport+" Expected:"+str( SOURCES.SEQ ,
    9, 0)+" Got:"+str( tinseq , 9 , 0 )

    endif

    tuser = substr( ptm , 8 , 4 ) ttoken = substr(
    ptm , 12 , 10 ) tbuy_sell = substr( ptm , 22 , 1
    ) tshares = val( substr( ptm , 23 , 6 ) ) tstock
    = substr( ptm , 29 , 6 ) tprice = val( substr(
    ptm , 35 , 11 ) ) treport = substr( ptm , 46 , 1
    ) tshort = substr( ptm , 47 , 1 ) tpa = substr(
    ptm , 48 , 1 ) tmmid = substr( ptm , 49 , 4 )
    tclearing = substr( ptm , 53 , 1 ) tcontra =
    substr( ptm , 54 , 4 )


    if ! treport $ "YNS" ? time()+" Jerk boy REPORT
    code TOKEN " +tport

    return

    endif


    if tshares <= 0

    ? time()+" Jerk boy REPORT zero shares
    TOKEN "+tport+"-"+tuser+"-"+ttoken

    return

    endif


    if tshares >= 1000000

    ? "Jerk boy REPORT million shares TOKEN
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif


    if tprice <= 0

    ? "Jerk boy REPORT zero price TOKEN
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif

    if tprice >= 1000000

    ? "Jerk boy REPORT million price TOKEN
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif


    if ! tclearing $ "ABSIQORN"

    ? "Jerk boy REPORT strange clearing
    >"+tclearing+"< TOKEN
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif

    if !gaccept

    ? "Report ignored outside SOD-EOD time
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif

    if tclearing = "A"

    if !gactaccept

    ? "ACT trade REPORT ignored
    outside ACT time
    "+tport+"-"+tuser+"-"+ttoken

    return

    endif

    endif

    do enter2report with tport , tuser , ttoken ,
    tbuy_sell , tshares , tstock , tprice , tshort ,
    tmmid , tpa , treport , tclearing , tcontra

    select SOURCES replace SEQ with tinseq + 1
    select ISLAND

    case tcommand = "D"

    tcseq = val( substr( ptm , 2 , 9 ) ) tcport =
    substr( ptm , 11 , 6 ) tcuser = substr( ptm , 17
    , 4 ) tctoken = substr( ptm , 21 , 10 )
    tcbuy_sell = substr( ptm , 31 , 1 ) tcshares =
    val( substr( ptm , 32 , 6 ) ) tcmatch = val(
    substr( ptm , 38 , 9 ) ) tcstock = substr( ptm ,
    47 , 6 ) tcprice = val( substr( ptm , 53 , 11 )
    ) tcmmid = substr( ptm , 64 , 4 ) tcmisc =
    substr( ptm , 68 , 1 ) tcreason = substr( ptm ,
    69 , 1 ) tcclearing = substr( ptm , 70 , 1 )

    do case case tcreason = "A" xreason = "#ERR"
    case tcreason = "B"
    xreason = "#CON" case tcreason =
    "C"
    xreason = "#SUP" case tcreason =
    "D"
    xreason = "#SYS" case tcreason =
    "E"
    xreason = "#EXT"

    otherwise

    ? time()+" Unvalid break reason
    = "+tcreason

    return

    endcase

    do case

    case tcbuy_sell = "B" xbuy_sell = "B"
    xshort = " "

    case tcbuy_sell = "S" xbuy_sell = "S"
    xshort = "L"

    case tcbuy_sell = "T" xbuy_sell = "S"
    xshort = "S"

    case tcbuy_sell = "E" xbuy_sell = "S"
    xshort = "E"

    otherwise

    ? time()+" Unvalid break
    buy_sell = "+tcbuy_sell return

    endcase


    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)