1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00

Update help files.

This commit is contained in:
Fellippe Heitor 2017-10-10 11:55:21 -03:00
parent 2cbd928800
commit f7abc0e1fd
372 changed files with 4863 additions and 4658 deletions

View file

@ -1,27 +1,22 @@
The $CHECKING metacommand turns C++ event checking ON or OFF.
The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
''Syntax:'' $CHECKING:OFF
{{PageSyntax}}
: [[$CHECKING]]:{ON|OFF}
{{PageDescription}}
* The Metacommand does '''not''' require a comment or REM before it. There is no space after the colon.
* The OFF action turns event checking off and should '''only be used when running stable, errorless code.'''
* The default [[$CHECKING]]:ON action is only required when checking has been turned OFF previously.
* When [[$CHECKING]]:OFF is used, all error code and the reporting code is removed from the EXE program.
* '''Warning: Turning OFF error checking could create a General Protection Fault.
===Details===
* After every QB64 command is translated to C++, the compiler adds special code sections to check for [[ON TIMER (n)]] events and errors that may have occured in the last function call. Disabling error checking with the [[$CHECKING]]:OFF directive prevents the compiler from adding the extra code sections.
* Setting [[$CHECKING]]:OFF is only designed for 100% stable, error-less sections of code, where every CPU cycle saved counts, such as in a software 3D texture mapper, for example.
* The Metacommand does '''NOT''' require a comment or REM before it! There is no space after the colon.
* The OFF action turns event checking off and should '''ONLY be used when running stable, errorless code!'''
* The default $CHECKING:ON action is only required when checking has been turned OFF previously.
* When $CHECKING:OFF is used, all error code and the reporting code is removed from the EXE program.
* '''WARNING! Turning OFF error checking could create a General Protection Fault!'''
''Explanation:'' After every QB64 command a C++ check as follows is performed: If (qbevent){...
: Using [[ON TIMER (n)]] merely sets qbevent when appropriate, causing little/no difference to the speed your program runs. Unless you are using the QB64 direct meta-command to avoid this:
:::$CHECKING:OFF
:But turning checking off is only designed for 100% stable, error-less sections of code, where every CPU cycle saved counts. Such as in a software 3D texture mapper.
''See also:''
{{PageSeeAlso}}
* [[ON TIMER(n)]]
* [[ON ERROR]]
* [[Metacommand]]

View file

@ -1,21 +1,22 @@
The '''$CONSOLE''' [[Metacommand]] creates a console window that can be used throughout a QB64 program module.
The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throughout a QB64 program module.
{{PageSyntax}}
::: '''$CONSOLE''' {ON|OFF|ONLY}
: [[$CONSOLE]][:ONLY]
* [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window. OFF can only be used after ON.
* The '''ONLY''' option can be used when only a console window is desired without a program window.
* [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window at run time.
* The ''':ONLY''' option can be used when only a console window is desired without a program window.
* [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window.
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window.
* [[_DELAY]] or [[SLEEP]] can be used to allow the console window to be set in front of the main program window.
* '''QB64 [[Metacommand]]s require that commenting or [[REM]] NOT be used anywhere on the Metacommand code line!'''
* Change the title of the [[$CONSOLE]] windows created using: [[SHELL]] "title consoletitle"
* '''QB64 [[Metacommand]]s are not commented out with ' or REM, differently from Qbasic metacommands'''
* Change the title of the [[$CONSOLE]] windows created using [[_CONSOLETITLE]]
* '''Note:''' Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
:: To copy console text output, right click the title bar and select ''Edit'' for ''Mark'' to highlight and repeat to ''Copy''
{{PageExamples}}
''Example 1:'' Hiding and displaying a console window. Use [[_DELAY]] to place console in front of main program window.
{{CodeStart}} '' ''
{{Cl|$CONSOLE}}
@ -65,10 +66,11 @@ Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
:''Copied text:'' The above text was copied after ''Select All'' was selected and the smaller area was re-highlighted with the mouse.
''See also:''
{{PageSeeAlso}}
* [[_CONSOLE]]
* [[$SCREENHIDE]], [[$SCREENSHOW]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[C_Libraries#Console_Window|C Console Library]]
{{PageNavigation}}

View file

@ -1,20 +1,20 @@
The '''$DYNAMIC''' Metacommand allows the creation of dynamic(changeable) array sizes.
The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (changeable) arrays.
{{PageSyntax}}
::REM $DYNAMIC
:{[[REM]] | ' } [[$DYNAMIC]]
* Qbasic [[Metacommand]]s require a REM or apostrophy (') before them and are always placed at the start of the main module.
{{PageDescription}}
* QBasic [[Metacommand|metacommands]] require [[REM]] or [[Apostrophe|apostrophe]] (') before them and are always placed at the start of the main module.
* Dynamic arrays can be resized using [[REDIM]]. The array's type cannot be changed.
* All data in the array will be lost when [[REDIM]]ensioned except when [[_PRESERVE]] is used in QB64 only.
* All data in the array will be lost when [[REDIM]]ensioned except when [[_PRESERVE]] is used.
* [[REDIM]] [[_PRESERVE]] can preserve and may move the previous array data when the array boundaries change.
* [[_PRESERVE]] allows the [[UBOUND|upper]] and [[LBOUND|lower]] boundaries of an array to be changed. The number of dimensions cannot change!
* Dynamic arrays can also be resized by the program user's input if desired.
* $DYNAMIC arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used as the arrays are removed completely.
* [[_PRESERVE]] allows the [[UBOUND|upper]] and [[LBOUND|lower]] boundaries of an array to be changed. The number of dimensions cannot change.
* [[$DYNAMIC]] arrays must be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used as the arrays are removed completely.
{{PageExamples}}
''Example:'' [[REDIM]]ing a $DYNAMIC array using [[_PRESERVE]] to retain previous array values.
{{CodeStart}} '' ''
{{Cl|REM}} {{Cl|$DYNAMIC}} 'create dynamic arrays only
@ -35,7 +35,7 @@ The '''$DYNAMIC''' Metacommand allows the creation of dynamic(changeable) array
{{OutputEnd}}
''See also:''
{{PageSeeAlso}}
* [[$STATIC]], [[$INCLUDE]]
* [[DIM]], [[REDIM]], [[_DEFINE]]
* [[STATIC]]

View file

@ -1,35 +1 @@
'''$ELSE''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $ELSE must follow a valid $IF statement
* There can only be one $ELSE in an $IF-$ELSEIF-$ELSE-$END IF block, and it must be the last block selection before the $END IF. $ELSEIF ''can not'' follow $ELSE.
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
For the above, the CONST slash is defined by the automatic internal flag (WIN), which tells us what operating system we're using. On a windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSEIF]]
* [[$END IF]]
{{PageNavigation}}
#REDIRECT [[$IF]]

View file

@ -1,43 +1 @@
'''$ELSEIF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.$ELSEIF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $ELSEIF must follow a valid $IF or $ELSEIF statement.
* If $ELSE is used, it must be used as the last conditional check before $END IF. $ELSEIF ''can non'' come after $ELSE.
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN AND 32Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Windows 32Bit"
{{Cl|$ELSEIF}} WIN AND 64Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Windows 64Bit"
{{Cl|$ELSEIF}} 32Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Non-Windows 32Bit"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|CONST}} OS = "Non-Windows 64Bit"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash; " and you're running on a "; OS; " operating system."
{{CodeEnd}}
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSE]]
* [[$END IF]]
{{PageNavigation}}
#REDIRECT [[$IF]]

View file

@ -1,22 +1 @@
'''$END IF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.$ELSEIF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $END IF denotes the end of a valid precompiler $IF block.
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSE]]
* [[$ELSEIF]]
{{PageNavigation}}
#REDIRECT [[$IF]]

View file

@ -1,23 +1,29 @@
'''$IF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compliing.
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.
::.
:: $END IF
:[[$IF]] variable = expression THEN
:.
:[[$ELSEIF]] variable = expression THEN
:.
:[[$ELSE]]
:.
:[[$END IF]]
* $IF is the start of a precompiler code block which includes or excludes sections of code from being compiled.
* Currently there is no single line $IF statement. $IF must be in a valid $IF THEN... $END IF block to work properly.
* Like all other metacommands, you can not use more than one metacommand per line. Use of : to separate multi-line statements onto one line will not work with $IF (or any other metacommand).
* Variable names can contain numbers, letters, and periods -- in any order!
* There is no single line $IF statement. $IF must be in a valid $IF THEN...$END IF block to work properly.
* Like all other metacommands, you can not use more than one metacommand per line. '''Use of : to separate statements in a single line is not allowed.'''
* Variable names can contain numbers, letters, and periods -- in any order.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order.
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude for us. These are: '''WIN''' or '''WINDOWS''' if the user is running QB64 in a windows environment. '''LINUX''' if the user is running QB64 in a Linux environment. '''MAC''' or '''MACOSX''' if the user is running QB64 in a Mac environment. '''32BIT''' if the user is running a 32-bit version of QB64. '''64BIT''' if the user is running a 64-bit version of QB64.
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude for us. These are: '''WIN''' or '''WINDOWS''' if the user is running QB64 in a Windows environment. '''LINUX''' if the user is running QB64 in a Linux environment. '''MAC''' or '''MACOSX''' if the user is running QB64 in a macOS environment. '''32BIT''' if the user is running a 32-bit version of QB64. '''64BIT''' if the user is running a 64-bit version of QB64.
* [[$END IF]] denotes the end of a valid precompiler $IF block.
* [[$ELSEIF]] must follow a valid $IF or $ELSEIF statement.
* If [[$ELSE]] is used, it must be used as the last conditional check before $END IF. $ELSEIF cannot come after $ELSE.
** There can only be one $ELSE in an '''$IF-$ELSEIF-$ELSE-$END IF''' block, and it must be the last block selection before the $END IF. $ELSEIF cannot follow $ELSE.
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$LET}} ScreenMode = 32
@ -31,13 +37,11 @@
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
Explanation:
If you look at the code above, you'll see that we have the same CONST defined twice inside the program. Normally, we get an error if we try to define a CONST more than once, but the $IF condition here is CHOOSING which CONST we want inside our program.
''Explanation:'' The same CONST is defined twice inside the program. Normally, defining a CONST more than once generates an error, but the $IF condition here is choosing which CONST will be inside the final program.
AS long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
The $LET and $IF statements let us control the code that actually gets compiled, while excluding the other blocks completely.
As long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
The [[$LET]] and $IF statements let the programmer control the code that actually gets compiled, while excluding the other blocks completely.
''Example 2:''
@ -51,13 +55,12 @@ The $LET and $IF statements let us control the code that actually gets compiled,
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
For the above, the CONST slash is defined by the automatic internal flags which tell us what operating system we're using. On a windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
''Explanation:'' For the above, the CONST slash is defined by the automatic internal flags which returns what operating system is being used at compile time. On a Windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
''See also:''
{{PageSeeAlso}}
* [[$LET]]
* [[$ELSE]]
* [[$ELSEIF]]
* [[$END IF]]
* [[Metacommand]]s
{{PageNavigation}}

View file

@ -1,41 +1,39 @@
'''$INCLUDE''' is a metacommand that is used to insert a source code file into your program which is then executed at the point of the insertion.
[[$INCLUDE]] is a metacommand that is used to insert a source code file into your program which is then executed at the point of the insertion.
{{PageSyntax}}
:: {[[REM]] | [[REM|']] } $INCLUDE: 'sourcefile'
: {[[REM]] | [[REM|']] } $INCLUDE: '{{Parameter|sourceFile}}'
* Qbasic required that a comment or REM preceded all [[Metacommand]]s at the start of the program.
* The ''source file'' name MUST have REM or apostrophe comments around the text source file name.
{{PageDescription}}
* QBasic [[Metacommand|metacommands]] must be commented with [[REM]] or an apostrophe.
* The {{Parameter|sourceFile}} name must be enclosed in apostrophes and can include a path.
* $INCLUDE is often used to add functions and subs from an external text QBasic code library.
* The source file included can contain any BASIC statement except [[GOTO]]
* QB 4.5 can use [[DECLARE]] SUB in BI files such as [[QB.BI]]. '''QB64''' ignores Qbasic's [[DECLARE]] statements.
* '''QB64 users can use all statements in their include files. See below.'''
* The $INCLUDE metacommand should be the only statement on a line since execution progresses ''after'' the code line.
* The $INCLUDE metacommand should be the only statement on a line.
<center>'''How to $INCLUDE a BAS or Text file with a QB64 Program'''</center>
* '''QB64''' does not require a comment or [[REM]] before any [[Metacommand]]. '''Do NOT comment QB64 specific [[Metacommand]]s!'''
* The ''source file'' name MUST have REM or apostrophe comments around the text source file name.
* 1) Assemble your text code into a TEXT file and name it something with a '''.BI''' or '''.BM''' file name extension.
* 2) $INCLUDE any [[DEFINT]], [[DIM]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the very '''beginning''' of the main program code.
* 3) $INCLUDE [[SUB]]s or [[FUNCTION]]s at the very bottom of the main program code '''AFTER any SUB procedures.'''
::: '''Note:''' [[TYPE]] definitions, [[DATA]] and [[DECLARE LIBRARY]] can be placed inside of sub-procedures.
* 4) '''Compile''' the program with the included text files '''in the QB64 folder!''' Save the text files to use them like '''Library files'''.
<center>'''Note: Once the program is compiled, the included text files are no longer needed with the program EXE.'''</center>
===How to $INCLUDE a BAS or Text file with a QB64 Program===
* Assemble the code to be reused into a file.
* Common extensions are '''.BI''' (for declarations, usually included in the beginning of a program) or '''.BM''' (with SUBs and FUNCTIONs, usually included at the end of a program).
** Any extension can be used, as long as the file contains code in plain text (binary files are not accepted).
* $INCLUDE any [[DIM]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the '''beginning''' of the main program code.
* $INCLUDE [[SUB]]s or [[FUNCTION]]s at the bottom of the main program code '''after any SUB procedures.'''
** '''Note:''' [[TYPE]] definitions, [[DATA]] and [[DECLARE LIBRARY]] can be placed inside of sub-procedures.
* '''Compile''' the program.
*''Note: Once the program is compiled, the included text files are no longer needed with the program EXE.''
''Example:'' ''' '$INCLUDE:''' '[[QB.BI]]'
{{PageExamples}}
{{CodeStart}}''' '$INCLUDE:''' 'QB.BI'{{CodeEnd}}
''See Library Examples:''
* [[SelectScreen]] (member $INCLUDE demo)
* [[FILELIST$ (function)]] (member FILE Search function)
===More examples===
* [[SelectScreen]] (member-contributed $INCLUDE demo)
* [[FILELIST$]] (member-contributed file search function)
* [[SAVEIMAGE]] (SUB program that creates bitmaps)
''See also:''
{{PageSeeAlso}}
* [[INTERRUPT]], [[INTERRUPTX]]
* [[TYPE]], [[DIM]]
* [[Metacommand]]

View file

@ -1,40 +1,27 @@
'''$LET''' is precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
[[$LET]] is precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
{{PageSyntax}}
:: $LET variable = expression
: [[$LET]] variable = expression
* $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is ONLY valid for the precompiler itself and does NOTHING to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names can contain numbers, letters, and periods -- in any order! $LET 3.2 = TRUE is a perfectly valid variable and expression.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. $LET 3.2 = "TRUE" is also perfectly, but $LET 3.2 = ""TRUE"" will error. (See the double quotes?)
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
{{Cl|$ELSEIF}} ScreenMode = 32 THEN
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|$END IF}}
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
Explaination:
If you look at the code above, you'll see that we have the same CONST defined inside the program. Normally, we get an error if we try to define a CONST more than once, but the $IF condition here is CHOOSING which CONST we want inside our program.
AS long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
The $LET and $IF statements let us control the code that actually gets compiled, while excluding the other blocks completely.
{{PageDescription}}
* Unlike [[LET]], [[$LET]] is not optional.
* $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names can contain numbers, letters, and periods in any order. [[$LET]] '''3.2 = TRUE''' is a perfectly valid variable and expression.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. [[$LET]] '''3.2 = "TRUE"''' is also perfectly valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
''See also:''
* [[Cavemen]]
{{PageExamples}}
* See example 1 in [[$IF]].
{{PageSeeAlso}}
* [[$IF]]
* [[$ELSE]]
* [[$ELSEIF]]
* [[$END IF]]
* [[Cavemen]]
{{PageNavigation}}

View file

@ -1,19 +1,112 @@
The '''$RESIZE''' metacommand determines if a program window can be resized by the user in '''QB64 GL''' only.
The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can be resized by the user.
{{PageSyntax}}
::: '''$RESIZE:'''{ON|OFF|STRETCH|SMOOTH}
: [[$RESIZE]]:{ON|OFF|STRETCH|SMOOTH}
{{PageDescription}}
* $RESIZE:ON is used to allow the program window to be resized by a program user. Otherwise it cannot be changed.
* $RESIZE:OFF (default) is used when the program's window size cannot be changed by the user.
* $RESIZE:OFF ('''default''') is used when the program's window size cannot be changed by the user.
* $RESIZE:STRETCH the screen will be stretched to fit the new window size with a 1 to 1 ratio of width and height.
* $RESIZE:SMOOTH the screen will be stretched also, but with linear filtering applied to the pixels.
* '''QB64 GL''' programs only. Not available in QB64 SDL versions .954 and older.
''See also:''
==Availability==
* '''Version 1.000 and up'''.
{{PageExamples}}
''Example:'' Resizing a program screen when the user changes it without clearing the entire screen image:
{{CodeStart}}
{{Cl|$RESIZE}}:ON
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(160, 140, 32)
{{Cl|_DELAY}} 0.1
{{Cl|_SCREENMOVE}} 20, 20
{{Cl|_DISPLAY}}
' CLEAR _RESIZE FLAG BY READING IT ONCE
temp& = {{Cl|_RESIZE (function)|_RESIZE}}
DO
{{Cl|_LIMIT}} 60
{{Cl|IF...THEN|IF}} CheckResize({{Cl|_SOURCE}}) = -1 {{Cl|THEN}}
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|CIRCLE}} ({{Cl|RND}} * {{Cl|_WIDTH (function)|_WIDTH}}(0) - 1, {{Cl|RND}} * {{Cl|_HEIGHT}}(0) - 1), {{Cl|RND}} * 100 + 5, {{Cl|_RGB32}}({{Cl|RND}} * 255, {{Cl|RND}} * 255, {{Cl|RND}} * 255)
{{Cl|NEXT}}
{{Cl|ELSE}}
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 200
{{Cl|PSET}} ({{Cl|RND}} * {{Cl|_WIDTH (function)|_WIDTH}}(0) - 1, {{Cl|RND}} * {{Cl|_HEIGHT}}(0) - 1), {{Cl|_RGB32}}({{Cl|RND}} * 255, {{Cl|RND}} * 255, {{Cl|RND}} * 255)
{{Cl|NEXT}}
{{Cl|END IF}}
{{Cl|_DISPLAY}}
k& = {{Cl|_KEYHIT}}
{{Cl|LOOP}} {{Cl|UNTIL}} k& = 27 {{Cl|OR (boolean)|OR}} k& = 32
{{Cl|SYSTEM}}
' *************************************************************************************************
' * *
' * CheckResize: This FUNCTION checks if the user resized the window, and if so, recreates the *
' * ORIGINAL SCREEN image to the new window size. *
' * *
' * Developer Note: You must use $RESIZE:ON, $RESIZE:SMOOTH, or $RESIZE:SMOOTH at *
' * the beginning of your project for this to work. *
' * This FUNCTION only works in QB64 version 1.000 and up. *
' * *
' *************************************************************************************************
{{Cl|FUNCTION}} CheckResize (CurrentScreen {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}})
' *** Define local variable for temporary screen
{{Cl|DIM}} TempScreen {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}}
CheckResize = 0
' *** Check to see if the user resized the window. If so, change the SCREEN image to the correct size.
{{Cl|IF...THEN|IF}} {{Cl|_RESIZE (function)|_RESIZE}} {{Cl|THEN}}
' *** First, create a copy of the current {{Cl|SCREEN}} image.
TempScreen = {{Cl|_COPYIMAGE}}(CurrentScreen, 32)
' *** Set the {{Cl|SCREEN}} to the copied image, releasing the current SCREEN image.
{{Cl|SCREEN}} TempScreen
' *** Remove ({{Cl|TIMER (statement)|FREE}}) the original {{Cl|SCREEN}} image.
{{Cl|_FREEIMAGE}} CurrentScreen
' *** Create a new "original" {{Cl|SCREEN}} image.
CurrentScreen = {{Cl|_NEWIMAGE}}({{Cl|_RESIZEWIDTH}}, {{Cl|_RESIZEHEIGHT}}, 32)
' *** Set the {{Cl|SCREEN}} to the new "original" image, releasing the copied {{Cl|SCREEN}} image.
{{Cl|SCREEN}} CurrentScreen
' {{Cl|DRAW}} PREVIOUS {{Cl|SCREEN}} ON THE NEW ONE
{{Cl|_PUTIMAGE}} (0, 0), TempScreen, CurrentScreen
{{Cl|_DISPLAY}}
' *** Remove ({{Cl|TIMER (statement)|FREE}}) the copied {{Cl|SCREEN}} image.
{{Cl|_FREEIMAGE}} TempScreen
' *** Tell the caller there was a resize
CheckResize = -1
{{Cl|END IF}}
{{Cl|END FUNCTION}}
{{CodeEnd}}{{small|Code by waltersmind}}
{{PageSeeAlso}}
* [[_RESIZE]], [[_RESIZE (function)]]
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(functions return the requested dimensions)}}

View file

@ -1,16 +1,16 @@
The '''$SCREENHIDE''' [[Metacommand]] can be used to hide the main program window throughout a program.
The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main program window throughout a program.
{{PageSyntax}}
::: $SCREENHIDE
: [[$SCREENHIDE]]
* $SCREENHIDE may be used at the start of a program to hide the main program window when using a [[$CONSOLE|console]] window.
* $SCREENHIDE must be used before the [[$SCREENSHOW]] [[Metacommand]] can be used!
* $SCREENHIDE may be used at the start of a program to hide the main program window when using a [[$CONSOLE|console]] window.
* The [[_SCREENHIDE]] statement must be used before [[_SCREENSHOW]] can be used in sections of a program.
* '''QB64 [[Metacommand]]s require that commenting or [[REM]] NOT be used!'''
* '''QB64 [[Metacommand|metacommand]]s cannot be commented out with [[apostrophe]] or [[REM]]'''.
{{PageExamples}}
''Example:'' Hiding a program when displaying a message box in Windows.
{{CodeStart}} '' ''
{{Cl|$SCREENHIDE}}
@ -28,8 +28,8 @@ ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET(f
{{CodeEnd}}{{small|Code by Michael Calkins}}
''See also:''
* [[$CONSOLE]], [[$SCREENSHOW]] {{text|(QB64 [[Metacommand]])}}
{{PageSeeAlso}}
* [[$CONSOLE]], [[$SCREENSHOW]]
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[_CONSOLE]]

View file

@ -1,17 +1,18 @@
The '''$SCREENSHOW''' [[Metacommand]] can be used to display the main program window throughout the program.
The [[$SCREENSHOW]] [[Metacommand|metacommand]] can be used to display the main program window throughout the program.
{{PageSyntax}}
::: $SCREENSHOW
: $SCREENSHOW
* The Metacommand is intended to be used in a modular program when a screen surface is necessary in one or more modules.
* $SCREENSHOW can only be used AFTER [[$SCREENHIDE]] or [[_SCREENHIDE]] have been used in another program module!
* If [[$SCREENHIDE]] and $SCREENSHOW are used in the same program module the window will never be hidden.
* '''QB64 [[Metacommand]]s require that commenting or [[REM]] NOT be used!'''
{{PageDescription}}
* The metacommand is intended to be used in a modular program when a screen surface is necessary in one or more modules.
* $SCREENSHOW can only be used after [[$SCREENHIDE]] or [[_SCREENHIDE]] have been used in another program module.
* If [[$SCREENHIDE]] and then [[$SCREENSHOW]] are used in the same program module the window will not be hidden.
* '''QB64 [[Metacommand|metacommand]]s cannot be commented out with [[apostrophe]] or [[REM]].'''
''See also:''
{{PageSeeAlso}}
* [[$CONSOLE]], [[$SCREENHIDE]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[_CONSOLE]]

View file

@ -1,20 +1,16 @@
{{DISPLAYTITLE:$VIRTUALKEYBOARD}}
The '''$VIRTUALKEYBOARD''' QB64 GL Metacommand turns the virtual keyboard ON or OFF in Android device programs.
The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
{{PageSyntax}}
::: '''$VIRTUALKEYBOARD:'''{ON|OFF}
: [[$VIRTUALKEYBOARD]]:{ON|OFF}
{{PageDescription}}
* If you haven't got an Android device and just want to try out the virtual keyboard add the following meta-command: $VIRTUALKEYBOARD:ON
* Places a virtual keyboard on screen, which can be used in touch-enabled devices like Windows tablets.
{{PageErrors}}
''Example:''
{{PageExamples}}
{{CodeStart}}
{{Cl|$VIRTUALKEYBOARD}}:ON
@ -23,6 +19,7 @@ The '''$VIRTUALKEYBOARD''' QB64 GL Metacommand turns the virtual keyboard ON or
{{PageSeeAlso}}
* [[Metacommand]]s
{{PageNavigation}}

View file

@ -1,17 +1,18 @@
The {{KW|ABS}} function returns the the unsigned numerical value of a variable or literal value.
The [[ABS]] function returns the the unsigned numerical value of a variable or literal value.
{{PageSyntax}}
:{{Parameter|positive}} = '''ABS({{Parameter|numericalvalue}})'''
:{{Parameter|positive}} = [[ABS]]({{Parameter|numericalValue}})
{{PageDescription}}
* ABS always returns positive numerical values. The value can be any numerical type.
* [[ABS]] always returns positive numerical values. The value can be any numerical type.
* Often used to keep a value positive when necessary in a program.
* Use [[SGN]] to determine a values sign when necessary.
* '''QB64''' allows programs to return only positive [[_UNSIGNED]] variable values using a [[DIM]] or {{KW|_DEFINE}} statement.
* Use [[SGN]] to determine a value's sign when necessary.
* '''QB64''' allows programs to return only positive [[_UNSIGNED]] variable values using a [[DIM]] or [[_DEFINE]] statement.
{{PageExamples}}
''Example:'' Finding the absolute value of positive and negative numerical values.
{{CodeStart}} '' ''
a = -6
@ -28,7 +29,7 @@ c = {{Cl|ABS}}(c)
{{PageSeeAlso}}
* [[SGN]], [[DIM]]
* [[_UNSIGNED]] {{text|(integer types only)}}
* [[_UNSIGNED]]
* [[_DEFINE]]
* [[Mathematical Operations]]

View file

@ -1,22 +1,20 @@
The '''ACCESS''' clause is used in a networking {{KW|OPEN}} statement. DOS 3.1 or above only!
#REDIRECT [[OPEN#File_ACCESS_and_LOCK_Permissions]]
The [[ACCESS]] clause is used in an [[OPEN]] statement when working over a network.
{{PageSyntax}}
:OPEN "file.dat" FOR APPEND ['''ACCESS {READ|WRITE}'''] AS #1
{{PageDescription}}
* Valid Options:
**Default: When specified, all other processes are denied file access.
**READ: When specified, read access is denied to other file procedures.
**WRITE: When specified, write access is denied to other file procedures.
**READ WRITE: When specified any access is denied to other file procedures.
''Valid Options:''
*Default: When specified, all other processes are denied file access.
*READ: When specified, read access is denied to other file procedures.
*WRITE: When specified, write access is denied to other file procedures.
*READ WRITE: When specified any access is denied to other file procedures.
''Limitations:''
* Requires that the DOS '''SHARED.EXE''' program be run for QBasic to use networking access modes.
===Limitations===
*If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.

View file

@ -1,8 +1,10 @@
The '''ALIAS''' clause in a [[DECLARE LIBRARY]] statement block tells the program the name of the procedure used in the external library.
#REDIRECT [[DECLARE LIBRARY]]
The [[ALIAS]] clause in a [[DECLARE LIBRARY]] statement block tells the program the name of the procedure used in the external library.
{{PageSyntax}}
::: SUB ''pseudoname'' '''ALIAS''' ''actualname'' [(''parameters'')]
: SUB ''pseudoname'' [[ALIAS]] ''actualname'' [(''parameters'')]
{{Parameters}}
@ -11,18 +13,28 @@ The '''ALIAS''' clause in a [[DECLARE LIBRARY]] statement block tells the progra
* QB64 must use all parameters of imported procedures including optional ones.
''Description:''
{{PageDescription}}
* The ALIAS name clause is optional as the original library procedure name can be used.
* The procedure name does not have to be inside of quotes when using [[DECLARE LIBRARY]].
* QB64 does not support creating optional parameters at this time.
* QB64 does not support optional parameters.
==QBasic/QuickBASIC==
* In Qbasic ALIAS was originally only used in a [[DECLARE (non-BASIC statement)]] library declarations.
{{PageExamples}}
''Example:'' Instead of creating a SUB with the Library statement inside of it, just rename it:
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} glutWarpPointer ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|_SCREENEXISTS}}: {{Cl|LOOP}}
{{Cl|PRINT}} "Hit a key..."
{{Cl|SLEEP}}
MouseMove 1, 1
{{CodeEnd}}
:''Explanation:'' When a Library procedure is used to represent another procedure name use ALIAS instead. Saves creating a SUB! Just place your name for the procedure first with the actual Library name after ALIAS.

View file

@ -1,15 +1,14 @@
The logical '''AND''' numerical operator compares two values in respect of their bits. If both bits at a certain position in both values are set, then that bit position is set in the result.
The logical [[AND]] numerical operator compares two values in respect of their bits. If both bits at a certain position in both values are set, then that bit position is set in the result.
{{PageSyntax}}
:{{Parameter|result}} = '''{{Parameter|firstvalue}} AND {{Parameter|secondvalue}}'''
:{{Parameter|result}} = {{Parameter|firstvalue}} AND {{Parameter|secondvalue}}
{{PageDescription}}
* AND compares the bits of the {{Parameter|firstvalue}} against the bits of the {{Parameter|secondvalue}}, the result is stored in the {{Parameter|result}} variable.
* If both bits are on or binary 1 then the result is on or 1.
* All other conditions return 0 or the bit is off.
* [[AND]] compares the bits of the {{Parameter|firstvalue}} against the bits of the {{Parameter|secondvalue}}, the result is stored in the {{Parameter|result}} variable.
* If both bits are on (1) then the result is on (1).
* All other conditions return 0 (bit is off).
* AND is often used to see if a bit is on by comparing a value to an exponent of 2.
* Can turn off a bit by subtracting the bit on value from 255 and using that value to AND a byte value.
@ -17,6 +16,7 @@ The logical '''AND''' numerical operator compares two values in respect of their
{{Template:LogicalTruthTable}}
{{PageExamples}}
''Example 1:''
{{WhiteStart}}
101
@ -26,7 +26,7 @@ The logical '''AND''' numerical operator compares two values in respect of their
001
{{WhiteEnd}}
:The 101 bit pattern equals 5 and the 011 bit pattern equals 3, it returns the bit pattern 001 which equals 1. Only the Least Significant Bits(LSB) match. So decimal values 5 AND 3 = 1.
:The 101 bit pattern equals 5 and the 011 bit pattern equals 3, it returns the bit pattern 001 which equals 1. Only the Least Significant Bits (LSB) match. So decimal values 5 AND 3 = 1.
''Example 2:''
@ -37,13 +37,13 @@ The logical '''AND''' numerical operator compares two values in respect of their
----------
11101011
{{WhiteEnd}}
:Both bits have to be set for the resulting bit to be set. You can use the AND operator to get one byte of a two byte integer this way:
:Both bits have to be set for the resulting bit to be set. You can use the [[AND]] operator to get one byte of a two byte integer this way:
:::::firstbyte = twobyteint AND 255
::firstbyte = twobyteint AND 255
:Since 255 is 11111111 in binary, it will represent the first byte completely when compared with AND.
:To find the second(HI) byte's decimal value of two byte {{KW|INTEGER}}s use: secondbyte = twobyteint \ 256
:To find the second (HI) byte's decimal value of two byte [[INTEGER]]s use: secondbyte = twobyteint \ 256
''Example 3:'' Finding the binary bits on in an [[INTEGER]] value.
@ -64,15 +64,13 @@ The logical '''AND''' numerical operator compares two values in respect of their
{{OutputStart}}
0001011110100111
{{OutputEnd}}
::''Note:'' The value of 32767 sets 15 bits. -1 sets all 16 bits. Negative values will all have the highest bit set. Use {{KW|LONG}} variables for input values to prevent overflow errors!
::''Note:'' The value of 32767 sets 15 bits. -1 sets all 16 bits. Negative values will all have the highest bit set. Use [[LONG]] variables for input values to prevent overflow errors.
{{PageSeeAlso}}
*{{KW|OR}} (operator), {{KW|XOR}} (operator), {{KW|NOT}} (operator)
*{{KW|AND (boolean)}}
*[[Binary]], [[Boolean]]
* [[OR]], [[XOR]], [[NOT]] {{text|(logical operators)}}
* [[AND (boolean)]]
* [[Binary]], [[Boolean]]
{{PageNavigation}}

