Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Tom Rettigs Library - fldcount() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 FLDCOUNT()
 Evaluates the number of fields in a database file.
 Returns <expN> number of fields in the currently selected database file.

 Useful in initializing arrays from database files where each element
 is a field.

 * Assumes open file, appropriate record, clear screen
 max_fields = FLDCOUNT()
 DECLARE array[ max_fields ]

 FOR i = 1 TO max_fields  && load field data into array
    m_field = FIELD(i)
    array[i] = &m_field
 NEXT

 FOR i = 1 TO max_fields  && paint the screen
    @ i, 0 SAY FIELDNAME(i) GET array[i]
 NEXT

 DO WHILE .T.  && does user want to edit, save, or cancel?
    @ 23, 5 SAY "Press <E> to edit, <S> to save, "+;
                "or any other key to cancel changes..."
    choice = INKEY(5000)
    @ 23, 5    && clear the user prompt
    DO CASE
       CASE CHR(choice) $ "eE"    && edit
          READ SAVE
          LOOP
       CASE CHR(choice) $ "sS"    && save
          FOR i = 1 TO max_fields
             m_field = FIELD(i)
             REPLACE &m_field WITH array[i]
          NEXT
    ENDCASE
    RETURN
 ENDDO


             Placed in the Public Domain by Tom Rettig Assoc.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson