Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hey guys, riddle me this...
#1
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
Reply
#2
`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.
Reply
#3
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.
Reply
#4
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
Reply
#5
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.
Reply
#6
You couldn't possibly do a shell dontwait and still get the return code. You're not waiting on the shelled program.
Tread on those who tread on you

Reply
#7
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
Reply
#8
(Yesterday, 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
Reply




Users browsing this thread: jcm, 1 Guest(s)