PixieEditor Help: PICK backservers



* READ Backserver for PixieEditor

* Started 981123 by John Calder, The Total Computer Co

* 

* 990917 JPC add capability to speed up summary list

*        delivery by taking a batch of Item IDs as input.

*        Hence introduce <&IM> as item separator

* 990917 JPC give up on one Program to cover both PICK and

*        UNIVERSE and instead have separate PIX.PICK.READ

*        and PIX.UV.READ

* 990913 JPC change to <&AM> as escape code for CHAR(254)

* 990106 JPC rewrite of how sub-values are analysed

*        to improve program speed

* 990105 JPC new optional parameter to limit length of

*        output string

* 981215 JPC conversion of CHAR(254) ... to escape codes

*        of printable characters for TCP/IP transmission

*        in a manner similar to HTML "tags"

*

***********************************************

* PICK vs UNIVERSE programs difference is only in which of these

* 2 lines is uncommented.

* for PICK

  TCLREAD sCommand

* for UNIVERSE

*  sCommand = SENTENCE() 

***********************************************

  iPos = INDEX(sCommand, " ", 1)

  sCommand = sCommand[iPos + 1, 99999]

  sFile = FIELD(sCommand, "|", 1)

  sID = FIELD(sCommand, "|", 2)

  nLeftSample = FIELD(sCommand, "|", 3)

  OPEN sFile to rFile ELSE

    CRT "ERROR on server, can not open file ":sFile:""

    STOP

  END

* We now have a successful read of the item into sRaw

* This is processed into sResponse for transmission with

* printable escape codes for reserved characters

* which PICK would otherwise convert in ways that could give

* us problems later with editing and writing back.

*

  nItems = DCOUNT(sID, "^")

  CONVERT "^" TO CHAR(254) IN sID

  sResponse = ""

  FOR i = 1 TO nItems

    READ sRaw FROM rFile, sID<i> ELSE

      CRT "" 

      STOP

    END

    sItem = ""

    IF nLeftSample = "" THEN

      n = DCOUNT(sRaw, CHAR(254))

      FOR i = 1 TO n

        * Test for multivalues

        IF INDEX(sRaw<i>, CHAR(253), 1) > 0 THEN

          sAttr = sRaw<i>

          LOOP

            iPos = INDEX(sAttr, CHAR(253), 1)

            IF iPos = 0 THEN EXIT

            sAttr = sAttr[1, iPos-1]:"<&VM>":sAttr[iPos+1,99999]

          REPEAT

          LOOP

            iPos = INDEX(sAttr, CHAR(252), 1)

            IF iPos = 0 THEN EXIT

            sAttr = sAttr[1, iPos-1]:"<&SVM>":sAttr[iPos+1,99999]

          REPEAT 

          LOOP

            iPos = INDEX(sAttr, CHAR(251), 1)

            IF iPos = 0 THEN EXIT

            sAttr = sAttr[1, iPos-1]:"<&SSVM>":sAttr[iPos+1,99999]

          REPEAT

          sItem = sItem: sAttr

        END ELSE

          sItem = sItem: sRaw<i>

        END

        sItem = sItem: "<&AM>"

      NEXT i

      * End of code for return of full length items

    END ELSE

      * alternative for return of sample data for quick summaries etc

      sItem = sRaw[1,nLeftSample]

      CONVERT CHAR(254) TO "^" IN sItem

    END

    IF sResponse = "" THEN

      sResponse = sItem

    END ELSE

      sResponse := "<&IM>":sItem

    END

  NEXT i

  CRT "":sResponse:""

STOP

END       



* WRITE backserver for PixieEditor

* Started 981125 JPC John Calder, The Total Computer Co

* General purpose write-item-on demand

* Transmission is of format:

*

* PIX.PICK.WRITE sFile|sID|sItem

* or

* PIX.UV.WRITE sFile|sID  ... followed by INPUTs of sItem

*

* where sItem is the data to write with attribute marks

* encoded as the "escape sequence" <&AM> which needs to be

* found and changed to CHAR(254) before writing to the file

*

* 990917 JPC give up on one Program to cover both PICK and

*        UNIVERSE and instead have separate PIX.PICK.WRITE

*        and PIX.UV.WRITE

* 990915 JPC allow for UNIVERSE INPUT buffer size by sending

*        items in 4K max chunks. 

* 990913 JPC change to <&AM> for attribute mark

* 981215 JPC Additional escape sequences for value marks <&VM> etc

*        See the 4 x LOOP .. REPEATs near the end

* 

*****************************************

* PICK version - feed in 1-step via TCLREAD

  TCLREAD sCommand

  iPos = INDEX(sCommand, " ", 1)

  sCommand = sCommand[iPos + 1, 99999]

  sFile = FIELD(sCommand, "|", 1)

  sID = FIELD(sCommand, "|", 2)

  sItem = sCommand[Col2() + 1, 99999]

  sSystem = "PICK"

*****************************************

* UNIVERSE version

*  sCommand = SENTENCE()

*  iPos = INDEX(sCommand, " ", 1)

*  sCommand = sCommand[iPos + 1, 99999]

*  sFile = FIELD(sCommand, "|", 1)

*  sID = FIELD(sCommand, "|", 2)

*  sSystem = "UNIVERSE"

*****************************************

  OPEN sFile to rFile ELSE

    CRT "ERROR! Can not open file " & sFile & "."

    STOP

  END

*

* Cover the UNIVERSE need 

* to drip feed small amounts only via INPUT

  IF sSystem = "UNIVERSE" THEN

    sItem = ""

    LOOP

      CRT ""

      INPUT s

      IF s[LEN(s)-5,6] = "" THEN

        sItem := s[1, LEN(s)-6]

        EXIT

      END ELSE

        sItem := s

      END

    REPEAT

  END

*

* Convert transmission tags to attribute and value marks

  LOOP

    iPos = INDEX(sItem, "<&AM>", 1)

    IF iPos = 0 THEN EXIT

    sItem = sItem[1, iPos-1]:CHAR(254):sItem[iPos+5, 99999]

  REPEAT

  LOOP

    iPos = INDEX(sItem, "<&VM>",1)

    IF iPos = 0 THEN EXIT

    sItem = sItem[1, iPos-1]:CHAR(253):sItem[iPos+5,99999]

  REPEAT

  LOOP

    iPos = INDEX(sItem, "<&SVM>",1)

    IF iPos = 0 THEN EXIT

    sItem = sItem[1, iPos-1]:CHAR(252):sItem[iPos+6,99999]

  REPEAT

  LOOP

    iPos = INDEX(sItem, "<&SSVM>",1)

    IF iPos = 0 THEN EXIT

    sItem = sItem[1, iPos-1]:CHAR(251):sItem[iPos+7,99999]

  REPEAT

  WRITE sItem ON rFile, sID

  CRT "Item successfully filed in ":sSystem:" System"

END  


Back to main PixieEditor Help