mirror of
https://github.com/QB64Official/qb64.git
synced 2024-08-30 00:10:17 +00:00
59 lines
2.1 KiB
Text
59 lines
2.1 KiB
Text
|
The '''SHELL''' function displays the console and returns the [[INTEGER]] code value sent by [[END]] or [[SYSTEM]] when a program exits.
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
::: return_code = '''SHELL(''command$'')'''
|
||
|
|
||
|
|
||
|
{{Parameters}}
|
||
|
* The literal or variable [[STRING]] ''command'' parameter can be any valid [[DOS]] command or call to another program.
|
||
|
|
||
|
|
||
|
''Usage:''
|
||
|
* A SHELL to a QB64 EXE program with an exit return code parameter after [[END]] or [[SYSTEM]] will return that code value.
|
||
|
* The console window may appear when using the SHELL function. The [[_SHELLHIDE]] function will hide the console from view.
|
||
|
|
||
|
|
||
|
''Example:'' Shelling to another QB64 program will return the exit code when one is set in the program that is run.
|
||
|
{{TextStart}}''''DesktopSize.BAS ''' Compile in Windows with QB64 first
|
||
|
|
||
|
{{Cb|CONST}} SM_CXSCREEN = 0
|
||
|
{{Cb|CONST}} SM_CYSCREEN = 1
|
||
|
|
||
|
{{Cb|DECLARE LIBRARY}}
|
||
|
{{Cb|FUNCTION}} GetSystemMetrics& ({{Cb|BYVAL}} n {{Cb|AS}} {{Cb|LONG}})
|
||
|
{{Cb|DECLARE LIBRARY|END DECLARE}}
|
||
|
|
||
|
{{Cb|PRINT}} trimstr$(GetSystemMetrics(SM_CXSCREEN)); "X"; trimstr$(GetSystemMetrics(SM_CYSCREEN))
|
||
|
|
||
|
s& = {{Cb|_SCREENIMAGE}}
|
||
|
{{Cb|PRINT}} {{Cb|_WIDTH (function)|_WIDTH}}(s&); "X"; {{Cb|_HEIGHT}}(s&)
|
||
|
|
||
|
{{Cb|END}} 3 '<<<<<< add a code to return after END or SYSTEM in any program
|
||
|
|
||
|
{{Cb|FUNCTION}} trimstr$ (whatever)
|
||
|
trimstr = {{Cb|LTRIM$}}({{Cb|RTRIM$}}({{Cb|STR$}}(whatever)))
|
||
|
{{Cb|END FUNCTION}} '' ''
|
||
|
{{TextEnd}}
|
||
|
: ''Explanation:'' To set a program exit code use an [[INTEGER]] parameter value after [[END]] or [[SYSTEM]] in the called program.
|
||
|
|
||
|
: After compiling ''DesktopSize.EXE'' run the following code in the QB64 IDE. After 1st program is done 3 will appear on screen:
|
||
|
{{CodeStart}} '' ''
|
||
|
returncode% = {{Cl|SHELL (function)|SHELL}}("DesktopSize") 'replace call with name of any QB64 program EXE
|
||
|
|
||
|
{{Cl|PRINT}} returncode% 'prints code sent by called program after it is closed
|
||
|
|
||
|
{{Cl|END}} '' ''
|
||
|
{{CodeEnd}}
|
||
|
{{OutputStart}}3 {{OutputEnd}}
|
||
|
|
||
|
|
||
|
|
||
|
''See also:''
|
||
|
* [[_SHELLHIDE]] {{text|(function)}}
|
||
|
* [[SHELL]], [[_HIDE]]
|
||
|
* [[_CONSOLE]], [[$CONSOLE]]
|
||
|
* [[SYSTEM]], [[END]]
|
||
|
|
||
|
|
||
|
{{PageNavigation}}
|