QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: FellippeHeitor on September 06, 2020, 10:17:50 am
-
Computers are great at doing repetitive tasks for us. Here's how you can loop in BASIC.
-
Oh wow, didn't know QB64 has _CONTINUE and can use it in any loop structure.
-
Glad there was something new for you, bplus!
_CONTINUE was added back in 2017 actually. It made its debut in v1.2.
-
I had forgotten about _CONTINUE!
Good job, Fellippe as always. You know, for a non-native English speaker your English is very good and clearly understandable.
Thanks again for keeping the tutorials coming.
- Dav
-
Good job, Fellippe as always. You know, for a non-native English speaker your English is very good and clearly understandable.
Thanks, Dav!
-
I have not used the new commands, so this is really helpful to me.
Very good video.
Thanks!!!
-
I have not used the new commands, so this is really helpful to me.
Very good video.
Thanks!!!
Glad you enjoyed it, wiggins.
-
Thanks Fellippe. Good to know about _Continue! Could prove useful.
-
_CONTINUE is my new toy, I think I have some work for it to do, Thank you.
-
Well done Fellippe!
I think that these your efforts to introduce to QB64 programming can be very useful for beginners to programming and beginners to QB64.
It maybe is good thing to group them into a separate section of the QB64 website.
Waiting feedbacks from veterans of the QB64.
-
_CONTINUE is a good shortcut to modify your code!
all that you can get with _continue you can get with a IF THEN END IF!
Surely in a large code it is simpler to use thanand these previous two way are more flexible than
-
_CONTINUE is a good shortcut to modify your code!
I just went through and replaced all my:
<loop structure>
IF condition THEN
block of code
END IF
<end loop structure>
with:
<loop structure>
IF <NOT> condition THEN _CONTINUE
block of code
<end loop structure>
It shaved off over a couple dozen END IFs in my ap without changing the action. It just requires an opposite condition test.
Doesn't really reduce typing, but cleans up some indentation nesting, which I did find desirable. Leaves a bit more space for comments.
-
I just went through and replaced all my:
<loop structure>
IF condition THEN
block of code
END IF
<end loop structure>
with:
<loop structure>
IF <NOT> condition THEN _CONTINUE
block of code
<end loop structure>
It shaved off over a couple dozen END IFs in my ap without changing the action. It just requires an opposite condition test.
Doesn't really reduce typing, but cleans up some indentation nesting, which I did find desirable. Leaves a bit more space for comments.
Only thing to remember:
IF NOT (condition) THEN _CONTINUE.... may not be the same as IF (condition) THEN...(code stuff)
For example:
IF x AND y THEN
do stuff
END IF
Now, if x = 4, and y = 2, then x AND y = 2, so you DO STUFF.
Now let’s try the other.
IF NOT (x AND y) THEN _CONTINUE
do stuff...
In this case, (x AND y) end up evaluating to 2, same as above, so NOT 2 gives us -3. -3 is still regarded as a TRUE evaluation, so you now _CONTINUE and skip doing your stuff.
The *ONLY* time you can safely interchange the two methods, is when you’re dealing with binary results. (0 and -1 only)
-
Hi boys
I think that Steve points out a very important issue:
NOT is not the reverse of AND so when condition is a compound evaluation of conditions we must use the CONST TRUE = -1 and FALSE = 0 (or if you prefer NOT TRUE), otherwise we must specify manually that (NOT compund condition) = 0 as inverse of compound conditions
following the example of Steve
IF x AND y THEN
do stuff
END IF
Now, if x = 4, and y = 2, then x AND y = 2, so you DO STUFF.
Now let’s try the other.
IF NOT (x AND y) THEN _CONTINUE
do stuff...
the good conversion ( because the condition is compound) is IF (NOT(x AND y) ) = 0 THEN or in alternative way
IF (NOT (x AND y)) = False THEN
because as we know also from the wiki is that IF executes the codeBlock_IF when the conditionEvaluated is not 0
The conditionStatement evaluation by IF must be true (-1) or a non-zero numerical value for the THEN {code} to be executed.
http://qb64.org/wiki/IF...THEN (http://qb64.org/wiki/IF...THEN)
-
Computers are great at doing repetitive tasks for us. Here's how you can loop in BASIC.
thank you FellippeHeitor
the great thing is that I can put the subtitles in Italian so I can understand what you say too
I saw in your videos you are very experienced a very good programmer and thanks for sharing your experience
-
Thanks, Kiara87!
the great thing is that I can put the subtitles in Italian so I can understand what you say too
Hmmm, interesting! I'll check out how it goes in Italian.