View file

@ -3,22 +3,22 @@ The [[AND (boolean)|AND]] conditonal operator is used to include another evaluat
{{PageSyntax}}
::: IF {{Parameter|condition}} '''AND''' {{Parameter|condition2}}
: IF {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}}
{{PageDescription}}
* If {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}} are True then the evaluation returns True.
* If {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}} are true then the evaluation returns true (-1).
* {{Parameter|condition}} and {{Parameter|condition2}} can also contain their own AND evaluations.
* Both the IF evaluation and the AND evaluation must be True for the statement to be True.
* Both the IF evaluation and the AND evaluation must be true for the statement to be true.
* Statements can use parenthesis to clarify an evaluation.
* [[AND]] and '''OR''' cannot be used to combine command line operations.
* '''A double AND syntax error may be ignored and create a QB64 compiler error!'''
* [[AND (boolean)]] and [[OR (boolean)]] cannot be used to combine command line operations.
* Not to be confused with the [[AND]] and [[OR]] numerical operations.
{{Template:RelationalTable}}
{{PageExamples}}
''Example:'' Using AND in an IF statement.
{{CodeStart}}
@ -55,6 +55,7 @@ True
{{PageSeeAlso}}
* [[AND]], [[OR]] {{text|(logical operators)}}
* [[OR (boolean)]], [[XOR (boolean)]]
* [[IF...THEN]]

View file

@ -1,3 +1,11 @@
#REDIRECT [[Data types]]
''This page is maintained for historic purposes. The keyword is not supported in QB64.''
----
ANY disables type checking for a variable used in a [[SUB]] or [[FUNCTION]] declaration.
@ -5,7 +13,7 @@ ANY disables type checking for a variable used in a [[SUB]] or [[FUNCTION]] decl
:: variable AS ANY
* [[Keywords currently not supported by QB64|Currently NOT supported in QB64]]
* [[Keywords currently not supported by QB64|Not supported in QB64.]]
* ANY can become any type variable or value later in the program.
* Commonly used in [[SUB]] or [[FUNCTION]] [[DECLARE|declarations]] to not type a parameter.

View file

@ -1,16 +1,20 @@
APPEND is used in an output type [[OPEN]] statement to add data to the end of a file.
#REDIRECT [[OPEN#File_Access_Modes]]
[[APPEND]] is used in an output type [[OPEN]] statement to add data to the end of a file.
{{PageSyntax}}
::: OPEN FileName$ '''FOR APPEND''' AS #1
: [[OPEN]] {{Parameter|fileName$}} '''FOR APPEND''' AS #1
{{PageDescription}}
* Creates an empty file using the filename if none exists.
* Mode places new data after the previous data in the file.
* Mode can use [[PRINT (file statement)]], [[WRITE (file statement)]] or [[PRINT USING (file statement)]] to output file data or text.
''See also:'' [[OUTPUT]], [[RANDOM]], [[INPUT (file mode)]], [[BINARY]]
{{PageSeeAlso}}
[[OUTPUT]], [[RANDOM]], [[INPUT (file mode)]], [[BINARY]]
{{PageNavigation}}

View file

@ -1,39 +1,29 @@
The '''AS''' keyword defines a variable value's [[type]].
The [[AS]] keyword defines a variable data [[type]].
* AS defines the variable or array type AS [[_BIT]], [[_BYTE]], [[INTEGER]], [[LONG]], [[_INTEGER64]], [[SINGLE]], [[DOUBLE]], [[_FLOAT]], [[STRING]] or [[ANY]].
{{PageDescription}}
* AS defines the variable or array type AS [[_BIT]], [[_BYTE]], [[INTEGER]], [[LONG]], [[_INTEGER64]], [[SINGLE]], [[DOUBLE]], [[_FLOAT]] or [[STRING]].
* Specifies a variable's [[type]] in a declarative statement or parameter list using:
** [[DIM]] or [[REDIM]]
** [[DECLARE LIBRARY]]
** [[SUB]]
** [[FUNCTION]]
** [[TYPE]]
** [[SHARED]]
** [[COMMON SHARED]]
** [[STATIC]]
:::::[[DIM]] or [[REDIM]]
:::::[[DECLARE]]
:::::[[SUB]]
:::::[[FUNCTION]]
:::::[[TYPE]]
:::::[[DEF FN]]
:::::[[SHARED]]
:::::[[COMMON SHARED]]
:::::[[STATIC]]
===Details===
* Specifies a '''[[parameter]]''' variable's type in a [[SUB]] or [[FUNCTION]] procedure. '''Cannot be used to define a function's [[type]]'''
* Specifies an element's type in a user-defined data [[TYPE]].
* Assigns a file number to a file or device in an [[OPEN]] statement.
* Specifies a field name in a random-access record (see [[FIELD]])
* Specifies a new file name when you rename a file (see [[NAME]])
* '''NOTE: Many QBasic keywords can be used as variable names if they are created as [[STRING]]s using the suffix '''$'''. You cannot use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements.'''
* Specifies a '''[[parameter]]''' variable's type in a [[SUB]] or [[FUNCTION]] procedure. '''Cannot be used to define a function's [[TYPE]]!'''
* Specifies an element's type in a user-defined data type: [[TYPE]]
* Assigns a file number to a file or device in an [[OPEN]] statement:
* Specifies a field name in a random-access record: [[FIELD]]
* Specifies a new file name when you rename a file: [[NAME]]
* '''NOTE: Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
''See also:''
{{PageSeeAlso}}
* [[DIM]], [[REDIM]]
* [[_DEFINE]]
* [[BYVAL]], [[TYPE]]

View file

@ -1,22 +1,22 @@
The '''ASC''' function returns the {{KW|ASCII}} code number of a certain {{KW|STRING}} text character or a keyboard press.
The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] text character or a keyboard press.
{{PageSyntax}}
:: code% = '''ASC('''''text$''[, ''position%'']''')'''
: {{Parameter|code%}} = [[ASC]]({{Parameter|text$}}[, {{Parameter|position%}}])
* String ''text'' [[STRING|string]] character parameter must have a length of at least 1 byte or an error occurs.
* '''In QB64''' an optional byte ''position'' [[INTEGER]] parameter greater than 0 can specify the ASCII code of any character in a string to be returned.
* If the optional position parameter is omitted, ASC will return the [[ASCII]] code of the '''first''' [[STRING]] character only.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned will range from 0 to 255 only.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, F function, Home\Page keys are used.
:: Use QB64's position parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
* {{Parameter|text$}} [[STRING|string]] character parameter must have a length of at least 1 byte or an error occurs.
* '''In QB64''' the optional byte {{Parameter|position%}} [[INTEGER]] parameter greater than 0 can specify the ASCII code of any character in a string to be returned.
* If the optional {{Parameter|position%}} parameter is omitted, ASC will return the [[ASCII]] code of the first [[STRING]] character.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned range from 0 to 255.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, function, Home/Page keys are used.
** Use QB64's {{Parameter|position%}} parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
* In '''QB64''' ASC string byte position reads are about '''5 times faster''' than [[MID$]] when parsing strings. See [[MID$]] ''Example 2''.
{{PageErrors}}
* If the function is used to read an '''empty string value''' an illegal function call [[ERROR Codes|error]] will occur! [[INKEY$]] returns an empty string when a key is not pressed.
* '''QB64''' ''position'' parameters must range from 1 to the [[LEN|length]] of the string being read or an illegal function call [[ERROR Codes|error]] will occur.
* If the function is used to read an '''empty string value''' an illegal function call [[ERROR Codes|error]] will occur. [[INKEY$]] returns an empty string when a key is not pressed.
* '''QB64''''s {{Parameter|position%}} parameters must range from 1 to the [[LEN|length]] of the string being read or an illegal function call [[ERROR Codes|error]] will occur.
{{WhiteStart}}' '''ASCII Keyboard Codes'''
@ -88,6 +88,7 @@ The '''ASC''' function returns the {{KW|ASCII}} code number of a certain {{KW|ST
:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: IF _KEYDOWN([[CVI]]([[CHR$]](0) + "P")) THEN
{{PageExamples}}
''Example 1:'' How ASC can be used to find any ASCII code in a string of characters using QB64.
{{CodeStart}} '' ''
{{Cl|PRINT}} ASC("A")
@ -96,7 +97,6 @@ The '''ASC''' function returns the {{KW|ASCII}} code number of a certain {{KW|ST
{{CodeEnd}}
''Returns:''
{{OutputStart}}
65
66
@ -128,11 +128,10 @@ DO
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The keypress read loop checks that ASC will not read an empty string. That would create a program error. {{KW|SLEEP}} reduces CPU memory usage between keypresses. Normal byte codes returned are indicated by the IF statement when ASC returns a value. Otherwise the routine will return the two byte ASCII code. The extended keyboard keys(Home pad, Arrow pad and Number pad), Function keys or Ctrl, Alt or Shift key combinations will return two byte codes. Ctrl + letter combinations will return control character codes 1 to 26.
''Explanation:'' The keypress read loop checks that ASC will not read an empty string. That would create a program error. [[SLEEP]] reduces CPU memory usage between keypresses. Normal byte codes returned are indicated by the IF statement when ASC returns a value. Otherwise the routine will return the two byte ASCII code. The extended keyboard keys(Home pad, Arrow pad and Number pad), Function keys or Ctrl, Alt or Shift key combinations will return two byte codes. Ctrl + letter combinations will return control character codes 1 to 26.
''Example 3:'' Reading only numerical values input by a program user.
{{CodeStart}}
DO: {{Cl|SLEEP}} ' requires a keypress to run loop once
K$ = {{Cl|{{Cl|INKEY$}}}}
@ -152,12 +151,11 @@ DO
{{Cl|LOOP}} {{Cl|UNTIL}} code = 13 {{Cl|AND}} L '' ''
{{CodeEnd}}
''Explanation:'' [[SLEEP]] waits for a keypress allowing background programs to use the processor time. It also keeps the press in the keyboard buffer for [[INKEY$]] to read and guarantees that ASC will not read an empty string value to create an error. Filtered codes 48 to 57 are only number characters. One decimal point is allowed by using the flag. Code 8 is a backspace request which is ignored if the entry has no characters. If it is allowed it removes the last character from the entry and the screen. The loop exits when the user presses the [Enter] key and the entry has a length. '''Try to do that with [[INPUT]]!'''
''Explanation:'' [[SLEEP]] waits for a keypress allowing background programs to use the processor time. It also keeps the press in the keyboard buffer for [[INKEY$]] to read and guarantees that ASC will not read an empty string value to create an error. Filtered codes 48 to 57 are only number characters. One decimal point is allowed by using the flag. Code 8 is a backspace request which is ignored if the entry has no characters. If it is allowed it removes the last character from the entry and the screen. The loop exits when the user presses the [Enter] key and the entry has a length.
''See also:''
* [[ASC (statement)]] {{text|(QB64 only)}}
{{Parameter|See also:'' }}
* [[ASC (statement)]]
* [[_KEYHIT]], [[_KEYDOWN]]
* [[MID$]], [[CHR$]], [[INKEY$]]
* [[VAL]], [[STRING$]]

View file

@ -1,19 +1,19 @@
The {{KW|ASC (statement)|ASC}} statement allows a '''QB64''' program to change a character at any position of a predefined {{KW|STRING}}.
The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a character at any position of a [[STRING]] variable.
{{PageSyntax}}
::: '''ASC({{Parameter|string_expression$}}'''[, {{Parameter|position%}}]''') =''' {{Parameter|code%}}
: [[ASC (statement)|ASC]]({{Parameter|stringExpression$}}[, {{Parameter|position%}}]) = {{Parameter|code%}}
{{PageDescription}}
* The ''string expression'' variable must have been previously defined and cannot be an empty string("").
* The ''position'' parameter is optional. If no position is used, the left-most position(1) is assumed.
* The ''position'' cannot be zero or greater than the string's length [[LEN]] or an [[ERROR Codes|Illegal function error]] will occur.
* The [[ASCII]] replacement ''code%'' value can be any [[INTEGER]] value from 0 to 255.
* The {{Parameter|stringExpression$}} variable's value must have been previously defined and cannot be an empty string ("").
* {{Parameter|position%}} is optional. If no position is used, the leftmost character at position 1 is assumed.
* {{Parameter|position%}} cannot be zero or greater than the string's [[LEN|length]] or an [[ERROR Codes|Illegal function error]] will occur.
* The [[ASCII]] replacement {{Parameter|code%}} value can be any [[INTEGER]] value from 0 to 255.
* Some [[ASCII]] control characters will not [[PRINT]] a character or may format the [[SCREEN]]. [[_PRINTSTRING]] can print them graphically.
{{PageExamples}}
''Example:'' Demonstrates how to change existing text characters one letter at a time.
{{CodeStart}}
a$ = "YZC"
@ -35,7 +35,7 @@ The {{KW|ASC (statement)|ASC}} statement allows a '''QB64''' program to change a
{{OutputEnd}}
''See also:''
{{PageSeeAlso}}
* [[ASC]] {{text|(function)}}
* [[MID$ (statement)]]
* [[_PRINTSTRING]]

View file

@ -1,22 +1,23 @@
The {{KW|ATN}} or arctangent function returns the angle in radians of a numerical [[TAN|tangent]] value.
The [[ATN]] or arctangent function returns the angle in radians of a numerical [[TAN|tangent]] value.
{{PageSyntax}}
:: radian_angle = '''ATN(''tangent!'')'''
: {{Parameter|radianAngle}} = [[ATN]]({{Parameter|tangent!}})
{{Parameters}}
* The return is that tangent value's ''angle'' in radians.
* ''tangent'' [[SINGLE]] or [[DOUBLE]] values are use by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
* The return is the {{Parameter|tangent!}}'s angle in '''radians'''.
* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
{{PageDescription}}
* To convert from radians to degrees, multiply radians * (180 / π).
* The ''tangent'' value would be equal to the tangent value of an angle. EX: '''{{text|[[TAN]](ATN(1)) <nowiki>=</nowiki> 1|green}}'''
* The ''tangent'' value would be equal to the tangent value of an angle. Ex: '''{{text|[[TAN]](ATN(1)) <nowiki>=</nowiki> 1|green}}'''
* The function return value is between -π / 2 and π / 2.
''Example 1:'' When the [[TAN]]gent value equals 1, the line is drawn at a 45 degree angle(.7853982 radians) where [[SIN]] / [[COS]] = 1.
{{PageExamples}}
''Example 1:'' When the [[TAN]]gent value equals 1, the line is drawn at a 45 degree angle (.7853982 radians) where [[SIN]] / [[COS]] = 1.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
x = 100 * {{Cl|COS}}({{Cl|ATN}}(1))
@ -25,12 +26,13 @@ y = 100 * {{Cl|SIN}}({{Cl|ATN}}(1))
{{CodeEnd}}
''Example 2:'' {{KW|ATN}} can be used to define π in [[SINGLE]] or [[DOUBLE]] precision. The calculation can NOT be used as a [[CONST]]ant.
''Example 2:'' [[ATN]] can be used to define π in [[SINGLE]] or [[DOUBLE]] precision. The calculation cannot be used as a [[CONST]]ant.
{{CodeStart}} '' ''
Pi = 4 * {{Cl|ATN}}(1) '{{Cl|SINGLE}} precision
Pi# = 4 * {{Cl|ATN}}(1#) '{{Cl|DOUBLE}} precision
PRINT Pi, Pi# '' ''
{{CodeEnd}}
:''Note:'' You can use QB64's native [[_PI]] function.
''Example 3:'' Finds the angle from the center point to the mouse pointer.

View file

@ -1,21 +1,23 @@
The '''apostrophe''' is used to tell Qbasic to ignore a statement or programmer comment.
The '''apostrophe''' is used to tell the compiler to ignore a statement or programmer comment.
{{PageDescription}}
* Allows programmer comments or temporary code removal.
* [[REM]] can also be used to "comment out" a line.
* QBasic [[Metacommand|metacommand]]s must be commented either with an apostrophe or [[REM]].
* [[$INCLUDE]] requires an apostrophe before and after the included file name.
''Usage:'' COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{PageExamples}}
{{CodeStart}}
COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{CodeEnd}}
{{OutputStart}}
{{text|Print this....|aqua}}
{{OutputEnd}}
* Allows programmer comments or temporary code removal.
* [[REM]] can also be used to "comment out" a line.
* [[Metacommand]]s require that they are commented either with an apostrophe or [[REM]].
* [[$INCLUDE]] requires a "comment" apostrophe before and after the included file name also.
''See also:''
{{PageSeeAlso}}
* [[Comma]], [[Semicolon]]
* [[REM]]

View file

@ -1,36 +1,24 @@
The '''BEEP''' statement produces a beeping sound through the sound card(QB64) or PC speaker(QB) if it has one.
The [[BEEP]] statement produces a beep sound through the sound card.
{{PageSyntax}}
:: [[BEEP]]
: [[BEEP]]
{{PageDescription}}
* {{KW|BEEP}} can be placed anywhere to alert the user that there is something to do or an error has occurred.
* [[ASCII]] control character 7 can also create a {{KW|BEEP}} sound when you {{KW|PRINT}} it (See [[CHR$]]).
* In Windows it may produce a "thunk" warning sound when a Qbasic program is running in a {{KW|SCREEN}} 0 window.
* Newer PC's may not have an internal speaker to hear ANY Qbasic [[SOUND|sounds]]!
* '''QB64''' produces the actual "beep" sound through the PC's stereo speakers.
* To produce the BEEP sound character in a QBasic(.BAS) or a batch(.BAT) file using a '''DOS''' editor (or the QB IDE) press ''Ctrl + P'' then ''G.'' PRINT it inside of quotation marks to beep in QB. Use the character after ECHO in a batch file. '''Not in the QB64 IDE!'''
{{PageExamples}}
''Example:'' Creating two beep sounds using [[BEEP]] and [[PRINT|printing]] the [[ASCII]] control character 7.
{{CodeStart}}'' ''
{{Cl|BEEP}}
{{Cl|PRINT}} {{Cl|CHR$}}(7) '' ''
{{CodeEnd}}
* [[BEEP]] can be placed anywhere to alert the user that there is something to do or an error has occurred.
* '''QB64''' produces the actual "beep" sound through the PC's sound card, to emulate QBasic's beeping through the [https://en.wikipedia.org/wiki/PC_speaker PC speaker].
==QBasic/QuickBASIC==
* Older programs may attempt to produce a BEEP by printing [[CHR$]](7) to the screen. This is no longer supported in QB64 after '''version 1.000'''.
** You may have to replace instances of PRINT CHR$(7) in older programs to the [[BEEP]] statement to maintain the legacy functionality.
{{PageSeeAlso}}
* {{KW|SOUND}}, {{KW|PLAY}}
* {{KW|_SNDPLAY}} (play sound files)
* {{KW|_SNDRAW}} (play frequency waves)
* {{KW|CHR$}}, {{KW|ASCII}} (code table)
* [[SOUND]], [[PLAY]]
* [[_SNDPLAY]] {{text|(play sound files)}}
* [[_SNDRAW]] {{text|(play frequency waves)}}
{{PageNavigation}}

View file

@ -1,25 +1,24 @@
{{KW|BINARY}} is used in an {{KW|OPEN}} statement to treat the file or port device as a {{KW|BINARY}}.
#REDIRECT [[OPEN#File_Access_Modes]]
[[BINARY]] is used in an [[OPEN]] statement to work with the file or port device manipulating its bytes directly.
{{PageSyntax}}
:{{KW|OPEN}} {{Parameter|filename$}} {{KW|FOR}} {{KW|BINARY}} {{KW|AS}} {{Parameter|#filenumber%}}
:[[OPEN]] {{Parameter|fileName$}} [[FOR]] [[BINARY]] [[AS]] {{Parameter|#fileNumber%}}
{{PageDescription}}
* [[OPEN]] FOR BINARY creates the file if the filename$ does not exist.
* {{Parameter|filename$}} is the name of the file to open, but could also configure a port.
* {{Parameter|#filenumber%}} is the number that will represent the file when performing file operations.
* [[OPEN]] FOR BINARY creates the file if the {{Parameter|fileName$}} does not exist.
* {{Parameter|fileName$}} is the name of the file to open, but could also configure a port.
* {{Parameter|#fileNumber%}} is the number that will represent the file when performing file operations.
* BINARY files use [[GET|GET #]] and [[PUT|PUT #]] to read or write the file at any byte position.
* '''QB64-GL''' allows [[LINE INPUT]] to be used for faster access to text file data.
* The number of bytes read or written depends on the byte [[LEN|length]] of the variable type used.
* When [[PUT]] is used with a variable, numerical values are converted to [[ASCII]] string types [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]] or [[_MK$]].
* One byte [[ASCII]] {{KW|STRING}} data character values can be read as number values using {{KW|ASC}}(values from 0 to 255).
* Some files, like bitmaps, contain standard length file information headers.
* Qbasic's [[BSAVE]] or BINARY save files can be read using a BINARY mode.
* BINARY mode ignores any [[LEN]] = recordlength statement in the {{KW|OPEN}} statement.
* Ports can also be opened in {{KW|BINARY}} mode. See: {{KW|OPEN COM}}
* In '''version 1.000 and up''' you can use [[LINE INPUT]] in [[BINARY]] mode for faster access to text file data.
* QBasic's [[BSAVE]] or BINARY save files can be read using BINARY mode.
* BINARY mode ignores any [[LEN]] = recordlength statement in the [[OPEN]] statement.
* Ports can also be opened in [[BINARY]] mode. See: [[OPEN COM]]
{{PageExamples}}
''Example 1:'' Shows how a PUT variable value is converted to an [[ASCII]] string [[_MK$]] format in a BINARY file.
{{CodeStart}} '' ''
{{Cl|DIM}} int64 {{Cl|AS}} {{Cl|_INTEGER64}}

View file

@ -1,34 +1,36 @@
{{KW|BLOAD}} loads a binary graphics file created by {{KW|BSAVE}} to an array.
[[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array.
==Legacy support==
* '''QB64 can load larger arrays directly from binary files using [[PUT]] # and [[GET]] # without BLOAD. For that reason, BLOAD isn't recommended practice anymore and is supported to maintain compatibility with legacy code.'''
{{PageSyntax}}
::: '''BLOAD''' {{Parameter|Filename$}}''', [[VARPTR]]('''{{Parameter|ImageArray%(index)}}''')'''
: [[BLOAD]] {{Parameter|fileName$}}, [[VARPTR]]({{Parameter|imageArray%({{Parameter|index}})}})
{{Parameters}}
* {{Parameter|Filename$}} is the name of the file that the image should be [[BSAVE]]d to.
* {{Parameter|ImageArray%(index)}} is the Integer [[arrays|array]] start index that holds the image you want to save.
* {{Parameter|fileName$}} is the name of the file that the image should be [[BSAVE]]d to.
* {{Parameter|imageArray%(index)}} is the [[INTEGER]] [[arrays|array]] start index to store the image loaded.
{{PageDescription}}
* There MUST be an Integer array of adequate size (up to 26K) to hold the graphic data!
* A [[DEF SEG]] pointing to the array is required. [[DEF SEG]] = [[VARSEG]](ImageArray%(index))
* There must be an [[INTEGER]] array of adequate size (up to 26K) to hold the graphic data.
* A [[DEF SEG]] pointing to the array is required. [[DEF SEG]] = [[VARSEG]](imageArray%(index))
* {{Parameter|index}} is the starting image element of the Array. Can also include RGB color settings at the start index.
* Fullscreen images in [[SCREEN]] 12 require 3 file BLOADs. A 26K array can hold 1/3 of screen.
* Custom RGB color settings can be embedded(indexed) at the start of the image array.
* BLOAD can be used to load any array that was saved with [[BSAVE]], not just graphics.
* Array sizes are limited to 32767 Integer elements due to use of [[VARPTR]] in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using [[PUT]] # and [[GET]] # without BLOAD.
* Array sizes are limited to 32767 Integer elements due to use of [[VARPTR]] in QBasic and '''QB64''''s emulated conventional memory.
{{PageExamples}}
''Example 1:'' Loading data to an array from a BSAVED file.
{{CodeStart}} '' ''
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0))
{{Cl|BLOAD}} filename$, {{Cl|VARPTR}}(Array({{Cl|LBOUND}}(Array))) ' changeable index
{{Cl|DEF SEG}} '' ''
{{CodeEnd}}
:''Explanation:'' Referance any type of array that matches the data saved. Can work with Integer, Single, Double, Long, fixed length Strings or {{KW|TYPE}} arrays. {{KW|LBOUND}} determines the starting offset of the array or another index could be used.
:''Explanation:'' Referance any type of array that matches the data saved. Can work with Integer, Single, Double, Long, fixed length Strings or [[TYPE]] arrays. [[LBOUND]] determines the starting offset of the array or another index could be used.
''Example 2:'' Using a QB default colored image.
@ -41,8 +43,6 @@
: ''Note:'' [[PSET]] is used as a [[PUT (graphics statement)|PUT]] action that places the image over any background objects.
{{PageSeeAlso}}
* [[BSAVE]], [[OPEN]], [[BINARY]]
* [[PUT]], [[GET]] {{text|(file statement)}}

View file

