Announcement

Collapse
No announcement yet.

How Unix-Data read in an array ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How Unix-Data read in an array ?

    Hello,

    I´ve serial data file in special kind:

    A;;1;Test1;134545;;;; +chr(13,10) Lineend and LF

    How to put the delimited data quick in an stringarray / type array

    without using instr to find the pos and mid$ to cut it ???

    (that way is too slow)

    Thank for help

    Matthias Kuhn

    ------------------

  • #2
    Since PB/DOS does not have a PARSE$ function, about all you can do to avoid using the string functions is to treat each line of input as a string, TALLY the delimiters, create enough output buffers (string array elements), and use a STRING PTR * 1 or BYTE PTR to move input to output, incrementing on the delimiter characters.

    Terribly tedious to code and test, but TANSTAAFL.

    If you do it right, though, you'll have your own PARSE$ function you can use over and over again.

    BTW, if this is a Unix file, are you sure you have a CR at the end of each record? Most Unix "text" files are terminated only with line feed (x'0A')

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      It would be an good excuse to buy PBCC or PBWIN which have an enhanced LINE INPUT #filenum&, Arr$() [RECORDS rcds] [TO count]. Using awk/mawk would also be a good option, using its field seperator FS. If this is an ongoing request, the awk program could easily moved to the unix machine and the processing done there.

      Comment


      • #4
        Parsing variable-length string data is pretty much inherently slow.
        If you know the maximum length, and don't expect $NUL characters,
        I'd suggest DIMensioning an array of fixed-length ASCIIZ strings
        and marching through the input with a BYTE PTR. Treating the input
        as a numeric byte stream and working with preallocated ASCIIZ strings
        will be much, much faster than traditional string approaches.

        PB/Win 7 and PB/CC 3 do have a PARSE statement that's designed to
        convert a delimited string to an array. This is certainly the easy
        way to get there, and may be fast enough for your purposes. Of
        course, these are Windows compilers...

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment

        Working...
        X