AnsweredAssumed Answered

Zeroing out all fields in a record

Question asked by dzittin on Nov 19, 2011
Latest reply on Nov 20, 2011 by LaRetta_1

Title

Zeroing out all fields in a record

Post

I have a global table that keeps track of objects that are opened; 1 for each opened item, zero for a closed item.

On startup initialization I would like to ensure that these fields are zero in case the last shutdown was due to a crash. 

As I develop and add an object, I add a new field to represent its open/close state. I do not want a long list of "set fields" in my init script. Ideally, a for loop, in pseudo code:

    goto layout ("GlobalTable")

    set $mystring = FieldNames("MyDB"; "GlobalTable")

    goto layout ("GlobalTable")

    foreach ( $i in $mystring ) {

          set field($i; 0)

    }

 

Unless I am missing something, I would have to write a script to parse out the carriage return separated fielnames in $mystring, assign each field name to an array (repeating field) and loop through the repeating field. This is a lot of work in FM (am I lazy? - don't answer :-).

Words of wisdom?

TIA.

Outcomes