@ -1,27 +1,31 @@
[[BSAVE]] saves the contents of an image array to a {{KW|BINARY}} file.
[[BSAVE]] saves the contents of an image array to a [[BINARY]] file.
==Legacy support==
* '''QB64 can save larger arrays directly to binary files using [[PUT]] # and [[GET]] # without BSAVE. For that reason, BSAVE isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
{{PageSyntax}}
::: '''BSAVE''' {{Parameter|savefile$}}''', [[VARPTR]]'''({{Parameter|Array(index)}})''',''' {{Parameter|Filesize&}}
: [[BSAVE]] {{Parameter|saveFile$}}, [[VARPTR]]({{Parameter|array(index)}}), {{Parameter|fileSize&}}
{{Parameters}}
* ''savefile$'' is the STRING file name of the file designated to be created.
* ''Array(index)'' is the image [[arrays|array]] that already holds the [[GET (graphics statement)|GET]] image data.
* ''Filesize'' must be a bit over twice the size of the elements used in an {{KW|INTEGER}} [[Arrays|array]].
* {{Parameter|saveFile$}} is the STRING file name of the file designated to be created.
* {{Parameter|array(index)}} is the image [[arrays|array]] that already holds the [[GET (graphics statement)|GET]] image data.
* {{Parameter|fileSize&}} must be a bit over twice the size of the elements used in an [[INTEGER]] [[Arrays|array]].
{{PageDescription}}
* To place image data into the array, use [[GET (graphics statement)|GET]] to store a box area image of the screen.
* [[SCREEN]] 12 can only GET 1/3 of the screen image at one time using a 26K array.
* Image arrays are [[DIM]]ensioned as [[INTEGER]]. Use [[DEFINT]] when working with large graphic arrays.
* Any arrays can be saved, but Image arrays are most common.
* Any arrays can be saved, but image arrays are most common.
* [[DEF SEG]] = [[VARSEG]] must be used to designate the array segment position in memory.
* [[VARPTR]] returns the Array index offset of the memory segment. Array sizes are limited to 32767 Integer elements due to the use of [[VARPTR]] in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using [[PUT]] # and [[GET]] # without BSAVE.
* [[BSAVE]] files can later be opened with {{KW|BLOAD}}.
* [[VARPTR]] returns the array index offset of the memory segment. Array sizes are limited to 32767 Integer elements due to the use of [[VARPTR]] in QBasic and '''QB64''''s emulated conventional memory.
* [[BSAVE]] files can later be opened with [[BLOAD]].
{{PageExamples}}
''Example 1:'' Saving array data to a file quickly.
{{CodeStart}} '' ''
LB% = {{Cl|LBOUND}}(Array)
@ -31,11 +35,10 @@
{{Cl|BSAVE}} filename$, {{Cl|VARPTR}}(Array(LB%)), filesize& ' changeable index
{{Cl|DEF SEG}} '' ''
{{CodeEnd}}
: ''Explanation:'' Procedure determines the filesize from the array size automatically. {{KW|LBOUND}} is used with {{KW|UBOUND}} to determine array size and byte size. Works with any type of array except variable length Strings. Great for saving program data fast!
: ''Explanation:'' Procedure determines the filesize from the array size automatically. [[LBOUND]] is used with [[UBOUND]] to determine array size and byte size. Works with any type of array except variable-length strings. Used for saving program data fast.
''Example 2:'' {{KW|BSAVE}}ing a bitmap and calculating the file size
''Example 2:'' [[BSAVE]]ing a bitmap and calculating the file size
{{CodeStart}} '' ''
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image(0))
{{Cl|PSET}}(BMPHead.PWidth - 1, BMPHead.PDepth - 1) 'color lower right corner if black
@ -47,7 +50,46 @@
{{Cl|DEF SEG}} '' ''
{{CodeEnd}}
: ''Explanation:'' The {{KW|FOR...NEXT|FOR}} loop reads backwards through the image array until it finds a value not 0. The {{KW|LONG}} {{Parameter|ArraySize&}} value is doubled and 200 is added. {{Parameter|BMPhead.PWidth}} and {{Parameter|BMPhead.PDepth}} are found by reading the bitmap's information header using a {{KW|TYPE}} definition. See [[Bitmaps]].
: ''Explanation:'' The [[FOR...NEXT|FOR]] loop reads backwards through the image array until it finds a value not 0. The [[LONG]] {{Parameter|ArraySize&}} value is doubled and 200 is added. {{Parameter|BMPhead.PWidth}} and {{Parameter|BMPhead.PDepth}} are found by reading the bitmap's information header using a [[TYPE]] definition. See [[Bitmaps]].
''Example 3:'' Using [[PUT]] and [[GET]] to write and read array data from a file without using BSAVE or [[BLOAD]]:
{{CodeStart}}
{{Cl|KILL}} "example2.BIN" 'removes old image file!
{{Cl|SCREEN}} 13
{{Cl|OPTION BASE}} 0
{{Cl|REDIM}} Graphic%(1001) 'REDIM makes array resize-able later
{{Cl|LINE}} (0, 0)-(10, 10), 12, B 'create image
{{Cl|GET (graphics statement)|GET}}(0, 0)-{{Cl|STEP}}(10, 10), Graphic%() 'get image to array
{{Cl|FOR...NEXT|FOR}} i% = 1000 {{Cl|TO}} 0 {{Cl|STEP}} -1 'reverse read array for size needed
{{Cl|IF...THEN|IF}} Graphic%(i%) <> 0 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|NEXT}}
size% = i% + 4 'size plus 2 integers(4 bytes) for dimensions
{{Cl|REDIM}} {{Cl|_PRESERVE}} Graphic%(size%) 'resize existing array in QB64 only!
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file
{{Cl|PUT}} #1, , Graphic%()
{{Cl|CLOSE}}
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen
{{Cl|DIM}} CopyBin%({{Cl|LOF}}(2) \ 2) 'create new array sized by half of file size
{{Cl|GET}} #2, , CopyBin%()
{{Cl|PUT (graphics statement)|PUT}}(100, 100), CopyBin%(), {{Cl|PSET}}
fsize% = {{Cl|LOF}}(2)
{{Cl|CLOSE}}
K$ = {{Cl|INPUT$}}(1) 'Press any key
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 20 'read all 3 arrays
{{Cl|PRINT}} Graphic%(i); CopyBin%(i)
{{Cl|NEXT}}
{{Cl|PRINT}} "Array:"; size%, "File:"; fsize%
{{CodeEnd}}{{small|Code by Ted Weissgerber}}
: ''Explanation:'' A 10 by 10 pixel box is saved to an array using the [[GET (graphics statement)]] and written to a BINARY file using [[PUT]] #1. Then [[GET]] #1 places the file contents into another INTEGER array and places it on the screen with the [[PUT (graphics statement)]].
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) <> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
{{PageSeeAlso}}

View file

@ -1,38 +1,39 @@
The '''BYVAL''' statement is used to pass a numerical parameter's value with procedures made in other programming languages.
The [[BYVAL]] statement is used to pass a numerical parameter's value with procedures made in other programming languages.
{{PageSyntax}}
:: SUB Procedure_Name ('''BYVAL''' ''variable1'', '''BYVAL''' ''variable2'')
: SUB ProcedureName ([[BYVAL]] {{Parameter|variable1}}, [[BYVAL]] {{Parameter|variable2}})
{{PageDescription}}
* '''QB64''' can only use BYVAL in [[DECLARE LIBRARY]] procedures that add DLL or Operating System API functions.
* Supported with [[DECLARE LIBRARY]] [[SUB]] and [[FUNCTION]] procedure declarations when passing '''numerical values only'''.
* Passing numerical values BYVAL assures that the original numerical variable value is not changed by another procedure.
* Use [[parenthesis]] around program [[SUB]] or [[FUNCTION]] parameters passed BY VALUE. Ex: ''CALL Procedure ((x&), (y&))''
''Historical:''
* Qbasic versions below 7 do not use BYVAL unless the [[SUB]] program referred to is from a different programming language.
* PDS versions can use BYVAL as it is intended in any [[SUB]] or [[FUNCTION]] parameters.
* BYVAL can also be used with [[ABSOLUTE]] in Qbasic only.
* Use [[parenthesis]] around program [[SUB]] or [[FUNCTION]] parameters passed '''by value'''. Ex: ''CALL Procedure ((x&), (y&))''
{{PageErrors}}
* '''Do not use BYVAL before [[STRING]] or [[TYPE]] variables or in regular prograam [[SUB]] or [[FUNCTION]] parameters!'''
* '''Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
* '''Do not use BYVAL before [[STRING]] or [[TYPE]] variables or in regular prograam [[SUB]] or [[FUNCTION]] parameters.'''
* '''NOTE: Many QBasic keywords can be used as variable names if they are created as [[STRING]]s using the suffix '''$'''. You cannot use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements.'''
==QBasic/QuickBASIC==
* QBasic versions below 7 do not use BYVAL unless the [[SUB]] program referred to is from a different programming language.
* PDS versions can use BYVAL as it is intended in any [[SUB]] or [[FUNCTION]] parameters.
* BYVAL could also be used with [[ABSOLUTE]] in QBasic.
{{PageExamples}}
''Example 1:'' BYVAL is used to preserve the values sent to an external procedure so they remain the same after they are used:
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}}
{{Cl|DECLARE LIBRARY}} "SDL"
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{CodeEnd}}
: ''Note:'' Since the DLL library was already used by QB64 SDL(up to v.954), it did not require a DLL name. GL would!
: ''Note:'' The DLL call above uses the SDL library, which was included with QB64 up to version 0.954. Won't work with '''version 1.000 and up'''.
''Example 2:'' Passing parameters "by value" using [[parenthesis|brackets]] when calling a [[SUB]] or [[FUNCTION]] in Qbasic or QB64.
''Example 2:'' Passing parameters "by value" using [[parenthesis|brackets]] when calling a [[SUB]] or [[FUNCTION]] in QBasic or QB64.
{{CodeStart}} '' ''
{{Cl|CALL}} MySUB (a%, (b%), (c%)) 'CALL SUB b and c stay 0 after sub
@ -50,7 +51,7 @@ Inside procedure: 1 1 1
Inside procedure: 2 1 1
After procedures: 2 1 0
{{OutputEnd}}
:''Explanation:'' Both SUB calls pass just the '''values''' of b% and c% to the procedure. The first variable, a%, is passed by '''reference''' (the default) so the value was changed by the SUB procedure. Brackets can only be used in the [[CALL]] or function reference!
:''Explanation:'' Both SUB calls pass just the '''values''' of b% and c% to the procedure. The first variable, a%, is passed by '''reference''' (the default) so the value was changed by the SUB procedure. Brackets can only be used in the [[CALL]] or function reference.
{{PageSeeAlso}}

View file

@ -1,24 +1,26 @@
{{KW|CALL}} sends code execution to a subroutine procedure in a program. In '''QB64''' the subroutine doesn't need to be declared.
[[CALL]] sends code execution to a subroutine procedure in a program. In '''QB64''' the subroutine doesn't need to be declared.
{{PageSyntax}}
::: '''CALL {{Parameter|ProcedureName}}''' ['''('''{{Parameter|parameters}}, {{Parameter|passed}},...''')''']
: [[CALL]] {{Parameter|ProcedureName}} ({{Parameter|parameter1}}, {{Parameter|parameter2}},...)]
===Alternative syntax===
: {{Parameter|ProcedureName}} {{Parameter|parameter1}}, {{Parameter|parameter2}},...]
''Non-call Syntax:''
::: '''{{Parameter|ProcedureName}}''' [{{Parameter|parameters}}, {{Parameter|passed}},...]
* CALL requires that {{KW|SUB}} program parameters be enclosed in brackets(parenthesis).
* CALL is NOT required to call a subprocedure. Use the SUB-procedure name and list any parameters without parenthesis.
* CALL requires [[SUB]] program parameters to be enclosed in brackets (parenthesis).
* CALL is not required to call a subprocedure. Use the SUB-procedure name and list any parameters without parenthesis.
* Neither syntax can be used to call [[GOSUB]] linelabel sub procedures.
* To pass by values, both syntaxes require that each of those variable names be enclosed in parenthesis.
* PDS or Quickbasic 7 up can use [[BYVAL]] to pass by values instead of reference.
* Quickbasic 4.5 can use [[BYVAL]] only for procedures created in Assembly or another language.
* Qbasic requires [[CALL ABSOLUTE]] only. It does not have to be [[DECLARE]]d.
* To pass parameters by value, instead of by reference, enclose passed variables in parenthesis.
==QBasic/QuickBASIC==
* PDS or Quickbasic 7 up could use [[BYVAL]] to pass variables by values instead of reference.
* QuickBASIC 4.5 could use [[BYVAL]] only for procedures created in Assembly or another language.
* QBasic required [[CALL ABSOLUTE]] only. It did not have to be [[DECLARE]]d.
{{PageExamples}}
''Example:'' How parameters are passed in two [[SUB]] calls, one with CALL using brackets and one without CALL or brackets:
{{CodeStart}} '' ''
{{Cl|DIM}} a {{Cl|AS}} {{Cl|INTEGER}} 'value not shared with SUB
@ -53,8 +55,6 @@ Hello World!
:The variable '''{{Parameter|c}}''' is the [[SUB]] parameter variable that passes values into the sub. Its value could be changed by the passed parameter value or inside of the subroutine. The un-shared '''{{Parameter|c}}''' variable value outside of the sub is irrelevant within the subroutine.
:''Note:'' CALL doesn't need to be used in order to call a subroutine. Just using the name of the sub with parameters and no brackets will do: '''{{text|helloworld a|green}}'''
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]

View file

@ -1,24 +1,24 @@
{{KW|CALLS}} is a statement that transfers control to a procedure written in a different programming language.
'''This page is maintained for historic purposes. The keyword is not supported in QB64.'''
----
[[CALLS]] is a statement that transfers control to a procedure written in a different programming language.
{{PageSyntax}}
:{{KW|CALLS}} {{Parameter|name}} [({{Parameter|argumentlist}})]
* [[Keywords currently not supported by QB64|Currently NOT supported in QB64]]
* The arguments are passed by reference as far addresses, unlike {{KW|CALL}} which passes arguments by value as default. You cannot use {{KW|BYVAL}} or {{KW|SEG}} in a {{KW|CALLS}} argumentlist.
{{KW|CALLS}} is the same as using {{KW|CALL}} with a {{KW|SEG}} before each argument.
:[[CALLS]] {{Parameter|name}} [({{Parameter|argumentList}})]
* [[Keywords currently not supported by QB64|Not supported in QB64.]]
* The arguments are passed by reference as far addresses, unlike [[CALL]] which passes arguments by value as default. You cannot use [[BYVAL]] or [[SEG]] in a [[CALLS]] argumentList.
* [[CALLS]] is the same as using [[CALL]] with a [[SEG]] before each argument.
{{PageSeeAlso}}
*{{KW|DECLARE (non-BASIC statement)}}
*{{KW|CALL}}
*[[DECLARE (non-BASIC statement)]]
*[[CALL]]
{{PageNavigation}}

View file

@ -1,209 +1,26 @@
'''CALL ABSOLUTE''' is used to access Interrupts on the computer or execute assembly type procedures.
[[CALL ABSOLUTE]] is used to access interrupts on the computer or execute assembly type procedures.
{{PageSyntax}}
: '''CALL ABSOLUTE([{{Parameter|argument_list}},] {{Parameter|integer_offset}})'''
: [[CALL ABSOLUTE]]([{{Parameter|argumentList}},] {{Parameter|integerOffset}})
==Legacy support==
* [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, the '''use [[_MOUSEINPUT]] and related functions'''.
{{PageDescription}}
* [[CALL]] and parameter brackets are required in the statement.
* {{Parameter|argument_list}} contains the list of arguments passed to the procedure.
* {{Parameter|integer_offset}} contains the offset from the current code segment, set by [[DEF SEG]] and [[SADD]], to the starting location of the called procedure.
* Qbasic and '''QB64''' have the Absolute statement built in and require no library.
* QuickBASIC requires the QB.QLB Quick Library, loaded with the <tt>/L</tt> switch.
* '''NOTE: QB64 does not currently support INT 33h mouse functions above 3 or {{KW|BYVAL}} in an ABSOLUTE statement!'''
''Example 1:'' Typical ABSOLUTE mouse program demonstrates the AX% mouse functions in QuickBASIC 4.x and QBasic 1.x:
{{CodeStart}}
{{Cl|DECLARE}} {{Cl|SUB}} MouseDriver (AX%, BX%, CX%, DX%, LB%, RB%, EX%)
{{Cl|DIM}} {{Cl|SHARED}} mouse$ ' Hardware communications resource string (created in SUB MouseDriver)
{{Cl|DIM}} {{Cl|SHARED}} CX%, DX%, LB%, RB% ' CX = column, DX = row, LB and RB are left and right buttons
{{Cl|SCREEN (statement)|SCREEN}} 12
MouseDriver 1, BX%, CX%, DX%, LB%, RB%, 1 ' EX% = 1 initiates the mouse. Otherwise use EX% = 0
' ----------------------- DEMO CODE ----------------------
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 1, 36: {{Cl|PRINT}} "H = Hide, S = Show, M = Move, L = Limit area"
{{Cl|COLOR}} 6: {{Cl|LOCATE}} 2, 10: {{Cl|PRINT}} "Hold mouse button down for total: P = Presses, R = Releases"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 29, 30: {{Cl|PRINT}} "Click or [Esc] EXIT!";
{{Cl|CIRCLE}} (220, 150), 90, 10 ' use radius and center coordinates to find circle later
{{Cl|LOCATE}} 9, 22: {{Cl|PRINT}} "Click in circle"
{{Cl|COLOR}} 12: {{Cl|LOCATE}} 27, 10: {{Cl|PRINT}} "Show the mouse the same number of times it was Hidden!"
{{Cl|COLOR}} 14
{{Cl|DO...LOOP|DO}}: Funct$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) ' any keypress....keeps loop running for mouse
MouseDriver 3, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 3 reads mouse every loop
{{Cl|LOCATE}} 1, 2: {{Cl|PRINT}} "LB "; LB% ' left button value 0 or 1 pressed
{{Cl|LOCATE}} 1, 29: {{Cl|PRINT}} "RB "; RB% ' right button value 0 or 1 pressed
{{Cl|LOCATE}} 1, 10: {{Cl|PRINT}} "COL"; CX% ' column coordinate
{{Cl|LOCATE}} 1, 20: {{Cl|PRINT}} "ROW"; DX% ' row coordinate
{{Cl|IF...THEN|IF}} CX% >= 230 {{Cl|AND (boolean)|AND}} CX% <= 390 {{Cl|AND (boolean)|AND}} DX% >= 445 {{Cl|AND (boolean)|AND}} DX% <= 460 {{Cl|AND (boolean)|AND}} LB% {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|SELECT CASE}} Funct$
{{Cl|CASE}} "S": MouseDriver 1, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 1 show mouse
{{Cl|CASE}} "H": MouseDriver 2, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 2 hide mouse(accumulates)
{{Cl|CASE}} "M": CX% = 220: DX% = 150 ' set CX% and DX% to circle center
MouseDriver 4, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 4 moves mouse pointer to a coordinate
{{Cl|CASE}} "P": BX% = -1
{{Cl|IF...THEN|IF}} LB% {{Cl|THEN}} BX% = 0: {{Cl|IF...THEN|IF}} RB% {{Cl|THEN}} BX% = 1
MouseDriver 5, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 5 read button presses since last read
{{Cl|COLOR}} 6: {{Cl|LOCATE}} 29, 10: {{Cl|PRINT}} "Presses ="; BX%; {{Cl|SPACE$}}(2);
{{Cl|CASE}} "R": BX% = -1
{{Cl|IF...THEN|IF}} LB% {{Cl|THEN}} BX% = 0: {{Cl|IF...THEN|IF}} RB% {{Cl|THEN}} BX% = 1
MouseDriver 6, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 6 read button releases since last read
{{Cl|COLOR}} 6: {{Cl|LOCATE}} 29, 10: {{Cl|PRINT}} "Releases ="; BX%; {{Cl|SPACE$}}(2);
{{Cl|CASE}} "L": limit = {{Cl|NOT}} limit ' alternates between partial to fullscreen cursor move area.
{{Cl|IF...THEN|IF}} limit {{Cl|THEN}} CX% = 100: DX% = 500 {{Cl|ELSE}} CX% = 0: DX% = 639 ' min and max column coordinates
MouseDriver 7, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 7 limit horizontal column area
{{Cl|IF...THEN|IF}} limit {{Cl|THEN}} CX% = 100: DX% = 400 {{Cl|ELSE}} CX% = 0: DX% = 479 ' min and max row coordinates
MouseDriver 8, BX%, CX%, DX%, LB%, RB%, 0 ' AX% = 8 limit vertical row area
{{Cl|END SELECT}}
' CALCULATING WHEN THE POINTER IS INSIDE OF THE CIRCLE
' Pythagorean calculation: X ^ 2 + Y ^ 2 <= Radius ^ 2 for a position inside circle
XX& = ((CX% - 220) ^ 2) + ((DX% - 150) ^ 2) ' 220 and 150 are circle center coordinates
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 22, 8
{{Cl|PRINT}} "Columns"; {{Cl|CHR$}}(253); " + Rows"; {{Cl|CHR$}}(253); " <= Radius"; {{Cl|CHR$}}(253); " : IF"; XX&; "<= 8100 THEN ";
{{Cl|IF...THEN|IF}} XX& <= 8100 {{Cl|THEN}} ' 90 ^ 2 = 8100 is the circle radius squared
{{Cl|PRINT}} "Over Circle"; {{Cl|SPACE$}}(7)
{{Cl|IF...THEN|IF}} LB% = 1 {{Cl|THEN}} {{Cl|COLOR}} 12 ' left mouse button pressed in circle
{{Cl|IF...THEN|IF}} RB% = 1 {{Cl|THEN}} {{Cl|COLOR}} 13 ' right mouse button pressed in circle
{{Cl|ELSE}}: {{Cl|PRINT}} "Out of Circle"; {{Cl|SPACE$}}(5): {{Cl|COLOR}} 14 ' when mouse is not over circle
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} Funct$ = {{Cl|CHR$}}(27) ' escape
{{Cl|SYSTEM}}
' -------------------- END DEMO CODE -----------------
MouseData:
{{Cl|DATA}} 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
{{Cl|DATA}} 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
{{Cl|DATA}} 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F
{{Cl|DATA}} 8B,5E,06,89,17,5D,CA,08,00
{{Cl|SUB}} MouseDriver (AX%, BX%, CX%, DX%, LB%, RB%, EX%)
{{Cl|IF...THEN|IF}} EX% = 1 {{Cl|THEN}} ' initiate mouse once. EX normally = 0
' mouse$ = Hardware communications resource string
{{Cl|RESTORE}} MouseData ' restore MouseDATA
mouse$ = {{Cl|SPACE$}}(57) ' defines fixed length as 57 bytes
{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} 57
{{Cl|READ}} a$ ' read data for communication string
H$ = {{Cl|CHR$}}({{Cl|VAL}}("&H" + a$)) ' get DATA hex ASCII character
{{Cl|MID$ (statement)|MID$}}(mouse$, i%, 1) = H$
{{Cl|NEXT}} i%
{{Cl|END IF}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(mouse$)
{{Cl|CALL ABSOLUTE|CALL Absolute}}(AX%, BX%, CX%, DX%, {{Cl|SADD}}(mouse$)) 'get coordinates and buttons
{{Cl|DEF SEG}}
{{Cl|IF...THEN|IF}} EX% = 1 {{Cl|THEN}}
{{Cl|LOCATE}} 29, 60
{{Cl|IF...THEN|IF}} AX% {{Cl|THEN}}
{{Cl|PRINT}} "Mouse Found"; ' AX = -1 IF FOUND
{{Cl|ELSE}} : {{Cl|BEEP}}: {{Cl|PRINT}} "Mouse not found"; : {{Cl|SYSTEM}}
{{Cl|END IF}}
{{Cl|END IF}}
LB% = BX% {{Cl|AND}} 1 ' positive 1 return values
RB% = (BX% {{Cl|AND}} 2) \ 2
MB% = (BX% {{Cl|AND}} 4) \ 4
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Code by: Ted Weissgerber}}
:::'''NOTE: QB64 does not currently support functions above AX% = 3 in above ABSOLUTE demo!'''
{{OutputStart}}
LB 0 COL 84 ROW 140 RB 0 H = Hide, S = Show, M = Move, L = Limit area
Hold mouse button down for total: P = Presses, R = Releases
Click in circle
Columns^2 + Rows^2 <= Radius^2 : IF 18596 <= 8100 THEN Out of Circle
Show the mouse the same number of times it was Hidden!
Click or [Esc] EXIT! Mouse Found
{{OutputEnd}}
''Explanation:'' The circle isn't shown in this output screen, but when you run the example you can move the mouse into a circle in the middle of the screen and the text will change color to reflect that you are inside the circle, you can also use the mousebuttons and the color will change.
''Example 2:'' An Absolute substitution for INTERRUPT that can be used by all QB versions including PDS(7.1):
{{CodeStart}}
{{Cl|TYPE}} regs
AX {{Cl|AS}} {{Cl|INTEGER}} ' mouse function call
CX {{Cl|AS}} {{Cl|INTEGER}} ' mouse column position
DX {{Cl|AS}} {{Cl|INTEGER}} ' mouse row position
BX {{Cl|AS}} {{Cl|INTEGER}} ' mouse button press
SP {{Cl|AS}} {{Cl|INTEGER}} ' Ignored
BP {{Cl|AS}} {{Cl|INTEGER}}
SI {{Cl|AS}} {{Cl|INTEGER}}
DI {{Cl|AS}} {{Cl|INTEGER}}
Flags {{Cl|AS}} {{Cl|INTEGER}}
DS {{Cl|AS}} {{Cl|INTEGER}}
ES {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|END TYPE}}
{{Cl|DIM}} R {{Cl|AS}} regs ' set dot variable to the TYPE
' Program code
' R.AX = 3 ' mouse read function = 3
' CALL INTX(R)
{{Cl|SUB}} INTX(R {{Cl|AS}} regs)
{{Cl|STATIC}} Code {{Cl|AS}} {{Cl|STRING}}, M() {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(Code) = 0 {{Cl|THEN}} ' setup only
{{Cl|DIM}} M(0 {{Cl|TO}} 26) {{Cl|AS}} {{Cl|INTEGER}}
Code = "5589E58B76069C061EB90B00FCAD50E2FC071F9D61CD"
'* Change this to the desired interrupt hex address number *
Code = Code + "33" ' IN HEXadecimal form only!
' mouse = "33"; DOS Services = "21"
Code = Code + "609C1E0689E58E46168B7E2283C714B90B00FD58ABE2FC1F079D5DCA02"
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(M(0))
{{Cl|FOR...NEXT|FOR}} I = 0 {{Cl|TO}} 51
{{Cl|POKE}} {{Cl|VARPTR}}(M(0)) + I, {{Cl|VAL}}("&H" + {{Cl|MID$}}(Code, I * 2 + 1, 2))
{{Cl|NEXT}}
{{Cl|END IF}} ' end setup
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(M(0))
{{Cl|CALL ABSOLUTE}}(R, {{Cl|VARPTR}}(M(0)))
{{Cl|DEF SEG}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{small|Code by: Artelius}}
''Explanation:'' To read or send values use dot variable names. Such as R.AX, R.BX(buttons), R.CX (horizontal coordinate) and R.DX (vertical coordinate). It can use all of the mouse functions used in previous code demo.
'''Note: The second example cannot currently be run in QB64 as "User defined types are invalid with Absolute"!'''
* {{Parameter|argumentList}} contains the list of arguments passed to the procedure.
* {{Parameter|integerOffset}} contains the offset from the current code segment, set by [[DEF SEG]] and [[SADD]], to the starting location of the called procedure.
* QBasic and '''QB64''' have the ABSOLUTE statement built in and require no library, like QuickBASIC did.
* '''NOTE: QB64 does not support INT 33h mouse functions above 3 or [[BYVAL]] in an ABSOLUTE statement. Registers are emulated.'''
{{PageSeeAlso}}
* [[SADD]], [[INTERRUPT]]
* [[DECLARE (non-BASIC statement)]]
* [[_MOUSEINPUT]]
{{PageNavigation}}

View file

@ -1,48 +1,27 @@
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE]] is used within a [[SELECT CASE]] block to specify a conditional value of the compared variable.
{{PageSyntax}}
:: '''CASE comparison_value(s)'''[:] execute_code_line_or_block
: [[CASE]] {{Parameter|comparisonValues}}[:] {code}
{{PageDescription}}
*{{Parameter|value}} can be any literal string or number, depending on the value specified in the {{KW|SELECT CASE}} statement.
*{{Parameter|comparisonValues}} can be any literal string or number, depending on the value specified in the [[SELECT CASE]] statement.
*Code is executed until the next case, so each case can handle multiple lines of code.
*CASE conditions normally are listed in some logical order going down the page.
*CASE order can affect the SELECT CASE code execution when more than one CASE can be true! This is specially true when multiple conditional operators, CASE IS or TO ranges are used!
* CASE lists can also be listed horizontally by using colon separators between cases.
*[[CASE]] conditions are normally listed in some logical order going down the page.
*[[CASE]] order can affect the SELECT CASE code execution when more than one CASE can be true. This is specially true when multiple conditional operators, CASE IS or TO ranges are used.
* [[CASE]] lists can also be listed horizontally by using colon separators between cases.
* Supports individual CASE values and ranges or lists of values as below:
:* CASE value
:* CASE value1 [[TO]] value2
:* CASE value1, value2, value3
:* [[CASE IS]] value1 > value2
:* [[CASE ELSE]]
''Relational Operators:'' Used in {{KW|CASE}} {{KW|IS}} evaluations Only.
* > is Greater than
* < is Less than
* = is Equal to
* >= is Greater than or Equal to
* <= is Less than or Equal to
* <> is Not Equal to
''Multiple Conditional Operators:'' Used in {{KW|CASE}} {{KW|IS}} Only.
* {{KW|AND (boolean)|AND}} can be used to add extra conditions to a {{KW|CASE}} {{KW|IS}} statement evaluation.
* {{KW|OR (boolean)|OR}} can be used to add alternate conditions to a {{KW|CASE}} {{KW|IS}} statement evaluation.
* Parenthesis are allowed in {{KW|CASE}} {{KW|IS}} statements to clarify an evaluation.
* The FIRST time a {{KW|CASE}} value matches the compared variable's value, that {{KW|CASE}} code is executed and {{KW|SELECT CASE}} is exited.
''Example:''
** [[CASE]] value
** [[CASE]] value1 [[TO]] value2
** [[CASE]] value1, value2, value3
** [[CASE IS]] value1 > value2
** [[CASE ELSE]]
* The first time a [[CASE]] value matches the compared variable's value, that [[CASE]] code is executed and [[SELECT CASE]] is exited, unless '''EVERYCASE''' is used.
{{PageExamples}}
{{CodeStart}}
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} 1, 3, 5, 7, 9: {{Cl|PRINT}} "Odd values under 10 will be shown."
@ -73,8 +52,8 @@ a = 100
:* [[CASE IS]] is used when we need to compare the value to a conditional expression range such as a value is "=" equal to, "<" less than, ">" greater than, "<>" not equal to or [[NOT]] a value.
:* A [[CASE]] range can be specified (in the example; 50 {{KW|TO}} 150) if needed.
<center>''Note:'' A {{KW|SELECT CASE}} block has to end with [[END SELECT]].</center>
:* A [[CASE]] range can be specified (in the example; 50 [[TO]] 150) if needed.
<center>''Note:'' A [[SELECT CASE]] block has to end with [[END SELECT]].</center>
{{PageSeeAlso}}

View file

@ -1,11 +1,11 @@
{{KW|CASE ELSE}} is used in a {{KW|SELECT CASE}} procedure as an alternative if no other {{KW|CASE}} statements are true.
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE ELSE]] is used in a [[SELECT CASE]] procedure as an alternative if no other [[CASE]] statements are true.
{{PageDescription}}
* CASE ELSE should be listed at the bottom of the case list as it will supercede any case statements after it.
* Use it as a "safety net" or as an alternative for ALL values not covered in the {{KW|CASE}} statements.
* [[CASE ELSE]] should be listed at the bottom of the case list as it will supersede any case statements after it.
* Use it as a "safety net" or as an alternative for all values not covered in the [[CASE]] statements.
{{PageExamples}}
@ -29,6 +29,7 @@ a is 100
{{OutputEnd}}
''Example 2:''
{{CodeStart}}
@ -54,9 +55,8 @@ a is something other than 10, 20 and 30
{{PageSeeAlso}}
*{{KW|SELECT CASE}}
*{{KW|IF...THEN}}, {{KW|ELSE}}
*[[SELECT CASE]]
*[[IF...THEN]], [[ELSE]]
{{PageNavigation}}

View file

@ -1,3 +1,5 @@
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE IS]] can be used in a [[SELECT CASE]] routine where you need to use relational conditional expressions.
@ -6,9 +8,12 @@
{{PageDescription}}
* [[AND (boolean)|AND]] can be used to add extra conditions to a [[CASE IS]] statement evaluation.
* [[OR (boolean)|OR]] can be used to add alternate conditions to a [[CASE IS]] statement evaluation.
* Parenthesis are allowed in [[CASE IS]] statements to clarify an evaluation.
* [[CASE IS]] > 100 uses the greater than expression.
* [[CASE IS]] <= 100 uses the less than or equal to expression.
* [[CASE IS]] <> 100 uses the not equal to expression(same as {{KW|NOT}} 100).
* [[CASE IS]] <> 100 uses the not equal to expression(same as [[NOT]] 100).
{{Template:RelationalTable}}

View file

@ -1,20 +1,21 @@
{{KW|CDBL}} converts a value to the closest {{KW|DOUBLE}}-precision value.
[[CDBL]] converts a value to the closest [[DOUBLE]]-precision value.
{{PageSyntax}}
:: doublevalue = '''CDBL('''''expression''''')'''
: {{Parameter|doubleValue#}} = [[CDBL]]({{Parameter|expression}})
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Rounds to the closest [[DOUBLE]] floating decimal point value.
* Also can be used to define a value as {{KW|DOUBLE}}-precision up to 15 decimals.
* Also can be used to define a value as [[DOUBLE]]-precision up to 15 decimals.
{{PageExamples}}
''Example:'' Prints a double-precision version of the single-precision value stored in the variable named A.
{{CodeStart}}
A = 454.67

View file

@ -1,17 +1,23 @@
CDECL is used to indicate that the external procedure uses the C-language argument order.
#REDIRECT [[DECLARE (non-BASIC statement)]]
'''This page is maintained for historic purposes. The keyword is not supported in QB64.'''
----
[[CDECL]] is used to indicate that the external procedure uses the C-language argument order.
{{PageSyntax}}
:: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name ['''CDECL'''] [ [[ALIAS]] "aliasname"] [([parameterlist])]
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name ['''CDECL'''] [ [[ALIAS]] "aliasname"] [([parameterlist])]
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
* QuickBASIC will pass the arguments in the argument list from right to left instead of left to right which is the BASIC convention.
{{PageSeeAlso}}
*{{KW|CALL}}, {{KW|CALLS}}
*{{KW|DECLARE (non-BASIC statement)}}
*[[CALL]], [[CALLS]]
*[[DECLARE (non-BASIC statement)]]
{{PageNavigation}}

View file

@ -1,34 +1,39 @@
'''CHAIN''' is used to change seamlessly from one module to another one in a program. Available in Quickbasic 4.0 and up.
[[CHAIN]] is used to change seamlessly from one module to another one in a program.
==Legacy support==
* The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 [[CHAIN]] has been implemented so that that older code can still be compiled, though '''it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.'''
{{PageSyntax}}
::: '''CHAIN {{Parameter|ModuleName$}}'''
: [[CHAIN]] {{Parameter|moduleName$}}
{{Parameters}}
* The ''module'' name is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
''Usage:''
* CHAIN requires that both the invoking and called modules are of either .BAS or .EXE file types!
{{PageDescription}}
* CHAIN requires that both the invoking and called modules are of either .BAS or .EXE file types.
* In Windows, '''QB64''' will automatically compile a CHAIN referenced BAS file if there is no EXE file found.
* CHAIN looks for a file extension that is the same as the invoking module's extension.
* The module's filename extension is NOT required. To save editing at compile time just omit the extensions in the calls.
* To pass data from one module to the other use [[COMMON SHARED]]. The COMMON list should match [[type]]s and names!
* Compiled EXE files MUST include BRUN45.EXE in QuickBasic 4.5 when CHAIN is used with [[COMMON SHARED]].
* Module screen modes will not change unless that is desired. '''QB64 currently does not retain the [[SCREEN]] mode!'''
* Use when modules are too large to compile(Over 100K approx.). Split the modules up. NOT necessary with '''QB64'''!
* The module's filename extension is not required. To save editing at compile time just omit the extensions in the calls.
* To pass data from one module to the other use [[COMMON SHARED]]. The COMMON list should match [[type]]s and names.
* '''QB64 does not retain the [[SCREEN]] mode like QBasic did.'''
* Variable data can be passed in files instead of using [[COMMON SHARED]] values. '''QB64''' uses files to pass [[COMMON]] lists.
* '''NOTE: CHAIN is no longer required using QB64 as it can run larger modules: [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not currently available in Linux or Mac operating systems!]]'''
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]'''.
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE) in QB 4.5.
''QBasic/QuickBASIC:''
* Compiled EXE files had to include BRUN45.EXE in QuickBASIC 4.5 when CHAIN was used with [[COMMON SHARED]].
{{PageExamples}}
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
{{CodeStart}} '' ''
{{Cl|CHAIN}} "Level1" '' ''
{{CodeEnd}}
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE". QuickBasic4.5 requires that [[COMMON]] or [[COMMON SHARED]] data sharing programs be compiled with BRUN45.EXE being included with the program package(the EXE file will also be larger). '''QB64''' does not have that requirement as it creates data files to pass common data information.
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".
{{PageSeeAlso}}

