I looked all through the manual - no goI am wondering how to have SCAR determin if a integer value is even (2,4,6,8, etc) or odd (1,3,5,7, etc).
If this is not in SCAR, it must be added!
~ Harry
I looked all through the manual - no goI am wondering how to have SCAR determin if a integer value is even (2,4,6,8, etc) or odd (1,3,5,7, etc).
If this is not in SCAR, it must be added!
~ Harry
Send SMS messages using Simba
Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!
Thank you Tarajunky![]()
![]()
Send SMS messages using Simba
Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!
This will do it for you:
SCAR Code:Const
t = 3;//Value
Procedure Determain;
Var
Value : String;
Begin
If t mod 2 = 0 Then
Begin
Value := 'Even';
end else
Value := 'Odd';
end;
hmm.. im gonna save that
it could come in handy down the track![]()
Project: Welcome To Rainbow
Yeah might do but its still pretty easy.
if someone were to add such a simple function then i think it would be of more use if you made it complicated or else you're better off using mod
something like this
SCAR Code:// 'and' returns true if all are even, 'or' returns false if at least one is
function EvenOdd(Numbers: TIntegerArray; Usage:string):boolean;
var i: integer;
begin
for i := 0 to high(Numbers) do
begin
if Usage = 'and' then
begin
if (Numbers[i] mod 2) <> 0 then
begin
break;
result := false
end else
if i = high(Numbers) then
result := true;
end else
if (numbers[i] mod 2) = 0 then
begin
result := true;
break;
end;
end;
end;
//returns all reesults of evenness
function EvenOddArray(Numbers: TIntegerArray): array of boolean;
var i: integer;
begin
SetArrayLength(result, GetArrayLength(Numbers));
for i := 0 to high(Numbers) do
begin
if (Numbers[i] mod 2) = 0 then
result[i] := true
else
result[i] := false;
end;
end;
SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
Programming Projects: NotePad | Tetris | Chess
lol...
SCAR Code:function IsEven(x: Integer): Boolean;
begin
Result := (x mod 2 = 0);
end;
There are currently 1 users browsing this thread. (0 members and 1 guests)