Oxygen Basic
Programming => Problems & Solutions => Topic started by: chrisc on April 25, 2018, 10:56:09 AM
-
In PB the RESET statement is to clear off the memory of strings, numeric variables and arrays
http://www.manmrk.net/tutorials/basic/PowerBASIC/pbcc6/reset_statement.html (http://www.manmrk.net/tutorials/basic/PowerBASIC/pbcc6/reset_statement.html)
what is the equivalent in O2 ?
But O2 del command only clear off strings and bstrings but not for
numeric variables and arrays
so del may not be equivalent to PB's RESET ? is this right?
-
Hi Chris,
del destroys strings and objects.
The most direct solution is to iterate over the array, and set each element to its reset value.
You can use scope to confine the iterator
This will work for non-dynamic variables and arrays
macro ResetString(s)
scope
indexbase 1
int i
for i=1 to countof s : s[i]="" : next
end scope
end macro
macro ResetNumber(s)
scope
indexbase 1
int i
for i=1 to countof s : s[i]=0 : next
end scope
end macro