View file

@ -1,39 +1,33 @@
The {{KW|CHDIR}} statement changes the program's location from one working directory to another by specifying a literal or variable [[STRING]] path.
The [[CHDIR]] statement changes the program's location from one working directory to another by specifying a literal or variable [[STRING]] path.
{{PageSyntax}}
:{{KW|CHDIR}} {{Parameter|path$}}
:[[CHDIR]] {{Parameter|path$}}
{{PageDescription}}
* Path directory names must use the 8 letter maximum DOS name in Qbasic. '''QB64''' can use long path names.
* {{Parameter|path$}} is the new directory path the program will work in.
* {{Parameter|path$}} can be an absolute(starting from root drive) or relative(starting from the present program location) path.
* {{Parameter|path$}} can be an absolute path (starting from the root folder) or relative path (starting from the current program location).
* If {{Parameter|path$}} specifies a non-existing path, a [[ERROR Codes|"Path not found"]] error will occur.
* '''A QB64 [[SHELL]] statement cannot currently use "CD " or "CHDIR " + path$ to change the directory using DOS.'''
* '''WARNING: The new program path location must have the relevant files the program requires to run properly!'''
* '''A QB64 [[SHELL]] statement cannot use "CD " or "CHDIR " + path$ to change directories.'''
''Example 1:'' The following code is MS DOS and Windows-specific:
{{PageExamples}}
''Example 1:'' The following code is Windows-specific:
{{CodeStart}} '' ''
{{Cl|CHDIR}} "C:\" 'change to the root drive C (absolute path)
{{Cl|CHDIR}} "DOCUME~1" 'change to "C:\Documents and Settings" from root drive (relative path)
{{Cl|CHDIR}} "..\" 'change back to previous folder one up '' ''
{{CodeEnd}}
:''Details:'' There is an 8 letter path folder name limit in Qbasic. For folder names longer than eight characters use the first 6 letters(remove spaces) with a tilde(~) and a number(normally 1). '''QB64''' can use long or short(8.3 notation) file and path names! ''Remember that the program location has actually been moved so files in the original location must be accessed using a path.''
:''Details:'' '''QB64''' can use long or short (8.3 notation) file and path names.
''Example 2:'' Using the Windows API to find the current program's name and root path. The PATH$ is a shared function value.
{{CodeStart}} '' ''
{{Cl|_TITLE}} "My program"
{{Cl|PRINT}} TITLE$
{{Cl|PRINT}} PATH$
{{Cl|FUNCTION}} TITLE$ ''=== SHOW CURRENT PROGRAM
{{Cl|SHARED}} PATH$ 'optional path information shared with main module only
{{Cl|DECLARE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav
@ -56,14 +50,14 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
{{Cl|END IF}}
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
: '''Note:''' The program's [[_TITLE]] name may be different from the actual program module's file name returned by Windows!
: '''Note:''' The program's [[_TITLE]] name may be different from the actual program module's file name returned by Windows.
{{PageSeeAlso}}
* [[SHELL]], [[FILES]]
* [[MKDIR]], [[RMDIR]]
* [[DOS]], [[Batch Files]]
* [[C_Libraries#Console_Window|C Console Library]]
* [[$CONSOLE]]
{{PageNavigation}}

View file

@ -1,14 +1,14 @@
The {{KW|CHR$}} function returns the character associated with a certain [[ASCII|character code]] as a {{KW|STRING}}.
The [[CHR$]] function returns the character associated with a certain [[ASCII|character code]] as a [[STRING]].
{{PageSyntax}}
:''result$'' = {{KW|CHR$}}({{Parameter|code%}})
:{{Parameter|result$}} = [[CHR$]]({{Parameter|code%}})
{{PageDescription}}
* Valid ASCII code numbers range from 0 to 255.
* The character code of a character can be found using {{KW|ASC}}.
* Some control codes below 32 will not {{KW|PRINT}} or will move the screen cursor.
* Valid ASCII {{Parameter|code%}} numbers range from 0 to 255.
* The character code of a character can be found using [[ASC]].
* Some control codes below 32 will not [[PRINT]] or will move the screen cursor, unless [[_CONTROLCHR|_CONTROLCHR OFF]] is used.
{{PageExamples}}
@ -36,7 +36,7 @@ This text uses "quotation marks" that could have caused a syntax error
{{OutputEnd}}
''Example 3:'' Using {{KW|ASC}} and {{KW|CHR$}} to '''Encrypt''' a text file size up to 32K bytes
''Example 3:'' Using [[ASC]] and [[CHR$]] to ''encrypt'' a text file size up to 32K bytes
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be encrypted
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) <= 32000 {{Cl|THEN}} Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' get Text as one string
{{Cl|CLOSE}} #1
@ -53,9 +53,7 @@ Send$ = "" ' clear value
{{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' Text as one string
{{Cl|CLOSE}} #1
{{CodeEnd}}
::'''Warning: Above routine will change ORIGINAL text file to be unreadable!'''
::::''Use a second Filename to preserve the original file!''
:''Warning: The routine above will change an original text file to be unreadable. Use a second file name to preserve the original file.''
''Example 4:'' '''Decrypting''' the above encrypted text file (32K byte file size limit).
@ -76,12 +74,12 @@ Send$ = ""
{{Cl|CLOSE}} #1 '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' Examples 3 and 4 Encrypt and Decrypt a file up to 32 thousand bytes only! [[INPUT$]] can only get strings less than 32767 characters. The upper and lower case letter characters are the only ones altered, but the encryption and decryption rely on the fact that MOST text files do not use the code characters above 193. You could alter any character from ASCII 32 to 125 without problems using the 130 adder. '''NO [[ASCII]] code above 255 is allowed!''' DON'T alter the codes below code 32 as they are Control characters. Specifically, characters 13 and 10 (CrLf) may be used for line returns in text files.
:''Explanation:'' Examples 3 and 4 encrypt and decrypt a file up to 32 thousand bytes. [[INPUT$]] can only get strings less than 32767 characters. The upper and lower case letter characters are the only ones altered, but the encryption and decryption rely on the fact that most text files do not use the code characters above 193. You could alter any character from ASCII 32 to 125 without problems using the 130 adder. No [[ASCII]] code above 255 is allowed. Don't alter the codes below code 32 as they are control characters. Specifically, characters 13 and 10 (CrLf) may be used for line returns in text files.
{{PageSeeAlso}}
* {{KW|ASC}}, {{KW|ASC (statement)}}(QB64)
* {{KW|INKEY$}}
* [[ASC]], [[ASC (statement)]]
* [[INKEY$]]
* [[ASCII|ASCII character codes]]

View file

@ -1,35 +1,35 @@
The {{KW|CINT}} function rounds decimal point numbers up or down to the nearest {{KW|INTEGER}} value.
The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value.
{{PageSyntax}}
:: value = '''CINT('''''expression''''')'''
: {{Parameter|value%}} = [[CINT]]({{Parameter|expression}})
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Values greater than .5 are rounded up. Values lower than .5 are rounded down just like "bankers rounding".
* Half(.5) [[SINGLE]] values are rounded to the nearest EVEN integer value whether it is up or down.
* ''Warning:'' Since {{KW|CINT}} is used for integer values, the input values cannot exceed 32767 to -32768!
* Use {{KW|CLNG}} for {{KW|LONG}} integer values exceeding Integer limitations.
* Note: When decimal point values are given to Basic functions requiring [[INTEGER]]s the value will be CINTed.
* Values greater than .5 are rounded up. Values lower than .5 are rounded down.
* ''Warning:'' Since [[CINT]] is used for integer values, the input values cannot exceed 32767 to -32768!
* Use [[CLNG]] for [[LONG]] integer values exceeding [[INTEGER]] limitations.
* Note: When decimal point values are given to BASIC functions requiring [[INTEGER]]s the value will be [[CINT]]ed.
''Example:'' Shows how CINT rounds values up or down as in bankers rounding.
{{PageExamples}}
''Example:'' Shows how CINT rounds values up or down as in "bankers' rounding".
{{CodeStart}} '' ''
a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c '' ''
{{CodeEnd}}
{{OutputStart}}{{text|1 2 11.5|red}}
{{OutputEnd}}
:''Note:'' Qbasic functions requiring [[INTEGER]] values such as text or graphic coordinates and {{KW|COLOR}} will be rounded like {{KW|CINT}}. Half values are rounded to the nearest even integer value.
{{PageSeeAlso}}
* {{KW|CLNG}}, {{KW|CSNG}}, {{KW|CDBL}}
* {{KW|INT}}, {{KW|FIX}}, {{KW|_ROUND}}
* [[_ROUND]], [[_CEIL]]
* [[CLNG]], [[CSNG]], [[CDBL]]
* [[INT]], [[FIX]]
{{PageNavigation}}

View file

@ -1,102 +1,29 @@
The {{KW|CIRCLE}} statement is used in graphics {{KW|SCREEN (statement)|SCREEN}} modes to create circles, arcs or ellipses.
The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes to create circles, arcs or ellipses.
{{PageSyntax}}
: '''CIRCLE''' [{{KW|STEP}}]'''('''{{Parameter|Column}}''',''' {{Parameter|Row}}'''),''' {{Parameter|radius%}}''',''' [{{Parameter|colour%}}][, {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
: [[CIRCLE]] [{{KW|STEP}}]'''('''{{Parameter|column}}''',''' {{Parameter|row}}'''),''' {{Parameter|radius%}}''',''' [{{Parameter|drawColor%}}][, {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
{{Parameters}}
* Can use [[STEP]] for relative coordinate moves from the previous graphic coordinates.
* Coordinates designate the center position of the circle. Can be partially drawn offscreen.
* {{Parameter|radius%}} is an [[INTEGER]] value for half of the total circle diameter.
* {{Parameter|colour%}} is any available color attribute in the {{KW|SCREEN (statement)|SCREEN}} mode used.
* {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} can be any {{KW|SINGLE}} value from 0 to 2 * pi to create partial circles or ellipses.
* ''aspect!'' [[SINGLE]] values of 0 to 1 affect the vertical height and values over 1 affect the horizontal width of an ellipse. Aspect = 1 is a normal circle.
* {{Parameter|drawColor%}} is any available color attribute in the [[SCREEN (statement)|SCREEN]] mode used.
* {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} can be any [[SINGLE]] value from 0 to 2 * π to create partial circles or ellipses.
* {{Parameter|aspect!}} [[SINGLE]] values of 0 to 1 affect the vertical height and values over 1 affect the horizontal width of an ellipse. Aspect = 1 is a normal circle.
''Usage:''
* When using {{Parameter|aspect!}} the {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} commas MUST be included even if not used.
* Radians move in a counter clockwise direction from 0 to 2 * Pi. Zero and 2 * Pi are the same circle radian at 3 o'clock.
{{PageDescription}}
* When using {{Parameter|aspect!}} the {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} commas must be included even if not used.
* Radians move in a counter clockwise direction from 0 to 2 * π. Zero and 2 * π are the same circle radian at 3 o'clock.
* Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.
* Commas after the {{Parameter|colour%}} parameter are not required when creating a normal circle. Color can also be omitted.
* The QB64 and QB graphic cursor is set to the center of the program window on program start.
* '''CIRCLE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!'''
<center>'''Circle.BI Include file or [[SUB]] to use when using [[PAINT]] with pie charts or arc slices:'''</center>
{{TextStart}} 'CIRCLE.BI
'**
'** QB64 temporary replacement CIRCLE command.
'**
'** The CIRCLE command in QB64 has a few bugs listed below:
'**
'** - radian end points are not calculate properly when creating arcs
'** - center line to radian end points do not close properly due to previous bug listed
'**
'** This circle command replacement works very similiarly to the native CIRCLE command:
'**
'** SYNTAX: CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!
'**
'** x% - center X coordinate of circle
'** y% - center Y coordinate of circle
'** radius! - the radius of the circle
'** color~& - the circle's color
'** start_radian! - the radian on circle curcunference to begin drawing at
'** end_radian! - the radian on circle circumference to end drawing at
'** aspect_ratio! - the aspect ratio of the circle
'**
'** '''NOTE: unlike the native CIRCLE command, all arguments MUST be supplied.''' For example,
'** with the native command this will draw a perfect circle with the default color,
'** start radian, end radian and aspect ratio:
'**
'** CIRCLE (319, 239), 100
'**
'** To do the same thing with this replacement command you must supply everything:
'**
'** CIRCLES 319, 239, 100, _RGB32(255, 255, 255), 0, 0, 0
'**
'** ACKNOWLEGEMENTS: The FOR/NEXT step formula was was written by Codeguy for Unseen
'** Machine's Visual library EllipseXS command. Specifically:
'** MinStep! = 1 / (2 * 3.1415926535 * Radius!)
'**
'**
'** Includes performance tweaks made by SMcNeill on 02/02/13 - specifically removing a few redundant * -1
'** statements and converting the FOR/NEXT loop to a DO loop for a ~3% increase in performance.
'**
'** Corrected bug in which variables being passed in were being modified and passed back - 02/02/13
'**
'''SUB CIRCLES (cx%, cy%, r!, c~&, s!, e!, a!)'''
DIM s%, e%, nx%, ny%, xr!, yr!, st!, en!, asp! ' local variables used
st! = s! ' copy start radian to local variable
en! = e! ' copy end radian to local variable
asp! = a! ' copy aspect ratio to local variable
IF asp! <= 0 THEN asp! = 1 ' keep aspect ratio between 0 and 4
IF asp! > 4 THEN asp! = 4
IF asp! < 1 THEN xr! = r! * asp! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF asp! > 1 THEN yr! = r! * asp! ELSE yr! = r!
IF st! < 0 THEN s% = -1: st! = -st! ' remember if line needs drawn from center to start radian
IF en! < 0 THEN e% = -1: en! = -en! ' remember if line needs drawn from center to end radian
IF s% THEN ' draw line from center to start radian?
nx% = cx% + xr! * COS(st!) ' yes, compute starting point on circle's circumference
ny% = cy% + yr! * -SIN(st!)
LINE (cx%, cy%)-(nx%, ny%), c~& ' draw line from center to radian
END IF
IF en! <= st! THEN en! = en! + 6.2831852 ' come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
c! = st! ' cycle from start radian to end radian
DO
nx% = cx% + xr! * COS(c!) ' compute next point on circle's circumfrerence
ny% = cy% + yr! * -SIN(c!)
PSET (nx%, ny%), c~& ' draw the point
c! = c! + stepp!
LOOP UNTIL c! >= en!
IF e% THEN LINE -(cx%, cy%), c~& ' draw line from center to end radian if needed
'''END SUB'''
{{TextEnd}}
* Commas after the {{Parameter|drawColor%}} parameter are not required when creating a normal circle. {{Parameter|drawColor%}} can also be omitted to use the last color used in a draw statement.
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
* '''CIRCLE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only.'''
{{PageExamples}}
''Example 1:'' Finding when the mouse is inside of a circular area:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
@ -118,7 +45,7 @@ DO
''Example 2:'' Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.
{{CodeStart}} '' ''
{{Cl|CONST}} PI = 3.141593 'The mathematical value of PI to six places
{{Cl|CONST}} PI = 3.141593 'The mathematical value of PI to six places. You can also use QB64's native _PI.
{{Cl|DIM}} clock(60) 'A dimensioned array to hold 60 radian points
clockcount% = 15 'A counter to keep track of the radians
@ -206,13 +133,13 @@ previoushour% = hours% 'hold current hour for later use
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key '' ''
{{CodeEnd}}
{{small|Circle clock - by Terry Ritchie 11/04/06}}
{{small|code by Terry Ritchie}}
{{PageSeeAlso}}
* [[STEP]], [[DRAW]]
* [[LINE]], [[PSET]], [[PRESET]]
* [[SCREEN]], [[SCREEN (function)]]
* [[Alternative circle routine]] {{text|(member-contributed program)}}
{{PageNavigation}}

View file

@ -1,18 +1,19 @@
The ''CLEAR''' statement clears all variable and array element values in a program. It does not affect constant values!
The [[CLEAR]] statement clears all variable and array element values in a program.
''Syntax:'' '''CLEAR''' [, ''stacksize&'' , ''stackspace&'']
{{PageSyntax}}
: [[CLEAR]] [, {{Parameter|ignored&}} , {{Parameter|ignored&}}]
{{PageDescription}}
* Optional ''stacksize'' parameter was not required as Qbasic managed that. '''All parameters and commas are ignored by QB64!'''
* The ''stackspace'' parameter sets the stack space to be added to the stack. Two commas kept Qbasic compatible with BASICA.
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become null.
* All parameters are optional and ignored by '''QB64'''.
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become empty ("").
* It does not clear [[CONST|constant]] values.
* Closes all opened files also.
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|re-dimensioned]] or an [[ERROR Codes|error]] will occur when referenced because it was removed.
* Closes all opened files.
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|redimensioned]] or an [[ERROR Codes|error]] will occur when referenced because they are removed.
{{PageExamples}}
''Example:'' Using CLEAR to clear array elements from [[STATIC|static]] arrays or arrays created using [[DIM]].
{{CodeStart}} '' ''
{{Cl|CLS}}
@ -29,9 +30,8 @@ array(5) = 23
{{PageSeeAlso}}
* [[ERASE]] {{text|(array names only)}}
* [[REDIM]] {{text|(array sizes only)}}
* [[_PRESERVE]] {{text|(REDIM arrays only)}}
* [[ERASE]]
* [[REDIM]], [[_PRESERVE]]
* [[Arrays]], [[&B|_BIT arrays]]

View file

@ -1,23 +1,22 @@
The {{KW|CLNG}} function rounds decimal point numbers up or down to the nearest {{KW|LONG}} integer value.
The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[LONG]] integer value.
{{PageSyntax}}
:: value = '''CLNG('''''expression''''')'''
: {{Parameter|value&}} = [[CLNG]]({{Parameter|expression}})
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Used when integer values exceed 32767 or are less than -32768.
* Values greater than .5 are rounded up; .5 or lower are rounded down like "bankers rounding".
* CLNG can return normal {{KW|INTEGER}} values under 32768 also.
* Use it when a number could exceed normal {{KW|INTEGER}} number limits.
* Values greater than .5 are rounded up; .5 or lower are rounded down.
* CLNG can return normal [[INTEGER]] values under 32768 too.
* Use it when a number could exceed normal [[INTEGER]] number limits.
{{PageExamples}}
{{CodeStart}}
a& = {{Cl|CLNG}}(2345678.51)
{{Cl|PRINT}}

View file

@ -1,22 +1,22 @@
{{KW|CLOSE}} closes an opened file or port using the number(s) assigned in an {{KW|OPEN}} statement.
[[CLOSE]] closes an open file or port using the number(s) assigned in an [[OPEN]] statement.
{{PageSyntax}}
::: '''CLOSE''' [''filenumber''[, ...]]
: [[CLOSE]] [{{Parameter|fileNumber}}[, ...]]
''[[Parameters]]:''
* ''filenumber'' indicates the file or list of file numbers to close. When not designated all files are closed.
{{Parameters}}
* {{Parameter|fileNumber}} indicates the file or list of file numbers to close. When not specified, all open files are closed.
''Usage:''
* A file MUST be closed when changing to another file mode.
* CLOSE files when they are no longer needed to save memory.
{{PageDescription}}
* A file must be closed when changing to another file mode.
* [[CLOSE]] files when they are no longer needed, in order to save memory.
* Files cannot be opened in the same [[OPEN]] mode using another number until the first one is closed.
* Use holding variables for each file number returned by [[FREEFILE]] so that the file reference is known.
* Will not return an error if a filenumber is already closed or was never opened. It does not verify that a file was closed.
* [[CLEAR]] will also close all open files.
* CLOSE can also be used to close an open TCP/IP connection using a handle returned by '''QB64'''.
* [[CLEAR]] can be used to close all open files.
* [[CLOSE]] can also be used to close an open TCP/IP connection using a handle returned by '''QB64'''.
{{PageSeeAlso}}

View file

@ -1,8 +1,8 @@
The {{KW|CLS}} statement clears the current write page.
The [[CLS]] statement clears the [[_DEST|current write page]].
{{PageSyntax}}
::: '''CLS''' [{{Parameter|method%}}] [, {{Parameter|BGcolor&}}]
: [[CLS]] [{{Parameter|method%}}] [, {{Parameter|bgColor&}}]
{{Parameters}}
@ -11,19 +11,20 @@ The {{KW|CLS}} statement clears the current write page.
** CLS 0 - Clears the entire page of text and graphics. Print cursor is moved to row 1 at column 1.
** CLS 1 - Clears only the graphics view port. Has no effect for text mode.
** CLS 2 - Clears only the text view port. The print cursor is moved to the top row of the text view port at column 1.
* The {{Parameter|BGcolor&}} specifies the color attribute or palette index to use when clearing the screen in '''QB64 only'''.
* The {{Parameter|bgColor&}} specifies the color attribute or palette index to use when clearing the screen in '''QB64'''.
''Usage:''
** In legacy [[SCREEN]] modes {{Parameter|BGcolor&}} specifies the color attribute of the background.
** For 32-bit graphics mode, {{Parameter|BGcolor&}} specifies the [[_RGB]] or [[_RGBA]] color to use.
* '''32 bit screen surface backgrounds(black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.'''
: Use [[CLS]] or [[_DONTBLEND]] to make a new surface background [[_ALPHA]] 255 or opague.
** If not specified, {{Parameter|BGcolor&}} is assumed to be the current background color. 32 bit backgrounds will change to opaque!
** If {{Parameter|BGColor&}} is not a valid attribute, an [[ERROR Codes|illegal function call]] error will occur!
{{PageDescription}}
* In legacy [[SCREEN]] modes {{Parameter|bgColor&}} specifies the color attribute of the background.
* For 32-bit graphics mode, {{Parameter|bgColor&}} specifies the [[_RGB]] or [[_RGBA]] color to use.
* '''32-bit screen surface backgrounds (black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.'''
** Use [[CLS]] or [[_DONTBLEND]] to make a new surface background [[_ALPHA]] 255 or opaque.
* If not specified, {{Parameter|bgColor&}} is assumed to be the current background color. 32-bit backgrounds will change to opaque.
* If {{Parameter|bgColor&}} is not a valid attribute, an [[ERROR Codes|illegal function call]] error will occur.
* Use [[_PRINTMODE]] to allow the background colors to be visible through the text or the text background.
{{PageExamples}}
''Example 1:'' Printing black text on a white background in QB64.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
@ -39,20 +40,18 @@ K$ = {{Cl|INPUT$}}(1
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|CLS}} , {{Cl|_RGB}}(0, 255, 0)
i = {{Cl|_LOADIMAGE}}('''"QB64.PNG"''') 'see note below examples to get the image
{{Cl|_PUTIMAGE}} (0, 0), i ' places image at upper left corner of window w/o stretching it
i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples to get the image
{{Cl|_PUTIMAGE}} (0, 0), i 'places image at upper left corner of window w/o stretching it
'' ''
{{CodeEnd}} '' ''
: ''Explanation:'' When QB64 loads a 256 color .PNG file containing a transparent color, that color will be treated as transparent when _PUTIMAGE is used to put it onto another image. So actually, you can use a 256-color .PNG file containing transparency information in a 256 color screen mode in QB64. [[CLS]] sets the [[_CLEARCOLOR]] setting using [[_RGB]].
<center>''Note:'' The ''QB64.PNG'' Bee image used can be copied from the top of the [http://www.qb64.net/forum/index.php Main Forum Page]</center>
: ''Explanation:'' When QB64 loads a .PNG file containing a transparent color, that color will be properly treated as transparent when _PUTIMAGE is used to put it onto another image. You can use a .PNG file containing transparency information in a 256-color screen mode in QB64. [[CLS]] sets the [[_CLEARCOLOR]] setting using [[_RGB]].
: ''Note:'' The ''qb64_trans.png'' bee image used can be downloaded from [http://www.qb64.net/qb64_trans.png qb64_trans.png]
{{PageSeeAlso}}
* [[SCREEN]]
* [[_RGB]], [[_RGBA]]
* [[_RGB]], [[_RGBA]], [[_RGB32]], [[_RGBA32]]
* [[VIEW PRINT]], [[VIEW]]
* [[_CLEARCOLOR]]

View file

@ -1,66 +1,45 @@
The {{KW|COLOR}} statement is used to change the color of text and background in some [[SCREEN]] modes.
{| align="Right"
| __TOC__
|}
The [[COLOR]] statement is used to change the foreground and background colors for printing text.
{{PageSyntax}}
:{{KW|COLOR}} [{{Parameter|foreground%}}][, {{Parameter|background%}}]
: [[COLOR]] [{{Parameter|foreground&}}][, {{Parameter|background&}}]
* ''Background'' colors are available in SCREEN modes 0, 1, 7, 8 and 9 only.
{{PageDescription}}
* {{Parameter|background&}} colors are available in all QB64 color SCREEN modes.
* [[SCREEN]] mode 10 has only 3 white foreground attributes including flashing.
* [[SCREEN]] modes 12 and 13 can use the foreground parameter only! Background color 0 can be changed using [[OUT]].
* '''[[SCREEN]] modes 2 and 11 cannot use the COLOR keyword as they are monochrome with white foreground!'''
* An [[ERROR Codes|illegal function error]] will occur if a background color is used in other screen modes!
* To change the ''background'' color only, use a comma and the color. EX: COLOR ,background%
* In '''GW-Basic''' a third border color parameter could be used while in SCREEN 0. The third argument can still be passed in SCREEN 0. Using the third argument in other screen modes will give "Illegal Function Call" Error or will '''crash''' without error in 32-bit screens.
* To change the {{Parameter|background&}} color only, use a comma and the desired color. Ex: [[COLOR]] , {{Parameter|background&}}
* Graphic drawing statements like [[PSET]], [[PRESET]], [[LINE]], etc, also use the colors set by the [[COLOR]] statement if no color is passed when they are called.
==Screen Mode Attributes==
* '''SCREEN 0''' ''background'' colors 0 to 7 can be changed each text character without affecting other text. Use {{KW|CLS}} after a background color statement to create a fullscreen background color. 64 [[DAC]] hues with 16 high intensity blinking foreground (16 to 31) color attributes. QBasic windows will not flash in a window in NT, XP, VISTA or 7 (will flash in '''QB64'''). See example 7 below for more SCREEN 0 background colors.
* '''SCREEN 0''' {{Parameter|background&}} colors 0 to 7 can be changed each text character without affecting other text. Use [[CLS]] after a background color statement to create a fullscreen background color. 64 [[DAC]] hues with 16 high intensity blinking foreground (16 to 31) color attributes. See [[_BLINK]].
** See example 7 below for more SCREEN 0 background colors.
* '''SCREEN 1''' has '''4 background color attributes''': 0 = black, 1 = blue, 2 = green, 3 = grey. White foreground color only.
* '''SCREEN 2''' is '''monochrome''' with white forecolor and black background. '''Cannot use the COLOR statement!'''
* '''SCREEN 7''' can use 16 ([[DAC]]) colors with background colors. RGB settings can be changed in colors 0 to 7 using {{KW|OUT}}.
* '''SCREEN 2''' is '''monochrome''' with white forecolor and black background.
* '''SCREEN 7''' can use 16 ([[DAC]]) colors with background colors. RGB settings can be changed in colors 0 to 7 using [[_PALETTECOLOR]].
* '''SCREEN 8''' has 16 color attributes with 16 background colors.
* '''SCREEN 9''' can use up to 64 [[DAC]] color hues in 16 color attributes with background colors assigned to attribute 0 with a {{KW|PALETTE}} swap. RGB settings can be changed in colors 0 to 5 and 7 using {{KW|OUT}}.
* '''SCREEN 9''' can use up to 64 [[DAC]] color hues in 16 color attributes with background colors assigned to attribute 0 with a [[_PALETTECOLOR]] swap. RGB settings can be changed in colors 0 to 5 and 7 using [[_PALETTECOLOR]].
* '''SCREEN 10''' has '''only 4 color attributes''' with black background. COLOR 0 = black, 1 = grey, 2 = flash white and 3 = bright white.
* '''SCREEN 11''' is '''monochrome''' with white forecolor and a black background, '''Cannot use the COLOR statement!'''
* '''SCREEN 12''' can use 16 color attributes with a black background. 256K possible RGB color hues.
* '''SCREEN 11''' is '''monochrome''' with white forecolor and a black background.
* '''SCREEN 12''' can use 16 color attributes with a black background. 256K possible RGB color hues. Background colors can be used with QB64.
* '''SCREEN 13''' can use 256 color attributes with a black background. 256K possible RGB hues.
* [[DAC]] screens 0, 7 and 9 color changes are limited in '''Qbasic ONLY'''!
* [[PALETTE]] swaps can be made in SCREEN 7 and 9 only. Those screens were [[DAC]] screen modes in Qbasic.
* [[PALETTE]] swaps can be made in SCREEN 7 and 9 only. Those screens were [[DAC]] screen modes in QBasic.
* [[_DEST]] can be used to set the destination page or image to color using '''QB64'''.
* [[_DEFAULTCOLOR]] returns the current color being used on an image or screen page handle.
<center>'''24/32 Bit Colors using QB64'''</center>
* Pixel color intensities for Red, Green, Blue and Alpha range from 0 to 255 when used with [[_RGB]], [[_RGBA]], [[_RGB32]] and [[RGBA32]].
* Combined RGB function values returned are [[LONG]] values! '''Blue intensity values may be cut off using [[SINGLE]] values!'''
===24/32-Bit colors using QB64===
* Pixel color intensities for red, green, blue and alpha range from 0 to 255 when used with [[_RGB]], [[_RGBA]], [[_RGB32]] and [[RGBA32]].
* Combined RGB function values returned are [[LONG]] values. '''Blue intensity values may be cut off using [[SINGLE]] variables.'''
* [[_ALPHA]] transparency values can range from 0 as transparent up to 255 which is fully opaque.
* [[_CLEARCOLOR]] can also be used to set a color as transparent.
* Colors can be mixed by using [[_BLEND]](default) in 32 bit screen modes ONLY. [[_DONTBLEND]] disables blending.
* '''NOTE: Default 32 bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0)! Use [[CLS]] to make the black opaque!'''
* Colors can be mixed by using [[_BLEND]] (default) in 32-bit screen modes. [[_DONTBLEND]] disables blending.
* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.'''
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==RGB Palette Intensities==
RGB intensity values can be converted to Hexadecimal values to create the [[LONG]] [[_PALETTECOLOR]] value in non-32 bit screens:
RGB intensity values can be converted to hexadecimal values to create the [[LONG]] [[_PALETTECOLOR]] value in non-32-bit screens:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
alpha$ = "FF" 'solid alpha colors only
@ -101,46 +80,28 @@ alpha$ = "FF" 'solid alpha colors only
{{text|COLOR 14 <nowiki>=</nowiki> &HFFFCFC54 FC FC 54|#FCFC54}}
{{text|COLOR 15 <nowiki>=</nowiki> &HFFFCFCFC FC FC FC|#FCFCFC}}
{{OutputEnd}}
:''Explanation:'' The RGB intensity values are multiplied by 4 to get the [[_RGB]] intensity values as [[HEX$|Hexadecimal]] values. The individual 2 digit [[HEX$]] intensity values can be added to "&HFF" to make up the 32 bit hexadecimal string value necessary for [[VAL]] to return to [[_PALETTECOLOR]]. The statement is only included in the example to show how that can be done with any 32 bit color value.
<center>'''Note:''' Black has a blue hex value of 50 due to the [[OUT]] background color setting which makes it dark blue.</center>
:''Explanation:'' The RGB intensity values are multiplied by 4 to get the [[_RGB]] intensity values as [[HEX$|hexadecimal]] values. The individual 2 digit [[HEX$]] intensity values can be added to "&HFF" to make up the 32-bit hexadecimal string value necessary for [[VAL]] to return to [[_PALETTECOLOR]]. The statement is only included in the example to show how that can be done with any 32-bit color value.
:'''Note:''' Black has a blue hex value of 50 due to the [[OUT]] background color setting which makes it dark blue.
<center>'''Reading and setting Color Port intensities using [[INP]] and [[OUT]]'''</center>
===Reading and setting color port intensities using [[INP]] and [[OUT]]===
* Legacy code may use [[INP]] and [[OUT]] to read or set color port intensities. '''QB64''' emulates VGA memory to maintain compatibility.
* The same can be achieved using [[_PALETTECOLOR]] ('''recommended practice''').
::::::::'''{{text|OUT &H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:::::::::'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
:'''{{text|OUT &H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
::::::::'''{{text|OUT &H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:::::::::'''{{text|OUT &H3C9, color_intensity|green}}''' 'writes new intensity setting
:'''{{text|OUT &H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:'''{{text|OUT &H3C9, color_intensity|green}}''' 'writes new intensity setting
* After every 3 reads or writes, changes to next higher color attribute. Loops can be used to set more than one attribute's intensities.
* Color port setting of Red, Green and Blue intensities can be done in ascending order.
* Color port attribute intensity values range from 0 to 63(1/4 of the 32 bit values) only in Qbasic 4 and 8 bit screen modes.
<center>'''Hexadecimal 32 bit colors can be set in 16 or 256 color screen modes with [[_PALETTECOLOR]]'''</center>
''Example:'' Changing light gray text in [[SCREEN]] 0 to a 32 bit custom color using a [[LONG]] HTML hexadecimal value:
{{CodeStart}} '' ''
{{Cl|COLOR}} 7
{{Cl|PRINT}} "Color 7 is gray"
K$ = {{Cl|INPUT$}}(1)
{{Cl|_PALETTECOLOR}} 7, {{Cl|&H}}FFDAA520 ' FF alpha makes the color translucent
{{Cl|PRINT}} "Color 7 is now Goldenrod in {{Cl|SCREEN}} 0! '' ''
{{CodeEnd}}
{{OutputStart}}
{{text|Color 7 is gray|#A8A8A8}}
{{text|Color 7 is now Goldenrod in SCREEN 0!|#DAA520}}
{{OutputEnd}}
: ''Explanation:'' [[_RGB32]] could be used to make custom 32 bit colors or HTML values could be used after &HFF for solid colors.
''See also:'' [[HEX$ 32 Bit Values]] to learn more about hexadecimal color values.
* Color port setting of red, green and blue intensities can be done in ascending order.
* Color port attribute intensity values range from 0 to 63 (1/4 of the 32-bit values) in QBasic's legacy 4 and 8 bit screen modes.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Examples:==
{{PageExamples}}
''Example 1:'' Reading the default RGB color settings of color attribute 15.
{{CodeStart}} '' ''
{{Cl|OUT}} &H3C7, 15
@ -227,28 +188,34 @@ text$ = "HelloWorld"
: ''Explanation:''Semicolon(;) means that the next PRINT happens on the same line, we don't want that when it comes to position 5 so when it is at position 5 the next PRINT will move to the next line (when it isn't at position 5 we want it to continue printing the letter side-by-side on the same line though).
''Example 7:'' Since SCREEN 0 only uses background colors 0 to 7 by default, use [[OUT]] to change color intensities of color 0 in QB64 only.
''Example 7:'' Since SCREEN 0 only uses background colors 0 to 7 by default, use [[_PALETTECOLOR]] to change color intensities of color 0.
{{CodeStart}} '' ''
{{Cl|OUT}} {{Cl|&H}}3C8, 0 'change color 0 intensities
{{Cl|OUT}} {{Cl|&H}}3C9, 63
{{Cl|OUT}} {{Cl|&H}}3C9, 63
{{Cl|OUT}} {{Cl|&H}}3C9, 63
{{Cl|OUT}} {{Cl|&H}}3C8, 8 'change color 8 intensities
{{Cl|OUT}} {{Cl|&H}}3C9, 0
{{Cl|OUT}} {{Cl|&H}}3C9, 0
{{Cl|OUT}} {{Cl|&H}}3C9, 0
{{Cl|_PALETTECOLOR}} 0, _RGB32(255, 255, 255) 'change color 0 intensity
{{Cl|_PALETTECOLOR}} 8, _RGB32(0, 0, 0) 'change color 8 intensity
{{Cl|COLOR}} 8: {{Cl|PRINT}} "Black on bright white!" '' ''
{{CodeEnd}}
{{WhiteStart}}'''{{text|Black on bright white!|#000000}}'''
{{WhiteEnd}}
----
: ''Explanation:'' Since QB64 does not use [[DAC]] [[SCREEN]] 0 limitations, changing color intensities for custom background colors is possible.
: ''Explanation:'' Since QB64 does not have [[DAC]] [[SCREEN]] 0 limitations, changing color intensities for custom background colors is possible.
''Example 8:'' Changing light gray text in [[SCREEN]] 0 to a 32 bit custom color using a [[LONG]] HTML hexadecimal value:
{{CodeStart}} '' ''
{{Cl|COLOR}} 7
{{Cl|PRINT}} "Color 7 is gray"
K$ = {{Cl|INPUT$}}(1)
{{Cl|_PALETTECOLOR}} 7, {{Cl|&H}}FFDAA520 ' FF alpha makes the color translucent
{{Cl|PRINT}} "Color 7 is now Goldenrod in {{Cl|SCREEN}} 0! '' ''
{{CodeEnd}}
{{OutputStart}}
{{text|Color 7 is gray|#A8A8A8}}
{{text|Color 7 is now Goldenrod in SCREEN 0!|#DAA520}}
{{OutputEnd}}
: ''Explanation:'' [[_RGB32]] could be used to make custom 32 bit colors or HTML values could be used after &HFF for solid colors.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==References:==
{{PageSeeAlso}}
* [[_RGB]], [[_RGBA]], [[_RGB32]], [[RGBA32]].
@ -258,6 +225,7 @@ text$ = "HelloWorld"
* [[PRINT]], [[LOCATE]], [[SCREEN]]
* [[POINT]], [[SCREEN (function)]]
* [[OUT]], [[INP]], [[PALETTE]]
* [[_BLINK]]
* [[_DEFAULTCOLOR]]
* [[_BACKGROUNDCOLOR]]
* [[_PALETTECOLOR]]

View file

@ -1,20 +1,18 @@
The '''COMMAND$''' [[STRING]] function returns the spaced [[DOS]] command line argument(s) passed when a program is run.
The '''COMMAND$''' function returns the command line argument(s) passed when a program is run.
{{PageSyntax}}
::: option$ = [[COMMAND$]][(count%)]
: {{Parameter|commandLine$}} = [[COMMAND$]][(count%)]
* Useful when the programmer wants to send specific program options to the command line for later use by the called program.
* The [[STRING]] return value is any '''spaced quoted or unquoted''' parameter(s) following the filename in a [[RUN]] or command line statement.
* '''QB64''' does not '''require or return all [[UCASE$|uppercase]]''' values so keep that fact in mind when checking parameters passed!
* In '''QB64 only''', COMMAND$ can work as an array to return specific elements passed to the command line. COMMAND$(2) would return the '''spaced''' second parameter passed at the command line. This can be used on modern operating systems to successfully retrieve file names and arguments which contain spaces properly. (versions after May 20, 2015)
* Use the [[_COMMANDCOUNT]] function to find the number of spaced parameters passed to a program via the command line. (versions after May 20, 2015) '''{{text|See ''Example 2''|green}}'''.
* Reading the spaced command options in the '''COMMAND$(i)''' array in a loop can also be done and reading a COMMAND$ without parameters is also possible. (versions after May 20, 2015) '''{{text|See ''Example 3''|green}}'''.
* COMMAND$ was '''not available in QuickBasic versions below 4.0''' and returned [[UCASE$|uppercase]] [[STRING]] parameters no matter what case they were sent originally.
{{PageDescription}}
* The [[STRING]] return value is anything typed after a program's executable file name in command line (or using the [[RUN]] statement).
* Unlike QuickBASIC, '''QB64''' does not return all [[UCASE$|uppercase]] values so keep that in mind when checking parameters.
* In '''QB64''', COMMAND$ works as an array to return specific elements passed to the command line. COMMAND$(2) would return the second parameter passed at the command line. Arguments can contain spaces if they are passed inside quotation marks. This can be used to properly retrieve file names and arguments which contain spaces.
* Use the [[_COMMANDCOUNT]] function to find the number of parameters passed to a program via the command line. See ''Example 2'' below.
{{PageExamples}}
''Example 1:'' Compile both programs. ProgramA [[RUN]]s ProgramB with a parameter passed following the filename:
{{CodeStart}}
{{Cl|LOCATE}} 12, 36: {{Cl|PRINT}} "ProgramA"
@ -28,7 +26,7 @@ K$ = {{Cl|INPUT$}}(1)
: ''ProgramB'' checks for fullscreen parameter pass in QB64 and goes full screen.
{{CodeStart}} '' ''
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'QB64 only as QB4.5 will always return upper case
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'UCASE$ is needed in QB64 only, as QB4.5 will always return upper case
{{Cl|LOCATE}} 20, 33: {{Cl|PRINT}} "Parameter = " + parameter$
{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(parameter$, 2) = "FS" {{Cl|THEN}} {{Cl|_FULLSCREEN}} 'parameter changes to full screen
@ -55,7 +53,7 @@ a data file
: ''Explanation: If we start ''ThisProgram.exe'' with the command line '''ThisProgram -l "a data file"''', COMMAND$ will return a single string of "-1 a data file" which might be hard to process and interpret properly, but COMMAND$(1) would return "-l" and COMMAND$(2) would return the quoted "a data file" option as separate entries for easier parsing and processing.
''Example 3:'' As part of the command array upgrade, you can also just read the array to see how many commands were sent:
''Example 3:'' As part of the command array syntax, you can also just read the array to see how many commands were sent (or simply check [[_COMMANDCOUNT]]):
{{CodeStart}}DO
count = count + 1
cmd$ = {{Cl|COMMAND$}}(count)
@ -64,10 +62,9 @@ a data file
{{Cl|LOOP}} '' ''
count = count - 1 'save the number of parameters sent to this program when run
{{CodeEnd}}
:'''Note:''' When using this command [[DO]] loop read procedure, the spaced commands sent must not be empty strings as the count will end!
''See also:''
{{PageSeeAlso}}
* [[SHELL]], [[RUN]]
* [[UCASE$]], [[LCASE$]]
* [[_COMMANDCOUNT]]

View file

@ -1,31 +1,25 @@
'''COMMON''' shares common variable values with other Linked or [[CHAIN]]ed modules.
[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules.
==Legacy support==
* The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 [[COMMON]] has been implemented so that that older code can still be compiled, though '''it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.'''
::::::''Syntax:'' COMMON [SHARED] [/blockname/] variablelist
{{PageSyntax}}
: [[COMMON]] [SHARED] variableList
{{PageDescription}}
* COMMON must be called before any executable statements.
* [[SHARED]] makes the variables shared within [[SUB]] and [[FUNCTION]] procedures within that module.
* /blockname/ gives the ability to name a block of variables (ex. COMMON /thename/ a, b, c), this name can later be referenced in the module to only give access to those variables. As such, many COMMON statements can be issued with different names to be shared in different modules.
* Variablelist is the list of common variables made available separated by commas.
* variableList is the list of common variables made available separated by commas.
* Remember to keep the variable type ''order'' the same in all modules, as the variables names don't matter.
* [[COMMON SHARED]] is most commonly used to share the variables with subs and functions of that module.
* In Qbasic, Common variables can only be passed by [[CHAIN]] using compiled modules if BRUN45.EXE is included with the program.
* Linked files are compiled first and linked with LINK.EXE in QB. '''QB64''' cannot link files presently!
* '''Note: Values assigned to shared variables used as procedure call parameters will not be passed to other procedures! The shared variable value MUST be assigned INSIDE of the [[SUB]] or [[FUNCTION]] procedure to be passed!'''
* '''Note: Values assigned to shared variables used as procedure call parameters will not be passed to other procedures. The shared variable value must be assigned inside of the [[SUB]] or [[FUNCTION]] procedure to be passed.'''
''See also:''
{{PageSeeAlso}}
* [[COMMON SHARED]], [[CHAIN]]
* [[DIM]], [[REDIM]], [[SHARED]]
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
{{PageNavigation}}

View file

@ -1,27 +1,29 @@
The {{KW|CONST}} statement globally defines one or more named numeric or string values which will not change while a program is running.
The [[CONST]] statement globally defines one or more named numeric or string values which will not change while the program is running.
{{PageSyntax}}
: '''CONST {{Parameter|constantName}} = {{Parameter|value}}'''[, ...]
: [[CONST]] {{Parameter|constantName}} = {{Parameter|value}}[, ...]
{{Parameters}}
* {{Parameter|constantName}} is the constant name or list of names assigned by the programmer.
* {{Parameter|value}} is the value to initialize the global constant which cannot change once defined:
* {{Parameter|value}} is the value to initialize the global constant which cannot change once defined.
** If {{Parameter|constantName}} specifies a numeric type, {{Parameter|value}} must be a numeric expression containing literals and other constants.
** If {{Parameter|constantName}} specifies a string type, the {{Parameter|value}} must be a literal value.
''Usage:''
* The {{Parameter|constantName}} does not have to include a type suffix! The datatype can be determined by the {{Parameter|value}}.
* Constant values cannot use a variable, [[SUB]] or [[FUNCTION]] return value when defined.
* Constants cannot be re-assigned values. They retain the same value throughout all of the program procedures.
{{PageDescription}}
* The {{Parameter|constantName}} does not have to include a type suffix. The datatype is automatically infered by the compiler using the {{Parameter|value}}.
* Constant values cannot reference a variable, [[SUB]] or [[FUNCTION]] return values when defined.
** The exception to the above are color functions [[_RGB32]] and [[_RGBA32]], which can be used in a CONST statement. See ''Example 2'' below.
* Constants cannot be reassigned values. They retain the same value throughout all of the program procedures.
* Constants defined in module-level code have [[SHARED|shared]] scope, so they can also be used in [[SUB]] or [[FUNCTION]] procedures.
* Constants defined in {{KW|SUB}} or {{KW|FUNCTION}} procedures are local to those procedures.
* Constants defined in [[SUB]] or [[FUNCTION]] procedures are local to those procedures.
* [[CLEAR]] will not affect or change constant values.
''Example:'' Display the circumference and area of circles:
{{PageExamples}}
''Example 1:'' Display the circumference and area of circles:
{{CodeStart}}' Declare a numeric constant approximately equal to the ratio of a circle's
' circumference to its diameter:
{{Cl|CONST}} PI = 3.141593
@ -48,12 +50,21 @@ The area of the circle is 47882.23
Enter the radius of a circle or zero to quit? ''0''
{{OutputEnd}}
: ''Explanation:'' PI cannot change as it is a mathematical constant so it is fitting to define it as a constant. Trying to change PI will result in a programming error.
: ''Explanation:'' PI cannot change as it is a mathematical constant so it is fitting to define it as a constant. Trying to change PI will result in a calculation error.
''Example 2'': Using _RGB32 to set a constant's value.
{{CodeStart}} '' ''
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
{{PageSeeAlso}}
* {{KW|DIM}}, {{KW|SHARED}}
* {{KW|STATIC}}, {{KW|COMMON}}
* [[DIM]], [[SHARED]]
* [[STATIC]], [[COMMON]]
* [[_PI]], [[_RGB32]], [[_RGBA32]]
* [http://doc.pcsoft.fr/en-US/?6510001 Windows 32 API constant values]

View file

@ -1,23 +1,23 @@
The '''COS''' function returns the horizontal component or the cosine of an angle measured in radians.
The [[COS]] function returns the horizontal component or the cosine of an angle measured in radians.
{{PageSyntax}}
::: value! = '''COS('''''radian_angle!''''')'''
: {{Parameter|value!}} = [[COS]]({{Parameter|radianAngle!}})
{{Parameters}}
* The ''radian_angle'' must be measured in radians.
* The {{Parameter|radianAngle!}} must be measured in radians.
{{PageDescription}}
* To convert from degrees to radians, multiply degrees * π/180.
* To convert from degrees to radians, multiply degrees * π / 180.
* [[COS]]INE is the horizontal component of a unit vector in the direction theta (θ).
* COS(x) can be calculated in either [[SINGLE]] or [[DOUBLE]] precision depending on its argument.
::: COS(4) = -.6536436 ...... COS(4#) = -.6536436208636119
''Example 1:'' Converting degree angles to radians for Qbasic's trig functions and drawing the line at the angle.
{{PageExamples}}
''Example 1:'' Converting degree angles to radians for QBasic's trig functions and drawing the line at the angle.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
PI = 4 * {{Cl|ATN}}(1)
@ -94,7 +94,7 @@ DEGREES% = RADIANS * 180 / PI = 45
{{small|Code by Ben}}
''See also:''
{{PageSeeAlso}}
* [[_PI]] {{text|(QB64 function)}}
* [[SIN]] {{text|(sine)}}
* [[ATN]] {{text|(arctangent)}}

View file

@ -1,21 +1,20 @@
'''CSNG'''
To converts a numerical value to the closest [[SINGLE]]-precision number.
[[CSNG]] converts a numerical value to the closest [[SINGLE]]-precision number.
{{PageSyntax}}
:: singlevalue = '''CSNG('''''expression''''')'''
: {{Parameter|singleValue!}} = [[CSNG]]({{Parameter|expression}})
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Returns the closest [[SINGLE]] decimal point value
* Returns the closest [[SINGLE]] decimal point value.
* Also used to define a value as [[SINGLE]]-precision up to 7 decimals.
''Example:''
{{PageExamples}}
{{CodeStart}}
A# = 975.3421222#
PRINT A#, CSNG(A#)

View file

@ -1,16 +1,20 @@
The '''CSRLIN''' function returns the current text row position of the [[PRINT]] cursor.
The [[CSRLIN]] function returns the current text row position of the [[PRINT]] cursor.
::::::::{{PageSyntax}} row% = CSRLIN
{{PageSyntax}}
: {{Parameter|row%}} = [[CSRLIN]]
{{PageDescription}}
* The value returned is within the range of 1 to the current number of rows in the [[SCREEN]] mode used.
** In [[SCREEN]] 0 (text mode), the [[_HEIGHT]] function returns the number of text rows.
** In graphic modes, the number of available text rows can be calculated by dividing [[_HEIGHT]] (measured in pixels in graphic modes) by [[_FONTHEIGHT]]: '''''totalRows%'' = _HEIGHT / _FONTHEIGHT'''
* In screen modes that support page flipping, the [[CSRLIN]] function returns the vertical coordinate of the cursor on the active page.
* x = [[POS]](0) returns the column location of the cursor.
{{PageExamples}}
''Example:'' A semicolon stops the print cursor immediately after the print.
{{CodeStart}} '' ''
LOCATE 5, 5: PRINT "HELLO ";
@ -35,10 +39,10 @@ The '''CSRLIN''' function returns the current text row position of the [[PRINT]]
{{OutputEnd}}
:''Explanation:'' "HELLO " is printed and the semicolon stops the cursor immediately after the text. The '''CSRLIN''' variable records the current print cursor's text row in Y. The [[POS]] function records the current print cursor's text column in X. The second [[PRINT]] statement displays the comment "WORLD" on the 10th line of the screen. The last [[LOCATE]] statement restores the position of the cursor to the original line and column immediately after the first print.
:''Explanation:'' "HELLO " is printed and the semicolon stops the cursor immediately after the text. The [[CSRLIN]] variable records the current print cursor's text row in Y. The [[POS]] function records the current print cursor's text column in X. The second [[PRINT]] statement displays the comment "WORLD" on the 10th line of the screen. The last [[LOCATE]] statement restores the position of the cursor to the original line and column immediately after the first print.
''See also:''
{{PageSeeAlso}}
* [[SCREEN]], [[LOCATE]], [[POS]]
* [[_PRINTSTRING]] (graphic print)

View file

@ -1,20 +1,19 @@
The '''CVD''' function converts 8 byte [[GET]] or [[MKD$]] [[STRING]] values to [[DOUBLE]] numeric values.
The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read from a file) to [[DOUBLE]] numeric values.
::::::''Syntax:'' CVD(''8-byte string'')
{{PageSyntax}}
: {{Parameter|result#}} = [[CVD]]({{Parameter|stringData$}})
* The 8 byte string value was created by [[MKD$]] or [[PUT]].
* Numeric values read from a [[RANDOM]]-access or [[BINARY]] file must be converted from [[ASCII]] string characters back into numbers if they are to be arithmetically manipulated.
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* Variables of numerical types are also encoded when [[PUT]] to a [[RANDOM]] or [[BINARY]]-access file.
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken.
* [[CVD]] converts an 8-byte string created by [[MKD$]] to a [[DOUBLE]]-precision numerical value.
* [[CVS]] converts a 4-byte string created by [[MKS$]] to a [[SINGLE]]-precision numerical value.
* [[CVI]] converts a 2-byte string created by [[MKI$]] to an [[INTEGER]] numerical value.
* [[CVL]] converts a 4 byte string created by [[MKL$]] to a [[LONG]] integer numerical value.
* CV functions can only be used to convert values from [[MK$]] string function values or data from [[BINARY]] files!
''Examples:''
{{PageExamples}}
''Example 1:'' Reading an 8-byte encoded string n$ from a file and obtaining the decoded [[DOUBLE]] value:
{{CodeStart}} '' ''
{{Cl|FIELD}} #1, 8 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
@ -22,13 +21,29 @@ Y# = {{Cl|CVD}}(N$) '' ''
{{CodeEnd}}
: ''Explanation:'' Reads a field from file #1, and converts the first eight bytes (N$) into an double-precision number assigned to the variable Y#.
:Since a double-precision number can contain as many as 15 ASCII characters (fifteen bytes), writing a file using [[MKD$]] conversion, and reading with the [[CVD]] conversion, as many as 7 bytes per number recorded are saved on the storage medium.
''Example 2:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKD$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKD$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVD:"; {{Cl|CVD}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
Value of a# encoded using MKD$: ñåxýâ╠‗@
The string above, decoded using CVD: 77000.24523213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 15 ASCII characters (fifteen bytes), writing to a file using [[MKD$]] conversion, and then reading back with the [[CVD]] conversion can save up to 7 bytes of storage space.
''See also:''
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]]
* [[CVI]], [[CVS]], [[CVL]]
{{PageSeeAlso}}
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVL]], [[CVSMBF]], [[CVDMBF]]
* [[_CV]], [[_MK$]]

View file

@ -1,18 +1,39 @@
The '''CVDMBF''' function converts a 8-byte string containing a Microsoft Binary format number to a double precision IEEE-format number.
The [[CVDMBF]] function decodes an 8-byte [[STRING]] generated by [[MKDMBF$]] (or read from a file) to [[DOUBLE]] numeric values.
::::''Syntax: value = CVDMBF(string_value)
{{PageSyntax}}
: {{Parameter|result#}} = [[CVDMBF]]({{Parameter|stringData$}})
* CVDMBF reads [[RANDOM]]-access or [[BINARY]] files containing [[MKDMBF$]] [[STRING|string]] values stored in the Microsoft Binary format.
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKDMBF$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKDMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVDMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
''See also:''
Value of a# encoded using MKDmbf$: 5─c▼d▬æ
* [[CVSMBF]]
The string above, decoded using CVDMBF: 77000.24523213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 15 ASCII characters (fifteen bytes), writing to a file using [[MKDMBF$]] conversion, and then reading back with the [[CVDMBF]] conversion can save up to 7 bytes of storage space.
* [[MKDMBF$]], [[MKSMBF$]]
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,18 +1,18 @@
The '''CVI''' function converts 2 byte [[GET]] or [[MKI$]] [[STRING]] values to [[INTEGER]] numeric values.
The [[CVI]] function decodes a 2-byte [[STRING]] generated by [[MKI$]] (or read from a file) to [[INTEGER]] numeric values.
::::::''Syntax:'' CVI(''2-byte string'')
{{PageSyntax}}
: {{Parameter|result%}} = [[CVI]]({{Parameter|stringData$}})
* Numeric values read from a [[RANDOM]]-access or [[BINARY]] disk file must be converted from [[ASCII]] string characters back into numbers if they are to be arithmetically manipulated.
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[INTEGER]] values can range from -32768 to 32767.
* [[CVI]] converts a 2-byte string created by [[MKI$]] to an [[INTEGER]] numerical value.
* [[CVL]] converts a 4 byte string created by [[MKL$]] to a [[LONG]] integer numerical value.
* [[CVS]] converts a 4-byte string created by [[MKS$]] to a [[SINGLE]]-precision numerical value.
* [[CVD]] converts an 8-byte string created by [[MKD$]] to a [[DOUBLE]]-precision numerical value.
* CV functions can only be used to convert values from [[MK$]] string function values or data from [[BINARY]] files!
* Doesn't return [[_UNSIGNED]] values.
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{Cl|FIELD}} #1, 2 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
@ -20,13 +20,12 @@ The '''CVI''' function converts 2 byte [[GET]] or [[MKI$]] [[STRING]] values to
Y = {{Cl|CVI}}(N$) '' ''
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first two bytes (N$) into an integer number assigned to the variable Y.
:Since an integer number can contain as many as five ASCII characters (five bytes), writing a file using [[MKI$]] conversion, and reading with the CVI conversion, as many as three bytes per number recorded are saved on the storage medium.
:Since the representation of an integer number can use up to 5 ASCII characters (five bytes), writing to a file using [[MKI$]] conversion, and then reading back with the [[CVI]] conversion can save up to 3 bytes of storage space.
''Example 2:'' How CVI converts the ASCII code values created by the MKI$ function.
{{CodeStart}}
{{Cl|SCREEN (statement)|SCREEN}} 12 '_PRINTSTRING requires a graphic screen mode
{{Cl|SCREEN (statement)|SCREEN}} 12
{{Cl|DIM}} Q {{Cl|AS}} {{Cl|STRING}} * 1
Q = {{Cl|CHR$}}(34)
' create Print using templates to align the values returned
@ -54,15 +53,13 @@ tmp4$ = " CVI Total = ##### "
{{Cl|SYSTEM}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired! "90" = 12345.
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired. ("90" gets decoded to 12345).
''See also:''
* [[MKI$]], [[ASC]]
* [[MKL$]], [[CVL]]
* [[MKS$]], [[CVS]]
* [[MKD$]], [[CVD]]
* [[Bitmaps]]
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,18 +1,18 @@
The '''CVL''' function converts 4 byte [[GET]] or [[MKL$]] [[STRING]] values to [[LONG]] numeric values.
The [[CVL]] function decodes a 4-byte [[STRING]] generated by [[MKL$]] (or read from a file) to [[LONG]] numeric values.
::::::''Syntax:'' CVL(''4-byte string'')
{{PageSyntax}}
: {{Parameter|result&}} = [[CVL]]({{Parameter|stringData$}})
* Numeric values read from a [[RANDOM]]-access or [[BINARY]] disk file must be converted from [[ASCII]] string characters back into numbers if they are to be arithmetically manipulated.
* [[LONG]] Integer values can be from -2147483648 to 2147483647.
* [[CVL]] converts a 4 byte string created by [[MKL$]] to a [[LONG]] integer numerical value.
* [[CVI]] converts a 2-byte string created by [[MKI$]] to an [[INTEGER]] numerical value.
* [[CVS]] converts a 4-byte string created by [[MKS$]] to a [[SINGLE]]-precision numerical value.
* [[CVD]] converts an 8-byte string created by [[MKD$]] to a [[DOUBLE]]-precision numerical value.
* CV functions can only be used to convert values from [[MK$]] string function values or data from [[BINARY]] files!
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[LONG]] values can range from -2147483648 to 2147483647.
* Doesn't return [[_UNSIGNED]] values.
{{PageExamples}}
''Example 1: 4 byte [[ASCII]] character strings show how CVL multipliers convert [[MKL$]] values into a 4 byte [[LONG]] value.
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(1) + {{Cl|STRING$}}(3, 0)) '{{Cl|ASC}}(CHR$(1)) * 1 = 1
@ -30,15 +30,13 @@ Y& = {{Cl|CVL}}(N$) '' ''
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first four bytes (N$) into a long integer value assigned to the variable Y&.
:Since a long number can contain as many as ten ASCII characters (ten bytes), writing a file using [[MKL$]] conversion, and reading with the CVL conversion, as many as six bytes per number recorded are saved on the storage medium.
:Since the representation of a long number can use up to 10 ASCII characters (ten bytes), writing to a file using [[MKL$]] conversion, and then reading back with the [[CVL]] conversion can save up to 6 bytes of storage space.
''See also:''
* [[MKL$]], [[MKI$]], [[MKS$]], [[MKD$]]
* [[CVI]], [[CVS]], [[CVD]]
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVDMBF]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
* [[Bitmaps]]
{{PageNavigation}}

View file

@ -1,35 +1,37 @@
The '''CVS''' function converts 2 byte [[GET]] or [[MKS$]] [[STRING]] values to [[SINGLE]] floating decimal numerical values.
The [[CVS]] function decodes a 4-byte [[STRING]] generated by [[MKS$]] (or read from a file) to [[SINGLE]] numeric values.
::::::''Syntax:'' CVS(''2-byte string'')
{{PageSyntax}}
: {{Parameter|result!}} = [[CVS]]({{Parameter|stringData$}})
* Numeric values read in from a [[RANDOM]]-access or [[BINARY]] disk file must be converted from [[ASCII]] string characters back into numbers if they are to be arithmetically manipulated.
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[SINGLE]] values can range up to 7 decimal point digits. Decimal point accuracy depends on whole value places taken.
* [[CVS]] converts a 4-byte string created by [[MKS$]] to a [[SINGLE]]-precision numerical value.
* [[CVD]] converts an 8-byte string created by [[MKD$]] to a [[DOUBLE]]-precision numerical value.
* [[CVI]] converts a 2-byte string created by [[MKI$]] to an [[INTEGER]] numerical value.
* [[CVL]] converts a 4 byte string created by [[MKL$]] to a [[LONG]] integer numerical value.
* CV functions can only be used to convert values from [[MK$]] string function values or data from [[BINARY]] files!
''Examples:''
{{CodeStart}} '' ''
{{Cl|FIELD}} #1, 4 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y = {{Cl|CVS}}(N$) '' ''
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKDMBF$}}(a!)
{{Cl|PRINT}} "Value of a# encoded using MKS$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVS:"; {{Cl|CVS}}(b$)
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first four bytes (N$) into a single-precision number assigned to the variable Y.
:Since a single-precision number can contain as many as seven ASCII characters (seven bytes), writing a file using [[MKS$]] conversion, and reading with the [[CVS]] conversion, as many as three bytes per number recorded are saved on the storage medium. Even more may be saved if double-precision numbers are required. [[MKD$]] and [[CVD]] conversions would be used in this case.
{{OutputStart}}
Value of a!: 700.2213
Value of a# encoded using MKS: *♫/D
The string above, decoded using CVS: 700.2213
{{OutputEnd}}
:Since the representation of a single-precision number can use up to 7 ASCII characters (seven bytes), writing to a file using [[MKS$]] conversion, and then reading back with the [[CVS]] conversion can save up to 3 bytes of storage space.
''See also:''
* [[MKS$]], [[MKI$]], [[MKL$]], [[MKD$]]
* [[CVI]], [[CVL]], [[CVD]], [[_CV]]
* [[_MK$]], [[_CV]]
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVD]], [[CVL]], [[CVDMBF]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,18 +1,37 @@
The '''CVSMBF''' function converts a 4-byte string containing a Microsoft Binary format value to a single precision IEEE-format number.
The [[CVDMBF]] function decodes a 4-byte [[STRING]] generated by [[MKSMBF$]] (or read from a file) to [[SINGLE]] numeric values.
''Syntax:'' value! = CVSMBF(string_value)
{{PageSyntax}}
: {{Parameter|result!}} = [[CVSMBF]]({{Parameter|stringData$}})
* CVSMBF read [[RANDOM]]-access or [[BINARY]] files containing numbers stored as [[STRING|strings]] in the Microsoft Binary format.
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[SINGLE]] values can range up to 7 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKSMBF$}}(a!)
{{Cl|PRINT}} "Value of a! encoded using MKSMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVSMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a!: 700.2213
Value of a# encoded using MKSMBF$: *♫/è
The string above, decoded using CVSMBF: 700.2213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 7 ASCII characters (seven bytes), writing to a file using [[MKSMBF$]] conversion, and then reading back with the [[CVSMBF]] conversion can save up to 3 bytes of storage space.
''See also:''
* [[CVDMBF]]
* [[MKDMBF$]], [[MKSMBF$]]
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,24 +1,27 @@
The '''DATA''' statement creates a line of fixed program information separated by commas. The DATA can be READ by the program.
The [[DATA]] statement creates a line of fixed program information separated by commas. The DATA can be later READ by the program at runtime.
''Syntax:'' DATA [value1, value2, ...]
{{PageSyntax}}
: [[DATA]] [value1, value2, ...]
{{PageDescription}}
* DATA is used at the beginning of every data field line with commas separating the values that follow.
* Values can be any '''literal''' [[STRING]] or numerical type. '''Variables cannot be used!'''
* Values can be any '''literal''' [[STRING]] or numerical type. '''Variables cannot be used.'''
* DATA fields can be placed and READ consecutively in the main program code body with or without line labels for [[RESTORE]].
* DATA is best placed after the main program code. '''QB64 DATA can be placed inside a [[SUB]] or [[FUNCTION]] procedures!'''
* [[RESTORE]] will only read the first data field if the DATA is not labeled or RESTORE call uses no label.
* When using multiple DATA fields, label each data field with a line label so that '''each''' data pointer can be reset for multiple reads with [[RESTORE]] ''linelabel''. Otherwise RESTORE will only read the '''first''' data field!
* QB comma separations were flexible to allow column alignments when creating them. QB64 removes spacing between commas.
* [[STRING]] DATA values with end spaces, QB keywords and commas in them '''require''' quotation marks.
* DATA is best placed after the main program code.
** '''QB64''' DATA can be placed inside a [[SUB]] or [[FUNCTION]] procedures.
* [[RESTORE]] will only read the first data field if the DATA is not labeled or no label is specified in a RESTORE call.
* When using multiple DATA fields, label each data field with a line label so that each data pointer can be reset for multiple reads with '''[[RESTORE]] ''linelabel'''''.
* QBasic comma separations were flexible to allow column alignments when creating them. QB64 removes spacing between commas.
* [[STRING]] DATA values with end spaces, QBasic keywords and values that include the comma character must be enclosed in quotation marks.
* DATA fields can only be created by the programmer and cannot be changed by a user or lost.
* Comments after a data line require a colon before the comment.
* If a [[READ]] is past the last data value, an [[ERROR Codes|"Out of Data" error]] will occur! Use end of data markers when necessary!
: Qbasic allowed programmers to add DATA fields anywhere because the [[IDE]] separated the main code from other procedures.
* '''Do not place labeled [[DATA]] fields after [[SUB]] or [[FUNCTION]] procedures! QB64 will FAIL to [[RESTORE]] properly!'''
* If a [[READ]] statement attempts to read past the last data value, an [[ERROR Codes|"Out of Data" error]] will occur. Use end of data markers when necessary.
* '''[[DATA]] fields can be placed after [[SUB]] or [[FUNCTION]] procedures, but line labels are not allowed.'''
{{PageExamples}}
''Example 1:'' Creating two DATA fields that can be [[READ]] repeatedly using [[RESTORE]] with the appropriate line label.
{{CodeStart}} '' ''
{{Cl|RESTORE}} Database2
@ -45,7 +48,7 @@ Database2:
{{OutputEnd}}
''Example 2:'' How to [[RESTORE]] and [[READ]] DATA in a [[SUB]] procedure in QB64 only. Line labels can be used for multiple DATA fields.
''Example 2:'' How to [[RESTORE]] and [[READ]] DATA in a [[SUB]] procedure in QB64. Line labels can be used for multiple DATA fields.
{{CodeStart}} '' ''
{{Cl|DIM}} {{Cl|SHARED}} num(10) 'shared array or must be passed as a parameter
ReadData 2 '<<<<<<< change value to 1 to read other data
@ -67,10 +70,9 @@ mydata2:
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{OutputStart}} 10 9 8 7 6 5 4 3 2 1 {{OutputEnd}}
: ''Note:'' A specific array index can be passed in a parameter or the entire array can be passed using empty brackets.
''See also:''
{{PageSeeAlso}}
* [[READ]]
* [[RESTORE]]
* [[SUB]], [[FUNCTION]]

View file

@ -1,14 +1,15 @@
The '''DATE$''' Function returns the present computer date as a string in a month, day and 4 digit year format.
The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
:::::''Syntax:'' today$ = DATE$
{{PageSyntax}}
: {{Parameter|today$}} = [[DATE$]]
* Returns the present computer date in a mm-dd-yyyy format such as: "12-25-2009"
* Returns "-" (dash) separators between month, day and year on most machines.
* '''NOTE''': Older computers may just use the last two digit years!
{{PageDescription}}
* Returns the current computer date in the format "mm-dd-yyyy" (e.g., "12-25-2009").
{{PageExamples}}
''Example:'' Displaying the weekday and current date.
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|DATE$}}
@ -31,8 +32,9 @@ year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$)
{{Cl|CASE}} 12: Moon$ = "December"
{{Cl|END SELECT}}
{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10)
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
{{Cl|DEFINT}} A-Z
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
{{Cl|IF}} M < 3 {{Cl|THEN}} M = M + 12: Y = Y - 1 'add 12 to Jan - Feb month, -1 year
C = Y \ 100: Y = Y {{Cl|MOD}} 100 'split century and year number
S1 = (C \ 4) - (2 * C) - 1 'century leap
@ -57,13 +59,10 @@ WeekDay$ = day$
06-02-2010
Today is Wednesday, June 2, 2010
{{OutputEnd}}
:'''NOTE:''' When using {{KW|DEFINT}} A-Z in the main program, place DEFINT A-Z before FUNCTION WeekDay$ line.
''See also:''
{{PageSeeAlso}}
* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]]
* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]]

