QB64 Phoenix Edition
Hey guys, riddle me this... - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Hey guys, riddle me this... (/showthread.php?tid=3325)



Hey guys, riddle me this... - Pete - 12-27-2024

Code: (Select All)
Print "Why, for example, is this undefined sub call allowed in an 'End' statement?"
Print "End 123, End a = 1, etc. are also allowed if you want to check into that, too."
End MenuOpen ' Program will terminate here.
System

Just a curiosity.

Pete


RE: Hey guys, riddle me this... - DSMan195276 - 12-27-2024

`End` takes an optional error code, if you use `Option _Explicit` things might make more sense Smile But in this case, `MenuOption` is just an automatically defined variable, not a sub.


RE: Hey guys, riddle me this... - SMcNeill - 12-27-2024

https://qb64phoenix.com/qb64wiki/index.php/END

Notice the first syntax END %returncode%

It's always been an option for END.  Its usage is to return a control code at the program exit.

Program 1 has:
returncode =  SHELL ("foo.exe")

foo.exe has
END 123

when foo.exe ends, it reports that code (123) back to Program 1.


RE: Hey guys, riddle me this... - Pete - 12-27-2024

I was hoping it was a feature, but instead of 123 I'm getting 1.407074E+14 for returncode.

Code: (Select All)
_title "foo.exe"
Print "Return Code Demo..."
End 123

Code: (Select All)
returncode = Shell("foo.exe")
Print returncode

Got it. Changed it to an integer type:
returncode% = Shell("foo.exe")
Print returncode%

Pete


RE: Hey guys, riddle me this... - Pete - 12-27-2024

Man getting old is a drag. I bet I made an app with this concept several years ago. Was this available in QuickBASIC?

Anyway, it is a neat feature to easily discover if a shelled program is still running. It works if you click the foo.exe window shut, as well. It can also by used with SYSTEM as in System 123.

Hey, is there anyway to keep the parent program moving while the child program is still running? I noticed...

Shell _DontWait ("foo.exe") 

... isn't accepted, with or without brackets.

Pete


RE: Hey guys, riddle me this... - SpriggsySpriggs - 12-28-2024

You couldn't possibly do a shell dontwait and still get the return code. You're not waiting on the shelled program.


RE: Hey guys, riddle me this... - Pete - 12-28-2024

Yeah, without that ability the usefulness seems pretty limited. Your pipecom or using the clipboard, tcp/ip, or  shared database are all better alternatives for reporting back the status of a child program, including message of termination. Sad 

Pete


RE: Hey guys, riddle me this... - Kernelpanic - 12-28-2024

(12-27-2024, 07:20 PM)Pete Wrote:
Code: (Select All)
Print "Why, for example, is this undefined sub call allowed in an 'End' statement?"
Print "End 123, End a = 1, etc. are also allowed if you want to check into that, too."
End MenuOpen ' Program will terminate here.
System

Just a curiosity.

Pete
I don't find it strange, but rather logical. At the "End" the program ends and everything after that is ignored.
Manual: End terminated the program and closed all open Files.

Code: (Select All)

Print "Why, for example, is this undefined sub call allowed in an 'End' statement?"
Print "End 123, End a = 1, etc. are also allowed if you want to check into that, too."
End MenuOpen ' Program will terminate here.
Print "Ende!"
Sleep 2
System

PS: How do one get to 123?

Code: (Select All)

returncode = Shell("notepad.exe")
Print returncode



RE: Hey guys, riddle me this... - Pete - 01-01-2025

(12-28-2024, 06:52 PM)Kernelpanic Wrote:
(12-27-2024, 07:20 PM)Pete Wrote:
Code: (Select All)
Print "Why, for example, is this undefined sub call allowed in an 'End' statement?"
Print "End 123, End a = 1, etc. are also allowed if you want to check into that, too."
End MenuOpen ' Program will terminate here.
System

Just a curiosity.

Pete
I don't find it strange, but rather logical. At the "End" the program ends and everything after that is ignored.
Manual: End terminated the program and closed all open Files.

Code: (Select All)

Print "Why, for example, is this undefined sub call allowed in an 'End' statement?"
Print "End 123, End a = 1, etc. are also allowed if you want to check into that, too."
End MenuOpen ' Program will terminate here.
Print "Ende!"
Sleep 2
System

PS: How do one get to 123?

Code: (Select All)

returncode = Shell("notepad.exe")
Print returncode

See Steve's example for foo.exe. Foo.exe was made from foo.bas and End 123 was in foo.bas. You can't put End 123 in notepad.exe unless you can figure out a way to hack the exe code to alter it.

Pete