SRL Archive - Bugs

Writeln-ing an Integer?


Coh3n

2011-02-19 15:50:56

Since when can you do this?

program new;

var
i: Integer;
begin
ClearDebug();

i := 10;
Writeln(i);
end.
And why can you do that, but not this?

program new;

var
i: Integer;
begin
ClearDebug();

i := 10;
Writeln('i := ' + i);
end.
^ That gives a type mismatch. Is this purely the interpreter?

Hobbit

2011-02-19 15:55:33

writeln('i := ' + inttostr(i));

Like that?

Putnam

2011-02-19 15:59:42

I thought you could always do this?
writeln('Banked := ' + inttostr(Banked));
Like in progress reports, essentially the same thing

Coh3n

2011-02-19 16:00:03

From: Hobbit
writeln('i := ' + inttostr(i));

Like that?

No, I know that works. I'm saying that Writeln(i) works also (or Writeln(55)), but Writeln('i := ' + i) or Writeln('i := ' + 55) will not.

Coh3n

2011-02-19 16:01:26

Lol guys, I know how to Writeln an integer, I'm saying that without a string in the Writeln you don't need to use IntToStr or ToStr.

Frement

2011-02-19 16:01:28

Thats because you can't combine string with integer.

Coh3n

2011-02-19 16:02:28

From: Frement
Thats because you can't combine string with integer.

But could you always do Writeln(55)?

Floor66

2011-02-19 16:02:31

Indeed. That's comparing banana's and motor oil.

Frement

2011-02-19 16:03:51

From: Coh3n
But could you always do Writeln(55)?


Yes, you can Writeln(TStringArray) or anything really. The thing is, you need to convert every variable to the same type before you can combine them AFAIK.

**BANNED The Man

2011-02-19 16:04:23

It's because:
Writeln(i);
Is just writing the integer whereas:
Writeln('blah' + (i));
Has to convert the integer to a string to be able to write it.

afaik.

-Boom

Coh3n

2011-02-19 16:05:33

From: Frement
Yes, you can Writeln(TStringArray) or anything really. The thing is, you need to convert every variable to the same type before you can combine them AFAIK.


Hm, learn something new every day. :p

@Dynamite: I know, but you'd think if you can do Writeln(i), you'd also be able to do Writeln('Hello' + i), like in any other programming language.

Train

2011-02-19 16:05:58

Summed up:
You could always print any data type. They just have to be the same if you print more than one (IntToStr).

Wizzup?

2011-02-19 16:06:20

From: Frement
Yes, you can Writeln(TStringArray) or anything really. The thing is, you need to convert every variable to the same type before you can combine them AFAIK.


This. Writeln can take ANY type, but 'str' + int is NOT a valid type. :)

Coh3n

2011-02-19 16:07:48

From: Wizzup?
This. Writeln can take ANY type, but 'str' + int is NOT a valid type. :)

Couldn't you just check the types between '+' in the Writeln procedure, and convert them accordingly?

Wizzup?

2011-02-19 16:08:25

From: Coh3n
Couldn't you just check the types between '+' in the Writeln procedure, and convert them accordingly?


No, that's technically not possible. The '+' is always evaluated before the call. :)

Coh3n

2011-02-19 16:09:43

From: Wizzup?
No, that's technically not possible. The '+' is always evaluated before the call. :)

Ah okay, too bad.

Nava2

2011-02-19 16:35:01

The automatic conversion to strings is already done in ben's cPascal. I bugged him enough that he implemented it. :D

I'd be curious if it could be implemented into PS as well.

Coh3n

2011-02-19 16:47:54

From: Nava2
The automatic conversion to strings is already done in ben's cPascal. I bugged him enough that he implemented it. :D

I'd be curious if it could be implemented into PS as well.

How's his interpreter coming anyway?

Gu3st...

2011-02-19 16:50:10

From: Coh3n
How's his interpreter coming anyway?
I didn't even know Ben was developing an interpreter :O

Nava2

2011-02-19 16:58:30

From: Zyt3x
I didn't even know Ben was developing an interpreter :O


https://github.com/BenLand100/CPascal

@Coh3n, ask him. There's memory issues he hasn't looked into from what I'm told.

I think the issue was something along the lines of he couldn't pass arrays around. I'm really not sure about that anymore though.

Wizzup?

2011-02-19 17:00:12

Well, I am. And I'm pretty sure he doesn't feel to continue on it much either.

nielsie95

2011-02-19 17:44:24

From: Nava2
I'd be curious if it could be implemented into PS as well.


It's possible. I've adjusted the engine so you can combine arrays using plus and compare records ;)

Nava2

2011-02-19 23:48:02

From: nielsie95
It's possible. I've adjusted the engine so you can combine arrays using plus and compare records ;)


As great as this is, I do think it'd be better to use a different interpreter as we all are aware there are better options. :)

If you know how to do it now though, it'd be a nice little addition and it would clean up a LOT of code. Especially progress reports.