Author Topic: Equivalent of PB Reset statement  (Read 1198 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
Equivalent of PB Reset statement
« 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

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?

Charles Pegge

  • Guest
Re: Equivalent of PB Reset statement
« Reply #1 on: April 26, 2018, 07:48:39 AM »
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

Code: [Select]
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