SRL Archive - SRL Archives

"Overloaded" println


BenLand100

2007-06-13 15:08:38

During testing stuff everyone likes to print debug output, and for me its a pain writing IntToStr and FloatToStr all the time, and diplaying booleans is just a pain, so I wrote this. Feel free to extend it with other types, like TDateTime if its too your liking.

procedure println(line: Variant);
begin
case varType(line) of
256: writeln(line); //String
11: if line then writeln('True') else writeln('False') //Boolean
3: writeln(inttostr(line)); //Integer
5: writeln(floattostr(line)); //Float
else
writeln('Unknown Type: ' + inttostr(varType(line)));
end;
end;

begin
println('Hi');
println(42);
println(3.14);
println(true);
end.

Markus

2007-06-13 15:12:19

Lol, you created almost the same thing as Danrox.
http://www.srl-forums.com/forum/writeln-t9613.html
Pretty usefull though.

bullzeye95

2007-06-13 15:18:07

procedure PrintLn(line: Variant);
begin
try
writeln(line);
except
end;
end;
Variants get converted automatically.
Ben got owned ;)

BenLand100

2007-06-13 15:23:25

Well thats funny ;) Oh well…

Bobarkinator

2007-06-13 16:19:43

Lol Ben thinks his is longer and must be better:p

Spky

2007-06-13 16:21:26

I still say it's retarded not to have a format function. It looks more professional plus it's easier to use.

Writeln('BlaBlaBla' + IntToStr(4532) + FloatToStr(23455.2345));
Vs.
Writeln(Format('BlaBlaBla%d%f', [4532, 23455.2345]));
or even overload Writeln to be like printf.
Writeln('BlaBlaBla%d%f', [4532, 23455.2345]);

Come on Freddy;)

YoHoJo

2007-06-13 17:53:37

From: bullzeye95
procedure PrintLn(line: Variant);
begin
try
writeln(line);
except
end;
end;
Variants get converted automatically.


ROFL Nice one, i knew knew that.
OWNED! :P
<3 Ben

ruler

2007-06-13 19:56:42

I might be mistaken but this depends on the order things are added to the intreptor?

Thus a SCAR update may break this?

R0b0t1

2007-06-13 20:43:58

Nope. WriteLn(''); Uses strings. It doesn't matter if a number comes first, you still must turn it into a string.

But updating SCAR to make different variables interchangeable is a bad idea.

Bebe

2007-06-13 20:46:00

Ben, you're still a noob…..

BenLand100

2007-06-14 14:48:32

From: Bebemycat2
Ben, you're still a noob…..

I could have deleted it and pretended that it never happened :sasmokin: But anyway, i assume this works in divi, cause it dosen't work in 2.03 ;):
begin
writeln(123);
end.

bullzeye95

2007-06-14 16:22:58

That doesn't work in any SCAR version. You have to convert it into a string.

Ben got owned… again ;)
For the sake of your reputation, you should delete this. :p

BenLand100

2007-06-14 16:36:56

From: bullzeye95
That doesn't work in any SCAR version. You have to convert it into a string.

Ben got owned… again ;)
For the sake of your reputation, you should delete this. :p

How did i get owned at all if that dosen't work :p Thats what my procedure does lol.

bullzeye95

2007-06-14 16:56:33

You had writeln not println. I'm confused!

Widget

2007-06-15 10:45:59

program New;
var something:variant;
begin
something := 1234;
Writeln(something);
end.
There

Bobarkinator

2007-06-15 12:13:44

That's what bullzeye had in a procedure :p

n3ss3s

2007-06-20 09:09:38

Ben, you're still a noob…..
Thats dangerous :D

But it is pretty funny :)

Spky

2007-06-20 11:59:31

No one agrees with me?

nielsie95

2007-06-20 12:04:39

I don't really mind WriteLn as it is.
Format function could be nice..
But if you really need it (now), why not use this?

Dark_Sniper

2007-06-20 12:37:25

From: n3ss3s
Thats dangerous :D

But it is pretty funny :)



its no way dangerous because ben wont do anything to bebe XD