View file

@ -1,23 +1,26 @@
The '''DATE$''' statement sets the current computer date to another [[STRING]] value.
'''This page is maintained for historic purposes. The keyword is not supported in QB64. Reading the current date is supported with the [[DATE$|DATE$ function]].'''
----
The [[DATE$]] statement sets the current computer date to another [[STRING]] value.
:::''Syntax:'' DATE$ = String_expression
{{PageSyntax}}
: [[DATE$]] = {{Parameter|stringExpression$}}
* String expression can use slash or dash formats when assigning the date:
* {{Parameter|stringExpression$}} can use slash or dash as separators:
::::mm-dd-yyyy
::::mm/dd/yyyy
* String expression or variable must contain the months, day and 4 digit year to be changed (10 valid characters).
* String expression or variable must contain the month, day and 4 digit year to be changed (10 valid characters).
* If value is not a valid formatted string, a "Type Mismatch" error results. The previous DATE$ value will be retained.
* The current date (as assigned when the operating system was initialized) can be saved to restore later with the [[DATE$]] function.
*The DATE$ function returns a 10-character string in the form ''mm-dd-yyyy''. ''mm'' is the month (01 to 12), ''dd'' is the day (01 to 31), and ''yyyy'' is the four digit year.
* '''Note: Some systems may not allow the DATE to be reset or require Administrator privileges.''' Try a batch file or [[SHELL]].
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]
{{PageExamples}}
''Example:'' Backdating computer to run old software.
{{CodeStart}}
@ -39,10 +42,8 @@ The '''DATE$''' statement sets the current computer date to another [[STRING]] v
''See also:''
{{PageSeeAlso}}
[[DATE$]], [[TIME$]], [[TIME$ (statement)]]
{{PageNavigation}}

