What does 'Clear' do?

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
SHughes_Fusion
Posts: 219
Joined: Wed Sep 11, 2013 1:27 pm
Location: Chesterfield

What does 'Clear' do?

Post by SHughes_Fusion » Thu Apr 17, 2014 8:04 am

Browsing through the help files I came across a command 'Clear'. However, it isn't actually documented anywhere in the help file. The usage was with structures, but I was wondering if this can be used to clear any variable?

I keep getting a compiler warning that I've not initialised a Char array. I was wondering if I could use Clear RxBuf rather than a for...next loop?

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: What does 'Clear' do?

Post by Jerry Messina » Thu Apr 17, 2014 10:05 am

'Clear' sets the variable to zero, and works with pretty much anything... variables, structures, arrays, etc.

For an array (or structure) it zeros each element and should be faster and use less code than using a for/next loop.

When used with a string it works a bit differently. For them it just sets the first char to 0, which gives you a null string.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: What does 'Clear' do?

Post by Jerry Messina » Thu Apr 17, 2014 11:30 am

Forgot to mention...

Clear is documented in the language reference pdf http://www.sfcompiler.co.uk/downloads/SFManual.pdf

There's probably some other nuggets in there that aren't in the help file (and vice-versa)

Post Reply