When I use a boolean is it set False as default? Or is it True?
To set the boolean to False or True I do this
Simba Code:Boolean := True/False
But if I just use it without seting it? Is it False or True by default?
When I use a boolean is it set False as default? Or is it True?
To set the boolean to False or True I do this
Simba Code:Boolean := True/False
But if I just use it without seting it? Is it False or True by default?
I believe they retain a null statement, meaning neither true or false when initally called upon. (declaring it)
Simba Code:program new;
var v: Boolean;
begin
if v then
writeln('v is true.')
else
writeln('v is false.');
end.
Progress Report:v is false.
on a complete off-topic question. is there a procedure in includes to select options like this:
![]()
Feel free to add me on msn: h4x_new@hotmail.co.ukDelete my old msn that got hacked (h4x_@hotmail.co.uk)
thanks.
A Boolean is simply an one or a zero. There is no null. Null is often used for object, like a TBitmap, where it is null because the object doesn't exist. Note that in some languages the memory space for a Boolean doesn't exist when you declare it, in that case you will have to set it. In simba you can set it to false at the start of you procedure or function, not for usefulness but for readability of the code.
Working on: Tithe Farmer
Booleans are set to false on call, but there once was a bug in SRL which turned out to be an integer who did not reset after the procedure where the integer was declared internally didn't reset. Basically; in Pascal Script you can't be 100% sure it's always at False state upon declaration without setting it to false yourself, even though it should have been set to false.
Zyt3x is right...
I've always thought that it's only for readability but in PS...
Simba Code:program new;
function TrueByDefault: Boolean;
begin
//Result:= False;
end;
begin
while not TrueByDefault do
wait(100);
writeln('We break out of an infinite loop! Time to switch to la-pe!');
end.
I got stuck for 15min today figuring out why a loop in my script ended prematurely...and i remembered this and sure enough, that bug is the cause of error.
Does that mean we should set other results (string, integer, arrays etc) to null/0 manually upon function entry as well?
EDIT: hmm could be a Simba bug actually... i ran it on a new Simba and it worked as expected, but on the original Simba...
Switching to la-pe (on the same bugged Simba) immediately fixed the problem.
What? Your code is named badly..
While Not FalseByDefault..
This will run infinitely because Not false is true..
A conditional statement/loop will run as long as the condition is true. This behaviour is perfectly normal. AFAIK, all languages set booleans to false by default.
Never heard of such a bug and I don't think such a bug would or did exist because by default, everything is set to off. You have to set it to >= 1 to turn it on. Computers read in binary. 1's and 0's. It will never start at one.
If such a bug did exist, someone programmed badly. I run your code and it works for me but my Simba is old.
Last edited by Brandon; 11-23-2012 at 02:20 AM.
I am Ggzz..
Hackintosher
Yes, it should be false by default, but it ended up as true by default instead, as demonstrated in my screenshot above. (the loop breaks out and debug is shown)
I think it could be a Simba bug though, as opening a new Simba fixed the problem.
Simba has nothing to do with the code tbh; it is pascal script that is failing to address "new" variables correctly. The Interpreter is doing all the script work.
Moral of the story; Use la-pe or declare everything yourself.
Too buggy. Takes FOREVER to compile. XOR doesn't work 100% of the time. AddOnTerminate doesn't work.
Simba Code:var
BMP: Integer;
{$I SRL/SRL.Simba}
Procedure FreeBMP;
Begin
FreeBitmap(BMP);
End;
begin
Bmp := BitmapFromString(25, 23, 'meJxtlYtWm0AQhl+rrdZ7buQCJN' +
'Fa7StVE2C56jNYE5ZdEu2z9Z8dQDA95zs5hLP75Z+ZDej0p2aSO3z' +
'usw922U2ZXutkqeJFEc0ZGboycpgidlXk6Ngtk/k+W7KnzO6Yt6e7' +
'96cfb9nNPr3eJcsyXuhoTphdbXCHiOZYg5W0uJYAJPn7fMuqxqNCl' +
'zjwIAlgScXT/fvzL4A8VBQbTIYitDsBCLuhTJxPKlPUPUnSW3SmSm' +
'I8TFtltnfYpQtsIaBNb1nC7UUtbJBiVnvs1ka3De60ArswNDOSJgw' +
'k7GFVI9ln84baY3d6yIOOacR5XVTdpVmTpOPJnDK1VTwtwin/rhQT' +
'wJ4isYGMZ91Z2/8vKpmRJ5rIcJwHYMoqHDk6aaljsA9m9AHdbEnII' +
'yyjqmhUOnNBteUAFNuWyMj6sLFQWPx3UMlcpwtW7WrKZKbjKVDRBB' +
'ShJcUoD4Zbf7ANerhokPCEY/LgDBgVdaPxUJjKQ8u6HlKJPsBXoxp' +
'hDR+GMlvuiTmH4TyfJJWnxadUVFddWpl2kmCBpD50JBuv31aZPOTB' +
'Fm5p008VjXVoKSwIhkD6Ayb3+kB6Q6bwR0AFFreRA1Tzjc1cxEiFg' +
'0L0ZdBrtpPBXJPTSMgQWFqMAXej7gm0aP6QckZDSFRwVfiXcl1ReF' +
'fK73E29mgxKcNpResQVoMQVxiKNBLyeBf5+jxfXRyqKImR7KKZxj+' +
'rpSoEGfLgfOtdbLzT18fjzer7dn2Se6ewwckq9A0N5NJUMKZgwi4j' +
'F/BjEE+brX8GA0nWJzA0Humfkce/hEcHfVZxf+ABu9DRoVM/x0i1W' +
'R2/Ph4BXIDcO5E+eYrgvCo26GEQrOKhq3AKqDqOZJ7teBe8PHx5+f' +
'31z8O37eNRvjo2nlN4lDCR0D14jApzqeZed8lQefA6+AcVQ5qj');
AddOnTerminate('FreeBMP'); //Leaks the bitmap.. OutOfMemory exception is thrown when ran too much..
//When testing scripts over and over, memory builds up, you need to restart simba/smart and continue where you left off.
//if you do SetupSRL, even worse.
end.
Last edited by Brandon; 11-23-2012 at 01:59 PM.
I am Ggzz..
Hackintosher
Miner & Urn Crafter & 07 Chicken Killer
SPS BlindWalk Tutorial
Working on: Nothing
teacher in every art, brought the fire that hath proved to mortals a means to mighty ends
Simba Code:function cXor(a, b: boolean): boolean;
begin
result := (a and not b) or (not a and b);
end;
or
^ a or b, and not a and b. basically the definition of xor ^.^Simba Code:function cXor(a, b: boolean): boolean;
begin
result := (a or b) and not (a and b);
end;
Can't test it on phone, but this should work
Edit: procedure -> function ofc xD
Last edited by Chris; 11-28-2012 at 10:51 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)