View file

@ -1,3 +1,8 @@
'''This page is maintained for historic purposes. The usage of the DECLARE keyword explained below isn't required/implemented in QB64. QB64 ignores any occurrences of DECLARE SUB/FUNCTION when older code is compiled. For the modern usage of the DECLARE keyword (for external C procedures), see [[DECLARE LIBRARY]].'''
----
The '''DECLARE''' statement is used to tell Qbasic that a [[SUB]] or [[FUNCTION]] is to be used in the program with specific parameter types.

View file

@ -1,3 +1,8 @@
'''This page is maintained for historic purposes. The usage of the DECLARE keyword explained below isn't supported by QB64. QB64 ignores any occurrences of DECLARE SUB/FUNCTION when older code is compiled. For the modern usage of the DECLARE keyword, see [[DECLARE LIBRARY]].'''
----
Declares calling sequences for external procedures written in other languages.
@ -6,7 +11,6 @@ Declares calling sequences for external procedures written in other languages.
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name [ [[CDECL]] ] [ [[ALIAS]] "aliasname"] [([parameterlist, ...])]
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
* [[CDECL]] indicates that the procedure uses the C language argument order.
* [[ALIAS]] indicates the procedure name used in the object or library file.
* The syntax for the parameterlist is as follows: [{ [[BYVAL]] | [[SEG]] }] variable [AS type [,[{ [[BYVAL]] | [[SEG]] }] variable2 [ [[AS]] type]]...
@ -17,7 +21,7 @@ Declares calling sequences for external procedures written in other languages.
''See also:''
* [[CALL]], [[CALLS]], [[SETMEM]]
* [[DECLARE LIBRARY]] (QB64 Only}
* [[DECLARE LIBRARY]] (QB64 Only)

View file

@ -2,29 +2,37 @@
{{PageSyntax}}
::: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [''"DLL_Library_file"'', "other_library..."]
::: {SUB|FUNCTION} [''procedure_name'' ALIAS] ''library_procedure'' (BYVAL ''parameter(s)'',...)
::::.
::::. 'other Library sub-procedures for named ''DLL''
::::.
::: END DECLARE
: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [''"DLL_Library_file"'', "other_library..."]
: {SUB|FUNCTION} [''procedure_name'' ALIAS] ''library_procedure'' (BYVAL ''parameter(s)'',...)
::.
::. 'other Library sub-procedures for named ''DLL''
::.
: END DECLARE
* '''This QB64 procedure is available as of WINDOWS version .923 and Linux and Mac version 0.94 releases!'''
{{PageDescription}}
* The dynamic library file can be located in the QB64 folder (alongside your programs '.EXE'), in Windows' system32 folder, or in a relative/absolute path specified along with the library name.
* '''Declarations MUST be made at the program start and only one ''.DLL'' file can be specified in each declaration block.'''
* ''Library_file'' is the ''DLL'' file's name with a specified path when not in the QB64 or the WINDOWS\SYSTEM32 folder. No extension!
* '''Declarations must be made at the program start and only one ''.DLL'' file can be specified in each declaration block.'''
* ''Library_file'' is the ''DLL'' file's name with a specified path when not in the QB64 or the WINDOWS\SYSTEM32 folder. Don't add a file extension.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* ''Procedure_name'' is any procedure name you want to designate by using [[ALIAS]] with the ''Library_procedure'' name following.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] values.
* '''''.h'' header files cannot be used with DECLARE DYNAMIC LIBRARY. Existence of any ''.h'' file of the same name as the ''.DLL'' file will cause DECLARE DYNAMIC LIBRARY to fail!'''
* '''IMPORTANT:''' [[DECLARE DYNAMIC LIBRARY]] let's you specify any SUB/FUNCTION calling format you wish, but '''if the size of the parameters does not match, the size expected within the library your code will probably cause a GPF(General Protection Fault)!''' It is important to understand that you are creating a 32-bit program (even under 64-bit Windows) so '''pointers (if required) will be 32-bits in size, the equivalent of a [[LONG]].'''
* '''''.h'' header files cannot be used with DECLARE DYNAMIC LIBRARY. Existence of any ''.h'' file of the same name as the ''.DLL'' file will cause DECLARE DYNAMIC LIBRARY to fail.'''
* '''IMPORTANT:''' [[DECLARE DYNAMIC LIBRARY]] let's you specify any SUB/FUNCTION calling format you wish, but '''if the size of the parameters does not match, the size expected within the library your code will probably cause a GPF (General Protection Fault).''' It is important to understand that you are creating a 32-bit program (even under 64-bit Windows) so '''pointers (if required) will be 32-bits in size, the equivalent of a [[LONG]].'''
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't really use shared libraries (DLLs are a bit different) this does not affect Windows users.
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* [[SUB]] procedures using DECLARE CUSTOMTYPE LIBRARY API procedures '''may error'''. Try DYNAMIC with the DLL name.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that ANY procedure will work and cannot quarantee ANY troubleshooting help!'''
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use. QB64 cannot guarantee that any procedure will work and cannot quarantee any troubleshooting help.'''
==Availability==
* '''Version 0.923 and up (Windows)'''
* '''Version 0.94 and up (Linux and macOS)'''
{{PageExamples}}
''Example 1:'' This example plays Midi files using the ''playmidi32.dll'' documented here: [http://libertybasicuniversity.com/lbnews/nl110/midi3.htm Liberty Basic University].                         Download the following DLL file to your main QB64 folder: [http://www.qb64.net/playmidi32.dll PlayMidi32.dll]
{{CodeStart}} '' ''
{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32"
@ -77,8 +85,11 @@ QuickUTF16toUTF32$ = b$
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Galleon}}
: '''Note:''' SUB procedures using CUSTOMTYPE LIBRARY API procedures inside may error. Try DYNAMIC with "KERNEL32".
<center>'''Note: QB64 requires all DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder!'''</center>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''

View file

@ -2,28 +2,30 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
{{PageSyntax}}
::: '''DECLARE''' [DYNAMIC|CUSTOMTYPE|STATIC] '''LIBRARY''' [{''"Library_filename"''|''"Headerfile"''}]
::: {[[SUB]]|[[FUNCTION]]} [''procedure_name'' {{KW|ALIAS}}] ''library_procedure'' ([{{KW|BYVAL}}] ''parameter {{KW|AS}}'', ...)
::::.
::::. 'other SUBs or Functions as required
::::.
::: '''END DECLARE'''
: '''DECLARE''' [DYNAMIC|CUSTOMTYPE|STATIC] '''LIBRARY''' [{''"Library_filename"''|''"Headerfile"''}]
: {[[SUB]]|[[FUNCTION]]} [''procedure_name'' {{KW|ALIAS}}] ''library_procedure'' ([{{KW|BYVAL}}] ''parameter {{KW|AS}}'', ...)
::.
::. 'other SUBs or Functions as required
::.
: '''END DECLARE'''
{{Parameters}}
* The ''Library name'' is needed if a Library is NOT already loaded by QB64. Do not include the ''.DLL'', ''LIB'' or ''.H'' file extension.
* ''Procedure_name'' is any program procedure name you want to designate by using [[ALIAS]] with the ''Library_procedure'' name.
* ''Library procedure'' is the actual procedure name used inside of the library or header file.
* The {{Parameter|Library_filename}} is needed if a Library is not already loaded by QB64. Do not include the ''.DLL'', ''LIB'' or ''.H'' file extension.
** It's always a good idea to try declaring Windows API libraries without a {{Parameter|Library_filename}} first, as most Windows headers are already included in QB64 source.
* Begin the {{Parameter|Library_filename}} with '''./''' or '''.\''' to make it relative to the path where your source file is saved, so you can keep all your project files together.
* {{Parameter|Procedure_name}} is any program procedure name you want to designate by using [[ALIAS]] with the {{Parameter|Library_procedure}} name.
* {{Parameter|Library procedure}} is the actual procedure name used inside of the library or header file.
''Library Types:''
===Library Types===
* '''[[DECLARE DYNAMIC LIBRARY|DYNAMIC]]''' links a program to functions in dynamically linkable libraries. At present, only .DLL files are supported
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries. Supports shared object (*.so) libraries
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries. Supports shared object (*.so) libraries.
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't use shared libraries (DLLs are different) this does not affect Windows users.
{{PageDescription}}
* The declaration can be used with C++ sub-procedures, Windows API and QB64 SDL Libraries.
* The declaration can be used with C++ sub-procedures, Windows API and QB64 SDL (versions prior to 1.000)/OpenGL (version 1.000 and up) Libraries.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* C procedures can use a header file name. File code must be included with program code. Do not include the ''.h'' extension.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] characters.
@ -31,10 +33,11 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that ANY procedure will work and cannot quarantee ANY troubleshooting help!'''
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that any procedure will work and cannot quarantee any troubleshooting help.'''
''Example 1:'' Using a '''QB64 SDL ONLY''' library procedure as a program SUB procedure to move the mouse pointer to a coordinate.
{{PageExamples}}
''Example 1:'' Using an '''SDL''' library procedure as a program SUB procedure to move the mouse pointer to a coordinate (works in versions prior to 1.000):
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} SDL_WarpMouse ({{Cl|BYVAL}} column {{Cl|AS}} {{Cl|LONG}}, {{Cl|BYVAL}} row {{Cl|AS}} {{Cl|LONG}}) 'SDL procedure name
@ -55,7 +58,7 @@ SDL_WarpMouse x, y 'call SDL library procedure
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{small|Code by Galleon}}
:''Explanation:'' The SDL Library is already included and loaded with QB64, so these procedures are directly available for use.
:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use.
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}} '' ''
@ -111,29 +114,20 @@ PRINT "&H" + HEX$(GetLPTPortAddress%(1))
{{TextEnd}}
<center>'''SDL Library Documentation'''</center>
:Library documentation is downloadable here in PS format: Use either [http://get.adobe.com/reader/ Acrobat Reader] or [http://download.cnet.com/PDF-XChange-Viewer/3000-10743_4-10598377.html PDF XChange Viewer]
<center>[http://www.libsdl.org/archives/sdldoc-ps.zip SDL Library Ebook Documentation Download]</center>
: Note: Unzip the downloaded "SDLdoc.PS" file and click on it. Make it into an Ebook in top choice box where it says Screen.
<center>[http://www.libsdl.org/archives/sdldoc-html.zip SDL Library HTML Browser References]</center>
<center>Galleon's '''OpenGL''' Library with demo program download: http://www.qb64.net/gl_package.zip</center>
<center>'''Note: QB64 requires all DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder!'''</center>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
* [[DECLARE DYNAMIC LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[C Libraries]], [[SDL Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
* [[OpenGL Libraries]]
* [[OpenGL Libraries]], [[SDL Libraries]]
* [[SFML Libraries]]
* [[SQL Client]]
* [http://www.qb64.net/forum/index.php?topic=11810.msg102081#msg102081 DECLARE LIBRARY and C++ Variable Types]

View file

@ -1,22 +1,38 @@
The '''DEFDBL''' statement defines all designated undefined variables AS [[DOUBLE]] variables instead of the [[SINGLE]] type default.
The [[DEFDBL]] statement defines all variables with names starting with the specified letter (or letter range) AS [[DOUBLE]] variables instead of the [[SINGLE]] type default.
==Legacy support==
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}'''DIM a AS DOUBLE, a2 AS DOUBLE, a3 AS DOUBLE'''{{InlineCodeEnd}}, simply having {{InlineCode}}'''DEFDBL A'''{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* '''For clarity, it is recommended to declare variables with meaningful names'''.
{{PageSyntax}}
:: '''DEFDBL ''letter'''''[-''range'']
: [[DEFDBL]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
* The first letters can be from A-Z or any other range.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFDBL sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFDBL]].
* [[DEFDBL]] sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
''Example:'' DEFDBL A, F, H
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures.
''See also:''
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFDBL}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type DOUBLE, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]

View file

@ -1,29 +1,41 @@
The '''DEFINT''' statement defines all designated undefined variables AS [[INTEGER]] variables instead of the [[SINGLE]] type default.
The [[DEFINT]] statement defines all variables with names starting with the specified letter (or letter range) AS [[INTEGER]] variables instead of the [[SINGLE]] type default.
==Legacy support==
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}'''DIM a AS INTEGER, a2 AS INTEGER, a3 AS INTEGER'''{{InlineCodeEnd}}, simply having {{InlineCode}}'''DEFINT A'''{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* '''For clarity, it is recommended to declare variables with meaningful names'''.
{{PageSyntax}}
:: '''DEFSINT ''letter'''''[-''range'']
: [[DEFINT]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
* The variable first letters can be from A-Z or any other range.
* You can also use commas for specific untyped variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFINT allows users to create larger graphical arrays up to the integer limits.
* The maximum value of a signed Integer variable is 32767. Minimum is -32768.
* [[UNSIGNED]] Integer values from 0 to 65535 must use [[_DEFINE]]
* DEFINT sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFINT]].
* [[DEFINT]] sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* For [[_UNSIGNED]] [[INTEGER]], use [[_DEFINE]]
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
''Examples:''
:: DEFINT A-Z
:: DEFINT A-D, Z
:: DEFINT A, I, O
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures.
''See also:''
* [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]], [[_DEFINE]]
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFINT}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type INTEGER, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,24 +1,40 @@
The '''DEFLNG''' statement defines all designated undefined variables AS [[LONG]] variables instead of the [[SINGLE]] type default.
The [[DEFLNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[LONG]] variables instead of the [[SINGLE]] type default.
==Legacy support==
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}'''DIM a AS LONG, a2 AS LONG, a3 AS LONG'''{{InlineCodeEnd}}, simply having {{InlineCode}}'''DEFLNG A'''{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* '''For clarity, it is recommended to declare variables with meaningful names'''.
{{PageSyntax}}
:: '''DEFSTR ''letter'''''[-''range'']
: [[DEFLNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
* The variable first letters can be from A-Z or any other range.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* [[UNSIGNED]] [[LONG]] Integer values from 0 to 4,294,967,295 must use [[_DEFINE]].
* DEFLNG sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFLNG]].
* [[DEFLNG]] sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* For [[_UNSIGNED]] [[LONG]], use [[_DEFINE]]
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
''Example:'' DEFLNG F-H, T
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures.
''See also:''
* [[DEFINT]], [[DEFSNG]], [[DEFDBL]], [[DEFSTR]]
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFLNG}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type LONG, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFDBL]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]

View file

@ -1,24 +1,40 @@
The '''DEFSNG''' statement defines all designated undefined variables AS [[SINGLE]] variables.
The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables.
==Legacy support==
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}'''DIM a AS SINGLE, a2 AS SINGLE, a3 AS SINGLE'''{{InlineCodeEnd}}, simply having {{InlineCode}}'''DEFSNG A'''{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* '''For clarity, it is recommended to declare variables with meaningful names'''.
{{PageSyntax}}
:: '''DEFSNG ''letter'''''[-''range'']
: [[DEFSNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
* The variable first letters can be from A-Z or any other range.
* You can also use commas for specific untyped variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFSNG is normally the Qbasic default type assignment for undefined variables without type suffixes.
* DEFSNG sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
{{PageDescription}}
* Undeclared variables with no type suffix are of type [[SINGLE]] by default.
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFSNG]].
* [[DEFSNG]] sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
''Example:'' DEFSNG A-D, S
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures.
''See also:''
* [[DEFINT]], [[DEFDBL]], [[DEFLNG]], [[DEFSTR]]
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFSNG}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type SINGLE, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFDBL]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]

View file

@ -1,23 +1,39 @@
The '''DEFSTR''' statement defines all designated undefined variables AS [[STRING]] variables instead of the [[SINGLE]] type default.
The [[DEFSTR]] statement defines all variables with names starting with the specified letter (or letter range) AS [[STRING]] variables instead of the [[SINGLE]] type default.
==Legacy support==
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}'''DIM a AS STRING, a2 AS STRING, a3 AS STRING'''{{InlineCodeEnd}}, simply having {{InlineCode}}'''DEFSTR A'''{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* '''For clarity, it is recommended to declare variables with meaningful names'''.
{{PageSyntax}}
:: '''DEFSTR ''letter'''''[-''range'']
: [[DEFSTR]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
* The variable starting letters can be from A-Z or any other range.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFSTR sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFSTR]].
* [[DEFSTR]] sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Warning: QBasic keyword names can only be used as string variable names when they are followed by the string type suffix ($).'''
''Example:'' DEFSTR A-S, Z
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures.
''See also:''
* [[DEFINT]], [[DEFLNG]], [[DEFSNG]], [[DEFDBL]]
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFSTR}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type STRING, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFDBL]]
* [[_DEFINE]]

View file

@ -1,3 +1,9 @@
'''This page is maintained for historic purposes. The keyword is not supported in QB64. Create functions using [[FUNCTION]]. If older code contains ''DEF FN'' functions, they must be adapted to be compiled with QB64.'''
----
The '''DEF FN''' statement defines a non-recursive function in the main module that can use the module's variable values.
@ -8,25 +14,28 @@ The '''DEF FN''' statement defines a non-recursive function in the main module t
::[{{Parameter|statements}}]
::[[DEF FN|FN]]{{Parameter|name}} = {{Parameter|expression}}
::[{{Parameter|statements}}]
:END DEF
:'''END DEF'''
{{PageDescription}}
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
* {{Parameter|name}} is the name of the function.
* {{Parameter|parameterList}} is a comma-separated list of one or more parameters, similar to [[SUB]] and [[FUNCTION]] statements.
* {{Parameter|expression}} is any numerical or string value to return from the function.
* Function can be created anywhere in a module. Not in [[SUB]] procedures.
* Function can NOT be defined in recursive(repeated) parts of a program. Declare it once only!
* Function must be defined only once and the definition cannot be in recursive (repeated) parts of a program.
* Function returns should be assigned to a variable when an alteration to the return value is necessary.
* Function references should only be made AFTER the declaration.
* Multi-line function definitions MUST end with '''END DEF'''.
* Function references should only be made after the declaration.
* Multi-line function definitions must end with '''END DEF'''.
* To leave a DEF Fn function early use '''EXIT DEF'''.
* This type of function can share values in module level code. To keep values local to the procedure use [[STATIC]].
* Parameters cannot be from arrays, records or fixed length strings!
* Fn must prefix the function name inside of the procedure and in a call.
* Other variable names or procedures cannot begin with FN or fn in Qbasic!
* Qbasic Help recommends creating real [[FUNCTION]]s over DEF FN functions because of the above limitations.
* Parameters cannot be from arrays, records or fixed length strings.
* ''Fn'' must prefix the function name inside of the procedure and in a call.
==QBasic/QuickBASIC==
* Other variable names or procedures cannot begin with FN or fn in QBasic.
* QBasic Help recommends creating real [[FUNCTION]]s over DEF FN functions because of the above limitations.
{{PageExamples}}

View file

