IF THEN and MACROS "Adventure"

Started by Theo Gottwald, February 18, 2024, 09:49:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

🚀 If you have a subroutine that you often want to jump to at the end of the program, for example during some checks. And then you make a macro because you like macros, like I do, and you use if-then. And here I got a surprising behavior from PowerBasic. This is really another PowerBasic adventure. See below. 🤔

🚀 Wenn du ein Unterprogramm hast, zu dem du oft am Ende des Programms springen möchtest, zum Beispiel während einiger Überprüfungen. Und dann machst du eine Makro, weil du Makros magst, wie ich es tue, und du benutzt if-then. Und hier habe ich ein überraschendes Verhalten von PowerBasic bekommen. Das ist wirklich ein weiteres PowerBasic Abenteuer. Siehe unten. 🤔

✨ #PowerBasic #Makros #Programmieren #Abenteuer

Assume you have defined this MACRO
Macro GoOut()
T01=0:GoTo enx
End Macro

And want to use it like this:
' Will ALWAYS jump out
If (T02<2) Or (T02>50) Then GoOut()


SO you will need to change it to this. Else it will not work as expected.
' Will work as expected
If (T02<2) Or (T02>50) Then
       GoOut()
End If


Charles Pegge

Hi Theo,

Is the colon inside the macro being converted to a line break?

Can you avoid the problem by using a macro function?

Theo Gottwald

#2
I avoided it by not using a Macro in this case.
The effect is possibly what you say, in fact it will always jump out.

If O2 could compile my Powerbasic i would not even use it.
But i have too much Code and -Snippets that can not easily be converted.