BBC BASIC
« OPENIN"" and FOR-NEXT clarifications »

Welcome Guest. Please Login or Register.
Feb 18th, 2018, 12:09am


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: OPENIN"" and FOR-NEXT clarifications  (Read 56 times)
pez
New Member
Image


member is offline

Avatar




Homepage PM


Posts: 6
xx OPENIN"" and FOR-NEXT clarifications
« Thread started on: Feb 3rd, 2018, 11:50am »

Dear Mr. Russell,

Would you, please, clarify for me the following confusing me matters?

OPENIN""
In which way I could catch the entered filename?

FOR-NEXT
0 may I suppose that I could use multiple NEXT lines for only one FOR line?

1 the comparison occurs at the FOR line or at the 1st NEXT line, which will be met after the FOR line?

2 the increment-decrement occurs at the FOR line or at the 1st NEXT line that will be met?

3 is the the loop body always executed at least once or that depends on the comparison?

4 the kind of comparison depends on the start-end values or it is always the same?

5 in any case, which of the following kinds of comparison are considered: (a) equal-unequal, (b) lower-greater, or (c) lower or equal - equal or greater?

6 the increment-decrement happens before or after the comparison?

Thanking you in advance,

Sincerely yours,

Petros Zimourtopoulos
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 727
xx Re: OPENIN"" and FOR-NEXT clarifications
« Reply #1 on: Feb 3rd, 2018, 1:15pm »

on Feb 3rd, 2018, 11:50am, pez wrote:
OPENIN""
In which way I could catch the entered filename?

I don't recommend that you use that feature because it's not supported in BBCSDL (SDL doesn't provide a file selector that OPENIN could call). Writing BB4W-specific code is naturally not something that I want to encourage, particularly at this forum!

However, with the above proviso, the answer to your query can be found at the Wiki.

Quote:
may I suppose that I could use multiple NEXT lines for only one FOR line?

The interpreter will not stop you doing so (it won't even know that you have) but it's undesirable - not least because it will break the auto-indenting in the editor. Any situation in which you might be tempted to do that can surely be re-jigged to avoid it, with an attendant improvement in program structure.

Quote:
the comparison occurs at the FOR line or at the 1st NEXT line, which will be met after the FOR line? 2 the increment-decrement occurs at the FOR line or at the 1st NEXT line that will be met?

The FOR statement is executed only once; the NEXT statement is executed once per loop. So, apart from initialisation, everything happens in the NEXT.

Quote:
3 is the the loop body always executed at least once or that depends on the comparison?

In BBC BASIC, yes. Some BASIC dialects work differently however (for example Liberty BASIC) so you should be careful.

Quote:
which of the following kinds of comparison are considered: (a) equal-unequal, (b) lower-greater, or (c) lower or equal - equal or greater?

Definitely not equality; a loop using a floating-point control variable might never stop, because of the slight errors inherent in many non-integer arithmetic operations. As far as the other possibilities are concerned I'm not sure. The only guaranteed behaviour is when the loop variable, and both the start and end values, are integers. Otherwise it will depend on floating-point calculations, and you might even find that a loop executes a different number of times in BB4W v5 and v6!

Richard.
« Last Edit: Feb 3rd, 2018, 3:06pm by Richard Russell » User IP Logged

pez
New Member
Image


member is offline

Avatar




Homepage PM


Posts: 6
xx Re: OPENIN"" and FOR-NEXT clarifications
« Reply #2 on: Feb 3rd, 2018, 4:56pm »

Dear Mr. Russell,

Thank you very much for your prompt reply.

I will try to follow your suggestions.

Sincerely yours,

Petros Zimourtopoulos
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls