Log in

View Full Version : Help with Functions



mal1t1a
03-20-2008, 12:07 AM
Hello, I'm kinda new to functions, but i was hoping to get some help at making a function


Function IsByteDown(B:Byte):Boolean;
begin
if something goes here then
result := false;
end else
result := True;
end;

Cazax
03-20-2008, 12:35 AM
There is already a function :
IsKeyDown(K: char): boolean

mal1t1a
03-20-2008, 01:18 AM
There is already a function :
IsKeyDown(K: char): boolean

I'm afraid thats not what i wish to have, instead of keydown, i was hoping to have it so that it is

If(isbytedown(13))then
Writeln('Enter has been pressed')
else
writeln('Enter is not Pressed');

Santa_Clause
03-20-2008, 12:03 PM
IsByteDown(13);

Same as:

IsKeyDown(Chr(13));

Next time, please post in the right section.

mal1t1a
03-20-2008, 07:15 PM
IsByteDown(13);

Same as:

IsKeyDown(Chr(13));

Next time, please post in the right section.


Sorry, i didn't know i was posting in the wrong selection, and also thanks. I thought i was going to have to use that, but still, i would like to know how to make that function.

Da 0wner
03-21-2008, 08:23 AM
Function IsByteDown(b : byte) : Boolean;
Begin
Result := IsKeyDown(chr(b));
End;


That is more work then you need...But it puts chr by itself :D.

n3ss3s
03-21-2008, 08:36 AM
a) Booleans are False by default.
b)


Function IsByteDown(B: Byte): Boolean;

Begin
Result := IsKeyDown(Chr(b));
End;