SRL Archive - Help and Support

Need a proc that prints out an Array of Integers...


WT-Fakawi

2011-03-08 06:53:00

…like this:
46234523, 3467347, 89078967, 12341234, 678995689, 12341234, 7898,

On one line (comma separated).

Dan Cardin

2011-03-08 06:57:05

procedure meow(arr: TintegerArray);
var i: integer;
s: string;
begin
for i := 0 to high(arr) do
s := inttostr(arr[i] + ", "
writeln(s);
end;

ReadySteadyGo

2011-03-08 06:57:46

for i := 0 to High(Array) do
TempString := TempString + ', ' + IntToStr(Array);
WriteLn(TempString);

WT-Fakawi

2011-03-08 06:58:04

Thank you!!!

Frement

2011-03-08 07:08:33

In Simba you can just Writeln(TIntegerArray); You can print any type with it.

ReadySteadyGo

2011-03-08 07:18:00

^ with that you do get [ ] but I guess that shouldn't be an issue.

lordsaturn

2011-03-08 14:16:26

From: ReadySteadyGo
^ with that you do get [ ] but I guess that shouldn't be an issue.


procedure WriteIntArrayWithoutBrackets(arr:TIntegerArray);
var
str: string;
begin
str := ToStr(arr);
Writeln(Between('[', ']', str));
end;

Frement

2011-03-08 14:19:28

From: lordsaturn
procedure WriteIntArrayWithoutBrackets(arr:TIntegerArray);
var
str: string;
begin
str := ToStr(arr);
Writeln(Between('[', ']', str));
end;


And you don't need the temp variable. But yeah, I would think the brackets wont matter.

lordsaturn

2011-03-08 14:28:38

From: Frement
And you don't need the temp variable. But yeah, I would think the brackets wont matter.


Thanks for the advice Frement. You forget your place. I put it there so that fawk would realize how easy it is to print an array or any other data type within simba using just ToStr.

Bad Boy JH

2011-03-08 18:23:12

ToStr

Greatest function ever.

Bonfield

2011-03-08 19:50:48

From: lordsaturn
Thanks for the advice Frement. You forget your place I put it there so that fawk would realize how easy it is to print an array or any other data type within simba using just ToStr.


I dont understand that? I had the exact same problem and created something similar to what you posted then a few days later realised the function i created was useless and I just needed to use writeln

Frement

2011-03-09 07:26:57

From: lordsaturn
Thanks for the advice Frement. You forget your place. I put it there so that fawk would realize how easy it is to print an array or any other data type within simba using just ToStr.


I wasn't trying to be hostile. I realize that readability is important, and that you probably knew already the thing I posted, but still. I don't know if you got it wrong what I was meaning, ofcourse I know you were showing ToStr, but I was talking about the temporary string variable, you could just have given it straight to the between function.

lordsaturn

2011-03-09 14:08:32

From: Frement
I wasn't trying to be hostile. I realize that readability is important, and that you probably knew already the thing I posted, but still. I don't know if you got it wrong what I was meaning, ofcourse I know you were showing ToStr, but I was talking about the temporary string variable, you could just have given it straight to the between function.


And what made you think I didn't realize that?

Frement

2011-03-09 14:23:31

From: lordsaturn
And what made you think I didn't realize that?


People miss simple things everyday, and why are you so hostile?

EvilChicken!

2011-03-09 14:26:40

What's up with hostility over such a minor thing? Lordsaturn, he was just trying to add to your answer in a friendly and helpful manner. Even after he politely apologized, something he had absolutely no need to do, you're still acting up?

The question has long been answered.
Closed.