Hi All,
After transcoding a dozen or so SuperBasic programs into ProPascal, I am now feeling much more at ease with the latter language.
I can error-trap character and integer input, but not string-type...
The main difficulty is to trap the dreaded null entry !
Has anyone overcome this hurdle ?
Regards,
Steve.
ProPascal INPUTs
Re: ProPascal INPUTs
Why not simply check the string that was input for a "Length()" of 0?
Code: Select all
valid := FALSE;
REPEAT
ReadLn (Input, inputLine)
valid := (Length (inputLine) > 0);
UNTIL valid;
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
-
- Aurora
- Posts: 889
- Joined: Mon Nov 24, 2014 2:03 pm
Re: ProPascal INPUTs
Hi Tofro,
Many thanks. Yes, your solution does work for strings.
I still can't see any way to avoid people entering a null string when an integer or real value is requested...
If ProPascal had a 'power' function, I could do it by adding powers of ten, but there is none...
Do Pascal programmers need to write their own libraries of core routines ?
Best Wishes,
Steve.
Many thanks. Yes, your solution does work for strings.
I still can't see any way to avoid people entering a null string when an integer or real value is requested...
If ProPascal had a 'power' function, I could do it by adding powers of ten, but there is none...
Do Pascal programmers need to write their own libraries of core routines ?
Best Wishes,
Steve.
Re: ProPascal INPUTs
Well, all Programmers in all languages that intend to lift their programs from fool-proof to (somewhat) damn-fool-proof, will generally only allow string input - then, in the program, see if this can be converted safely to a number if they actually want one.stevepoole wrote: Do Pascal programmers need to write their own libraries of core routines ?
Tobias
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: ProPascal INPUTs
Norm's second law of computing:
Whenever you write fool proof code, the universe invents a bigger fool!
Norm's first law, for those wondering:
The complexity of programs doubles every 18 months thus negating all the benefits of Moore's Law.
Cheers,
Norm.
Whenever you write fool proof code, the universe invents a bigger fool!
Norm's first law, for those wondering:
The complexity of programs doubles every 18 months thus negating all the benefits of Moore's Law.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: ProPascal INPUTs
I'm with you on that, that's the reason for the somewhat damn-fool-proof.NormanDunbar wrote:Norm's second law of computing:
Whenever you write fool proof code, the universe invents a bigger fool!
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: ProPascal INPUTs



Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Aurora
- Posts: 889
- Joined: Mon Nov 24, 2014 2:03 pm
Re: ProPascal INPUTs
Hi Guys,
Without going into details, Propascal string 'lengths' are no good for dealing with numeric inputs.
Propascal arrays are not much use either...
After a lot of experimenting, I finally had to resort to using Tofro's INKEY function to construct my own integer INPUT routine.
Programs are now watertight, but ProPascal is far from being as easy to prototype with as QL Basics !
Many thanks again for the INKEY snippets.
Steve.
Without going into details, Propascal string 'lengths' are no good for dealing with numeric inputs.
Propascal arrays are not much use either...
After a lot of experimenting, I finally had to resort to using Tofro's INKEY function to construct my own integer INPUT routine.
Programs are now watertight, but ProPascal is far from being as easy to prototype with as QL Basics !
Many thanks again for the INKEY snippets.
Steve.