Re: The mystery of the missing (compound) variables.



On Sat, 10 May 2008 21:34:01 UTC, Pit Zyclade <pit@xxxxxxxx> wrote:

Gordon Snider schrieb:
On Wed, 7 May 2008 11:54:29 UTC, Pit Zyclade <pit@xxxxxxxx> wrote:

phillips_js@xxxxxxxxxxx schrieb:
...
So I use a text file with a max 50 records as a number all alone on
its line (so I can recover it as a number) and a following space-
separated text string line which can be PARSEd. Code snippet:

IF STREAM(file,"C","QUERY EXISTS")\="" THEN DO
CALL STREAM file,"C","OPEN READ"

rec_num = 0

DO FILELN = 1 TO 50
IF STREAM(file,"S")\="READY" THEN
LEAVE
ln = LINEIN(file)
IF LEFT(ln,1) > 0 THEN DO
....
....
....
The DO instruction opens a loop that initializes the control variable
FILELN to 1 and sets a
limit of 50 passes through the loop. This will stop reading files
greater
than 50 records, leaving the file OPEN and READY, and will pass
control
to the second last END clause.

The next IF instruction tests the STATE of the open file to see if it
is not equal
to 'READY'. The most likely reason for the STATE being not equal to
READY is
a NOTREADY condition due to END-OF-FILE. In the event of a STATE
other than READY the THEN LEAVE clause passes control to the second
last
END clause and the file is CLOSED with the CALL STREAM.
This clause would catch any files that had fewer than 50 records.
It would not catch any files that had exactly 50 or more records
because the control
variable of the DO loop (FILELN) would end looping after the 50th pass
and
send control to the second last END clause. The IF STREAM instruction

test for 'READY' would not be executed.
....
....
....
What happens by STRAEM(file,S)\=READY ???

This comparison is tested on each pass through the loop.
I fthere are fewer than 50 records in the file then the THEN LEAVE
is excuted to end the loop

I have tested in in my environment (WinXP, Rexx r4 from
KilowattSoftware) with a datfile test.txt structure:
line 1: several numbers separated with a blank
line 2: only one number
line 3: text without -delimiters
line 4: pure blank
line 5: text with - as a string
line 6: only one digit.
My test program:
file="test.txt"
IF STREAM(file,"C","QUERY EXISTS")\="" THEN DO
CALL STREAM file, 'C' , "open read"
SAY "file "file" is open yet"
END

DO ln = 1 TO 50
SAY ln
a = LINEIN(file)
SAY a
rc=STREAM(file,"S")
SAY rc
END

The result demonstrates a correct listing of the lines 1 to 6,
then following by blank lines and
50 READYs !

I doubt you got exactly 50. I got NOTREADY after line 7 up to ln =
50

Therefore, IF LINES(file)>0 or/and IF DATATYPE(left(a,1)\=N are better
statements for differentiation as STREAM(file,S).

I agree that LINES() is the better function to use when reading a
file.


Pit
Greifswald,Germany


--
Gordon Snider
Toronto, Canada
.



Relevant Pages

  • Re: How to OpenRecordset(queryName refering to form)
    ... Yes, you can store the where clause in the table field, but when it's read in the code it will indeed be treated a string - stupid of me. ... It is still possible to do it in a similar fashion, though more complicated: you would need a separate table with a one to many relationship to the forms, one record per field to filter on with fields for FormName, FieldName, FormCOntrolName and type; then you would need to open this table as a recordset in your code, filtering on the form name, and loop through the records constructing the Where clause. ... Alternatively, you could use a convention like: no additional table, all the info for fields to filter on comes from the form itself: for all fields you wish to filter on, name the corresponding control on the form with a perfix followed by the field name, then loop in your code through the form controls and add to the where clause string for those controls starting fltr, extracting the field name from the control name -4)...). ...
    (microsoft.public.access.queries)
  • Re: The mystery of the missing (compound) variables.
    ... Here is how I see this snippet. ... The THEN clause consists of a DO clause whose END is the ... The DO instruction opens a loop that initializes the control variable ...
    (comp.lang.rexx)
  • Re: The mystery of the missing (compound) variables.
    ... its line (so I can recover it as a number) and a following space- ... separated text string line which can be PARSEd. ... to the second last END clause. ... other than READY  the THEN LEAVE clause passes control to the second ...
    (comp.lang.rexx)
  • Re: Anyone know why this javascript doesnt work?
    ... this loop? ... string, and used as a property name. ... checkboxes, none of these names match a control within the form, resulting in an undefined value, and an error with the subsequent property access. ...
    (alt.html)
  • RE: for loop is used to assign values to textboxed?
    ... So you mean that I have to declare score as textbox: ... which would suggest score is a control. ... Can I use a variable and FOR loop to assign values to those boxes like what ... The proble is the variable score as string. ...
    (microsoft.public.dotnet.framework.aspnet)