clearing_20the_20contents_20of_20a_20structure
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| clearing_20the_20contents_20of_20a_20structure [2018/03/31 13:19] – external edit 127.0.0.1 | clearing_20the_20contents_20of_20a_20structure [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| //by Jon Ripley, May 2007//\\ \\ The following routine will clear the contents of any structure passed to it:\\ | //by Jon Ripley, May 2007//\\ \\ The following routine will clear the contents of any structure passed to it:\\ | ||
| + | <code bb4w> | ||
| REM Clear any structure (by Jon Ripley) | REM Clear any structure (by Jon Ripley) | ||
| DEF PROC_ClearStruct(S{}) | DEF PROC_ClearStruct(S{}) | ||
| Line 8: | Line 9: | ||
| E{} = S{} : S{} = F{} | E{} = S{} : S{} = F{} | ||
| ENDPROC | ENDPROC | ||
| + | </ | ||
| \\ Call using: | \\ Call using: | ||
| + | <code bb4w> | ||
| PROC_ClearStruct( StructToBeCleared{} ) | PROC_ClearStruct( StructToBeCleared{} ) | ||
| + | </ | ||
| The **StructToBeCleared{}** can be any kind of structure.\\ \\ To clear the contents of a structure array you need to iterate through all elements calling " | The **StructToBeCleared{}** can be any kind of structure.\\ \\ To clear the contents of a structure array you need to iterate through all elements calling " | ||
| + | <code bb4w> | ||
| FOR I% = 0 TO DIM(StructToBeCleared{()}, | FOR I% = 0 TO DIM(StructToBeCleared{()}, | ||
| PROC_ClearStruct(StructToBeCleared{(I%)}) | PROC_ClearStruct(StructToBeCleared{(I%)}) | ||
| NEXT I% | NEXT I% | ||
| + | </ | ||
| \\ | \\ | ||
| ---- | ---- | ||
| ==== How it works ==== | ==== How it works ==== | ||
| - | //by Richard Russell, June 2007//\\ \\ The statements "LOCAL F{}" and "DIM F{} = S{}" create a local structure **" | + | //by Richard Russell, June 2007//\\ \\ The statements "LOCAL F{}" and "DIM F{} = S{}" create a local structure **" |
| + | <code bb4w> | ||
| LOCAL E{}, F{} : REM Declare local structures E{} and F{} | LOCAL E{}, F{} : REM Declare local structures E{} and F{} | ||
| DIM E{} = S{}, F{} = S{} : REM Set E{} and F{} to have the same format as S{} | DIM E{} = S{}, F{} = S{} : REM Set E{} and F{} to have the same format as S{} | ||
| Line 23: | Line 30: | ||
| S{} = F{} : REM Copy empty structure F{} into S{}, hence clearing it | S{} = F{} : REM Copy empty structure F{} into S{}, hence clearing it | ||
| ENDPROC | ENDPROC | ||
| + | </ | ||
clearing_20the_20contents_20of_20a_20structure.1522502349.txt.gz · Last modified: 2024/01/05 00:18 (external edit)