@ -1,19 +1,24 @@
'''DEF SEG''' is used to define the area in memory to access QB64's emulated conventional memory.
[[DEF SEG]] is used to define the area in memory to access QB64's emulated conventional memory.
==Legacy support==
* '''QB64 implements memory access using [[_MEM]] and related functions. For that reason, [[DEF SEG]] isn't recommended practice anymore and is supported to maintain compatibility with legacy code.'''
{{PageSyntax}}
:: DEF SEG [=][{segment|VARSEG(variable}]
: [[DEF SEG]] [=][{segment|VARSEG(variable}]
{{PageDescription}}
* Used to set the pointer to a memory area of a variable/array or register.
* [[PEEK]] and [[POKE]] require a segment memory address (often just 0) without using VARSEG.
* Important segments using [[PEEK]] and [[POKE]] include &HB800 (text segment) and &HA000 (graphics segment).
* [[BSAVE]] and [[BLOAD]] require a VARSEG reference to the grahic array(0 index) used.
* ALWAYS use DEF SEG when the procedure is completed to reset the segment to Qbasic's default value!
* '''Warning: DEF SEG, VARSEG , VARPTR, PEEK or POKE access QB64's emulated 16 bit conventional memory block!'''
: '''It is highly recommended that QB64's [[_MEM]] memory system be used to avoid running out of memory.'''
* Always use DEF SEG when the procedure is completed, in order to reset the segment to QBasic's default value.
* [[DEF SEG]], [[VARSEG]], [[VARPTR]], [[PEEK]] and [[POKE]] access QB64's emulated 16 bit conventional memory block. '''It is highly recommended to use QB64's [[_MEM]] memory system to avoid running out of memory.'''
<!--
{{PageExamples}}
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
{{CodeStart}} '' ''
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
@ -55,7 +60,7 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{Cl|END}} '' ''
{{CodeEnd}}
{{small|Code by Michael Calkins as Public Domain(2011)}}
-->
''See also:''
* [[DEF SEG = 0]]

View file

@ -1,41 +1,43 @@
The '''DIM''' statement is used to [[_DEFINE|define]] a variable or a list of variable types or dimension [[$STATIC]] or [[$DYNAMIC]] [[Arrays]].
The [[DIM]] statement is used to declare a variable or a list of variables as a specified data type or to dimension [[$STATIC]] or [[$DYNAMIC]] [[Arrays|arrays]].
{{PageSyntax}}
::::''Syntax 1:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]]
::''Syntax 1:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]]
::::''Syntax 2:'' [[DIM]] [{{KW|SHARED}}] ''Array(lowest% [{{KW|TO}}) highest%])''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]
::''Syntax 2:'' [[DIM]] [{{KW|SHARED}}] ''array(lowest% [{{KW|TO}}) highest%])''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]
:::'' '''QB64''' Syntax:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
:'' '''QB64''' Syntax:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
* Sets the [[INTEGER]] range of elements(indices) of a [[STATIC]] array. If only one number is used, the [[LBOUND|lowest boundary]] is 0.
* When used before an array is dimensioned, [[OPTION BASE]] 1 can set the array's default [[LBOUND|lower boundary]] to 1.
{{PageDescription}}
* Sets the [[INTEGER]] range of elements (indices) of a [[STATIC]] array. If only one number is used, the [[LBOUND|lowest boundary]] is 0 by default.
* When used before an array is dimensioned, '''[[OPTION BASE]] 1''' can set the default [[LBOUND|lower boundary]] of arrays to 1.
* DIM [[SHARED]] shares variable values with sub-procedures without passing the value in a parameter.
* Uses the [[AS]] keyword to define a variable or array ''type'' [[AS]]...
** [[INTEGER]] or use variable suffix '''%'''
** [[LONG]] or use variable suffix '''&'''
** [[SINGLE]] or use variable suffix '''!''' or no suffix by default
** [[DOUBLE]] or use variable suffix '''#'''
** [[STRING]] or use variable suffix '''$'''. An AS multiplier can set the string [[LEN|length]]. {{text|EX: DIM ''variable'' AS STRING * 8|green}}
* Use the [[AS]] keyword to define a variable or array ''type'' [[AS]]...
** [[INTEGER]] (or use variable suffix '''%''')
** [[LONG]] (or use variable suffix '''&''')
** [[SINGLE]] (or use variable suffix '''!''' or no suffix by default)
** [[DOUBLE]] (or use variable suffix '''#''')
** [[STRING]] (or use variable suffix '''$'''). An AS multiplier can set the string [[LEN|length]]. Ex: {{InlineCode}}DIM ''variable'' AS STRING * 8{{InlineCodeEnd}}
* '''QB64''' variable types:
** [[_BIT]] or use variable suffix '''`'''. An AS multiplier can be used for multiple bits. {{text|EX: DIM ''variable'' AS _BIT * 8|green}}
** [[_BYTE]] or use variable suffix '''%%'''
** [[_INTEGER64]] or use variable suffix '''&&'''
** [[_FLOAT]] or use variable suffix '''##'''
** [[_OFFSET]] or use variable suffix '''%&'''
** DIM AS [[_MEM]] only! Does not have a variable type suffix
** [[_BIT]] (or use variable suffix '''`'''). An AS multiplier can be used for multiple bits. Ex: {{InlineCode}}DIM ''variable'' AS _BIT * 8{{InlineCodeEnd}}
** [[_BYTE]] (or use variable suffix '''%%''')
** [[_INTEGER64]] (or use variable suffix '''&&''')
** [[_FLOAT]] (or use variable suffix '''##''')
** [[_OFFSET]] (or use variable suffix '''%&''')
** DIM AS [[_MEM]] (the _MEM type has no type suffix).
* '''Note: When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* When the [[$DYNAMIC]] metacommand or [[REDIM]] is used, array element sizes are changeable(not [[$STATIC]]).
* When the [[$DYNAMIC]] metacommand or [[REDIM]] is used, array element sizes are changeable (not [[$STATIC]]).
* Use [[REDIM]] instead of DIM to dimension arrays as dynamic without the {{KW|$DYNAMIC}} metacommand.
* Use [[REDIM]] [[_PRESERVE]] in QB64 to retain previous array values when changing the size of an array.
* [[REDIM]] [[_PRESERVE]] cannot change the number of array dimensions! An [[ERROR Codes|error]] will occur!
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used as the arrays are completely removed.
* All numerical variable types '''except''' {{KW|SINGLE}}, {{KW|DOUBLE}} and {{KW|_FLOAT}} can be dimensioned as [[_UNSIGNED]](suffix ~) or positive only.
* '''NOTE: Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use DIM, [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
* '''Warning! Do not use negative array Upper bound index values as OS access or "Out of Memory" [[ERROR Codes|errors]] will occur!'''
* Use [[REDIM]] [[_PRESERVE]] in '''QB64''' to retain previous array values when changing the size of an array.
* [[REDIM]] [[_PRESERVE]] cannot change the number of array dimensions. An [[ERROR Codes|error]] will occur.
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used, as the arrays are completely removed.
* All numerical variable types '''except''' {{KW|SINGLE}}, {{KW|DOUBLE}} and {{KW|_FLOAT}} can be dimensioned as [[_UNSIGNED]] (suffix ~) or positive only.
* '''NOTE:''' Many QBasic keyword variable names can be used with a [[STRING]] suffix ($). You cannot use them without the suffix, use a numerical suffix or use ''DIM, [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]]'' statements. '''Although possible, it's recommended to avoid using reserved names.'''
* '''Warning: Do not use negative array upper bound index values, or OS access or "Out of Memory" [[ERROR Codes|errors]] will occur.'''
{{PageExamples}}
''Example 1:'' Defines Qt variable as a one byte fixed length string.
{{CodeStart}}
{{Cl|DIM}} Qt {{Cl|AS}} {{Cl|STRING}} * 1
@ -62,7 +64,7 @@ The '''DIM''' statement is used to [[_DEFINE|define]] a variable or a list of va
{{CodeEnd}}
''Example 6:'' QB64 is more flexible than Qbasic when it comes to "Duplicate Definition" errors. The following code does not error:
''Example 6:'' QB64 is more flexible than QBasic when it comes to "Duplicate Definition" errors. The following code does not error:
{{CodeStart}} '' ''
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
@ -89,6 +91,7 @@ x = 1 'x is a {{Cl|SINGLE}} variable
* [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]]
* [[Mathematical Operations]], [[Arrays]]
* [[Variable Types]]
* [[OPTION _EXPLICIT]]
{{PageNavigation}}

View file

@ -1,61 +1,52 @@
The '''DIR$''' function below is '''NOT A QB64 FUNCTION!''' This page supplies equivalent QB code:
{{DISPLAYTITLE:_DIR$}}
The [[_DIR$]] function returns common paths in '''Windows''' only such as My Documents, My Pictures, My Music, Desktop.
{{PageSyntax}}
::: filename$ = '''DIR$('''{filespec$|""}''')'''
: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}")
The DIR$ function used in PDS(7.1) returns a filename or a list when more than one exist. The file spec can use a path and/or wildcards.
{{CodeStart}} '' ''
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT}}
{{Cl|LINE INPUT}} "Enter a file spec: ", spec$
file$ = DIR$(spec$) 'use a file spec ONCE to find the last file name listed
{{Cl|PRINT}} DIRCount%, file$, 'function can return the file count using {{Cl|SHARED}} variable
{{Cl|IF...THEN|IF}} DIRCount% > 1 {{Cl|THEN}}
DO
K$ = {{Cl|INPUT$}}(1)
file$ = DIR$("") ''''use an empty string parameter to return a list of files!'''
{{Cl|PRINT}} file$,
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}(file$) = 0 'file list ends with an empty string
{{Cl|END IF}}
{{Cl|NEXT}}
{{Parameters}}
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* Some variation is accepted for the folder specification:
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
:: MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS
:: MY PICTURES, PICTURE, PICTURES, IMAGE, IMAGES, PHOTO, PHOTOS, DCIM, CAMERA, CAMERA ROLL
:: MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES,
:: DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA
{{Cl|END}}
{{Cl|FUNCTION}} DIR$ (spec$)
{{Cl|CONST}} TmpFile$ = "DIR$INF0.INF", ListMAX% = 500 'change maximum to suit your needs
{{Cl|SHARED}} DIRCount% 'returns file count if desired
{{Cl|STATIC}} Ready%, Index%, DirList$()
{{Cl|IF...THEN|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} DirList$(ListMAX%): Ready% = -1 '{{Cl|DIM}} array first use
{{Cl|IF...THEN|IF}} spec$ > "" {{Cl|THEN}} 'get file names when a spec is given
{{Cl|SHELL}} {{Cl|_HIDE}} "DIR " + spec$ + " /b > " + TmpFile$
Index% = 0: DirList$(Index%) = "": ff% = {{Cl|FREEFILE}}
{{Cl|OPEN}} TmpFile$ {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} #ff%
size& = {{Cl|LOF}}(ff%)
{{Cl|CLOSE}} #ff%
{{Cl|IF...THEN|IF}} size& = 0 {{Cl|THEN}} {{Cl|KILL}} TmpFile$: {{Cl|EXIT FUNCTION}}
{{Cl|OPEN}} TmpFile$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #ff%
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|NOT}} {{Cl|EOF}}(ff%) {{Cl|AND (boolean)|AND}} Index% < ListMAX%
Index% = Index% + 1
{{Cl|LINE INPUT (file statement)|LINE INPUT}} #ff%, DirList$(Index%)
{{Cl|LOOP}}
DIRCount% = Index% '{{Cl|SHARED}} variable can return the file count
{{Cl|CLOSE}} #ff%
{{Cl|KILL}} TmpFile$
{{Cl|ELSE}} {{Cl|IF...THEN|IF}} Index% > 0 {{Cl|THEN}} Index% = Index% - 1 'no spec sends next file name
{{Cl|END IF}}
DIR$ = DirList$(Index%)
{{Cl|END FUNCTION}} '' ''
{{PageDescription}}
* The path returned ends with a backslash (Windows).
* A nonexistent folder specification usually defaults to the Desktop folder path.
* In Linux and macOS the function always returns '''"./"'''
{{PageExamples}}
Example: Displaying default paths in Windows only.
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop")
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download")
{{Cl|PRINT}} "DOCUMENTS=" + {{Cl|_DIR$}}("my documents")
{{Cl|PRINT}} "PICTURES=" + {{Cl|_DIR$}}("pictures")
{{Cl|PRINT}} "MUSIC=" + {{Cl|_DIR$}}("music")
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video")
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data")
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data"
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning it's name or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it MUST use an empty string parameter until QB64 supports optional parameters!''' The function does NOT delete empty files.
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\
DOWNLOADS=C:\Documents and Settings\Administrator\Downloads\
DOCUMENTS=C:\Documents and Settings\Administrator\My Documents\
PICTURES=C:\Documents and Settings\Administrator\My Documents\My Pictures\
MUSIC=C:\Documents and Settings\Administrator\My Documents\My Music\
VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\
APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\
LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\
{{OutputEnd}}
''See also:''
* [[FILES]]
* [[KILL]]
* [[SHELL]]
{{PageSeeAlso}}
* [[_CWD$]]
* [[_STARTDIR$]]
{{PageNavigation}}

View file

@ -2,36 +2,37 @@
{{PageSyntax}}
''Syntax 1:''
:'''[[DO]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
:.
:.
:.
:: ''{code}''
:: ⋮
:'''[[LOOP]]'''
''Syntax 2:''
:'''[[DO]]'''
:.
:.
:.
:: ''{code}''
:: ⋮
:'''[[LOOP]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
{{PageDescription}}
* DO UNTIL or DO WHILE used with LOOP. The DO will evaluate the condition before running the loop code:
::[[UNTIL]] checks if the condition is False each time before running code.
::[[WHILE]] checks if the condition is True each time before running code.
* DO used with LOOP UNTIL or LOOP WHILE. The loop code will run at least once:
::[[UNTIL]] checks if the condition is False before running loop code again.
::[[WHILE]] checks if the condition is True before running loop code again.
* NOTE: You cannot use a condition after both the DO and LOOP statements at the same time!
* Use '''[[EXIT]] DO''' to exit a DO loop within the loop code.
* If a loop never meets an exit condition requirement, it will never stop!
* '''Condition expressions are required after WHILE or UNTIL or QB64 will return a compiler error!'''
* '''DO UNTIL or DO WHILE used with LOOP''': The condition is evaluated before running the loop code.
::[[UNTIL]] checks if the condition is false each time before running code.
::[[WHILE]] checks if the condition is true each time before running code.
* '''DO used with LOOP UNTIL or LOOP WHILE''': The code block will run at least once:
::[[UNTIL]] checks if the condition is false before running loop code again.
::[[WHILE]] checks if the condition is true before running loop code again.
* NOTE: You cannot use a condition after both the DO and LOOP statements at the same time.
* Use '''[[EXIT]] DO''' to exit a loop block even before the condition is met.
** If you don't specify a condition, you must exit the loop block manually using '''[[EXIT]] DO'''.
* If a loop never meets an exit condition requirement, it will never stop.
{{Template:RelationalTable}}
{{PageExamples}}
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}

View file

@ -1,20 +1,23 @@
'''DOUBLE''' type floating point numerical values use 8 bytes per value.
[[DOUBLE]] type floating point numerical values use 8 bytes per value.
{{PageSyntax}}
:: [[DIM]] ''variable'' AS DOUBLE
: [[DIM]] {{Parameter|variable}} [[AS]] [[DOUBLE]]
{{PageDescription}}
* Literal or variable values can range up to 15 decimal point places.
* Qbasic variable suffix type is #. The IDE may add the suffix after literal values.
* Results of mathematical calculations may be approximate or slow in Quickbasic 4.5.
* Use DOUBLE and [[_FLOAT]] variables SPARINGLY! They use a lot of program memory.
* The variable suffix type is '''#'''.
* Use DOUBLE and [[_FLOAT]] variables sparingly as they use a lot of program memory.
* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision.
* Floating decimal point numerical values cannot be [[_UNSIGNED]]!
* Floating decimal point numerical values cannot be [[_UNSIGNED]].
* Values can be converted to 8 byte [[ASCII]] string values using [[_MKD$]] and back with [[_CVD]].
* '''When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5.
{{PageSeeAlso}}

View file

@ -1,44 +1,45 @@
:::The '''DRAW''' graphics statement uses a [[STRING]] expression to draw lines on the screen.
The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
{{PageSyntax}}
:: '''DRAW''' draw_string$
: [[DRAW]] {{Parameter|drawString$}}
* The draw string can be a draw value in quotation marks or a [[STRING]] variable using DRAW function letters.
* DRAW starting coordinates can be set using [[PSET]], [[PRESET]], [[CIRCLE]] or [[LINE]] ending positions. [[PSET]] or [[PRESET]] colors pass too.
{{PageDescription}}
* The {{Parameter|drawString$}} can be [[DRAW]] instructions in quotation marks or a [[STRING]] variable using [[DRAW]] instructions.
* [[DRAW]] starting coordinates can be set using [[PSET]], [[PRESET]], [[CIRCLE]] or [[LINE]] ending positions.
* Other graphic objects can be located at or relative to the last DRAW position using [[STEP]].
* DRAW can adopt colors from other graphics objects such as [[PSET]], [[LINE]] and [[CIRCLE]] statements.
* [[DRAW]] can inherit colors from other graphic statements such as [[PSET]], [[LINE]] and [[CIRCLE]].
* Draw strings use letters followed by the number of pixels to move, an angle, coordinate or a color value.
* Draw strings are flexible with spacing. '''Spacing is not required!''' DRAW will look for a number value after a valid letter.
* DRAW statements are not Case sensitive. Use upper or lower case.
:* "'''B'''" (Blind) before a line move designates that the line move will be hidden. Use to offset from a "P" or [[PAINT]] border.
:* "'''C''' n" designates the color attribute or [[_RGB]] [[STR$|string]] numerical color value to be used in the draw statement immediately after.
:* "'''M''' x, y" can move to another coordinate area of the screen. When a + or - sign is used before a coordinate,
::it is a relative coordinate move similar to using the [[STEP]] graphics keyword. DRAW "M+=" + [[VARPTR$]](variable%)
:* "'''N'''" before a line move designates that the drawn line will return to the line start position. Saves moves!
:* "'''P''' f [, b]" is used to [[PAINT|paint]] enclosed objects. f denotes the fill color and b the border color if needed.
:* "'''S''' n" changes the pixel move size of the lines. Default is 4(1 pixel) minimum. "S8" would double the pixel line moves.
:* "'''X'''" + [[VARPTR$]](value) can draw another substring.
* Draw strings are flexible with spacing. '''Spacing is not required.''' [[DRAW]] will look for a number value after a valid letter.
* DRAW statements are not case sensitive.
** "'''B'''" (blind) before a line move designates that the line move will be hidden. Use to offset from a "P" or [[PAINT]] border.
** "'''C''' n" designates the color attribute or [[_RGB]] [[STR$|string]] numerical color value to be used in the draw statement immediately after.
** "'''M''' x, y" can move to another coordinate area of the screen. When a + or - sign is used before a coordinate, it is a relative coordinate move similar to using the [[STEP]] graphics keyword. DRAW "M+=" + [[VARPTR$]](variable%)
** "'''N'''" before a line move designates that the graphic cursor will return to the starting position after the line is drawn.
** "'''P''' f [, b]" is used to [[PAINT|paint]] enclosed objects. f denotes the fill color and b the border color, if needed.
** "'''S''' n" changes the pixel move size of the lines. Default is 4 (1 pixel) minimum. "S8" would double the pixel line moves.
** "'''X'''" + [[VARPTR$]](value) can draw another substring.
* Certain letter designations create line moves on the SCREEN. Each move is followed by the number of pixels:
:* "'''D''' n" draws a line vertically DOWN n pixels.
:* "'''E''' n" draws a diagonal / line going UP and RIGHT n pixels each direction.
:* "'''F''' n" draws a diagonal \ line going DOWN and RIGHT n pixels each direction.
:* "'''G''' n" draws a diagonal / LINE going DOWN and LEFT n pixels each direction.
:* "'''H''' n" draws a diagonal \ LINE going UP and LEFT n pixels each direction.
:* "'''L''' n" draws a line horizontally LEFT n pixels.
:* "'''R''' n" draws a line horizontally RIGHT n pixels.
:* "'''U''' n" draws a line vertically UP n pixels.
** "'''D''' n" draws a line vertically DOWN n pixels.
** "'''E''' n" draws a diagonal / line going UP and RIGHT n pixels each direction.
** "'''F''' n" draws a diagonal \ line going DOWN and RIGHT n pixels each direction.
** "'''G''' n" draws a diagonal / LINE going DOWN and LEFT n pixels each direction.
** "'''H''' n" draws a diagonal \ LINE going UP and LEFT n pixels each direction.
** "'''L''' n" draws a line horizontally LEFT n pixels.
** "'''R''' n" draws a line horizontally RIGHT n pixels.
** "'''U''' n" draws a line vertically UP n pixels.
* Angles are used to rotate ALL draw moves following their use. U could become a down move or even rotate.
:* "'''A''' n" can use values of 1 to 3 to rotate up to 3 90 degree(270) angles.
:* '''TA''' n" can use any n angle from -360 to 0 to 360 to rotate a DRAW (Turn Angle). "TA0" resets to normal.
:* When [[VARPTR$]] is used DRAW functions such as '''TA''' angles use an equal sign: "TA=" + VARPTR$(angle%)
* '''DRAW can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!'''
* Angles are used to rotate all subsequent draw moves.
** "'''A''' n" can use values of 1 to 3 to rotate up to 3 90 degree(270) angles.
** '''TA''' n" can use any n angle from -360 to 0 to 360 to rotate a DRAW (Turn Angle). "TA0" resets to normal.
** When [[VARPTR$]] is used, DRAW functions such as '''TA''' angles use an equal sign: "TA=" + VARPTR$(angle%)
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
* '''DRAW can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only.'''
{{PageExamples}}
''Example 1:'' Placing an octagon shape DRAW across the the screen using PSET.
{{CodeStart}} '' ''
@ -67,7 +68,6 @@
NEXT '' ''
{{CodeEnd}}
''Explanation:'' To place 12 circles in a circle each move is 30 degrees. PSET sets the center of the circular path every loop. TA moves counter-clockwise with positive degree angles. Once TA sets the angle a blind Up move is at that angle. The hour circles use the end point of the blind line as centers using the STEP relative coordinates of 0. After the circles are drawn, a draw "P" string paints the circle centers. DRAW paint strings use the last coordinate position also.
@ -85,8 +85,7 @@
LOOP
{{CodeEnd}}
''Explanation:'' The degrees to move from the original UP line move is calculated by dividing 360/60 seconds in a full rotation. That value of 6 is made negative to use TA correctly and multiplied by the [[VAL]]ue of seconds from the TIME$ function. The degree angle is converted by [[STR$]] to a string and added to the DRAW string using the [[STRING]] '''concatenation +''' operator. DO NOT USE SEMICOLONS to create DRAW strings! Once the second hand is placed on the screen, a loop waits for the second value to change. It then erases the hand and it repeats the process again.
''Explanation:'' The degrees to move from the original UP line move is calculated by dividing 360/60 seconds in a full rotation. That value of 6 is made negative to use TA correctly and multiplied by the [[VAL]]ue of seconds from the TIME$ function. The degree angle is converted by [[STR$]] to a string and added to the DRAW string using the [[STRING]] '''concatenation +''' operator. Do not use semicolons to create DRAW strings. Once the second hand is placed on the screen, a loop waits for the second value to change. It then erases the hand and it repeats the process again.
''Example 4:'' Creating digital displays using DRAW format strings to create the LED segments. (See [[SELECT CASE|SELECT EVERYCASE]] example 5)
@ -159,7 +158,7 @@ k = {{Cl|_RGB}}(80, 255, 80)
: ''Explanation:'' DRAW strings will ignore spaces between letters and numbers so string trimming is not necessary.
''See also:''
{{PageSeeAlso}}
* [[LINE]], [[PSET]], [[PRESET]], [[CIRCLE]]
* [[PAINT]], [[SCREEN (statement)|SCREEN]]
* [[COLOR]], [[PLAY]]

View file

@ -1,24 +1,32 @@
'''ELSE''' is used in [[IF...THEN]] or [[SELECT CASE]] statements to offer an alternative to other conditional statements.
[[ELSE]] is used in [[IF...THEN]] or [[SELECT CASE]] statements to offer an alternative to other conditional statements.
{{PageSyntax}}
:: IF condition <> 0 THEN evaluation = -1 [[ELSE]] evaluation = 0
''Single-line syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]] ''{code}'' [[ELSE]] ''{alternative-code}''
''Block {{PageSyntax}}
:: IF condition > 0 THEN
:: evaluation = -1
:: [[ELSEIF]] condition < 0 THEN evaluation = -1
:: [[ELSE]] evaluation = 0
:: [[END IF]]
''Block syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
* ELSE is used in a IF block statement to cover any remaining conditions not covered in the block by IF or [[ELSEIF]].
{{PageDescription}}
* ELSE is used in a IF block statement to cover any remaining conditions not covered in the main block by IF or [[ELSEIF]].
* [[CASE ELSE]] covers any remaining conditions not covered by the other CASE statements.
* ELSE can also be used as a False comparison to a True IF statement when a condition will only be True or False.
* ELSE can also be used as a false comparison to a true IF statement when a condition will only be true or false.
* Other [[IF...THEN]] statements can be inside of an ELSE statement.
{{PageExamples}}
''Example 1:'' One line IF statement
{{CodeStart}}
@ -46,7 +54,7 @@ IF a = 3 THEN a = 5 ELSE a = 3
''See also:''
{{PageSeeAlso}}
* [[ELSEIF]]
* [[IF...THEN]]

View file

@ -1,17 +1,23 @@
'''ELSEIF''' is used in a block [[IF...THEN]] statement to offer an alternative condition.
[[ELSEIF]] is used in an [[IF...THEN]] block statement to offer an alternative condition.
''Block'' {{PageSyntax}}
:: IF condition > 0 THEN
:: evaluation = -1
:: [[ELSEIF]] condition < 0 THEN evaluation = -1
:: [[ELSE]] evaluation = 0
:: [[END IF]]
{{PageSyntax}}
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
* ELSEIF statements REQUIRE a '''separate''' code block line with [[THEN]] for each alternative condition.
{{PageDescription}}
* ELSEIF statements require a '''separate''' code block line with [[THEN]] for each alternative condition.
* There can be more than one [[ELSE]] IF statement in a single-line IF statement.
* If there is only ONE possible alternative condition(such as 0 or [[NOT]] 0), then use [[ELSE]] instead.
* If there is only one possible alternative condition (such as 0 or [[NOT]] 0), use [[ELSE]] instead.
* If the comparisons are based on multiple conditions being true, it may require many ELSEIF comparisons. ELSE could help cover some of those conditions.
* You can use [[SELECT CASE]] when IF blocks have a long list of alterative ELSEIF conditions.
@ -19,6 +25,7 @@
{{Template:RelationalTable}}
{{PageExamples}}
''Example 1:'' IF statement using ELSE IF in one statement line.
{{CodeStart}}
@ -40,13 +47,9 @@ END IF
''See also:''
{{PageSeeAlso}}
*[[ELSE]], [[END IF]]
*[[IF...THEN]]
{{PageNavigation}}

View file

@ -1,27 +1,25 @@
The {{KW|END}} statement terminates a program without an immediate exit or ends a procedure or statement block.
The [[END]] statement terminates a program without an immediate exit or ends a procedure or statement block.
{{PageSyntax}}
::: END
::: END [[IF...THEN|IF]]
::: END [[TYPE]]
::: END [[SELECT CASE|SELECT]]
::: END [[SUB]]
::: END [[FUNCTION]]
QB64 {{PageSyntax}}
::: END [return_code%]
::: END [[DECLARE LIBRARY|DECLARE]]
: [[END]] [{{Parameter|returnCode%}}]
: [[END]] [[IF...THEN|IF]]
: [[END]] [[TYPE]]
: [[END]] [[SELECT CASE|SELECT]]
: [[END]] [[SUB]]
: [[END]] [[FUNCTION]]
: END [[DECLARE LIBRARY|DECLARE]]
* In '''QB64''' END can be followed by a code that can be read in another module using the [[SHELL (function)|_SHELL]] or [[_SHELLHIDE]] function.
* When END is used to end a program a pause and "Press any key to continue..." is displayed at the bottom of the window.
* If the program does not use END or [[SYSTEM]] the program will still end with a pause and display "Press any key to continue...".
* In '''QB64''' [[SYSTEM]] will end the program immediately and close the window.
* The '''QB64''' [[_EXIT (function)]] can block a user's Ctrl + Break key press or click on the window X box until the program is ready.
* When running a Qbasic BAS module from the command line, use [[SYSTEM]] to avoid returning to the [[IDE]].
{{PageDescription}}
* In '''QB64''', [[END]] can be followed by a code that can be read by another module using the [[SHELL (function)|_SHELL]] or [[_SHELLHIDE]] function (known as [https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743 '''errorlevel'''])
* When END is used to end a program, there is a pause and the message "Press any key to continue..." is displayed at the bottom of the program's window.
* If the program does not use END or [[SYSTEM]], the program will still end with a pause and display "Press any key to continue...".
* In '''QB64''', [[SYSTEM]] will end the program immediately and close the window.
* The '''QB64''' [[_EXIT (function)]] can block a user's Ctrl + Break key presses and clicks on the window's close button (X button) until the program is ready to close.
{{PageExamples}}
''Example:'' In QB64 you won't return to the IDE unless you are using it to run or edit the program module.
{{CodeStart}} '' ''
@ -41,7 +39,7 @@ Hello world!
Press any key to continue...
{{OutputEnd}}
:''Explanation:''"Hello no one!" isn't returned because the program ended with the END statement no matter what is after that.
:The message "Press any key to continue..." is displayed after the program ends in QB or '''QB64'''.
:The message "Press any key to continue..." is displayed after the program ends, both in QBasic and in '''QB64'''.

View file

@ -1,34 +1,33 @@
The '''ENVIRON$''' function returns a [[STRING]] environmental value from the '''Windows''' PC's environmental settings list.
The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windows'''' environmental settings list.
{{PageSyntax}}
::: setting$ = ENVIRON$({''list_number%''|''systemID$''})
: {{Parameter|setting$}} = [[ENVIRON$]]({{{Parameter|listIndex%}}|{{Parameter|systemID$}}})
* The function can use an [[INTEGER]] ''list_number'' order value or [[STRING]] ''systemID$'' parameter.
* ''List_number'' refers to the number order of the environmental list. Returns are not in any particular numerical order.
* ''SystemID'' is the specific [[STRING]] parameter requested. Returns that environmental [[STRING]] setting only:
::* "BLASTER" = current Sound Blaster settings if installed.
::* "COMPUTERNAME" or "USERDOMAIN" = OEM PC serial number or the computer name assigned by owner.
::* "HOMEDRIVE" or "SystemDrive" = Windows root drive, normally C: on single partition drives.
::* "HOMEPATH" = current user's Administrator or the single user's "OWNER" folder path.
::* "OS" = Windows Operating System version. Often WindowsNT these days.
::* "PATH" = full Windows path settings that windows uses to look for file extensions in PATHEXT below.
::* "PATHEXT = Windows extensions used: COM, EXE, BAT, CMD, VBS, VBE, JS, JSE, WSF, WSH, MSC
::* "PROCESSOR_ARCHITECTURE" = x86 for 32 or 64 bit so far.
::* "PROGRAMFILES" = path to Program files folder normally "C:\PROGRAM FILES"
::* "PROMPT" = $P$G normaly on Windows NT. Windows 95 and 98 = "[WIN 98]$P$G" but cannot run QB64!
::* "SYSTEMROOT" or "windir" = path to the Windows folder including the drive letter like "C:\WINDOWS"
::* "TEMP" or "TMP" = path to TEMP folder. "C:\TEMP" or the user specific temp folder on later versions.
::* "USERNAME" = current Administrator name or "OWNER".
: ''Note:'' There are other possible system settings that are not listed or never used on older versions! Run ''Example 1''
* The OS in Win 9X or ME can be found in the "PROMPT" parameter ID. Returns are limited in Win 9X and ME.
* ''Note:'' '''QB64''' may not return the same environment list as Qbasic or SET does in DOS.
{{PageDescription}}
* The function can use an [[INTEGER]] {{Parameter|listIndex%}} value or [[STRING]] {{Parameter|systemID$}} parameter.
* {{Parameter|listIndex%}} refers to the number order of the environmental list. Returns are not in any particular numerical order.
* {{Parameter|systemID$}} is the specific [[STRING]] parameter requested. Returns only the specified environmental [[STRING]] setting:
** "BLASTER" = current Sound Blaster settings if installed.
** "COMPUTERNAME" or "USERDOMAIN" = OEM PC serial number or the computer name assigned by owner.
** "HOMEDRIVE" or "SystemDrive" = Windows root drive, normally C: on single partition drives.
** "HOMEPATH" = current user's Administrator or the single user's "OWNER" folder path.
** "OS" = Windows Operating System version. Often WindowsNT in modern computers.
** "PATH" = full path setting that Windows uses to look for file extensions in PATHEXT below.
** "PATHEXT = Windows extensions used: COM, EXE, BAT, CMD, VBS, VBE, JS, JSE, WSF, WSH, MSC
** "PROCESSOR_ARCHITECTURE" = x86 for 32 or 64 bit.
** "PROGRAMFILES" = path to ''Program files'' folder, normally "C:\PROGRAM FILES"
** "PROMPT" = normally "$P$G" on Windows NT.
** "SYSTEMROOT" or "windir" = path to the Windows folder including the drive letter like "C:\WINDOWS"
** "TEMP" or "TMP" = path to TEMP folder. "C:\TEMP" or the user specific temp folder on later versions.
** "USERNAME" = current Administrator name or "OWNER".
: ''Note:'' There are other possible system settings that are not listed or never used on older versions. Run ''Example 1'' below for a complete list in your system.
<!-- Sentence removed for being unclear/needs revision: * The OS in Win 9X or ME can be found in the "PROMPT" parameter ID. Returns are limited in Win 9X and ME. -->
* ''Note:'' '''QB64''' may not return the same environment list as QBasic or SET did in DOS.
{{PageExamples}}
''Example 1:'' Viewing the list of environmental parameter settings using a counter loop like SET does in DOS.
{{CodeStart}} '' ''
@ -64,7 +63,7 @@ USERDOMAIN=TED-LAPTOP
USERNAME=Ted
USERPROFILE=C:\Users\Ted
{{OutputEnd}}
:''Note:'' Windows environmental settings are listed alphabetically, 20 at a time. '''QB64 may not read all of them or return an empty string!''' The settings above were returned with SET in DOS. PROMPT returned nothing where SET returned $P$G.
:''Note:'' Windows environmental settings are listed alphabetically, 20 at a time. '''QB64 may not read all of them or may return an empty string.''' The settings above were returned with SET in DOS. PROMPT returned nothing where SET returned $P$G.
''Example 2:'' Creating a shortcut on a user's desktop for QB64.EXE using the program's icon. Must be run in program's folder to work!
@ -114,8 +113,7 @@ Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
{{CodeEnd}}
{{small|Adapted from code by Dav}}
: ''Explanation:'' The SUB program finds the current program's path and user's desktop path. It then creates the shortcut on the desktop with a program icon. The custom icon should be in the program's folder. If an environmental path is not found, the shortcut is placed in the program's folder. The SUB can be added to any program.
<center>{{Text|'''NOTE:''' A temorary file named PRGMDIR.INF is created and deleted.|darkred}}</center>
:{{Text|'''NOTE:''' A temorary file named PRGMDIR.INF is created and deleted in the example above.}}
''See also:''

View file

@ -1,22 +1,25 @@
The '''ENVIRON''' statement is used '''in Windows''' to temporarily set or change an environmental string value.
'''This page is maintained for historic purposes. The keyword is [[Keywords_currently_not_supported_by_QB64|not supported in QB64]]. Reading values is supported with [[ENVIRON$]].
----
The [[ENVIRON]] statement is used in DOS/Windows to temporarily set or change an environmental string value.
{{PageSyntax}}
:: ENVIRON string_expression$
: [[ENVIRON]] {{Parameter|stringExpression$}}
* [[Keywords_currently_not_supported_by_QB64]]
* The string expression must include the environmental parameter ID and the setting two ways:
: * Using an = : ENVIRON parameterID=setting
: * Using a space: ENVIRON parameterID setting
{{PageDescription}}
* [[Keywords_currently_not_supported_by_QB64|Not supported in QB64.]]
* The {{Parameter|stringExpression$}} must include the environmental parameter ID and the setting:
** Using an '''=''' sign: [[ENVIRON]] "parameterID=setting"
** Using a space: [[ENVIRON]] "parameterID setting"
* If the parameter ID did not previously exist in the environmental string table, it is appended to the end of the table.
* If a parameter ID did exist, it is deleted and the new value is appended to end of the list.
* DOS discards any changes when your program ends so the program must set them when run!
* DOS discards any changes when your program ends so the program must set them when run.
* '''WARNING:''' The amount of space in a environmental table is limited and may create memory errors.
''See also:''
{{PageSeeAlso}}
* [[ENVIRON$]]
* [[Windows Environment]]

View file

@ -1,19 +1,24 @@
The '''EOF''' Function indicates that the end of a file has been reached.
The [[EOF]] function indicates that the end of a file has been reached.
{{PageSyntax}}
:: DO WHILE [[NOT]] EOF(filenumber&)
: {{Parameter|endReached%%}} = EOF([#]{{Parameter|fileNumber&}})
* Filenumber is the number of the file being read. # is not required.
{{PageDescription}}
* {{Parameter|fileNumber&}} is the number of the file being read. '''#''' is not required.
* Returns 0 until the end of a file. This avoids a file read error.
* Returns -1 at the end of the file.
* [[CHR$]](26) can be used to denote the end of a file.
* Returns -1 (true) at the end of the file.
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
* '''Note that [[GET]] can return invalid data at the end of a file.''' Read [[EOF]] after a GET operation to see if the end of the file has been reached and discard last read.
''See also:''
* [[LOF]]
{{PageSeeAlso}}
* [[OPEN]]
* [[LOF]], [[LEN]]
* [[INPUT (file statement)]]
* [[LINE INPUT (file statement)]]
* [[GET]], [[PUT]]
{{PageNavigation}}

View file

@ -1,12 +1,12 @@
The '''EQV''' statement returns a value based on the ''equivalence'' of two conditions or values.
The [[EQV]] operator returns a value based on the ''equivalence'' of two conditions or values.
{{PageSyntax}}
:first_value {{KW|EQV}} second_value
: {{Parameter|result}} = {{Parameter|firstValue}} [[EQV]] {{Parameter|secondValue}}
{{PageDescription}
* Returns True only when both values are the same.
{{PageDescription}}
* Returns true (-1) when both values are the same (''equivalent'').
* Turns a bit on if both bits are the same, turns a bit off if both bits are different.

View file

@ -1,21 +1,19 @@
The '''ERASE''' statement is used to clear all data from an array. [[$STATIC]] [[Arrays|array]] dimensions will not be changed.
The [[ERASE]] statement is used to clear all data from an array. [[$STATIC]] [[Arrays|array]] dimensions are not affected.
{{PageSyntax}}
:: ERASE ''ArrayName'' [, ''arrayname2''...]
: ERASE ''arrayName'' [, ''arrayName2''...]
* String array elements will all become null strings("") and numerical array elements will all become 0.
{{PageDescription}}
* All string array elements become null strings ("") and all numerical array elements become 0.
* Multiple arrays can be erased using commas between the array names.
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if they are referenced after erased.
* Dimension subprocedure arrays as [[STATIC]] to use ERASE and not have to REDIM.
* You do not have to include the array brackets in an ERASE call.
* [[$DYNAMIC|Dynamic]] arrays must be [[REDIM]]ensioned if they are referenced after erased.
* Dimension subprocedure arrays as [[STATIC]] to use [[ERASE]] and not have to REDIM.
* You do not have to include array brackets in an [[ERASE]] call.
''See also:''
{{PageSeeAlso}}
* [[DIM]], [[REDIM]]
* [[CLEAR]]
* [[STATIC]]

View file

@ -1,16 +1,20 @@
ERDEV$ is a string function that returns the name of the last device to declare an error.
'''This page is maintained for historic purposes. The keyword is [[Keywords currently not supported by QB64|not supported in QB64]].'''
----
[[ERDEV$]] is a string function that returns the name of the last device to declare an error.
{{PageSyntax}}
::device$ = ERDEV$
: {{Parameter|device$}} = [[ERDEV$]]
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
* It will contain the 8-byte character device name if the error was declared by a character device (such as a printer), while it will contain the 2-byte block name (A:, B:, etc.) if the device was not a character device.
* It is set when [[ERDEV]] is set, meaning that DOS has encountered a error that prevents it from continuing.
''See also:''
{{PageSeeAlso}}
* [[ERDEV]]
* [[ERROR]]

View file

@ -1,12 +1,18 @@
ERDEV is an integer function that returns an error code from the last device to create an error.
'''This page is maintained for historic purposes. The keyword is [[Keywords currently not supported by QB64|not supported in QB64]].'''
----
[[ERDEV]] is an integer function that returns an error code from the last device to create an error.
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
* The code is bit-encoded containing DOS error information, the first 8-bit (first byte) contain the DOS error code, while the second bit contains device specific information (bits 15, 14, 13, (12-4 always zero), 3, 2, 1 in that order of the device attribute word).
* ERDEV is set by the critical error handler (interrupt 24h) when DOS encounters a error that prevents it from continuing.
* [[ERDEV]] is set by the critical error handler (interrupt 24h) when DOS encounters a error that prevents it from continuing.
''See also:'' [[ERDEV$]], [[ERROR]]
{{PageSeeAlso}}
[[ERDEV$]], [[ERROR]]

View file

@ -1,8 +1,8 @@
The {{KW|ERL}} function returns the closest previous line number before the last error.
The [[ERL]] function returns the closest previous line number before the last error.
{{PageSyntax}}
:''result&'' = {{KW|ERL}}
: ''lastErrorLine&'' = [[ERL]]
{{PageDescription}}
@ -11,6 +11,7 @@ The {{KW|ERL}} function returns the closest previous line number before the last
* Use [[_ERRORLINE]] to return the actual code line position of an error in a QB64 program.
{{PageExamples}}
''Example:'' Using a fake error code to return the line number position in a program.
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} errorfix
@ -35,7 +36,7 @@ errorfix:
* [[ERR]]
* [[ERROR]]
* [[ON ERROR]]
* [[_ERRORLINE]]
* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]]
* [[ERROR Codes]]

