Posts: 2,584
Threads: 263
Joined: Apr 2022
Reputation:
138
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 | | System |
Just a curiosity.
Pete
Posts: 292
Threads: 5
Joined: Apr 2022
Reputation:
52
`End` takes an optional error code, if you use `Option _Explicit` things might make more sense  But in this case, `MenuOption` is just an automatically defined variable, not a sub.
Posts: 2,997
Threads: 353
Joined: Apr 2022
Reputation:
280
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.
Posts: 2,584
Threads: 263
Joined: Apr 2022
Reputation:
138
12-27-2024, 08:47 PM
(This post was last modified: 12-27-2024, 09:08 PM by Pete.)
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
Posts: 2,584
Threads: 263
Joined: Apr 2022
Reputation:
138
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
Shoot first and shoot people who ask questions, later.
Posts: 799
Threads: 35
Joined: Apr 2022
Reputation:
58
You couldn't possibly do a shell dontwait and still get the return code. You're not waiting on the shelled program.
The noticing will continue
Posts: 2,584
Threads: 263
Joined: Apr 2022
Reputation:
138
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.
Pete
Posts: 955
Threads: 51
Joined: May 2022
Reputation:
31
12-28-2024, 06:52 PM
(This post was last modified: 12-28-2024, 07:40 PM by Kernelpanic.)
(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 | | 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 | | Print "Ende!" | | Sleep 2 | | System |
PS: How do one get to 123?
Code: (Select All)
| | | returncode = Shell("notepad.exe") | | Print returncode |
Posts: 2,584
Threads: 263
Joined: Apr 2022
Reputation:
138
(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 | | 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 | | 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
|