APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) APPX Utility : (Category) APPX Development Environment : (Category) Tips & Techniques :
What is the proper usage of --- STREAM READ LENGTH field?
I have a job that takes a tab-delimited file and reformats it to an appxio file. The STREAM READ only returns a valid record the first time, subsequent reads return varying data.
My simple subroutine looks like this:
     SET      --- STREAM OPEN TYPE           =      r
     SET      --- STREAM READ LENGTH         =
     GOSUB    --- STREAM OPEN
     SET      --- STREAM EOR SEQUENCE        =      LF
     IF       --- STREAM RETURN CODE         NE     0
     *
     *        read tab file record
     LABEL    :NEXT RECORD
     TRAP
     GOSUB    --- STREAM READ
     IF       --- STREAM RETURN CODE         EQ     0
     IF       --- STREAM BUFFER              EQ
     GOTO     :NEXT RECORD 

The field --- STREAM READ LENGTH is used for two things. If set to a value other than zero the READ subroutine will limit the data bytes it reads to no more than that many bytes. What gets you is that your READ routine also uses that field to tell you how many bytes it actually did read. So, the first time you call it the value was zero, it read in number of bytes (if you count the tab bytes) up to the linefeed and set that number of bytes into this field. Since you didn't reset it to zero that value carried forward to the next read. It read that number of bytes and stopped leaving the rest<lf> unread. The next time you called read it read the remaining number of bytes up to the linefeed and set the length to that number. And so on.....
So, you need to set this field to zero before each read attempt.

[Append to This Answer]
2006-Jan-18 8:57am
Previous: (Answer) I have an ALPHA field with a validation table, but it allows for any value to be entered, regardless of the validation table values
Next: (Answer) Can the STREAM READ look for the presence of the \r character as a record delimeter?
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=617
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.