View file

@ -1,14 +1,16 @@
'''ERR''' function returns the last Qbasic error code number.
The [[ERR]] function returns the last QBasic error code number.
{{PageSyntax}}
:: errornum% = ERR
: {{Parameter|errorNum%}} = [[ERR]]
* If there is no error it returns 0
* Can be used in an error handling routine to report the error number.
{{PageDescription}}
* If there is no error, the function returns 0
* Can be used in an error handling routine to report the last error code number.
{{PageExamples}}
''Example:'' Simulating an error to test a program error handler that looks for a "Subscript out of range" error.
{{CodeStart}} '' ''
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
@ -31,10 +33,10 @@ handler:
{{CodeEnd}}
''See also:''
{{PageSeeAlso}}
* [[ON ERROR]], [[RESUME]]
* [[ERL]], [[_ERRORLINE]]
* [[ERL]]
* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]]
* [[ERROR]]
* [[ERROR Codes]]

View file

@ -1,15 +1,17 @@
The '''ERROR''' statement is used to simulate a program error or to troubleshoot error handling procedures.
The [[ERROR]] statement is used to simulate a program error or to troubleshoot error handling procedures.
{{PageSyntax}}
:: ERROR code
: [[ERROR]] {{Parameter|codeNumber%}}
{{PageDescription}}
* Can be used to test an error handling routine by simulating an error.
* Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97.
* Use error codes between 100 and 200 for custom program errors that will not be responded to by QB64.
{{PageExamples}}
''Example:'' Creating custom error codes for a program that can be handled by an [[ON ERROR]] handling routine.
{{CodeStart}} '' ''
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
@ -26,10 +28,10 @@ handler:
{{Cl|BEEP}}
{{Cl|RESUME}} {{Cl|NEXT}} '' ''
{{CodeEnd}}
: '''Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program!'''
: '''Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program.'''
''See also:''
{{PageSeeAlso}}
*[[ON ERROR]]
*[[ERR]], [[ERL]]
*[[_ERRORLINE]]

View file

@ -1,21 +1,21 @@
The [[EXIT]] statement is used to exit certain Qbasic procedures.
The [[EXIT]] statement is used to exit certain QBasic procedures.
{{PageSyntax}}
::EXIT {DO|WHILE|FOR|SUB|FUNCTION|DEF}
: [[EXIT]] {DO|WHILE|FOR|SUB|FUNCTION}
{{PageDescription}}
* EXIT leaves any of the following procedures immediately.
:* [[EXIT]] DO exits a [[DO...LOOP]] when called.
:* [[EXIT]] WHILE exits a [[WHILE...WEND]] loop when called.
:* [[EXIT]] FOR exits a [[FOR...NEXT]] counter loop when called.
:* [[EXIT]] SUB exits a [[SUB]] procedure before it ends. Use before any [[GOSUB]] procedures using [[RETURN]].
:* [[EXIT]] FUNCTION exits a [[FUNCTION]] procedure before it ends. The value passed by the function's name should be defined.
:* [[EXIT]] DEF exits a [[DEF FN]] function procedure before it ends. The value passed by the function's name should be defined.
* [[EXIT]] leaves any of the following procedures immediately.
** [[EXIT]] DO exits a [[DO...LOOP]].
** [[EXIT]] WHILE exits a [[WHILE...WEND]] loop.
** [[EXIT]] FOR exits a [[FOR...NEXT]] counter loop.
** [[EXIT]] SUB exits a [[SUB]] procedure before it ends. Use before any [[GOSUB]] procedures using [[RETURN]].
** [[EXIT]] FUNCTION exits a [[FUNCTION]] procedure before it ends. The value passed by the function's name should be defined.
<!-- ** [[EXIT]] DEF exits a [[DEF FN]] function procedure before it ends. The value passed by the function's name should be defined. -->
* EXIT statements normally use an [[IF...THEN]] statement to evaluate a program condition that would require the EXIT.
* To exit a program and allow the last program screen to be displayed with "Press any key to continue", use [[END]].
* To exit the program immediately you can use [[SYSTEM]].
* To exit a program and allow the last program screen to be displayed with the message "Press any key to continue...", use [[END]].
* To exit the program immediately, use [[SYSTEM]].
{{PageSeeAlso}}

View file

@ -1,20 +1,20 @@
The '''EXP''' math function returns the value of '''e''' to the power of the parameter used.
The [[EXP]] math function calculates the exponential function ('''e''' raised to the power of a {{Parameter|numericExpression}}).
{{PageSyntax}}
:: value = EXP(exponent)
: {{Parameter|result}} = [[EXP]]({{Parameter|numericExpression}})
* '''e''' is defined as the base of natural logarithms or as the limit of (1 + 1 / n) ^ n as n goes to infinity
* The exponent value MUST be less than or equal to '''88.02969''' or an [[ERROR Codes|"overflow" error]] will occur!
* Value returned is '''e''' to the exponent parameter. '''e = 2.718282''' (approximately)
* Values returned are [[SINGLE]] by default but will return [[DOUBLE]] precision if the exponent uses a double value.
{{PageDescription}}
* '''e''' is defined as the base of natural logarithms or as the limit of (1 + 1 / n) ^ n, as n goes to infinity.
* The {{Parameter|numericExpression}} must be less than or equal to '''88.02969''' or an [[ERROR Codes|"overflow" error]] will occur.
* Value returned is '''e''' to the exponent parameter ('''e = 2.718282''' approximately).
* Values returned are [[SINGLE]] by default but will return [[DOUBLE]] precision if the {{Parameter|result}} is a variable of type [[DOUBLE]].
* Positive exponent values indicate the number of times to multiply '''e''' by itself.
* Negative exponent values indicate the number of times to divide by '''e'''. Example: e<sup>-3</sup> = 1 / e<sup>3</sup> = 1 /(e * e * e)
* Negative exponent values indicate the number of times to divide by '''e'''. Example: <span style="font-family: Courier New, monospace, Courier; background: #dddddd">e<sup>-3</sup> = 1 / e<sup>3</sup> = 1 / (e * e * e)</span>
''See also:''
{{PageSeeAlso}}
*[[LOG]]
*[[Mathematical Operations]]
*[http://qb64.net/wiki/index.php?title=Mathematical_Operations#Derived_Mathematical_Functions Derived Trigonometric Functions]

View file

@ -1,20 +1,21 @@
The '''FIELD''' statement creates a [[STRING]] type definition for a [[RANDOM|random]]-access file buffer.
The [[FIELD]] statement creates a [[STRING]] type definition for a [[RANDOM|random]]-access file buffer.
{{PageSyntax}}
:{{KW|FIELD}} [#]{{Parameter|fileNumber&}} {{Parameter|fieldWidth1%}} AS {{Parameter|variable1$}}[, {{Parameter|fieldWidthN%}} AS {{Parameter|variableN$}}]
: [[FIELD]] [#]{{Parameter|fileNumber&}} {{Parameter|fieldWidth1%}} AS {{Parameter|variable1$}}[, {{Parameter|fieldWidthN%}} AS {{Parameter|variableN$}}]
{{PageDescription}}
* {{Parameter|fileNumber%}} is a file number used in the [[OPEN]] statement or a value from the [[FREEFILE]] function.
* Combined size of the {{Parameter|fieldWidth%}} parameters '''MUST not exceed''' the [[LEN]] = recordsize in the [[RANDOM]] [[OPEN]] statement or a [[ERROR Codes|"FIELD overflow" error]] will occur.
* Combined size of the {{Parameter|fieldWidth%}} parameters '''must not exceed the [[LEN]] = recordsize in the [[RANDOM]] [[OPEN]] statement''' or a [[ERROR Codes|"FIELD overflow" error]] will occur.
* Variables are limited to [[STRING]] types. Use [[TYPE]] instead of FIELD if you want to use numerical values.
* Once a FIELD is defined in a statement, [[GET]] can read and [[PUT]] can write data without placeholders or variables.
* Once a [[FIELD]] is defined in a statement, [[GET]] can read and [[PUT]] can write data without placeholders or variables.
* [[LSET]], [[RSET]], [[PRINT (file statement)|PRINT #]], [[PRINT USING (file statement)|PRINT # USING]], and [[WRITE (file statement)|WRITE #]] can be used to place characters in the file buffer before a [[PUT]].
* All field definitions for a file are removed when the file is [[CLOSE|closed]] or [[RESET]] and all strings are set to null("").
* Do NOT re-assign a field defined variable value or use it in an [[INPUT]] statement if you want the variable to remain a field!
* All field definitions for a file are removed when the file is [[CLOSE|closed]] or [[RESET]] and all strings are set to null ("").
* '''Do not re-assign a field defined variable value or use it in an [[INPUT]] statement if you want the variable to remain a field'''.
{{PageExamples}}
''Example:'' Comparing a [[TYPE]] definition with a FIELD [[STRING|string]] definition. Demo using a [[TYPE]] definition to create a file:
{{CodeStart}} '' ''
{{Cl|TYPE}} ClientType

View file

@ -1,15 +1,19 @@
The {{KW|FILEATTR}} function can return a file's current file mode or DOS handle.
'''This page is maintained for historic purposes. The keyword is [[Keywords currently not supported by QB64|not supported in QB64]].'''
----
The [[FILEATTR]] function returns a file's current file mode or DOS handle.
{{PageSyntax}}
:''result%'' = {{KW|FILEATTR}}({{Parameter|fileNumber%}}, {{Parameter|mode%}})
: {{Parameter|result%}} = [[FILEATTR]]({{Parameter|fileNumber%}}, {{Parameter|mode%}})
{{PageDescription}}
*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]'''
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
* {{Parameter|fileNumber%}} is the number assigned in the file's [[OPEN]] statement.
* {{Parameter|mode%}} specifies the type of information to return, which may have the following values
** ''mode%'' = 1: returns the open mode with the following return values:
** {{Parameter|mode%}} = 1: returns the open mode with the following return values:
::{| border="2" cellpadding="1"
! Return || Open Mode
|-
@ -23,7 +27,7 @@ The {{KW|FILEATTR}} function can return a file's current file mode or DOS handle
|-
|  32 ||  [[BINARY]]
|}
:* ''mode%'' = 2: returns the [[DOS]] handle number of a file.
** {{Parameter|mode%}} = 2: returns the [[DOS]] handle number of a file.
{{PageSeeAlso}}

View file

@ -1,30 +1,34 @@
The {{KW|FILES}} statement is used to return a list of files in the current directory using a filespec, but long lists will scroll the screen.
The [[FILES]] statement is used to print a list of files in the current directory using a file specification.
{{PageSyntax}}
:{{KW|FILES}} [{{Parameter|fileSpec$}}]
: [[FILES]] [{{Parameter|fileSpec$}}]
{{PageDescription}}
* Filespec is a string expression or variable containing a path when required.
* Filespec can use the * and ? wildcard specs like normal DOS DIR statements.
: * denotes one or more wildcard characters in a filename or path spec as any legal file name character(s).
: ? denotes one wildcard letter in a filename or path spec as any legal filename character.
* If {{Parameter|fileSpec$}} is omitted, it is assumed to be <code>"*.*"</code> (all files and folders in the current directory).
* {{Parameter|fileSpec$}} is a string expression or variable containing a path when required.
* {{Parameter|fileSpec$}} can use the * and ? wildcard specifications:
** '''*''' denotes one or more wildcard characters in a filename or path specification as any legal file name character(s).
** '''?''' denotes one wildcard letter in a filename or path specification as any legal filename character.
* If {{Parameter|fileSpec$}} is omitted, it is assumed to be '''"*.*"''' (all files and folders in the current directory).
* Illegal filename characters in '''QB64''' include * > < : " | \ / with any amount of dot extensions being allowed in Windows.
* Illegal filename characters in '''Qbasic''' include * ? , > < ; : " | \ / + [ ] and more than one dot extension in [http://www.computerhope.com/issues/ch000209.htm DOS].
* FILES lists can make the screen roll. Try using SHELL "DIR" with the /P option. [http://www.computerhope.com/dirhlp.htm DIR command].
* FILES lists can make the screen roll up. Try using SHELL "DIR" with the /P option. [http://www.computerhope.com/dirhlp.htm DIR command].
==QBasic/QuickBASIC==
* Illegal filename characters in QBasic included '''* ? , > < ; : " | \ / + [ ]''' and more than one dot extension in [http://www.computerhope.com/issues/ch000209.htm DOS].
{{PageExamples}}
''Example 1:'' Finding a list of all BAS files in the current folder.
{{CodeStart}}{{Cl|FILES}} "*.BAS"
{{CodeEnd}}
<center>'''[http://i301.photobucket.com/albums/nn53/burger2227/FILESss.jpg Screenshot shows only the end of a long list of files]'''</center>
<!-- broken link: <center>'''[http://i301.photobucket.com/albums/nn53/burger2227/FILESss.jpg Screenshot shows only the end of a long list of files]'''</center> -->
''Example 2:'' A function that verifies that a file exists if it is NOT empty. Note: Function WILL deleted empty files!
<!-- function obsoleted by _FILEEXISTS; function doesn't use the FILES statement and is not relevant in this context; may be moved to an exclusive page if desired;
{{Parameter|Example 2:'' A function that verifies that a file exists if it is not empty. Note: This function will delete empty files.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a file name: ", file$
{{Cl|IF}} Exist%(file$) {{Cl|THEN}} {{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1: found% = -1 'function call demo
@ -38,10 +42,11 @@ f% = {{Cl|FREEFILE}}
{{Cl|IF}} {{Cl|LOF}}(f%) {{Cl|THEN}} Exist% = -1 {{Cl|ELSE}} Exist% = 0: {{Cl|CLOSE}} #f%: {{Cl|KILL}} filename$ 'delete empty files
{{Cl|CLOSE}} #f%
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}{{small|Code by Ted Weissgerber}}
{{CodeEnd}}{{small|Code by Ted Weissgerber}}}}
-->
''Example 3:'' The DIR$ function used in PDS(7.1) returns a filename or a list when more than one exist. The file spec can use a path and/or wildcards.
==Alternative file list solutions==
''Alternative 1:'' The DIR$ function adapted from PDS (7.1) returns a filename or a list when more than one exist. The file spec can use a path and/or wildcards.
{{CodeStart}} '' ''
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT}}
@ -85,21 +90,16 @@ DIR$ = DirList$(Index%)
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning it's name or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it MUST use an empty string parameter until QB64 supports optional parameters!''' The function does NOT delete empty files.
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning its name, or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it must use an empty string parameter as QB64 doesn't support optional parameters.''' The function does not delete empty files.
<center>'''Alternative File List Solution'''</center>
A member created a [[FILELIST$ (function)]] that uses the mouse and does not affect your program screens. It can verify that a file name exists or display a list of long and short file names to choose from. It also avoids program errors when a file name does not exist.
''Alternative 2:''
* The member-contributed [[FILELIST$]] function uses the mouse and does not affect your program screens. It can verify that a file name exists or display a list of long and short file names to choose from. It also avoids program errors when a file name does not exist. <!-- broken link: [http://i301.photobucket.com/albums/nn53/burger2227/FILE-ss2.jpg FILELIST$ function screenshot] -->
<center>NEW expanded code is available here: [[FILELIST$]]</center>
<center>[http://i301.photobucket.com/albums/nn53/burger2227/FILE-ss2.jpg FILELIST$ function Screenshot]</center>
''See Library:'' File Exist C++ Function that does not create a temp file. [http://qb64.net/wiki/index.php?title=C_Libraries#File_Exist FileExist Function]
<!-- The referenced library is not present in this link anymore ''See Library:'' File Exist C++ Function that does not create a temp file. [http://qb64.net/wiki/index.php?title=C_Libraries#File_Exist FileExist Function] -->
{{PageSeeAlso}}
* [[SHELL]], [[SCREEN (function)]] {{text|(See Example 2)}}
* [[SHELL]], [[SCREEN (function)]] {{text|(See Example 3)}}
* [[CHDIR]], [[MKDIR]]
* [[RMDIR]], [[KILL]]
* [[_CWD$]], [[_STARTDIR$]]
@ -107,9 +107,7 @@ A member created a [[FILELIST$ (function)]] that uses the mouse and does not aff
* [[DOS]], [[Batch Files]], [[DOS#DIR|DIR]]
* [[Windows_Libraries#File_Exist|Windows File Exist Library]]
* [[Windows_Libraries#File_Open_and_Save_Dialog|Windows Open and Save Dialog Boxes]]
* [[C_Libraries#Console_Window|C Console Library]]
* [[FILELIST$]], [[DIR$]] {{text|(member file list array functions)}}
* [[$CONSOLE]]
{{PageNavigation}}

View file

@ -1,21 +1,21 @@
The '''FIX''' function rounds a numerical value to the next whole number closest to zero.
The [[FIX]] function rounds a numerical value to the next whole number closest to zero.
{{PageSyntax}}
:: result = '''FIX('''''expression''''')'''
: {{Parameter|result}} = [[FIX]]({{Parameter|expression}})
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* {{Parameter|expression}} is any [[Data types|type]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* [[FIX]] effectively truncates (removes) the fractional part of ''expression'', returning the integer part.
* This means that [[FIX]] rounds down for positive values and up for negative values.
* [[FIX]] effectively truncates (removes) the fractional part of {{Parameter|expression}}, returning the integer part.
** This means that [[FIX]] rounds down for positive values and up for negative values.
* Use [[INT]] to round down negative values. Positive values are rounded down by both.
{{PageExamples}}
''Example 1:'' Showing the behavior of [[FIX]] with positive and negative decimal point values.
{{CodeStart}} '' ''
PRINT FIX(2.5)
@ -48,7 +48,8 @@ The '''FIX''' function rounds a numerical value to the next whole number closest
{{OutputEnd}}
''See also:''
{{PageSeeAlso}}
* [[_CEIL]]
* [[INT]], [[CINT]]
* [[CLNG]], [[_ROUND]]
* [[MOD]], [[\|Integer Division]]

View file

@ -1,37 +1,36 @@
The '''FOR''' statement creates a counter loop using specified start and stop numerical boundaries. The default increment is + 1.
The [[FOR]] statement creates a counter loop using specified start and stop numerical boundaries. The default increment is + 1.
{{PageSyntax}}
:: '''FOR ''counter_variable'' = ''start_value'' [[TO]] ''stop_value''''' [{{KW|STEP}} ''increment'']
:: .
:: .
:: .
:: '''NEXT''' [''counter_variable'']
: [[FOR]] {{Parameter|counterVariable}} = {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} [{{KW|STEP}} {{Parameter|increment}}]
:: ''{code}''
:: ⋮
: [[NEXT]] [{{Parameter|counterVariable}}]
{{Parameters}}
* The FOR ''counter_variable'' name is required to define the counter span and may also be used after the NEXT keyword.
* The ''start_value'' [[TO]] ''stop_value'' can be any literal or variable numerical type. BOTH values are required!
* [[STEP]] can be used for a loop ''increment'' other than the default plus 1 and can be any positive or negative literal or variable numerical value as long as the STEP value corresponds to the loop's ''start value'' and ''stop value''s.
* [[NEXT]] ends the FOR loop code block and increments the counter to the next value even when it exceeds the stop limit.
* The [[FOR]] {{Parameter|counterVariable}} name is required to define the counter span and may also be used after the NEXT keyword.
* The {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} can be any literal or variable numerical type. Both values are required.
* [[STEP]] can be used for a loop {{Parameter|increment}} other than the default ''plus 1 and can be any positive or negative literal or variable numerical value as long as the STEP value corresponds to the loop's {{Parameter|startValue}} and {{Parameter|stopValue}}.
* [[NEXT]] ends the [[FOR]] loop code block and increments the counter to the next value even when it exceeds the stop limit.
''Usage:''
* FOR NEXT counter loops must be within the proper start, stop and increment values or the entire loop code block will not be executed.
* Avoid changing the FOR ''counter_variable'''s value inside of the loop. This obfuscates code and is a poor programming practice!
* Once the loop has been started, changing the ''start_value'', ''stop_value'' or ''increment'' value will not affect loop execution.
* '''If the [[STEP]] ''increment'' value does not match the ''start_value'' [[TO]] ''stop_value'' the FOR loop block will be ignored!'''
:* If ''start_value'' is less than ''stop_value'', use default increment or positive [[STEP]] value or the loop will NOT be executed.
:* If ''start_value'' is more than ''stop_value'', use a negative [[STEP]] interval or the loop will NOT be executed.
:* The [[STEP]] ''increment'' value cannot be changed inside of the loop!
{{PageDescription}}
* [[FOR...NEXT]] counter loops must be within the proper start, stop and increment values or the entire loop code block will not be executed.
* Avoid changing the FOR {{Parameter|counterVariable}}'s value inside of the loop. This obfuscates code and is a poor programming practice.
* Once the loop has been started, changing the variables holding the {{Parameter|startValue}}, {{Parameter|stopValue}} or {{Parameter|increment}} value will not affect loop execution.
* '''If the [[STEP]] ''increment'' value does not match the {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} the FOR loop block will be ignored.'''
** If {{Parameter|startValue}} is less than {{Parameter|stopValue}}, use the default increment or positive [[STEP]] value or the loop will not be executed.
** If {{Parameter|startValue}} is more than {{Parameter|stopValue}}, use a negative [[STEP]] interval or the loop will not be executed.
** The [[STEP]] {{Parameter|increment}} value cannot be changed inside of the loop.
* Use '''[[EXIT]] FOR''' to leave a FOR loop early when a certain condition is met inside of the loop.
* The [[NEXT]] counter variable name is not required. NEXT loop increments can be separated by colons in nested FOR loops.
* '''NOTE: The counter value AFTER a FOR loop will be incremented one more than the ''stop_value'' requested by the loop!'''
* '''Beware of FOR loop counts that EXCEED the count variable's type limits and may repeat without error in QB64!'''
* '''NOTE: When the FOR loop is exited after the {{Parameter|stopValue}} is reached, the {{Parameter|counterVariable}}'s value will be {{Parameter|stopValue}} + 1 (or {{Parameter|stopValue}} + {{Parameter|increment}})
* '''Beware of FOR loop counts that exceed the {{Parameter|counterVariable}} type limits and may repeat without error in QB64.'''
** For example, if {{Parameter|counterVariable}} is of type [[INTEGER]] and the stop limit exceeds 32767, the {{Parameter|counterVariable}} will reset back to -32768 and loop endlessly.
{{PageExamples}}
''Example 1:'' Adding all of the even numbers from 10 to 0.
{{CodeStart}} '' ''
FOR i = 10 TO 0 {{Cl|STEP}} -2
@ -59,12 +58,13 @@ PRINT "After loop, i ="; i '' ''
bye {{OutputEnd}}
<!-- removed redundant example as Example 2 above shows exactly the same technique
''See Example:''
* [http://qb64.net/wiki/index.php?title=Controller_Devices#Example Example that shows how ignoring bad FOR loops can work to a program's advantage without errors.]
* [http://qb64.net/wiki/index.php?title=Controller_Devices#Example Example that shows how ignoring bad FOR loops can work to a program's advantage without errors.] -->
''See also:''
* [[NEXT]], [[STEP]]
{{PageSeeAlso}}
* [[STEP]]
* [[DO...LOOP]], [[WHILE...WEND]]

View file

@ -1,13 +1,14 @@
{{KW|FOR (file statement)|FOR}} is used in a {{KW|OPEN}} statement to select the filemode to open the file with.
#REDIRECT [[OPEN#File_Access_Modes]]
[[FOR (file statement)|FOR]] is used in a [[OPEN]] statement to indicate the file mode with which to open a file.
{{PageSyntax}}
:{{KW|OPEN}} ... {{KW|FOR (file statement)|FOR}} {APPEND|BINARY|INPUT|OUTPUT|RANDOM}
: [[OPEN]] ... [[FOR (file statement)|FOR]] {APPEND|BINARY|INPUT|OUTPUT|RANDOM}
{{PageDescription}}
* If {{KW|FOR (file statement)|FOR}} isn't used in a {{KW|OPEN}} statement then the default filemode {{KW|RANDOM}} is used.
* If [[FOR (file statement)|FOR]] isn't used in an [[OPEN]] statement, the default file mode {{KW|RANDOM}} is used.
** {{KW|APPEND}} - Keeps the information of the file intact while you can insert information at the end of it, writing permission only.
** {{KW|BINARY}} - Opens the file in binary mode, use this with binary files.
** {{KW|INPUT (file mode)|INPUT}} - Opens the file for viewing only.
@ -16,7 +17,7 @@
{{PageExamples}}
'''Warning:''' ''Make sure you don't have a file named test.tst before you run this! It will be overwritten if so!''
'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten.
{{CodeStart}}
@ -50,13 +51,8 @@ It was overwritten with this and deleted.
{{OutputEnd}}
{{PageSeeAlso}}
* {{KW|OPEN}}
* [[OPEN]]
{{PageNavigation}}

Some files were not shown because too many files have changed in this diff Show more