diff --git a/.ci/bootstrap.bat b/.ci/bootstrap.bat index 1fd9014c9..fb336fceb 100644 --- a/.ci/bootstrap.bat +++ b/.ci/bootstrap.bat @@ -15,7 +15,7 @@ echo Extracting %MINGW% as C++ Compiler @echo off %MINGW% -y -o"./internal/c/c_compiler/" -echo Bootstrapping QB64 -internal\c\c_compiler\bin\mingw32-make.exe -j8 OS=win BUILD_QB64=y EXE=.\qb64_bootstrap.exe +echo Bootstrapping QB64-PE +internal\c\c_compiler\bin\mingw32-make.exe -j8 OS=win BUILD_QB64=y EXE=.\qb64pe_bootstrap.exe IF ERRORLEVEL 1 exit /b 1 diff --git a/.ci/bootstrap.sh b/.ci/bootstrap.sh index fca5d9d67..9f75c7fb7 100755 --- a/.ci/bootstrap.sh +++ b/.ci/bootstrap.sh @@ -2,11 +2,11 @@ OS=$1 -echo -n "Bootstrapping QB64..." -make -j8 OS=$OS BUILD_QB64=y EXE=./qb64_bootstrap +echo -n "Bootstrapping QB64-PE..." +make -j8 OS=$OS BUILD_QB64=y EXE=./qb64pe_bootstrap if [ $? -ne 0 ]; then - echo "QB64 bootstrap failed" + echo "QB64-PE bootstrap failed" exit 1 fi echo "Done" diff --git a/.ci/compile.bat b/.ci/compile.bat index 5c8ec49fa..2224645b6 100644 --- a/.ci/compile.bat +++ b/.ci/compile.bat @@ -1,10 +1,10 @@ @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION -qb64_bootstrap.exe -x -w source\qb64.bas +qb64pe_bootstrap.exe -x -w source\qb64pe.bas IF ERRORLEVEL 1 exit /b 1 -del qb64_bootstrap.exe +del qb64pe_bootstrap.exe del /q /s internal\source\* move internal\temp\* internal\source\ diff --git a/.ci/compile.sh b/.ci/compile.sh index 0ee7c734c..cfa21f906 100755 --- a/.ci/compile.sh +++ b/.ci/compile.sh @@ -2,14 +2,14 @@ os=$1 -./qb64_bootstrap -x -w source/qb64.bas +./qb64pe_bootstrap -x -w source/qb64pe.bas SUCCESS=$? -rm qb64_bootstrap +rm qb64pe_bootstrap rm internal/source/* rm internal/temp/debug_* internal/temp/recompile_* -rm internal/temp/qb64.sym -rm internal/temp/qb64_bootstrap.sym +rm internal/temp/qb64pe.sym +rm internal/temp/qb64pe_bootstrap.sym mv internal/temp/* internal/source/ diff --git a/.ci/make-dist.sh b/.ci/make-dist.sh index 6c32de49e..a257befb8 100755 --- a/.ci/make-dist.sh +++ b/.ci/make-dist.sh @@ -4,9 +4,15 @@ buildPlatform=$1 version=$2 format= -ARCHIVE_ROOT=qb64 +ARCHIVE_ROOT=qb64pe DIST_ROOT=./dist/$ARCHIVE_ROOT +# populate internal/help from static download and updates from Wiki +curl --silent -o ./help.zip https://qb64phoenix.com/qb64_files/help.zip +unzip -oqq ./help.zip -d ./internal +./qb64pe -u +# end internal/help + case "$buildPlatform" in windows-latest) ./internal/c/c_compiler/bin/mingw32-make.exe OS=win clean @@ -25,10 +31,9 @@ mkdir -p $DIST_ROOT/internal/c cp -rp ./source $DIST_ROOT cp -rp ./licenses $DIST_ROOT -cp ./CHANGELOG.md $DIST_ROOT cp ./COPYING.txt $DIST_ROOT cp ./README.md $DIST_ROOT -cp ./qb64.1 $DIST_ROOT +cp ./qb64pe.1 $DIST_ROOT cp ./Makefile $DIST_ROOT cp -rp ./internal/source $DIST_ROOT/internal/ @@ -45,30 +50,30 @@ cp -p ./internal/c/* $DIST_ROOT/internal/c/ case "$buildPlatform" in windows-latest) - filename="qb64_win-$PLATFORM-$version.7z" + filename="qb64pe_win-$PLATFORM-$version.7z" format=7zip - cp ./qb64.exe $DIST_ROOT + cp ./qb64pe.exe $DIST_ROOT cp -r ./internal/c/c_compiler $DIST_ROOT/internal/c/ ;; ubuntu-latest) - filename="qb64_lnx-$version.tar.gz" + filename="qb64pe_lnx-$version.tar.gz" format=tar # Not sure if we should distribute this - # cp -p ./qb64 $DIST_ROOT + # cp -p ./qb64pe $DIST_ROOT cp -p ./setup_lnx.sh $DIST_ROOT ;; macos-latest) - filename="qb64_osx-$version.tar.gz" + filename="qb64pe_osx-$version.tar.gz" format=tar - cp -p ./qb64_start.command $DIST_ROOT - cp -p ./qb64.1 $DIST_ROOT - cp -p ./setup_osx.command $DIST_ROOT + cp -p ./qb64pe_start.command $DIST_ROOT + cp -p ./qb64pe.1 $DIST_ROOT + cp -p ./setup_osx.command $DIST_ROOT ;; esac diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b5134ea2..1dc1da354 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,23 +78,23 @@ jobs: shell: bash run: tests/run_c_tests.sh - - name: Print QB64 Version - run: ./qb64 -? + - name: Print QB64-PE Version + run: ./qb64pe -? - name: Test shell: bash run: tests/run_tests.sh - - name: Create QB64 Artifact + - name: Create QB64-PE Artifact shell: bash run: .ci/make-dist.sh ${{ matrix.os }} "${{ env.version }}" # Note that compiling programs in dist does modify the ./dist and make it # dirty, but that's ok because we've already create the .7z or .tar.gz # artifacts in the previous step - - name: Test QB64 Artifact + - name: Test QB64-PE Artifact shell: bash - run: tests/run_dist_tests.sh ./dist/qb64 ${{ matrix.prefix }} + run: tests/run_dist_tests.sh ./dist/qb64pe ${{ matrix.prefix }} # Only update ./internal/source if we're building on Linux, building on # the main branch, and building a Pull request merge. Otherwise the repo @@ -106,13 +106,13 @@ jobs: - uses: actions/upload-artifact@v3 if: always() with: - name: qb64-${{ matrix.prefix }}${{ matrix.prefix == 'win' && format('-{0}', matrix.platform) || '' }}-${{ env.version }} + name: qb64pe-${{ matrix.prefix }}${{ matrix.prefix == 'win' && format('-{0}', matrix.platform) || '' }}-${{ env.version }} path: | tests/results/ - qb64_win-x86*.7z - qb64_win-x64*.7z - qb64_lnx*.tar.gz - qb64_osx*.tar.gz + qb64pe_win-x86*.7z + qb64pe_win-x64*.7z + qb64pe_lnx*.tar.gz + qb64pe_osx*.tar.gz - name: Create release if: startsWith(github.ref, 'refs/tags/v') @@ -120,9 +120,9 @@ jobs: with: draft: true files: | - qb64_win-x86*.7z - qb64_win-x64*.7z - qb64_lnx*.tar.gz - qb64_osx*.tar.gz + qb64pe_win-x86*.7z + qb64pe_win-x64*.7z + qb64pe_lnx*.tar.gz + qb64pe_osx*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b8fbf4537..fb21c9c2c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,12 +6,12 @@ internal/temp* *.bas internal/config*.txt internal/config.ini -# internal/help +internal/help internal/commit.txt tempfoldersearch.bin internal/c/qbx[2-9].cpp *.ttf -/run_qb64.sh -/qb64 +/run_qb64pe.sh +/qb64pe mingw32.exe mingw64.exe diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index de08c16e3..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,41 +0,0 @@ -# QB64 development build - Changelog -Upcoming version is currently identified as v2.1, but that number may change before release. - -## New features -### All platforms -- Implement the `_Bin$` function as counterpart to `&B` prefixed number strings. Usage is analog to the legacy OCT$ and HEX$ functions. -- Save Watch Panel position and size. -- Add `$NOPREFIX` support for `$COLOR`. -- Allow changing color of menu panels and dialogs (Options->IDE Colors). -- Add support to different number formats in Watch Panel and Watch List dialog (dec/hex/oct/bin). - - - -## Fixes -### All platforms -- Fix function `LOC` returning wrong values when used on physical files. -- Fix glitch in syntax highlighter mistaking variable names with scientific notation. -- Fix Variable List dialog's "Add All" button not properly considering the active filter. -- Fix wiki update feature. -- Fix issue with Sub/Function parameters in `Declare` blocks with `$NoPrefix`. -- Fix issue with Sub/Function parameters without types after `As`. -- Fix issue with capitalization of array names in `LBound/UBound` calls. -- Fix capitalization of 'To' in `Case` statements. -- Fix indentation issue in disabled precompiler blocks. -- Fix crash when a variable was deleted between `$Debug` sessions. -- Reenables selecting a line by clicking the line number bar when `$Debug` is not used and the `Auto-add $Debug metacommand` feature is disabled. - - - -### Linux -- Fix building static libraries when installation path contains spaces. \ No newline at end of file diff --git a/Makefile b/Makefile index d6d6e6a1b..4f965a12e 100644 --- a/Makefile +++ b/Makefile @@ -103,9 +103,9 @@ endif ifdef BUILD_QB64 ifeq ($(OS),win) - EXE ?= qb64.exe + EXE ?= qb64pe.exe else - EXE ?= qb64 + EXE ?= qb64pe endif endif @@ -154,14 +154,14 @@ EXE_OBJS += $(QB_QBX_OBJ) CLEAN_LIST += $(QB_QBX_OBJ) ifdef BUILD_QB64 - # Copy the QB64 source code into temp before compiling + # Copy the QB64-PE source code into temp before compiling ifeq ($(OS),win) _shell := $(shell $(CP) $(PATH_INTERNAL_SRC)\\* $(PATH_INTERNAL_TEMP)\\) else _shell := $(shell $(CP) $(PATH_INTERNAL_SRC)/* $(PATH_INTERNAL_TEMP)/) endif - # Required dependencies of QB64 itself + # Required dependencies of QB64-PE itself DEP_FONT := y DEP_ICON := y DEP_ICON_RC := y diff --git a/README.md b/README.md index 5765bf897..43e515915 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -# QB64 +# QB64 Phoenix Edition -![githubstrip](https://avatars.githubusercontent.com/u/104205737?s=200&v=4) +![QB64-PE](source/peLogo.png) -QB64 is a modern extended BASIC+OpenGL language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows (XP and up), Linux and macOS. -[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/QB64Team/qb64/issues) +QB64 is a modern extended BASIC+OpenGL language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows (Vista and up), Linux and macOS. # Table of Contents 1. [Installation](#Installation) @@ -16,51 +15,51 @@ QB64 is a modern extended BASIC+OpenGL language that retains QB4.5/QBasic compat 3. [Additional Info](#Additional_Info) # Installation -Download the appropriate package for your operating system over at https://github.com/QB64-Phoenix-Edition/QB64pe/releases/tag/v1.0alpha +Download the appropriate package for your operating system over at https://github.com/QB64-Phoenix-Edition/QB64pe/releases/latest ## Windows Make sure to extract the package contents to a folder with full write permissions (failing to do so may result in IDE or compilation errors). -* It is advisable to to whitelist the QB64 folder in your antivirus/antimalware software * +* It is advisable to to whitelist the 'qb64pe' folder in your antivirus/antimalware software * ## macOS -Before using QB64 make sure to install the Xcode command line tools with: +Before using QB64-PE make sure to install the Xcode command line tools with: ```bash xcode-select --install ``` -Run ```./setup_osx.command``` to compile QB64 for your OS version. +Run ```./setup_osx.command``` to compile QB64-PE for your OS version. ## Linux -Compile QB64 with ```./setup_lnx.sh```. +Compile QB64-PE with ```./setup_lnx.sh```. Dependencies should be automatically installed. Required packages include OpenGL, ALSA and the GNU C++ Compiler. # Usage -Run the QB64 executable to launch the IDE, which you can use to edit your .BAS files. From there, hit F5 to compile and run your code. +Run the ```qb64pe``` executable to launch the IDE, which you can use to edit your .BAS files. From there, hit F5 to compile and run your code. To generate a binary without running it, hit F11. Additionally, if you do not wish to use the integrated IDE and to only compile your program, you can use the following command-line calls: -```qb64 -c yourfile.bas``` +```qb64pe -c yourfile.bas``` -```qb64 -c yourfile.bas -o outputname.exe``` +```qb64pe -c yourfile.bas -o outputname.exe``` Replacing `-c` with `-x` will compile without opening a separate compiler window. # Additional Information -More about QB64 at our wiki: https://qb64phoenix.com/qb64wiki +More about QB64-PE at our wiki: https://qb64phoenix.com/qb64wiki We have a community forum at: https://qb64phoenix.com/forum We don't currently tweet. Sorry. -Find us on Discord: https://discord.gg/8YsAZrN3qb +Find us on Discord: https://discord.gg/D2M7hepTSx diff --git a/docs/build-system.md b/docs/build-system.md index 0997cdd35..504df8e68 100644 --- a/docs/build-system.md +++ b/docs/build-system.md @@ -6,7 +6,7 @@ Build Process This describes the process that goes on to compile a QB64 program into an executable. -1. `QB64.bas` takes the QB64 source code and produces C++ source code for the program. That C++ source is placed into various files and goes into `./internal/temp`. +1. `QB64-PE` takes the QB64 source code and produces C++ source code for the program. That C++ source is placed into various files and goes into `./internal/temp`. 2. `make` is used to run the `Makefile` at the root of this repository. It is supplied the `OS` parameter, the `EXE` parameter for the final executable name, and a variety of `DEP_*` parameters depending on what dependencies the QB64 program requires. 1. 3rd party dependencies located in `./internal/c/parts/` are compiled if requested. Each of these has its own `build.mk` file that includes the `make` logic to build that dependency. 2. `./internal/c/libqb.cpp` is compiled with various C preprocessor flags depending on the provided `DEP_*` flags. The name is changed depending on the settings it is compiled with so that we don't accidentally use a libqb compiled with different settings. @@ -17,22 +17,22 @@ This describes the process that goes on to compile a QB64 program into an execut CI Process ---------- -This describes how QB64 itself is built by the CI process to produce a release of QB64. The actual build scripts that do all of this are located in `.ci/`.` +This describes how QB64-PE itself is built by the CI process to produce a release of QB64-PE. The actual build scripts that do all of this are located in `.ci/`.` -1. Before CI ever begins, `./internal/source/` contains the generated C++ source of a previous version of `qb64.bas`. +1. Before CI ever begins, `./internal/source/` contains the generated C++ source of a previous version of `qb64pe.bas`. 2. `.ci/calculate_version.sh` is run to determine what version this CI build should be considered. That information is written to `./internal/version.txt`, if it is a release version `./internal/version.txt` is removed. -3. 'bootstrap_qb64' is compiled from `./internal/source` - 1. `make` is used to call the `Makefile` with the proper `OS` setting, `EXE=bootstrap_qb64`, and `BUILD_QB64=y`. - 2. The Makefile will take care of copying `./internal/source` into `./internal/temp` and compiling QB64 with the proper settings. -4. `bootstrap_qb64` is used to compile `./source/qb64.bas` into a proper `qb64` executable - 1. We run `./bootstrap_qb64 -x ./source/qb64.bas` to compile QB64. This compiles QB64 the same way as a regular QB64 program as detailed in 'Build Process' -5. `./internal/source` is cleared out and, excluding a few files, the contents of `./internal/temp` are copied into `./internal/source` as the new generated C++ source of QB64. -6. `tests/run_tests.sh` is run to test the compiled version of QB64. A failure of these tests fails the build at this stage. -7. `.ci/make-dist.sh` is run to produce the distribution of QB64, which is stored as a build artifact and potentially a release artifact.. +3. `qb64pe_bootstrap` is compiled from `./internal/source` + 1. `make` is used to call the `Makefile` with the proper `OS` setting, `EXE=qb64pe_bootstrap`, and `BUILD_QB64=y`. + 2. The Makefile will take care of copying `./internal/source` into `./internal/temp` and compiling QB64-PE with the proper settings. +4. `qb64pe_bootstrap` is used to compile `./source/qb64pe.bas` into a proper `qb64pe` executable + 1. We run `./qb64pe_bootstrap -x ./source/qb64pe.bas` to compile QB64-PE. This compiles QB64-PE the same way as a regular QB64 program as detailed in 'Build Process' +5. `./internal/source` is cleared out and, excluding a few files, the contents of `./internal/temp` are copied into `./internal/source` as the new generated C++ source of QB64-PE. +6. `tests/run_tests.sh` is run to test the compiled version of QB64-PE. A failure of these tests fails the build at this stage. +7. `.ci/make-dist.sh` is run to produce the distribution of QB64-PE, which is stored as a build artifact and potentially a release artifact.. 1. The contents of the distribution depends on the OS it is being created for. - 1. The Windows distribution contains a precompiled copy of QB64 as `qb64.exe` and can be used immediately. - 2. The Linux and OSX distributions do not contain a precompiled copy of QB64. Those version come with a "setup" script that has to be run which builds QB64 based on the contents of `./internal/source`. -8. `tests/run_dist_tests.sh` is run to verify the distribution of QB64 works correctly. + 1. The Windows distribution contains a precompiled copy of QB64-PE as `qb64pe.exe` and can be used immediately. + 2. The Linux and OSX distributions do not contain a precompiled copy of QB64-PE. Those version come with a "setup" script that has to be run which builds QB64-PE based on the contents of `./internal/source`. +8. `tests/run_dist_tests.sh` is run to verify the distribution of QB64-PE works correctly. 9. If this is a CI build of `main` and `./internal/source` has changed due to the newly compiled version, then `git` is used to commit and push the updated version of `./internal/source` to the GitHub repo. Repository Layout @@ -40,34 +40,34 @@ Repository Layout - `.ci/` - All files in this folder are related to the CI build process. - `bootstrap.bat` - - Windows only, Downloads MinGW compiler, builds the precompiled version of QB64 located in `./internal/source` as `bootstrap_qb64.exe`. + - Windows only, Downloads MinGW compiler, builds the precompiled version of QB64-PE located in `./internal/source` as `qb64pe_bootstrap.exe`. - `bootstrap.sh` - - Linux and OSX, builds the precompiled version of QB64 located in `./internal/source` as `bootstrap_qb64.exe`. + - Linux and OSX, builds the precompiled version of QB64-PE located in `./internal/source` as `qb64pe_bootstrap.exe`. - `compile.bat` - - Uses `bootstrap_qb64.exe` to build `./source/qb64.bas`. This compiled QB64 is the released QB64.exe. + - Uses `qb64pe_bootstrap.exe` to build `./source/qb64pe.bas`. This compiled QB64-PE is the released `qb64pe.exe`. - `compile.sh` - - Uses `bootstrap_qb64` to build `./source/qb64.bas`. This built QB64 is what is used for testing, and the sources from this QB64 are placed into `./internal/source`. + - Uses `qb64pe_bootstrap` to build `./source/qb64pe.bas`. This built QB64-PE is what is used for testing, and the sources from this QB64-PE are placed into `./internal/source`. - `make-dist.sh` - - Copies all the relevant parts of QB64 into a new folder, which can be distributed as a release. + - Copies all the relevant parts of QB64-PE into a new folder, which can be distributed as a release. - `push-internal-source.sh` - - If `./internal/source` is different after building `./source/qb64.bas`, then this will automatically push those changes to the repository to update the sources used to build `bootstrap_qb64`. + - If `./internal/source` is different after building `./source/qb64pe.bas`, then this will automatically push those changes to the repository to update the sources used to build `qb64pe_bootstrap`. - `internal/` - `help/` - - Contains a downloaded copy of the help files, so that they do not have to be downloaded when QB64 is installed. - - `c/` - Contains everything related to the C/C++ source files for QB64. + - Contains a downloaded copy of the help files, so that they do not have to be downloaded when QB64-PE is installed. + - `c/` - Contains everything related to the C/C++ source files for QB64-PE. - `c_compiler/` - On Windows, this folder is populated with the MinGW C++ compiler during the CI process (or when using `setup_win.bat`. - `parts/` - Contains the sources to many of the dependencies that QB64 uses. Most of the dependencies have a `build.mk` file that is used by the main `Makefile` to build them. - `source/` - - Contains a copy of the generated C++ source of a previous version of QB64. This is used to build a copy of QB64 using only a C++ ccompiler. This is updated automatically via the CI process. + - Contains a copy of the generated C++ source of a previous version of QB64-PE. This is used to build a copy of QB64-PE using only a C++ ccompiler. This is updated automatically via the CI process. - `version.txt` - - QB64 checks this file to determine if there is a version tag (`-foobar` on the end of the version) for this version of QB64. + - QB64-PE checks this file to determine if there is a version tag (`-foobar` on the end of the version) for this version of QB64-PE. - `source/` - - Contains the QB64 source to QB64 itself. - - `tests/` - Contains the tests run on QB64 during CI to verify changes. + - Contains the QB64 source to QB64-PE itself. + - `tests/` - Contains the tests run on QB64-PE during CI to verify changes. - `compile_tests/` - - Testcases related to specific dependencies that QB64 that can pull in. These tests are largely intended to test that QB64 and the Makefile correctly pulls in the proper dependencies. + - Testcases related to specific dependencies that QB64 can pull in. These tests are largely intended to test that QB64-PE and the Makefile correctly pulls in the proper dependencies. - `qbasic_testcases/` - A variety of collected QB64 sample programs - `dist/` @@ -77,17 +77,17 @@ Repository Layout - `qbasic_tests.sh` - Compiled all the testcases in `qbasic_testcases` and verifies they compile successfully. - `dist_tests.sh` - - Verifies the output of `make-dist.sh` is a functioning distribution of QB64 + - Verifies the output of `make-dist.sh` is a functioning distribution of QB64-PE - `run_dist_tests.sh` - Runs the distribution test collecitons. - `run_tests.sh` - Runs all individual test collections. - `setup_lnx.sh` - - Used as part of the Linux release to install dependencies and compile QB64. + - Used as part of the Linux release to install dependencies and compile QB64-PE. - `setup_osx.command` - - Used as part of the OSx release to compile QB64. + - Used as part of the OSx release to compile QB64-PE. - `setup_win.bat` - - Used only for compiled QB64 directly from a clone of the repository (not a release, we distribute QB64 already compiled in the Windows release) + - Used only for compiled QB64-PE directly from a clone of the repository (not a release, we distribute QB64-PE already compiled in the Windows release) - `Makefile` - Used for building QB64 programs. @@ -95,14 +95,14 @@ Repository Layout Makefile Usage and Parameters ----------------------------- -> Note: These parameters are not guaranteed to stay the same. The 'setup' scripts and QB64 are the only things intended to call the Makefile directly. +> Note: These parameters are not guaranteed to stay the same. The 'setup' scripts and QB64-PE are the only things intended to call the Makefile directly. These flags control some basic settings for how the `Makefile` can compile the program. | Parameter | Default Value | Valid Values | Required | Description | | :-------- | :-----------: | :----------: | :------: | :---------- | | `OS` | None | `win`, `lnx`, or `osx` | Yes | Indicates to the Makefile which OS it is being used to compile for. Controls what utilities the Makefile assumes is available and where they are located, and also platform dependent compiler settings. | -| `BUILD_QB64` | None | `y` | No | If set then the Makefile will build the QB64 source located in `./internal/source`. If `EXE` is not specified, that is set to `qb64`. Dependency settings for QB64 are set automatically. | +| `BUILD_QB64` | None | `y` | No | If set then the Makefile will build the QB64-PE source located in `./internal/source`. If `EXE` is not specified, that is set to `qb64pe`. Dependency settings for QB64-PE are set automatically. | | `EXE` | None | Executable name | Yes, if not using `BUILD_QB64` | Specifies the name of the executable to build. If on Windows, it should include `.exe` on the end. Spaces in the filename should be escaped with `\` | | `TEMP_ID` | None | blank, or an integer | No | Controls the name of `qbx*.cpp` and `./internal/temp*` that are used for compilation. This is mainly relevant for multiple instances of the IDE, where the second instance compiles to `./internal/temp2` and tells the Makefile which to use. Further instances will use higher numbers. | | `CXXFLAGS_EXTRA` | None | Collection of C++ compiler flags | No | These flags are provided to the compiler when building the C++ files. This includes the generate source files, but also files like `libqb.cpp`. | @@ -136,7 +136,7 @@ Versioning QB64 Phoenix Edition follows SemVer, which means that major releases indicate a breaking change, minor releases indicate new features, and patch release indicates bug fixes. - - Release versions of QB64 will have just a version number in the form `X.Y.Z`. All other versions of QB64 will have some kind of 'tag' at the end of the version, which is arbitrary text after a `-` placed on the end of the version. + - Release versions of QB64-PE will have just a version number in the form `X.Y.Z`. All other versions of QB64-PE will have some kind of 'tag' at the end of the version, which is arbitrary text after a `-` placed on the end of the version. - CI versions get a tag in the form of `-XX-YYYYYYYY`, where `XX` is the number of commits since the last release, and `YYYYYYYY` is the first 8 digits of the commit hash of that build. - If you build the repository directly, you would get an `-UNKNOWN` version, which indicates that due to not running through the CI process we do not know what particular version (if any) that you are using. diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index bf7094c89..18b777ccd 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -321,175 +321,172 @@ static int32 image_qbicon32_handle; static int32 image_qbicon16_w = 16; static int32 image_qbicon16_h = 16; static const uint8 image_qbicon16[] = { - 209, 0, 0, 96, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, - 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 209, 0, 0, 96, - 210, 0, 0, 192, 244, 191, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 244, 191, 0, 255, - 210, 0, 0, 255, 244, 96, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 244, 96, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 255, 255, 0, 255, 255, 255, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, - 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 255, 255, 0, 255, 255, 255, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, - 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 128, 0, 255, 244, 96, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 255, 255, 0, 255, 255, 255, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, - 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 255, 255, 0, 255, 255, 255, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, - 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 128, 0, 255, 244, 96, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 244, 191, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 244, 191, 0, 255, - 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 210, 0, 0, 255, 210, 0, 0, 255, 244, 191, 0, 255, 255, 255, 0, 255, 244, 191, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, - 210, 0, 0, 255, 244, 96, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 255, 128, 0, 255, 244, 96, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, - 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 53, 191, 191, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 53, 191, 191, 255, - 210, 0, 0, 255, 53, 96, 191, 255, 53, 96, 191, 255, 210, 0, 0, 255, 210, 0, 0, 255, 53, 96, 191, 255, 53, 96, 191, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 0, 255, 255, 255, 0, 255, 255, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, - 210, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 255, 210, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 53, 191, 191, 255, - 210, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 255, 210, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 0, 255, 255, 255, 0, 255, 255, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 210, 0, 0, 255, 53, 96, 191, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 0, 255, 255, 255, 0, 255, 255, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 210, 0, 0, 192, - 210, 0, 0, 192, 53, 191, 191, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 53, 191, 191, 255, - 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 210, 0, 0, 255, 53, 96, 191, 255, 53, 96, 191, 255, 210, 0, 0, 192, - 209, 0, 0, 96, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, - 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 210, 0, 0, 192, 209, 0, 0, 96}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x05, 0x07, 0x07, 0x38, 0x55, 0x12, 0x12, 0x56, 0x96, 0x59, 0x51, 0x31, 0xBE, 0x4F, 0x47, 0x25, 0x8B, 0x05, 0x04, 0x03, 0x0F, + 0x19, 0x08, 0x06, 0x30, 0x6E, 0x1C, 0x11, 0x99, 0x6F, 0x24, 0x1B, 0xBD, 0x17, 0x12, 0x4F, 0x9A, 0x07, 0x07, 0x37, 0x54, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x09, 0x09, 0x09, 0xA3, 0xC9, 0x06, 0x06, 0xC3, 0xDB, 0x3A, 0x35, 0x22, 0x79, 0x52, 0x4B, 0x27, 0x93, 0x52, 0x4A, 0x26, 0x92, 0x38, 0x32, 0x1B, 0x67, + 0x32, 0x0E, 0x0A, 0x52, 0xAA, 0x2B, 0x19, 0xE2, 0xAD, 0x2B, 0x19, 0xE2, 0x2E, 0x10, 0x0E, 0x5D, 0x07, 0x07, 0xBE, 0xD7, 0x0A, 0x0A, 0x96, 0xBB, 0x02, 0x02, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x05, 0x1A, 0x2D, 0x0B, 0x0B, 0x6C, 0x97, 0x07, 0x07, 0xE0, 0xFC, 0x07, 0x07, 0x55, 0x71, 0x1E, 0x1B, 0x0F, 0x3F, 0x7A, 0x6F, 0x38, 0xCE, 0x85, 0x78, 0x3B, 0xD2, 0x23, 0x20, 0x12, 0x4D, + 0x30, 0x0E, 0x0A, 0x52, 0xA7, 0x2A, 0x18, 0xDF, 0x9C, 0x28, 0x19, 0xDA, 0x31, 0x0E, 0x0A, 0x52, 0x07, 0x07, 0x5E, 0x7A, 0x07, 0x07, 0xE2, 0xFD, 0x0A, 0x0A, 0x71, 0x9C, 0x05, 0x05, 0x1B, 0x2F, + 0x07, 0x07, 0x8A, 0xA7, 0x06, 0x06, 0xD5, 0xEA, 0x09, 0x09, 0xC8, 0xEE, 0x07, 0x07, 0x60, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1A, 0x22, 0x47, 0x23, 0x4E, 0x58, 0xB4, 0x0D, 0x0C, 0x07, 0x23, + 0x01, 0x01, 0x01, 0x07, 0x0D, 0x23, 0x4D, 0x85, 0x0D, 0x26, 0x55, 0x8B, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x72, 0x8F, 0x0A, 0x0A, 0xC4, 0xED, 0x05, 0x05, 0xDA, 0xEE, 0x07, 0x07, 0x89, 0xA6, + 0x0C, 0x0C, 0x6B, 0x9C, 0x00, 0x00, 0xFF, 0xFF, 0x02, 0x02, 0xF7, 0xFF, 0x08, 0x08, 0x9B, 0xBB, 0x03, 0x09, 0x0C, 0x1B, 0x0F, 0x85, 0xB5, 0xE0, 0x10, 0x70, 0x97, 0xCD, 0x04, 0x12, 0x17, 0x2B, + 0x09, 0x1D, 0x43, 0x65, 0x13, 0x44, 0x9C, 0xE6, 0x0D, 0x3D, 0x94, 0xBE, 0x01, 0x01, 0x02, 0x07, 0x07, 0x07, 0x9D, 0xBB, 0x02, 0x02, 0xF6, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0C, 0x0C, 0x75, 0xA6, + 0x0F, 0x0F, 0x96, 0xCF, 0x0E, 0x0E, 0x9C, 0xD3, 0x00, 0x00, 0xFE, 0xFF, 0x0F, 0x0F, 0x6D, 0xAA, 0x07, 0x14, 0x1B, 0x3A, 0x10, 0x78, 0xA3, 0xD6, 0x10, 0x74, 0x9E, 0xD1, 0x06, 0x1E, 0x28, 0x42, + 0x09, 0x1D, 0x41, 0x63, 0x12, 0x38, 0x7E, 0xC1, 0x0F, 0x45, 0xA9, 0xD8, 0x05, 0x06, 0x0A, 0x21, 0x0F, 0x0F, 0x6B, 0xA8, 0x00, 0x00, 0xFD, 0xFF, 0x0E, 0x0E, 0xAC, 0xE5, 0x0F, 0x0F, 0xA4, 0xDE, + 0x07, 0x07, 0xAA, 0xC8, 0x03, 0x03, 0xF2, 0xFE, 0x05, 0x05, 0xEC, 0xFF, 0x0D, 0x0D, 0x9B, 0xCF, 0x0A, 0x0A, 0x8F, 0xB8, 0x04, 0x04, 0x09, 0x1D, 0x02, 0x02, 0x02, 0x0E, 0x08, 0x08, 0x58, 0x78, + 0x08, 0x08, 0x9D, 0xBF, 0x09, 0x09, 0x33, 0x59, 0x03, 0x03, 0x05, 0x10, 0x0B, 0x0B, 0x82, 0xAF, 0x0C, 0x0C, 0x8E, 0xBF, 0x06, 0x06, 0xE9, 0xFF, 0x02, 0x02, 0xF6, 0xFF, 0x07, 0x07, 0xB0, 0xCE, + 0x04, 0x04, 0x18, 0x29, 0x0E, 0x0E, 0x92, 0xCD, 0x09, 0x09, 0xCA, 0xEF, 0x04, 0x04, 0xF1, 0xFF, 0x0F, 0x0F, 0xB6, 0xF2, 0x0B, 0x0B, 0xC3, 0xEE, 0x0E, 0x0E, 0x3B, 0x74, 0x0B, 0x0B, 0x9A, 0xC6, + 0x05, 0x05, 0xE7, 0xFC, 0x07, 0x07, 0x1D, 0x38, 0x0B, 0x0B, 0xBE, 0xEA, 0x0F, 0x0F, 0xAE, 0xEA, 0x04, 0x04, 0xEF, 0xFF, 0x09, 0x09, 0xC8, 0xEB, 0x0F, 0x0F, 0x8C, 0xC8, 0x04, 0x04, 0x15, 0x26, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x30, 0x49, 0x0A, 0x0A, 0xC0, 0xE9, 0x08, 0x08, 0xDE, 0xFF, 0x06, 0x06, 0xE6, 0xFE, 0x10, 0x7D, 0xBB, 0xFF, 0x12, 0x95, 0x9B, 0xEC, 0x0A, 0x44, 0xB9, 0xF6, + 0x04, 0x0A, 0xE7, 0xFF, 0x12, 0xA7, 0xA8, 0xF0, 0x14, 0x92, 0xA4, 0xFF, 0x07, 0x09, 0xBD, 0xFF, 0x08, 0x08, 0xE1, 0xFF, 0x0B, 0x0B, 0xB0, 0xDE, 0x06, 0x06, 0x27, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x0E, 0x07, 0x07, 0x53, 0x70, 0x11, 0x11, 0x5E, 0xA4, 0x12, 0xBD, 0xB6, 0xFC, 0x0D, 0x82, 0xA9, 0xFF, 0x0B, 0x62, 0xA3, 0xFF, + 0x08, 0x37, 0xD9, 0xFF, 0x0F, 0xBF, 0xBE, 0xFF, 0x10, 0x66, 0x7D, 0xF2, 0x0F, 0x0F, 0x5E, 0xAB, 0x08, 0x08, 0x47, 0x65, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x14, 0x13, 0x32, 0x0E, 0x9D, 0x95, 0xE7, 0x0B, 0x28, 0x4B, 0xAF, 0x01, 0x01, 0xDA, 0xFF, + 0x0A, 0x68, 0xD6, 0xFF, 0x10, 0x91, 0x8A, 0xEA, 0x0C, 0x42, 0x3F, 0xB0, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x1B, 0x07, 0x17, 0x1D, 0x6A, 0x0C, 0x0C, 0xAC, 0xDF, 0x00, 0x00, 0xFF, 0xFF, + 0x05, 0x17, 0xD3, 0xFF, 0x0F, 0x33, 0x87, 0xF7, 0x07, 0x19, 0x1C, 0x6C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0x0C, 0x20, 0x0D, 0x0D, 0x8B, 0xBD, 0x09, 0x09, 0xD9, 0xFE, + 0x0B, 0x0B, 0xCC, 0xF7, 0x0D, 0x0D, 0x92, 0xC7, 0x04, 0x04, 0x08, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0xAD, 0xD0, 0x0E, 0x0E, 0x9D, 0xD4, + 0x0E, 0x0E, 0x8B, 0xC2, 0x08, 0x08, 0xB5, 0xD7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x12, 0x24, 0x10, 0x10, 0x4D, 0x8F, + 0x10, 0x10, 0x51, 0x90, 0x05, 0x05, 0x19, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x05, 0x15, + 0x08, 0x08, 0x0E, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; static int32 image_qbicon32_w = 32; static int32 image_qbicon32_h = 32; static const uint8 image_qbicon32[] = { - 251, 0, 0, 64, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, - 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, - 0, 176, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, - 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, - 167, 0, 0, 32, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, - 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, - 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 96, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, 0, 255, 253, 127, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, - 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 0, 255, 253, 127, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, 253, 64, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, - 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 253, 64, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, 0, 176, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, - 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, - 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 252, 0, 0, 192, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, - 255, 255, 255, 0, 255, 255, 255, 0, 255, 212, 128, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 234, 192, 0, 255, 255, 255, - 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, - 128, 0, 192, 255, 128, 0, 192, 254, 64, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 254, 64, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, 0, 176, 168, 0, 0, 255, 255, 255, 0, - 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, - 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 255, 128, 0, 192, 255, - 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 252, 0, 0, 192, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, 0, - 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, - 0, 255, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, 255, - 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 254, 64, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 254, 64, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, 0, - 176, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, - 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 96, 168, 0, 0, 176, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, 0, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, - 0, 0, 255, 168, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 192, 252, 0, 0, 96, 252, 0, 0, 176, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 212, 64, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 212, 64, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, - 192, 252, 0, 0, 192, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, - 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, 0, 176, 168, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, - 0, 255, 255, 255, 0, 255, 254, 128, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 254, 128, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 212, 64, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 212, 64, 0, 192, 255, 128, 0, 192, 255, 128, 0, - 192, 255, 128, 0, 192, 255, 128, 0, 192, 252, 0, 0, 192, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, - 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, - 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, 0, 176, 168, 0, 0, 255, 253, 127, - 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 253, 127, 0, 255, 168, 0, 0, 255, 252, 0, 0, 192, 253, 64, 0, 192, - 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, - 192, 255, 128, 0, 192, 255, 128, 0, 192, 255, 128, 0, 192, 253, 64, 0, 192, 252, 0, 0, 192, 168, 0, 0, 96, 168, 0, 0, 176, 252, 0, - 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 96, 252, 0, - 0, 176, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 253, 127, 0, 255, 255, 255, 0, 255, 255, - 255, 0, 255, 255, 255, 0, 255, 253, 127, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, - 0, 96, 168, 0, 0, 96, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, - 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, - 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, - 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, - 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, 252, 0, 0, 192, 126, 127, 127, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, - 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 126, 127, 127, 192, 252, 0, 0, 192, 168, 0, 0, 255, 126, 64, 127, 255, 0, 128, 255, 255, 0, 128, 255, 255, 126, 64, 127, - 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 126, 64, 127, 255, 0, 128, 255, 255, 0, 128, - 255, 255, 126, 64, 127, 255, 168, 0, 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, - 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 0, 255, 255, 192, 126, 127, 127, 192, 168, 0, 0, 192, 252, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, - 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 0, 128, 255, 255, 0, 128, - 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, 252, 0, 0, 192, 0, 255, 255, 192, 0, - 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 84, 128, 128, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, - 255, 0, 128, 255, 255, 0, 128, 255, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 0, 128, - 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, 0, - 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 255, 0, 128, 255, - 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, 252, - 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 84, 128, 128, 192, 252, 0, 0, 192, 168, 0, 0, 192, - 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 126, 64, 128, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 126, 64, 128, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 176, 252, - 0, 0, 96, 168, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 126, 127, 127, 192, 168, 0, 0, - 192, 252, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, - 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 252, 0, 0, 255, 168, - 0, 0, 176, 168, 0, 0, 96, 252, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, - 192, 252, 0, 0, 192, 168, 0, 0, 255, 126, 64, 127, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, - 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 168, - 0, 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 126, 128, 128, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 126, 128, 128, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, - 192, 0, 255, 255, 192, 168, 0, 0, 192, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 84, 64, 128, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, - 128, 255, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, 252, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, - 192, 0, 255, 255, 192, 0, 255, 255, 192, 252, 0, 0, 192, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, - 128, 255, 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, 0, 255, 255, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 0, 255, 255, 192, 126, 128, 128, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 126, 128, 128, 192, 0, 255, 255, - 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 168, 0, 0, 192, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 0, 128, 255, 255, 0, - 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, 252, 0, 0, 192, 0, 255, 255, 192, - 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, - 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 252, 0, 0, 192, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 0, - 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 0, 128, 255, 255, 168, 0, 0, 255, 252, 0, 0, 176, 252, 0, 0, 96, 168, 0, 0, 192, - 126, 127, 127, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, - 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 0, 255, 255, 192, 126, 127, 127, 192, 168, 0, 0, 192, 252, 0, 0, 255, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, - 0, 0, 255, 126, 64, 127, 255, 0, 128, 255, 255, 0, 128, 255, 255, 126, 64, 127, 255, 252, 0, 0, 255, 168, 0, 0, 176, 168, 0, 0, 96, - 252, 0, 0, 96, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, - 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, 0, 192, 252, 0, 0, 192, 168, 0, - 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, - 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 255, 252, 0, 0, 255, 168, 0, 0, 176, 252, 0, 0, 176, - 167, 0, 0, 32, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, - 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, 0, 96, 252, 0, 0, 96, 168, 0, - 0, 96, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, - 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, 168, 0, 0, 176, 252, 0, 0, 176, - 251, 0, 0, 64}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x09, 0x0B, 0x2F, 0x0F, 0x0F, 0x3C, 0x7B, 0x1C, 0x1C, 0x26, 0x9A, 0x15, 0x14, 0x14, 0x6F, 0x0A, 0x0A, 0x09, 0x3A, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x1B, 0x08, 0x08, 0x08, 0x33, 0x08, 0x08, 0x08, 0x33, 0x10, 0x10, 0x10, 0x5F, 0x1E, 0x1E, 0x22, 0x9D, 0x12, 0x12, 0x42, 0x89, 0x0B, 0x0B, 0x10, 0x3A, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x12, 0x0F, 0x0F, 0x3E, 0x79, 0x0F, 0x0F, 0xA1, 0xDA, + 0x0D, 0x0D, 0xCA, 0xFB, 0x22, 0x20, 0x46, 0xB3, 0x85, 0x79, 0x3F, 0xEE, 0xAC, 0x9B, 0x4B, 0xFF, 0xAC, 0x9B, 0x4B, 0xFF, 0x86, 0x79, 0x3F, 0xEB, 0x13, 0x12, 0x0C, 0x3D, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x5F, 0x1D, 0x14, 0xA4, 0xDC, 0x31, 0x1B, 0xFF, 0xD0, 0x31, 0x1B, 0xFF, 0xD3, 0x31, 0x1B, 0xFF, 0xBB, 0x2F, 0x1B, 0xFA, 0x33, 0x1C, 0x31, 0xB3, 0x0D, 0x0D, 0xBA, 0xF1, + 0x0F, 0x0F, 0xA2, 0xDC, 0x0F, 0x0F, 0x37, 0x71, 0x02, 0x02, 0x02, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x2C, 0x5C, 0x0B, 0x0B, 0xC1, 0xF0, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0xDA, 0xF9, + 0x0B, 0x0B, 0x1D, 0x4A, 0x66, 0x5D, 0x31, 0xC2, 0xA4, 0x94, 0x49, 0xFF, 0x14, 0x13, 0x0E, 0x4E, 0x13, 0x12, 0x0E, 0x4D, 0xA4, 0x93, 0x49, 0xFF, 0x67, 0x5E, 0x32, 0xC4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x63, 0x1D, 0x14, 0xA4, 0xE0, 0x32, 0x1A, 0xFF, 0x15, 0x15, 0x15, 0x8C, 0x1B, 0x15, 0x14, 0x8B, 0xDD, 0x31, 0x1B, 0xFF, 0x6E, 0x1F, 0x16, 0xB2, 0x08, 0x08, 0x10, 0x32, + 0x09, 0x09, 0xCB, 0xF2, 0x00, 0x00, 0xFD, 0xFF, 0x0E, 0x0E, 0xB2, 0xE7, 0x0A, 0x0A, 0x1C, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x14, 0x03, 0x03, 0x03, 0x11, 0x0E, 0x0E, 0xA2, 0xD9, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x01, 0xFC, 0xFF, 0x0F, 0x0F, 0x37, 0x74, + 0x00, 0x00, 0x00, 0x00, 0x76, 0x6B, 0x38, 0xD7, 0x91, 0x83, 0x43, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x82, 0x43, 0xFC, 0x78, 0x6D, 0x38, 0xD9, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x63, 0x1D, 0x14, 0xA4, 0xE6, 0x32, 0x1A, 0xFF, 0xCF, 0x31, 0x1B, 0xFF, 0xD4, 0x31, 0x1B, 0xFF, 0xE6, 0x32, 0x1A, 0xFF, 0x41, 0x18, 0x13, 0x91, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x0F, 0x30, 0x6B, 0x01, 0x01, 0xFC, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x8A, 0xC3, 0x02, 0x02, 0x02, 0x0A, 0x05, 0x05, 0x05, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x0F, 0x13, 0x13, 0x86, 0xD1, 0x0A, 0x0A, 0x0A, 0x34, 0x0E, 0x0E, 0xC2, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0x0C, 0x0C, 0xC0, 0xF3, 0x02, 0x02, 0x02, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x66, 0x5D, 0x31, 0xC2, 0xA4, 0x94, 0x49, 0xFF, 0x14, 0x13, 0x0E, 0x4E, 0x13, 0x12, 0x0E, 0x4D, 0xA4, 0x94, 0x49, 0xFF, 0x67, 0x5E, 0x32, 0xC4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x63, 0x1D, 0x14, 0xA4, 0xE0, 0x32, 0x1A, 0xFF, 0x13, 0x13, 0x13, 0x81, 0x11, 0x10, 0x10, 0x6D, 0xC9, 0x30, 0x1C, 0xFF, 0x8D, 0x26, 0x19, 0xD3, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0x02, 0x0B, 0x0C, 0x0C, 0xCA, 0xFA, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0xC2, 0xF8, 0x0A, 0x0A, 0x0A, 0x31, 0x12, 0x12, 0x93, 0xDC, 0x04, 0x04, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x63, 0xA4, 0x00, 0x00, 0xFE, 0xFF, 0x0E, 0x0E, 0x20, 0x57, 0x0E, 0x0E, 0xC2, 0xF9, 0x00, 0x00, 0xFF, 0xFF, 0x0D, 0x0D, 0x93, 0xCA, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x13, 0x11, 0x0C, 0x3C, 0x85, 0x79, 0x3E, 0xEB, 0xAC, 0x9B, 0x4B, 0xFF, 0xAD, 0x9C, 0x4B, 0xFF, 0xB2, 0xA0, 0x4D, 0xFF, 0x26, 0x23, 0x17, 0x71, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x5F, 0x1D, 0x14, 0xA4, 0xDB, 0x31, 0x1B, 0xFF, 0xD0, 0x31, 0x1B, 0xFF, 0xD2, 0x31, 0x1B, 0xFF, 0xC5, 0x30, 0x1C, 0xFE, 0x37, 0x14, 0x0F, 0x75, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0xAD, 0xE4, 0x00, 0x00, 0xFF, 0xFF, 0x0D, 0x0D, 0xC8, 0xFD, 0x0F, 0x0F, 0x2A, 0x64, 0x00, 0x00, 0xFF, 0xFF, 0x10, 0x10, 0x67, 0xA7, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x0A, 0x2A, 0x07, 0x07, 0xE3, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x6F, 0xAB, 0x0E, 0x0E, 0xA3, 0xDB, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0x9C, 0xD4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x0C, 0x0C, 0x0B, 0x49, 0x17, 0x1B, 0x1B, 0x8E, 0x59, 0x53, 0x33, 0xD9, 0x35, 0x31, 0x1D, 0x8B, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x1A, 0x08, 0x08, 0x08, 0x33, 0x11, 0x16, 0x21, 0x7C, 0x13, 0x1E, 0x32, 0x96, 0x08, 0x09, 0x0B, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x04, 0x0D, 0x0D, 0xC3, 0xF7, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0xA0, 0xD8, 0x0F, 0x0F, 0x7E, 0xBA, 0x00, 0x00, 0xFF, 0xFF, 0x07, 0x07, 0xE0, 0xFE, 0x07, 0x07, 0x08, 0x26, + 0x0E, 0x0E, 0x3C, 0x74, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x06, 0x06, 0xE6, 0xFE, 0x19, 0x19, 0x7E, 0xE0, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0xDD, 0xFD, 0x07, 0x07, 0x08, 0x24, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x08, 0x12, 0x5C, 0x7A, 0xC3, 0x0F, 0xA6, 0xE4, 0xFF, 0x0C, 0x26, 0x31, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x17, 0x2D, 0x67, 0x0F, 0x59, 0xDE, 0xFE, 0x0D, 0x5E, 0xF2, 0xFF, 0x0B, 0x14, 0x25, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0C, 0x0C, 0x14, 0x43, 0x03, 0x03, 0xF4, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x1B, 0x1B, 0x71, 0xDD, 0x05, 0x05, 0xED, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0x3E, 0x76, + 0x0D, 0x0D, 0x26, 0x5A, 0x02, 0x02, 0xF6, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0xE0, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x10, 0x10, 0x5E, 0x9F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x48, 0x5F, 0xAA, 0x0D, 0xAE, 0xF1, 0xFF, 0x13, 0x84, 0xB2, 0xF3, 0x0D, 0x2D, 0x3B, 0x7A, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0B, 0x14, 0x25, 0x5A, 0x10, 0x56, 0xD8, 0xFD, 0x15, 0x47, 0xA5, 0xF6, 0x0D, 0x5E, 0xF2, 0xFF, 0x0B, 0x14, 0x25, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x0F, 0x62, 0x9F, 0x00, 0x00, 0xFF, 0xFF, 0x02, 0x02, 0xF9, 0xFF, 0x07, 0x07, 0xE3, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x01, 0xFB, 0xFF, 0x0E, 0x0E, 0x27, 0x5E, + 0x11, 0x11, 0x15, 0x59, 0x11, 0x11, 0x7A, 0xBC, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0xF3, 0xFF, 0x0C, 0x0C, 0x1C, 0x4D, + 0x00, 0x00, 0x00, 0x00, 0x0C, 0x24, 0x2E, 0x69, 0x0E, 0xAA, 0xEB, 0xFF, 0x11, 0x72, 0x9A, 0xD9, 0x11, 0x64, 0x85, 0xC8, 0x0E, 0xAA, 0xEB, 0xFF, 0x10, 0x45, 0x5C, 0xA1, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x0E, 0x17, 0x41, 0x10, 0x54, 0xD2, 0xFA, 0x15, 0x46, 0x9E, 0xF3, 0x14, 0x2C, 0x57, 0xB3, 0x0D, 0x5E, 0xF2, 0xFF, 0x12, 0x23, 0x44, 0x9A, 0x04, 0x05, 0x06, 0x1B, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x0D, 0x1D, 0x4F, 0x02, 0x02, 0xF5, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x98, 0xD5, 0x13, 0x13, 0x1A, 0x65, + 0x15, 0x15, 0x9F, 0xF5, 0x10, 0x10, 0x24, 0x62, 0x0F, 0x0F, 0x99, 0xD5, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0xB2, 0xE9, 0x0C, 0x0C, 0x0C, 0x3B, + 0x00, 0x00, 0x00, 0x00, 0x0E, 0x41, 0x55, 0x93, 0x0D, 0xAF, 0xF2, 0xFF, 0x10, 0x2A, 0x35, 0x87, 0x0C, 0x18, 0x1D, 0x5E, 0x10, 0x9F, 0xD9, 0xFF, 0x11, 0x65, 0x88, 0xC8, 0x00, 0x00, 0x00, 0x00, + 0x0E, 0x1C, 0x36, 0x77, 0x12, 0x53, 0xCA, 0xFF, 0x12, 0x53, 0xCA, 0xFF, 0x11, 0x56, 0xD5, 0xFF, 0x0D, 0x5E, 0xF2, 0xFF, 0x11, 0x55, 0xD0, 0xFF, 0x0B, 0x11, 0x1D, 0x57, 0x00, 0x00, 0x00, 0x00, + 0x0C, 0x0C, 0x0C, 0x3A, 0x0E, 0x0E, 0xB7, 0xED, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0D, 0x0D, 0xB6, 0xE7, 0x15, 0x15, 0x3C, 0x90, 0x14, 0x14, 0xAB, 0xFB, + 0x0E, 0x0E, 0xB2, 0xE9, 0x06, 0x06, 0xE4, 0xFD, 0x14, 0x14, 0x54, 0xA4, 0x15, 0x15, 0x83, 0xD5, 0x01, 0x01, 0xFA, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0x96, 0xCD, 0x15, 0x15, 0x64, 0xB8, + 0x09, 0x09, 0x11, 0x35, 0x05, 0x06, 0x07, 0x20, 0x12, 0x68, 0x8B, 0xD2, 0x10, 0x9E, 0xD9, 0xFF, 0x0F, 0xA2, 0xDE, 0xFF, 0x12, 0x7A, 0xA6, 0xE7, 0x08, 0x13, 0x17, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x04, 0x02, 0x02, 0x02, 0x10, 0x0C, 0x0C, 0x12, 0x45, 0x1B, 0x2A, 0x45, 0xBF, 0x13, 0x50, 0xC0, 0xFF, 0x0D, 0x13, 0x20, 0x62, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x0C, 0x2B, + 0x16, 0x16, 0x52, 0xAC, 0x0E, 0x0E, 0x96, 0xCD, 0x00, 0x00, 0xFF, 0xFF, 0x02, 0x02, 0xF9, 0xFF, 0x16, 0x16, 0x8F, 0xE7, 0x16, 0x16, 0x6F, 0xC7, 0x04, 0x04, 0xF0, 0xFF, 0x0E, 0x0E, 0xB9, 0xEF, + 0x0E, 0x0E, 0x85, 0xBD, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0C, 0x0C, 0xCD, 0xFB, 0x13, 0x13, 0xB1, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0C, 0x0C, 0xC2, 0xF3, 0x11, 0x11, 0x55, 0x99, + 0x0C, 0x0C, 0xB1, 0xE3, 0x07, 0x07, 0x09, 0x24, 0x00, 0x00, 0x00, 0x01, 0x05, 0x05, 0x05, 0x23, 0x06, 0x06, 0x06, 0x2A, 0x01, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0A, 0x0E, 0x35, + 0x0E, 0x0E, 0x3B, 0x72, 0x0F, 0x0F, 0x56, 0x8F, 0x14, 0x14, 0x9A, 0xEB, 0x04, 0x04, 0x04, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0x05, 0x19, 0x0E, 0x0E, 0xA3, 0xDA, + 0x10, 0x10, 0x40, 0x7F, 0x0D, 0x0D, 0xBA, 0xEE, 0x01, 0x01, 0xFA, 0xFF, 0x15, 0x15, 0xAC, 0xFF, 0x0A, 0x0A, 0xD8, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0E, 0x0E, 0x90, 0xC8, + 0x0E, 0x0E, 0x2C, 0x63, 0x02, 0x02, 0xF9, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0x16, 0x16, 0x57, 0xB0, + 0x0B, 0x0B, 0xC2, 0xEF, 0x0B, 0x0B, 0xBE, 0xEB, 0x0C, 0x0C, 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x0C, 0x11, 0x11, 0x69, 0xAB, 0x05, 0x05, 0xEB, 0xFF, + 0x00, 0x00, 0xFF, 0xFF, 0x06, 0x06, 0xE3, 0xFC, 0x0D, 0x0D, 0x2F, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0A, 0x15, 0x3D, 0x0D, 0x0D, 0xAD, 0xE1, 0x0D, 0x0D, 0xB5, 0xE8, + 0x13, 0x13, 0x42, 0x90, 0x01, 0x01, 0xFB, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x01, 0xFB, 0xFF, 0x0E, 0x0E, 0x38, 0x72, + 0x01, 0x01, 0x01, 0x03, 0x11, 0x11, 0x5E, 0xA1, 0x08, 0x08, 0xDE, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0xF1, 0xFF, + 0x1A, 0x1A, 0x68, 0xD3, 0x0C, 0x0C, 0xCA, 0xF9, 0x04, 0x04, 0xEF, 0xFF, 0x0F, 0x0F, 0x7D, 0xBB, 0x08, 0x08, 0x10, 0x2E, 0x12, 0x12, 0x4F, 0x97, 0x10, 0x10, 0x83, 0xC4, 0x0D, 0x0D, 0xC9, 0xFD, + 0x00, 0x00, 0xFF, 0xFF, 0x0D, 0x0D, 0xBE, 0xF4, 0x00, 0x00, 0x00, 0x01, 0x06, 0x06, 0x0B, 0x25, 0x0F, 0x0F, 0x71, 0xAD, 0x06, 0x06, 0xE6, 0xFE, 0x0B, 0x0B, 0xC9, 0xF5, 0x19, 0x19, 0x57, 0xBB, + 0x05, 0x05, 0xE9, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0A, 0x0A, 0xD2, 0xFA, 0x10, 0x10, 0x55, 0x95, 0x01, 0x01, 0x01, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x17, 0x23, 0x7F, 0x1B, 0x1B, 0x4A, 0xB8, 0x15, 0x15, 0x7C, 0xD0, 0x0F, 0x0F, 0xAF, 0xEC, 0x09, 0x09, 0xDA, 0xFF, 0x02, 0x02, 0xF9, 0xFF, + 0x01, 0x01, 0xFD, 0xFF, 0x15, 0x15, 0xAA, 0xFE, 0x16, 0x16, 0xA7, 0xFF, 0x02, 0x02, 0xF8, 0xFF, 0x0F, 0x0F, 0x77, 0xB2, 0x11, 0x11, 0x15, 0x59, 0x0D, 0x0D, 0x22, 0x58, 0x02, 0x02, 0xF9, 0xFF, + 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0xE0, 0xFF, 0x06, 0x06, 0x06, 0x1F, 0x0F, 0x0F, 0x61, 0x9C, 0x01, 0x01, 0xFA, 0xFF, 0x15, 0x15, 0xA9, 0xFF, 0x16, 0x16, 0xA2, 0xFA, 0x01, 0x01, 0xFA, 0xFF, + 0x01, 0x01, 0xFB, 0xFF, 0x09, 0x09, 0xDA, 0xFF, 0x0E, 0x0E, 0xAB, 0xE7, 0x14, 0x14, 0x76, 0xC7, 0x1B, 0x1B, 0x40, 0xAC, 0x16, 0x16, 0x20, 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x2C, 0x0D, 0x0D, 0xAD, 0xE4, 0x07, 0x07, 0xE4, 0xFF, 0x0C, 0x0C, 0xCD, 0xFE, 0x10, 0x10, 0xC0, 0xFF, 0x10, 0x10, 0xBD, 0xFF, + 0x02, 0x02, 0xF6, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0C, 0x26, 0xC3, 0xFF, 0x17, 0x82, 0x99, 0xFF, 0x14, 0x7E, 0xA5, 0xFD, 0x10, 0x71, 0x6C, 0xB6, 0x12, 0x2B, 0x77, 0xDA, 0x00, 0x00, 0xF7, 0xFF, + 0x00, 0x00, 0xFF, 0xFF, 0x05, 0x05, 0xE0, 0xFF, 0x14, 0x78, 0x73, 0xCA, 0x13, 0x7D, 0x9F, 0xF8, 0x17, 0x81, 0x9B, 0xFF, 0x12, 0x7D, 0xAC, 0xFF, 0x08, 0x0E, 0xB7, 0xFF, 0x00, 0x00, 0xFC, 0xFF, + 0x0E, 0x0E, 0xC5, 0xFF, 0x10, 0x10, 0xBF, 0xFE, 0x0D, 0x0D, 0xCB, 0xFE, 0x08, 0x08, 0xDF, 0xFF, 0x11, 0x11, 0x92, 0xD3, 0x07, 0x07, 0x0A, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x16, 0x10, 0x10, 0x68, 0xA8, 0x06, 0x06, 0xE8, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x01, 0xFC, 0xFF, + 0x12, 0x12, 0xB5, 0xFB, 0x04, 0x04, 0xED, 0xFF, 0x0F, 0x6C, 0xB8, 0xFF, 0x0F, 0xE2, 0xD6, 0xFF, 0x12, 0x9F, 0x9F, 0xFF, 0x11, 0xC8, 0xC0, 0xFF, 0x10, 0xDB, 0xD0, 0xFF, 0x07, 0x09, 0xA5, 0xFF, + 0x00, 0x00, 0xFD, 0xFF, 0x0B, 0x24, 0xC0, 0xFF, 0x0D, 0xF2, 0xE5, 0xFF, 0x13, 0xB1, 0xAB, 0xFF, 0x12, 0xA9, 0xA7, 0xFF, 0x13, 0xA1, 0xA0, 0xFF, 0x09, 0x09, 0x76, 0xFF, 0x0C, 0x0C, 0xCC, 0xFF, + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x0A, 0x0A, 0xCF, 0xF7, 0x0F, 0x0F, 0x45, 0x83, 0x02, 0x02, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x11, 0x37, 0x0F, 0x0F, 0x71, 0xAD, 0x0A, 0x0A, 0xD5, 0xFB, + 0x0C, 0x0C, 0xBB, 0xEA, 0x14, 0x14, 0x22, 0x73, 0x14, 0x9F, 0x9F, 0xF3, 0x13, 0xA9, 0xA4, 0xFF, 0x01, 0x01, 0x7E, 0xFF, 0x10, 0x5A, 0x92, 0xFF, 0x0E, 0xEB, 0xDE, 0xFF, 0x09, 0x0C, 0x7A, 0xFF, + 0x00, 0x00, 0xF9, 0xFF, 0x0E, 0x55, 0xBB, 0xFF, 0x0E, 0xEC, 0xDF, 0xFF, 0x11, 0x37, 0x59, 0xFF, 0x0C, 0x30, 0x79, 0xFF, 0x10, 0x20, 0x3F, 0xDA, 0x11, 0x11, 0x20, 0x8C, 0x0A, 0x0A, 0xCD, 0xF5, + 0x0B, 0x0B, 0xC3, 0xF3, 0x0F, 0x0F, 0x56, 0x92, 0x05, 0x05, 0x06, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0x05, 0x19, + 0x0E, 0x0E, 0x36, 0x6F, 0x15, 0x15, 0x63, 0xC2, 0x12, 0xCC, 0xC1, 0xFF, 0x10, 0xDD, 0xD1, 0xFF, 0x13, 0xC4, 0xBA, 0xFF, 0x0E, 0xE8, 0xDC, 0xFF, 0x13, 0x8F, 0x93, 0xFF, 0x01, 0x01, 0xA1, 0xFF, + 0x00, 0x00, 0xFC, 0xFF, 0x11, 0x87, 0xB6, 0xFF, 0x0D, 0xF0, 0xE3, 0xFF, 0x0E, 0xEB, 0xDE, 0xFF, 0x0E, 0xEB, 0xDE, 0xFF, 0x14, 0x5C, 0x5D, 0xF0, 0x12, 0x12, 0x5D, 0xC4, 0x0E, 0x0E, 0x2F, 0x68, + 0x03, 0x03, 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0A, 0x12, 0x11, 0x4B, 0x0D, 0xEE, 0xE2, 0xFF, 0x12, 0x7D, 0x77, 0xF0, 0x0E, 0x56, 0x52, 0xD2, 0x11, 0x3D, 0x47, 0xE3, 0x03, 0x03, 0x87, 0xFF, 0x00, 0x00, 0xE9, 0xFF, + 0x01, 0x01, 0xF8, 0xFF, 0x13, 0xB7, 0xB7, 0xFF, 0x12, 0x90, 0x89, 0xF7, 0x0B, 0x0B, 0x0B, 0xB3, 0x0E, 0x0E, 0x0E, 0xAF, 0x04, 0x04, 0x04, 0x74, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3F, 0x3D, 0x7F, 0x0D, 0xF0, 0xE3, 0xFF, 0x0A, 0x17, 0x16, 0xAE, 0x01, 0x01, 0x01, 0x29, 0x0D, 0x0D, 0x94, 0xDE, 0x00, 0x00, 0xF8, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0x07, 0x07, 0xD3, 0xFF, 0x0F, 0xE2, 0xD6, 0xFF, 0x10, 0xDE, 0xD2, 0xFF, 0x12, 0xCC, 0xC2, 0xFF, 0x12, 0xCC, 0xC2, 0xFF, 0x0D, 0x28, 0x26, 0x9E, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0A, 0x22, 0x21, 0x67, 0x0E, 0x4D, 0x4A, 0xC9, 0x02, 0x02, 0x02, 0x68, 0x10, 0x10, 0x45, 0x89, 0x02, 0x02, 0xF7, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0x06, 0x09, 0xD6, 0xFF, 0x0E, 0x54, 0x8D, 0xFF, 0x0E, 0x55, 0x7E, 0xFF, 0x11, 0x58, 0x65, 0xF0, 0x0E, 0x53, 0x4F, 0xCE, 0x05, 0x07, 0x07, 0x7C, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x0C, 0x0C, 0x26, 0x62, 0x07, 0x07, 0xE1, 0xFE, 0x19, 0x19, 0x91, 0xF5, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0x00, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0xEB, 0xFF, 0x19, 0x19, 0x72, 0xEF, 0x07, 0x07, 0xC6, 0xFC, 0x0A, 0x0A, 0x19, 0x59, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x29, 0x62, 0x12, 0x12, 0x6F, 0xB5, 0x0E, 0x0E, 0xA6, 0xE0, 0x09, 0x09, 0xDD, 0xFF, 0x03, 0x03, 0xF3, 0xFF, + 0x0A, 0x0A, 0xD8, 0xFF, 0x06, 0x06, 0xE9, 0xFF, 0x0F, 0x0F, 0xA6, 0xE0, 0x12, 0x12, 0x77, 0xBD, 0x0D, 0x0D, 0x1D, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x1D, 0x10, 0x10, 0x21, 0x61, 0x03, 0x03, 0xF5, 0xFF, 0x0F, 0x0F, 0xC0, 0xFA, 0x0B, 0x0B, 0xD1, 0xFE, + 0x0E, 0x0E, 0xB8, 0xEF, 0x0D, 0x0D, 0xBA, 0xF1, 0x02, 0x02, 0xF9, 0xFF, 0x13, 0x13, 0x31, 0x80, 0x03, 0x03, 0x03, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x10, 0x95, 0xD4, 0x00, 0x00, 0xFF, 0xFF, 0x0D, 0x0D, 0xAD, 0xE3, 0x0E, 0x0E, 0xAB, 0xE2, + 0x0E, 0x0E, 0x9C, 0xD3, 0x0E, 0x0E, 0x95, 0xCC, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0xAA, 0xE7, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x34, 0x6E, 0x05, 0x05, 0xEA, 0xFE, 0x0E, 0x0E, 0x9A, 0xD1, 0x0E, 0x0E, 0x82, 0xB9, + 0x0E, 0x0E, 0x81, 0xB8, 0x0D, 0x0D, 0x7C, 0xB3, 0x03, 0x03, 0xF2, 0xFF, 0x0F, 0x0F, 0x3B, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x48, 0x89, 0x0E, 0x0E, 0x85, 0xBE, 0x0E, 0x0E, 0x58, 0x8F, + 0x0D, 0x0D, 0x66, 0x9C, 0x0D, 0x0D, 0x6C, 0xA3, 0x11, 0x11, 0x60, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, 0x17, 0x17, 0x29, 0x88, 0x0E, 0x0E, 0x2F, 0x66, + 0x0E, 0x0E, 0x4A, 0x81, 0x16, 0x16, 0x28, 0x81, 0x03, 0x03, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x04, 0x0C, 0x0C, 0x0E, 0x3D, + 0x10, 0x10, 0x28, 0x66, 0x01, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x13, + 0x0F, 0x0F, 0x0F, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; static int32 display_x = 640; static int32 display_y = 400; @@ -27499,7 +27496,7 @@ void sub__icon(int32 handle_icon, int32 handle_window_icon, int32 passed) { if (!ExeIcon16) ExeIcon16 = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(0), IMAGE_ICON, 16, 16, 0); - // If we have an embedded icon, we'll use it instead of QB64's default + // If we have an embedded icon, we'll use it instead of QB64-PE's default if (!(passed & 1) && (ExeIcon)) { SendMessage(window_handle, WM_SETICON, ICON_BIG, (LPARAM)ExeIcon); diff --git a/internal/c/myip.cpp b/internal/c/myip.cpp index 6b059bfea..89feaca02 100644 --- a/internal/c/myip.cpp +++ b/internal/c/myip.cpp @@ -1,4 +1,5 @@ -// Note: Updated 23/9/2018: Switched to www.qb64.org since .net is down; +// Note: Updated 12/8/2022: Switched to qb64phoenix.com since .org is dead; +// Note: Updated 23/9/2018: Switched to www.qb64.org since .net is dead; // replaces implementation with download sample code from wiki Note: Updated // 26/3/2014: Switched to WWW.QB64.NET to avoid IP changes when QB64 moves // servers Note: Updated 16/1/2013: Switched to QB64.NET IP service Note: Updated @@ -14,7 +15,7 @@ $CHECKING:OFF FUNCTION whatismyip$ - url$ = "www.qb64.org/ip.php" + url$ = "qb64phoenix.com/qb64_files/ip.php" url2$ = url$ x = INSTR(url2$, "/") IF x THEN url2$ = LEFT$(url$, x - 1) @@ -145,7 +146,7 @@ qbs *WHATISMYIP() { // changed name from FUNC_WHATISMYIP to WHATISMYIP if (new_error) goto exit_subfunc; qbs_set(_FUNC_WHATISMYIP_STRING_URL, - qbs_new_txt_len("www.qb64.org/ip.php", 19)); + qbs_new_txt_len("qb64phoenix.com/qb64_files/ip.php", 33)); qbs_cleanup(qbs_tmp_base, 0); qbs_set(_FUNC_WHATISMYIP_STRING_URL2, _FUNC_WHATISMYIP_STRING_URL); qbs_cleanup(qbs_tmp_base, 0); diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index b7eee61fb..ae8f09edd 100755 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -1638,7 +1638,7 @@ chain_retry: // attempt .bas compilation qbs_set(str, qbs_new_txt_len("\x022", 1)); qbs_set(str, qbs_add(str, thisexe_path)); - qbs_set(str, qbs_add(str, qbs_new_txt("qb64.exe"))); + qbs_set(str, qbs_add(str, qbs_new_txt("qb64pe.exe"))); qbs_set(str, qbs_add(str, qbs_new_txt_len("\x022", 1))); qbs_set(str, qbs_add(str, qbs_new_txt(" -c "))); qbs_set(str, qbs_add(str, f_path)); diff --git a/internal/clean.bat b/internal/clean.bat index 9d836f7ac..38f8c7353 100644 --- a/internal/clean.bat +++ b/internal/clean.bat @@ -1,6 +1,6 @@ @echo off -echo This batch is an admin tool to return QB64 to its pre-setup state +echo This batch is an admin tool to return QB64-PE to its pre-setup state pause echo Purging temp folders diff --git a/internal/help/$ASSERTS_$1111111.txt b/internal/help/$ASSERTS_$1111111.txt deleted file mode 100644 index 3457b4956..000000000 --- a/internal/help/$ASSERTS_$1111111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:10}} -The '''$ASSERTS''' [[metacommand]] enables debug tests with the [[_ASSERT]] macro. - - -{{PageSyntax}} -: '''$ASSERTS''' -: '''$ASSERTS:CONSOLE''' - - -{{PageDescription}} -* This metacommand does not require a comment ''[[Apostrophe|']]'' or [[REM]] before it. There is no space between the metacommand name, the colon and the CONSOLE parameter. -* If this metacommand is used in a program and any of the set [[_ASSERT]] checkpoints will fail, then the program will stop with an '''{{Text|_ASSERT failed|red}}''' error. -* Detailed error messages passed to the [[_ASSERT]] statement will be displayed in the console window, but only if '''$ASSERTS:CONSOLE''' is used. - -;Note: This metacommand is the main switch to enable debug tests during development. Later just remove this metacommand to compile the program without debugging code, all the [[_ASSERT]] statements may remain in the code for later debugging sessions, they are simply ignored without this metacommand. - - -{{PageAvailability}} -* '''QB64 v1.4 and up''' (QB64 Team) -* '''QB64-PE v0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -;Example:Adding test checks for parameter inputs in a function. -{{CodeStart}} -{{Cl|$ASSERTS|$ASSERTS:CONSOLE}} - -{{Cl|DO}} - a = {{Cl|INT}}({{Cl|RND}} * 10) - b$ = myFunc$(a) - {{Cl|PRINT}} a, , b$ - {{Cl|_LIMIT}} 3 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_KEYHIT}} - -{{Cl|FUNCTION}} myFunc$ (value {{Cl|AS}} {{Cl|SINGLE}}) - {{Cl|_ASSERT}} value > 0, "Value cannot be zero" - {{Cl|_ASSERT}} value <= 10, "Value cannot exceed 10" - - {{Cl|IF}} value > 1 {{Cl|THEN}} plural$ = "s" - myFunc$ = {{Cl|STRING$}}(value, "*") + {{Cl|STR$}}(value) + " star" + plural$ + " :-)" -{{Cl|END}} {{Cl|FUNCTION}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[Metacommand]] -* [[_ASSERT]] -* [[$CHECKING]] -* [[Relational Operations]] -* [[ERROR Codes]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/$CHECKING_$11111111.txt b/internal/help/$CHECKING_$11111111.txt deleted file mode 100644 index 703068d77..000000000 --- a/internal/help/$CHECKING_$11111111.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:34}} -The [[$CHECKING]] metacommand turns C++ event checking ON or 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 (or segfault). Use only with 100% stable sections of code.''' - -===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, errorless sections of code, where every CPU cycle saved counts, such as in a software 3D texture mapper, for example. - - -{{PageSeeAlso}} -* [[ON TIMER(n)]] -* [[ON ERROR]] -* [[Metacommand]] -* [[ERROR Codes]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$COLOR_$11111.txt b/internal/help/$COLOR_$11111.txt deleted file mode 100644 index 2b9597d5b..000000000 --- a/internal/help/$COLOR_$11111.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:45}} -[[$COLOR]] is a metacommand that adds named color [[CONST|constants]] in a program. - - -{{PageSyntax}} -: [[$COLOR]]:0 -: [[$COLOR]]:32 - - -{{PageDescription}} -* [[$COLOR]]:0 adds [[CONST|constants]] for colors 0-15. The actual constant names can be found in the file '''source/utilities/color0.bi'''. -* [[$COLOR]]:32 adds [[CONST|constants]] for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file '''source/utilities/color32.bi'''. -* [[$COLOR]] is a shorthand to manually using [[$INCLUDE]] pointing to the files listed above. -* Prior to QBPE v0.5 ({{Text|ü|red}}), [[$COLOR]] was not compatible with [[$NOPREFIX]]. -* Since QBPE v0.5, [[$COLOR]] can now be used with [[$NOPREFIX]], with a few notable differences to three conflicting colors -- Red, Green, Blue. - -:Red would conflict with [[_RED]], Green would conflict with [[_GREEN]], and Blue would conflict with [[_BLUE]], once the underscore was removed from those commands with [[$NOPREFIX]]. -: -:To prevent these conflicts, the [[COLOR]] values have had '''NP_''' prepended to the front of them, to distinguish them from the non-prefixed command names. All other color names remain the same, with only the three colors in conflict having to use '''NP_''' (for '''N'''o '''P'''refix) in front of them. - -({{Text|ü|red}}) QBPE = QB64 Phoenix Edition - - -{{PageExamples}} -;Example 1:Adding named color constants for SCREEN 0. -{{CodeStart}} -{{Cl|$COLOR}}:0 -{{Cl|COLOR}} BrightWhite, Red -{{Cl|PRINT}} "Bright white on red." -{{CodeEnd}} -{{OutputStartBG4}} -{{Text|Bright white on red.|#fcfcfc}} -{{OutputEnd}} - -;Example 2:Adding named color constants for 32-bit modes. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32) -{{Cl|$COLOR}}:32 -{{Cl|COLOR}} CrayolaGold, DarkCyan -{{Cl|PRINT}} "CrayolaGold on DarkCyan." -{{CodeEnd}} - -;Example 3:Adding named color constants for 32-bit modes (with $NOPREFIX in effect). -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32) -{{Cl|$COLOR}}:32 -{{Cl|$NOPREFIX}} -{{Cl|COLOR}} NP_Red, White 'notice the NP_ in front of Red? -'This is to distinguish the color from the command with $NOPREFIX. -{{Cl|PRINT}} "Red on White." -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[COLOR]], [[SCREEN]] -* [[_NEWIMAGE]], [[$INCLUDE]] -* [[Metacommand]] - - -{{PageNavigation}} diff --git a/internal/help/$CONSOLE_$1111111.txt b/internal/help/$CONSOLE_$1111111.txt deleted file mode 100644 index 224cf0db8..000000000 --- a/internal/help/$CONSOLE_$1111111.txt +++ /dev/null @@ -1,79 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:50}} -The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throughout a QB64 program module. - - -{{PageSyntax}} -: [[$CONSOLE]][:ONLY] - - -* [[_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 are not commented out with ' or REM, unlike QuickBASIC 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}} -{{Cl|_DELAY}} 4 - -{{Cl|_CONSOLE}} OFF -{{Cl|_DELAY}} 4 -{{Cl|_CONSOLE}} ON - -{{Cl|_DEST}} {{Cl|_CONSOLE}} -{{Cl|PRINT}} "Close this console window or click main window and press a key!" -{{CodeEnd}} - - -''Example 2:'' How to use a Console window to copy screen output using the ''Edit'' menu by right clicking the console title bar. -{{CodeStart}} -{{Cl|$CONSOLE}} -{{Cl|_DEST}} {{Cl|_CONSOLE}} - -c&& = -1: d& = -1: e% = -1: f%% = -1 -hx$ = {{Cl|HEX$}}(f%%) -{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(e%) -{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(d&) -{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(c&&) -{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(9223372036854775807) -{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" -hx$ = {{Cl|HEX$}}(-9223372036854775808) -{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" -{{CodeEnd}} -{{OutputStart}}Max hex _BYTE = FF with 2 digits = 255 -Max hex INTEGER = FFFF with 4 digits = 65535 -Max hex LONG = FFFFFFFF with 8 digits = 4294967295 -Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1 -Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits -Min _INTEGER64 value = 8000000000000000 with 16 digits -{{OutputEnd}} -: ''Console:'' Right click and select ''Edit'' > ''Select All'' (mouse highlight after) then hit Enter or select ''Edit'' > ''Copy'' to the clipboard. -{{TextStart}}Max hex _BYTE = FF with 2 digits = 255 -Max hex INTEGER = FFFF with 4 digits = 65535 -Max hex LONG = FFFFFFFF with 8 digits = 4294967295 -Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1 -{{TextEnd}} -:''Copied text:'' The above text was copied after ''Select All'' was selected and the smaller area was re-highlighted with the mouse. - - -{{PageSeeAlso}} -* [[_CLIPBOARD$]] (function), [[_CLIPBOARD$ (statement)]] -* [[_CONSOLE]] -* [[$SCREENHIDE]], [[$SCREENSHOW]] (QB64 [[Metacommand]]s) -* [[_SCREENHIDE]], [[_SCREENSHOW]] -* [[C_Libraries#Console_Window|C Console Library]] - - -{{PageNavigation}} diff --git a/internal/help/$DEBUG_$11111.txt b/internal/help/$DEBUG_$11111.txt deleted file mode 100644 index 93528a78b..000000000 --- a/internal/help/$DEBUG_$11111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:05}} -'''$DEBUG''' is precompiler [[Metacommand|metacommand]], which enables debugging features, allowing you to step through your code running line by line and to inspect variables and change their values in real time. - - -{{PageSyntax}} -:[[$DEBUG]] - - -{{PageDescription}} -* '''$DEBUG''' injects extra code in the resulting binary, allowing the IDE to control the execution flow of your program. -* When '''$DEBUG''' is used, the IDE will connect to your running program using a local TCP/IP connection. -** You may get a prompt from your Operating System regarding this, so it may be necessary to allow the IDE to receive connections. -** No external connections are created, and your running program will only attempt to connect locally to the IDE. -* The default TCP/IP port starts at 9001. Multiple running instances of the IDE will attempt to open ports 9002 and up. -** You can change the base port in the Debug menu. -* The metacommand is supposed to be removed once your program is ready for release, although leaving it in won't have any effect if your program isn't run from the IDE. -** The only drawback of leaving the metacommand in is that your binary will end up being larger than required. - -== $DEBUG Mode Operation == -* To start execution in pause mode, you can use '''F7''' or '''F8'''. -* There will be an arrow next to the line number where execution is paused, indicating the next line that will be run. -* When you enable '''$DEBUG''' mode, you can set breakpoints by clicking the line number at which you wish to stop execution. This can also be achieved by using the '''F9''' key. -** Breakpoints are indicated by a red dot next to the line number. -** To clear all breakpoints, hit '''F10'''. -* To skip a line during execution, shift-click a line number -** Lines marked for skipping are indicated by an exclamation mark next to the line number. -* '''F4''' opens the Variable List dialog, which allows you to add variables to the Watch List. -* During execution, the Variable List dialog also allows you to set the values of variables and also to create Watchpoints. -* Watchpoints halt execution, similarly to breakpoints, but do so when a variable matches the condition you specify. -** You can use relational operators (=, <>, >=, <=, >, <) to create watchpoint conditions. -* After a breakpoint or a watchpoint is reached, '''F5''' can be used to continue execution. -* '''F6''' can be used when the execution pointer is inside a sub/function. When used, execution will proceed until the procedure is ended. -* '''F7''' can be used to run line by line, and can be used to debug code inside subs/functions (Step Into). -* '''F8''' can be used to run line by line without entering sub/function calls (Step Over). -* '''F12''' can be used to show the current call stack (which procedure calls led to the current line). - - -{{PageSeeAlso}} -* [[Metacommand]]s - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$DYNAMIC_$1111111.txt b/internal/help/$DYNAMIC_$1111111.txt deleted file mode 100644 index 503c6997c..000000000 --- a/internal/help/$DYNAMIC_$1111111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:02}} -The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (resizable) arrays. - - -{{PageSyntax}} -:{[[REM]] | [[apostrophe|']] } [[$DYNAMIC]] - - -{{PageDescription}} -* QBasic [[Metacommand|metacommands]] require [[REM]] or [[Apostrophe|apostrophe]] (') before them and are normally 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. -* [[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 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 -{{Cl|DIM}} array(10) 'create array with 11 elements -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 10 - array(i) = i: {{Cl|PRINT}} array(i); 'set and display element values -{{Cl|NEXT}} -{{Cl|PRINT}} -{{Cl|REDIM}} {{Cl|_PRESERVE}} array(10 {{Cl|TO}} 20) -{{Cl|FOR...NEXT|FOR}} i = 10 {{Cl|TO}} 20 - {{Cl|PRINT}} array(i); -{{Cl|NEXT}} -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}}0 1 2 3 4 5 6 7 8 9 10 - -0 1 2 3 4 5 6 7 8 9 10 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[$STATIC]], [[$INCLUDE]] -* [[DIM]], [[REDIM]], [[_DEFINE]] -* [[STATIC]] -* [[ERASE]], [[CLEAR]] -* [[Arrays]], [[Metacommand]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$ELSEIF_$111111.txt b/internal/help/$ELSEIF_$111111.txt deleted file mode 100644 index 3632fe9ae..000000000 --- a/internal/help/$ELSEIF_$111111.txt +++ /dev/null @@ -1,5 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:34}} -See page [[$IF]] - -[[Category:Final]] diff --git a/internal/help/$ELSE_$1111.txt b/internal/help/$ELSE_$1111.txt deleted file mode 100644 index 726d44886..000000000 --- a/internal/help/$ELSE_$1111.txt +++ /dev/null @@ -1,5 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:33}} -See page [[$IF]] - -[[Category:Final]] diff --git a/internal/help/$END_IF_$111_11.txt b/internal/help/$END_IF_$111_11.txt deleted file mode 100644 index 059b31413..000000000 --- a/internal/help/$END_IF_$111_11.txt +++ /dev/null @@ -1,5 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:35}} -See page [[$IF]] - -[[Category:Final]] diff --git a/internal/help/$ERROR_$11111.txt b/internal/help/$ERROR_$11111.txt deleted file mode 100644 index 16e4343e4..000000000 --- a/internal/help/$ERROR_$11111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:38}} -The '''$ERROR''' [[metacommand]] triggers a compilation error. - - -{{PageSyntax}} -: '''$ERROR''' {{Parameter|message}} - - -{{PageDescription}} -* This metacommand does not require a comment ''[[Apostrophe|']]'' or [[REM]] before it. -* {{Parameter|message}} is any text. Quotation marks are not required. -* When QB64 tries to compile an '''$ERROR''' metacommand a compilation error is triggered and {{Parameter|message}} is shown to the user. This is useful in [[$IF]] blocks. - - -{{PageDescription}} -* If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with [[$IF]]. -* An '''$ERROR''' directive not inside an conditional [[$IF]] (or [[$ELSEIF]]) block is useless because the program will '''never''' compile in that case. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN - {{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above -{{Cl|$END IF}} -{{CodeEnd}} -;Output (IDE Status Area):Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements). - - -{{PageSeeAlso}} -* [[Metacommand]] -* [[$IF]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/$EXEICON_$1111111.txt b/internal/help/$EXEICON_$1111111.txt deleted file mode 100644 index 3fa2eb93a..000000000 --- a/internal/help/$EXEICON_$1111111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:41}} -'''$EXEICON''' pre-compiler metacommand embeds a designated icon file into the compiled EXE file to be viewed in Windows Explorer. - - -{{PageSyntax}} -: [[$EXEICON]]:'{{Parameter|iconfile.ico}}' - - -{{PageParameters}} -* '{{Parameter|iconfile.ico}}' is a valid [https://en.wikipedia.org/wiki/ICO_(file_format) ICO file] - - -{{PageDescription}} - -* Calling [[_ICON]] without an {{Parameter|imageHandle&}} uses the embeded icon, if available. -** Starting with '''build 20170906/64''', the window will automatically use the icon embedded by [[$EXEICON]], without having to call _ICON. -* '''[[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:'' Embeds a designated icon file into the compiled EXE which can be viewed in Windows Explorer folders. -{{CodeStart}} -{{Cl|$EXEICON}}:'mush.ico' -{{Cl|_ICON}} -{{CodeEnd}}{{small|Code and command by Fellippe Heitor}} - - -{{PageSeeAlso}} -* [[_ICON]] -* [[_TITLE]] - - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$IF_$11.txt b/internal/help/$IF_$11.txt deleted file mode 100644 index 53ec3082d..000000000 --- a/internal/help/$IF_$11.txt +++ /dev/null @@ -1,89 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:06}} -'''$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 -:. -:[[$ELSEIF]] variable = expression THEN -:. -:[[$ELSE]] -:. -:[[$END IF]] - - -{{PageDescription}} -* $IF is the start of a precompiler code block which includes or excludes sections of code from being compiled. -* 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. 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. -** '''VERSION''', which is set to the version of the QB64 compiler. This is a number and can be ordered, see example below. -* Special values '''DEFINED''' and '''UNDEFINED''' can be used to check whether a precompiler variable has already been assigned a value. Useful for code in libraries which may be repeated. -* [[$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 -{{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}} - -''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 the programmer control the code that actually gets compiled, while excluding the other blocks completely. - - -''Example 2:'' -{{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}} - -''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. - - -''Example 3:'' -{{CodeStart}} -{{Cl|$IF}} VERSION < 1.5 THEN - {{Cl|$ERROR}} Requires QB64 version 1.5 or greater -{{Cl|$END IF}} -{{CodeEnd}} - -''Explanation:'' VERSION is a predefined variable that holds the QB64 compiler version. If we know our program needs features only available above a certain version, we can check for that and give the user a helpful error message instead of a confusing error elsewhere in the program. - - -{{PageSeeAlso}} -* [[$LET]] -* [[$ERROR]] -* [[Metacommand]]s - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$INCLUDE_$1111111.txt b/internal/help/$INCLUDE_$1111111.txt deleted file mode 100644 index 781d36dfd..000000000 --- a/internal/help/$INCLUDE_$1111111.txt +++ /dev/null @@ -1,46 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:37}} -[[$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]] | [[apostrophe|']] } [[$INCLUDE]]''':''' '{{Parameter|sourceFile}}' - - -{{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 $INCLUDE metacommand should be the only statement on a line. - - -===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.'' - - -{{PageExamples}} -{{CodeStart}}''' '$INCLUDE:''' 'QB.BI'{{CodeEnd}} - - -===More examples=== -* [[SelectScreen]] (member-contributed $INCLUDE demo) -* [[FILELIST$]] (member-contributed file search function) -* [[SAVEIMAGE]] (SUB program that creates bitmaps) - - -{{PageSeeAlso}} -* [[INTERRUPT]], [[INTERRUPTX]] -* [[TYPE]], [[DIM]] -* [[Metacommand]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$LET_$111.txt b/internal/help/$LET_$111.txt deleted file mode 100644 index 7d48a61e3..000000000 --- a/internal/help/$LET_$111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:18}} -[[$LET]] is a precompiler command, which helps to include and/or exclude sections of code in a program based on OS/bit-size or other predefined conditions. - - -{{PageSyntax}} -: [[$LET]] variable = expression - - -{{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 must follow QB64's variable naming conventions. -* You can check a precompiler variable against special values '''DEFINED''' and '''UNDEFINED''', in order to assess whether the variable has already been assigned a value. Useful for code in libraries which may be repeated. -* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. 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. -** '''VERSION''', which is set to the version of the QB64 compiler. - - -{{PageExamples}} -* See example 1 in [[$IF]]. - - -{{PageSeeAlso}} -* [[$IF]] -* [[$ELSE]] -* [[$ELSEIF]] -* [[$END IF]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$NOPREFIX_$11111111.txt b/internal/help/$NOPREFIX_$11111111.txt deleted file mode 100644 index 53b473daf..000000000 --- a/internal/help/$NOPREFIX_$11111111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:01}} -The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be used without the leading underscore (_). - - -{{PageSyntax}} -:[[$NOPREFIX]] - - -{{PageDescription}} -* QB64-specific keywords are by default prefixed with an underscore, in order to differentiate them from legacy keywords inherited from QBasic/QuickBASIC 4.5. -* The convention exists in order to allow older code to be loaded and compiled in QB64 without naming conflicts with existing variables or constants. -* If you are writing new code with QB64, and not importing code from QBasic/QuickBASIC 4.5, [[$NOPREFIX]] allows you to reduce typing by not having to use underscores in modern keywords. -* '''SUB _GL''' still must be prefixed. -* When [[$NOPREFIX]] is used, QB64 keywords can be used both with or without the leading underscore, so that both [[_DISPLAY]] and [[_DISPLAY|DISPLAY]] are valid in the same program, for example. -* [[$NOPREFIX]] must be the first non-comment and non-whitespace line in a program. -** Since QB64 2.0 respectively QBPE 0.5 [[$NOPREFIX]] can be placed anywhere in a program. - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[Keyword Reference - Alphabetical]] -* [[Metacommand]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$RESIZE_$111111.txt b/internal/help/$RESIZE_$111111.txt deleted file mode 100644 index 728d1bc64..000000000 --- a/internal/help/$RESIZE_$111111.txt +++ /dev/null @@ -1,119 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:36}} -The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can be resized by the user. - - -{{PageSyntax}} -: [[$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: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. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{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)}} - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$SCREENHIDE_$1111111111.txt b/internal/help/$SCREENHIDE_$1111111111.txt deleted file mode 100644 index 3923c55b2..000000000 --- a/internal/help/$SCREENHIDE_$1111111111.txt +++ /dev/null @@ -1,41 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:49}} -The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main program window throughout a program. - - -{{PageSyntax}} -: [[$SCREENHIDE]] - - -* $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|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}} -{{Cl|DECLARE DYNAMIC LIBRARY}} "user32" - {{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hWnd%&, {{Cl|BYVAL}} lpText%&, {{Cl|BYVAL}} lpCaption%&, {{Cl|BYVAL}} uType~&) -{{Cl|DECLARE LIBRARY|END DECLARE}} -{{Cl|DECLARE DYNAMIC LIBRARY}} "kernel32" - {{Cl|SUB}} ExitProcess ({{Cl|BYVAL}} uExitCode~&) -{{Cl|DECLARE LIBRARY|END DECLARE}} -{{Cl|DIM}} s0 {{Cl|AS}} {{Cl|STRING}} -{{Cl|DIM}} s1 {{Cl|AS}} {{Cl|STRING}} -s0 = "Text" + {{Cl|CHR$}}(0) -s1 = "Caption" + {{Cl|CHR$}}(0) -ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET (function)|_OFFSET}}(s1), 0) -{{CodeEnd}}{{small|Code by Michael Calkins}} - - -{{PageSeeAlso}} -* [[$CONSOLE]], [[$SCREENSHOW]] -* [[_SCREENHIDE]], [[_SCREENSHOW]] -* [[_CONSOLE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$SCREENSHOW_$1111111111.txt b/internal/help/$SCREENSHOW_$1111111111.txt deleted file mode 100644 index 66f3beee7..000000000 --- a/internal/help/$SCREENSHOW_$1111111111.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:56}} -The [[$SCREENSHOW]] [[Metacommand|metacommand]] can be used to display the main program window throughout the program. - - -{{PageSyntax}} -: $SCREENSHOW - - -{{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]].''' - - -{{PageSeeAlso}} -* [[$CONSOLE]], [[$SCREENHIDE]] (QB64 [[Metacommand]]s) -* [[_SCREENHIDE]], [[_SCREENSHOW]] -* [[_CONSOLE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$STATIC_$111111.txt b/internal/help/$STATIC_$111111.txt deleted file mode 100644 index 41e945d68..000000000 --- a/internal/help/$STATIC_$111111.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:04}} -The [[$STATIC]] [[Metacommand|metacommand]] allows the creation of static (unresizable) arrays. - - -{{PageSyntax}} -:{[[REM]] | [[apostrophe|']] } [[$STATIC]] - - -{{PageDescription}} -* QBasic [[Metacommand]]s require a REM or apostrophy (') before them and are normally placed at the start of the main module. -* Static arrays cannot be resized. If a variable is used to size any array, it becomes [[$DYNAMIC]]. -* A [[REDIM]] statement has no effect on [[$STATIC]] arrays except perhaps a [[ERROR Codes|duplicate definition error]] at the [[REDIM]] statement. -* The array's type cannot be changed once [[DIM]] and a literal value sets the dimensions and element size. -* [[$STATIC]] defined program [[arrays]] cannot be [[REDIM|re-sized]] or use [[_PRESERVE]]. - - -{{PageExamples}} -''Example:'' When a variable is used, the array can be resized despite $STATIC. The array becomes [[$DYNAMIC]]. -{{CodeStart}} -'{{Cl|$STATIC}} - -{{Cl|INPUT}} "Enter array size: ", size -{{Cl|DIM}} array(size) 'using an actual number instead of the variable will create an error! - -{{Cl|REDIM}} array(2 * size) - -{{Cl|PRINT}} {{Cl|UBOUND}}(array) -{{CodeEnd}} -: ''Note:'' [[DIM]] using a literal numerical size will create a Duplicate definition error. - - -{{PageSeeAlso}} -* [[$DYNAMIC]], [[STATIC]] -* [[Arrays]], [[Metacommand]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$VERSIONINFO_$11111111111.txt b/internal/help/$VERSIONINFO_$11111111111.txt deleted file mode 100644 index 9f8a6e82f..000000000 --- a/internal/help/$VERSIONINFO_$11111111111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:46}} -The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resulting executable for identification purposes across the OS. Windows-only. - - -{{PageSyntax}} -: [[$VERSIONINFO]]:{{Parameter|key}}={{Parameter|value}} - - -{{PageParameters}} -* Text ''keys'' can be: '''Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Web''' -* Numeric {{Parameter|keys}} can be:'''FILEVERSION#''' and '''PRODUCTVERSION#''' -**When provided, the numerical keys '''FILEVERSION#''' and '''PRODUCTVERSION#''' will also provide values to the text keys '''FileVersion''' and '''ProductVersion,''' if the text versions are not provided separately. (QBPE 0.6 and up (QB64 Phoenix Edition)) - - -{{PageDescription}} -* Text and numerical values are string literals without quotes entered by programmer. '''No variables are accepted.''' (variable names would be interpreted as literals). -* Numeric key=''value'' must be 4 comma-separated numerical text values entered by programmer which usually stand for major, minor, revision and build numbers). -* A manifest file is automatically embedded into the resulting .exe file so that Common Controls v6.0 gets linked at runtime, if required. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageAvailability}} -* '''QB64 1.2 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Adding metadata to a Windows exe compiled with QB64: -{{CodeStart}} -{{Cl|$VERSIONINFO}}:CompanyName=Your company name goes here -{{Cl|$VERSIONINFO}}:FILEVERSION#=1,0,0,0 -{{Cl|$VERSIONINFO}}:PRODUCTVERSION#=1,0,0,0 -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$EXEICON]] -* [[_ICON]] -* [https://msdn.microsoft.com/library/windows/desktop/aa381058(v=vs.85).aspx VERSIONINFO resource (MSDN)] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/$VIRTUALKEYBOARD_$111111111111111.txt b/internal/help/$VIRTUALKEYBOARD_$111111111111111.txt deleted file mode 100644 index 146279e2c..000000000 --- a/internal/help/$VIRTUALKEYBOARD_$111111111111111.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:48}} -The ({{Text|now deprecated|red}}) '''$VIRTUALKEYBOARD''' [[metacommand]] did turn the virtual keyboard ON or OFF. - - -{{PageSyntax}} -: '''$VIRTUALKEYBOARD:ON''' -: '''$VIRTUALKEYBOARD:OFF''' - - -{{PageDescription}} -* This metacommand did not require a comment ''[[Apostrophe|']]'' or [[REM]] before it. There was no space between the metacommand name, the colon and the ON/OFF parameter. -* It placed a virtual keyboard on screen, which could be used in touch-enabled devices like Windows tablets. -* {{Text|Deprecated|red}}, in all current versions of QB64 it just generates a warning now, but has no other effect anymore. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|$VIRTUALKEYBOARD|$VIRTUALKEYBOARD:ON}} - -{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[Metacommand]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%26B_%261.txt b/internal/help/%26B_%261.txt deleted file mode 100644 index 40cf77283..000000000 --- a/internal/help/%26B_%261.txt +++ /dev/null @@ -1,59 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:02}} -The [[&B]] prefix denotes that an integer value is expressed in a Binary base 2 format. Every 8 digits represent a [[_BYTE]]. - - -{{PageSyntax}} -: {{Parameter|a&}} = [[&B]]10010110 - - -{{PageDescription}} -* The base 2 numbering system uses binary digit values of 0 and 1 only. -* Leading zero values can be omitted just like in decimal values as they add nothing to the return value. -* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as: -:* [[_BYTE]]: 8 binary digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255. -:* [[INTEGER]]: 16 binary digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535. -:* [[LONG]]: 32 binary digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295. -:* [[_INTEGER64]]: 64 binary digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. -:* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615. -* The maximum binary value for each numerical type is the maximum number of digits listed above, each valued at '''1'''. -* Convert binary to [[LONG]] values by appending the values with the suffix '''&'''. Example: [[&B]]1000000000000000 = -32768: [[&B]]1000000000000000'''&''' = 32768 -* To convert binary strings returned from [[_BIN$]] with [[VAL]] you need to prefix the string with [[&B]] (for example, if the string is "1101" you should do {{InlineCode}}{{Cl|VAL}}("&B1101"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&B" + binvalue$){{InlineCodeEnd}}. - - -{{PageExamples}} -;Example 1:The maximum binary values of decimal value -1 in each numerical type are: -{{CodeStart}} -c&& = -1: d& = -1: e% = -1: f%% = -1 -bi$ = {{Cl|_BIN$}}(f%%) -{{Cl|PRINT}} "Max binary {{Cl|_BYTE}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$) -bi$ = {{Cl|_BIN$}}(e%) -{{Cl|PRINT}} "Max binary {{Cl|INTEGER}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$) -bi$ = {{Cl|_BIN$}}(d&) -{{Cl|PRINT}} "Max binary {{Cl|LONG}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$) -bi$ = {{Cl|_BIN$}}(c&&) -{{Cl|PRINT}} "Max binary {{Cl|_INTEGER64}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$) -bi$ = {{Cl|_BIN$}}(9223372036854775807) -{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits" -bi$ = {{Cl|_BIN$}}(-9223372036854775808) -{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits" -{{CodeEnd}} -{{OutputStart}} -Max binary _BYTE = 11111111 with 8 digits = 255 -Max binary INTEGER = 1111111111111111 with 16 digits = 65535 -Max binary LONG = 11111111111111111111111111111111 with 32 digits = 4294967295 -Max binary _INTEGER64 = 1111111111111111111111111111111111111111111111111111111111111111 with 64 digits =-1 -Max _INTEGER64 value = 111111111111111111111111111111111111111111111111111111111111111 with 63 digits -Min _INTEGER64 value = 1000000000000000000000000000000000000000000000000000000000000000 with 64 digits -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]] -* [[&H]] (hexadecimal), [[&O]] (octal), [[VAL]] -* [[Base Comparisons]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%26H_%261.txt b/internal/help/%26H_%261.txt deleted file mode 100644 index 198b5464a..000000000 --- a/internal/help/%26H_%261.txt +++ /dev/null @@ -1,96 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:05}} -The [[&H]] prefix denotes that an integer value is expressed in a Hexadecimal base 16 format. Every 2 digits represent a [[_BYTE]]. - - -{{PageSyntax}} -: {{Parameter|a&}} = [[&H]]C0DEBA5E - - -{{PageDescription}} -* The base 16 numbering system uses hexadecimal digit values of 0 to F, where '''A''' = 10, '''B''' = 11, '''C''' = 12, '''D''' = 13, '''E''' = 14 and '''F''' = 15. -* Leading zero values can be omitted just like in decimal values as they add nothing to the return value. -* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as: -:* [[_BYTE]]: 2 hex digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255. -:* [[INTEGER]]: 4 hex digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535. -:* [[LONG]]: 8 hex digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295. -:* [[_INTEGER64]]: 16 hex digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. -:* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615. -* The maximum hexadecimal value for each numerical type is the maximum number of digits listed above, each valued at '''F'''. -* Convert hexadecimal to [[LONG]] values by appending the values with the suffix '''&'''. Example: [[&H]]8000 = -32768: [[&H]]8000'''&''' = 32768 -* [[LONG]] 32 bit [[_RGB]] values can be made using hexadecimal values from '''&HFF{{Text|00|red}}{{Text|00|green}}{{Text|00|blue}}''' to '''&HFF{{Text|FF|red}}{{Text|FF|green}}{{Text|FF|blue}}''' with full [[_ALPHA]] only. -* [[LONG]] 32 bit [[_RGBA]] values can be made using hexadecimal values from '''&H00{{Text|00|red}}{{Text|00|green}}{{Text|00|blue}}''' to '''&HFF{{Text|FF|red}}{{Text|FF|green}}{{Text|FF|blue}}''' with any [[_ALPHA]]. -* Hexadecimal '''0x''' is often used to prefix [[HEX$]] port addresses in documentation. Replace '''0x''' with [[&H]] in QB64 or QBasic. -* To convert hexadecimal strings returned from [[HEX$]] with [[VAL]] you need to prefix the string with [[&H]] (for example, if the string is "FF" you should do {{InlineCode}}{{Cl|VAL}}("&HFF"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&H" + hexvalue$){{InlineCodeEnd}}. - - -{{PageExamples}} -;Example 1:The maximum hexadecimal values of decimal value -1 in each numerical type are: -{{CodeStart}} -c&& = -1: d& = -1: e% = -1: f%% = -1 -hx$ = {{Cl|HEX$}}(f%%) -{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(e%) -{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(d&) -{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(c&&) -{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$) -hx$ = {{Cl|HEX$}}(9223372036854775807) -{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" -hx$ = {{Cl|HEX$}}(-9223372036854775808) -{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" -{{CodeEnd}} -{{OutputStart}} -Max hex _BYTE = FF with 2 digits = 255 -Max hex INTEGER = FFFF with 4 digits = 65535 -Max hex LONG = FFFFFFFF with 8 digits = 4294967295 -Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1 -Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits -Min _INTEGER64 value = 8000000000000000 with 16 digits -{{OutputEnd}} - - -;Example 2:Converting a decimal number to a binary string value using [[HEX$]]. -{{CodeStart}} -{{Cl|FUNCTION}} BIN$ (n&) - h$ = {{Cl|HEX$}}(n&) 'get hexadecimal string value - {{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(h$) 'scan the HEX$ digits - {{Cl|SELECT CASE}} {{Cl|MID$}}(h$, i, 1) 'read each HEX$ digit - {{Cl|CASE}} "0": b$ = b$ + "0000" - {{Cl|CASE}} "1": b$ = b$ + "0001" - {{Cl|CASE}} "2": b$ = b$ + "0010" - {{Cl|CASE}} "3": b$ = b$ + "0011" - {{Cl|CASE}} "4": b$ = b$ + "0100" - {{Cl|CASE}} "5": b$ = b$ + "0101" - {{Cl|CASE}} "6": b$ = b$ + "0110" - {{Cl|CASE}} "7": b$ = b$ + "0111" - {{Cl|CASE}} "8": b$ = b$ + "1000" - {{Cl|CASE}} "9": b$ = b$ + "1001" - {{Cl|CASE}} "A": b$ = b$ + "1010" - {{Cl|CASE}} "B": b$ = b$ + "1011" - {{Cl|CASE}} "C": b$ = b$ + "1100" - {{Cl|CASE}} "D": b$ = b$ + "1101" - {{Cl|CASE}} "E": b$ = b$ + "1110" - {{Cl|CASE}} "F": b$ = b$ + "1111" - {{Cl|END SELECT}} - {{Cl|NEXT}} i - b$ = {{Cl|RIGHT$}}(b$, {{Cl|LEN}}(b$) - {{Cl|INSTR}}(b$, "1") + 1) 'eliminate leading zeroes - {{Cl|IF}} {{Cl|VAL}}(b$) {{Cl|THEN}} BIN$ = b$ {{Cl|ELSE}} BIN$ = "0" 'return zero if n& = 0 -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{small|Code by CodeGuy}} -;Explanation: Hexadecimal digits can be any value up to 15 which also corresponds to all four bits on in binary. The function above just adds every four bit binary string value together to return the binary value. After they are concatenated, the leading bit on is found by [[INSTR]] and everything from that point is kept removing the leading "0"'s. -;Note: Since QB64 2.1 (QB64 Team) respectively QBPE 0.5 (QB64 Phoenix Edition) the built-in [[_BIN$]] function should be used instead. - - -{{PageSeeAlso}} -* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]] -* [[&B]] (binary), [[&O]] (octal), [[VAL]] -* [[Base Comparisons]] -* [[HEX$ 32 Bit Values]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%26O_%261.txt b/internal/help/%26O_%261.txt deleted file mode 100644 index a6afba18e..000000000 --- a/internal/help/%26O_%261.txt +++ /dev/null @@ -1,60 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:03}} -The [[&O]] prefix denotes that an integer value is expressed in a Octal base 8 format. - - -{{PageSyntax}} -: {{Parameter|a&}} = [[&O]]377 - - -{{PageDescription}} -* The base 8 numbering system uses octal digit values of 0 to 7 only. -* Leading zero values can be omitted just like in decimal values as they add nothing to the return value. -* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as: -:* [[_BYTE]]: 3 octal digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255. -:* [[INTEGER]]: 6 octal digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535. -:* [[LONG]]: 11 octal digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295. -:* [[_INTEGER64]]: 22 octal digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. -:* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615. -* The maximum octal value for each numerical type is the maximum number of digits listed above, each valued at '''7''' (except the first digit). -** If the maximum number of digits is used, then the first digit (usually the highest significant position) may not be maxed out to '''7''', but only up to '''3''' ([[_BYTE]] and [[LONG]]) and up to '''1''' ([[INTEGER]] and [[_INTEGER64]]). -* Convert octal to [[LONG]] values by appending the values with the suffix '''&'''. Example: [[&O]]100000 = -32768: [[&O]]100000'''&''' = 32768 -* To convert octal strings returned from [[OCT$]] with [[VAL]] you need to prefix the string with [[&O]] (for example, if the string is "377" you should do {{InlineCode}}{{Cl|VAL}}("&O377"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&O" + octvalue$){{InlineCodeEnd}}. - - -{{PageExamples}} -;Example 1:The maximum octal values of decimal value -1 in each numerical type are: -{{CodeStart}} -c&& = -1: d& = -1: e% = -1: f%% = -1 -oc$ = {{Cl|OCT$}}(f%%) -{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) -oc$ = {{Cl|OCT$}}(e%) -{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) -oc$ = {{Cl|OCT$}}(d&) -{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) -oc$ = {{Cl|OCT$}}(c&&) -{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) -oc$ = {{Cl|OCT$}}(9223372036854775807) -{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits" -oc$ = {{Cl|OCT$}}(-9223372036854775808) -{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits" -{{CodeEnd}} -{{OutputStart}} -Max octal _BYTE = 377 with 3 digits = 255 -Max octal INTEGER = 177777 with 6 digits = 65535 -Max octal LONG = 37777777777 with 11 digits = 4294967295 -Max octal _INTEGER64 = 1777777777777777777777 with 22 digits =-1 -Max _INTEGER64 value = 777777777777777777777 with 21 digits -Min _INTEGER64 value = 1000000000000000000000 with 22 digits -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]] -* [[&B]] (binary), [[&H]] (hexadecimal), [[VAL]] -* [[Base Comparisons]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%2A_%21.txt b/internal/help/%2A_%21.txt deleted file mode 100644 index 3be90ef1e..000000000 --- a/internal/help/%2A_%21.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:07}} -The [[*]] mathematical operator performs the multiplication of two values. - - -{{PageSyntax}} -: {{Parameter|return_value}} = {{Parameter|number1}} [[*]] {{Parameter|number2}} - - -{{PageDescription}} -* Multiplication can use any two literal or variable numerical type values. -* Multiplication of two negative numbers returns a positive result. One negative number will always return a negative value. -* Return values may exceed certain numerical variable type limits creating an [[ERROR Codes|"Overflow" error.]] -* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. - - -{{PageSeeAlso}} -* [[Mathematical Operations]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%2B_%21.txt b/internal/help/%2B_%21.txt deleted file mode 100644 index 5b4e5dcb9..000000000 --- a/internal/help/%2B_%21.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:00}} -The '''+''' plus mathematical operator performs addition on two numerical values or [[concatenation|concatenate]] [[STRING]] values. - - - -''Syntax:'' return_value = number1 + number2 - - - -{{PageDescription}} -* A [[+]] sign also can indicate a positive numerical value, but it is not required. -* Numbers used can be any literal or variable numerical value type. -* Adding one negative value will actually perform subtraction on the other value. -* Adding two negative values will make the return value more negative. -* Addition and subtraction are the last operations performed in QBasic's normal order of operations. -* The [[+|plus(+)]] operator can also be used to add ([[concatenation|concatenate]]) literal or variable [[STRING]] values. -* [[PRINT]] can also use + operations on string values ONLY! Numerical values will need to be converted to strings first or be included using [[semicolon]]s or [[comma]]s instead. - - - -''See also:'' - -[[-|- minus]] (subtraction or [[negation]] operator) - -[[Mathematical Operations]] - - - -{{PageNavigation}} diff --git a/internal/help/%2F_%21.txt b/internal/help/%2F_%21.txt deleted file mode 100644 index 0961ab356..000000000 --- a/internal/help/%2F_%21.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:08}} -The [[/]] mathematical operator performs decimal point division on a numerical value. - - -{{PageSyntax}} -: {{Parameter|return_value}} = {{Parameter|number}} [[/]] {{Parameter|divisor}} - - -{{PageDescription}} -* Number value can be any literal or variable numerical type. -* Return values can be any literal or variable numerical type, but [[SINGLE]] or [[DOUBLE]] type decimal point returns are likely. -* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision. -* Use the [[\|\ integer division]] operator to guarantee [[INTEGER]] or [[LONG]] return values. -* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. - - -{{PageSeeAlso}} -* [[Mathematical Operations]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/%5C_%51.txt b/internal/help/%5C_%51.txt deleted file mode 100644 index c92db6196..000000000 --- a/internal/help/%5C_%51.txt +++ /dev/null @@ -1,44 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:09}} -The [[\]] mathematical operator performs [[INTEGER]] division on a numerical value. - - -{{PageSyntax}} -: {{Parameter|return_value}} = {{Parameter|number}} [[\]] {{Parameter|divisor}} - - -{{PageDescription}} -* Number value can be any literal or variable numerical type. -* '''Divisor (second value) must not be a value of 0 to .5'''. This will create a [[ERROR Codes|"Division by zero" error!]] due to [[CINT]] rounding. -* Return values will be [[INTEGER]] or [[LONG]] value types only. -* Rounding is done to the closest EVEN [[INTEGER|integer]] or [[LONG|long integer]] value. -* Use the [[/|/ normal division]] operator for [[SINGLE]] or [[DOUBLE]] floating decimal point return values. -* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. - - -{{PageExamples}} -;Example:Displays how floating decimal point values are rounded to the closest even [[INTEGER|integer]] value. -{{CodeStart}} -{{Cl|PRINT}} 0.5 \ 1 -{{Cl|PRINT}} 1.5 \ 1 -{{Cl|PRINT}} 2.5 \ 1 -{{Cl|PRINT}} 3.5 \ 1 -{{Cl|PRINT}} 4.5 \ 1 -{{Cl|PRINT}} 5.5 \ 1 -{{CodeEnd}} -{{OutputStart}}0 -2 -2 -4 -4 -6 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[Mathematical Operations]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/-_-.txt b/internal/help/-_-.txt deleted file mode 100644 index 3dad9b83b..000000000 --- a/internal/help/-_-.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:06}} -The '''-''' mathematical operator performs subtraction on two numerical values or [[negation|negates]] a single value. - - - -''Syntax:'' return_value = number1 - number2 - - - -{{PageDescription}} - -* Numbers used can be any literal or variable numerical value type. -* Subtracting a negative value will actually perform addition with the other value. -* Subtracting a negative or [[negation|negated]] value will make the return value more positive. -* Addition and subtraction are the last operations performed in QBasic's normal order of operations. -* Subtraction cannot be performed on [[STRING]] values. - - - -''See also:'' - -[[+|+ positive]] (addition operator) - -[[Mathematical Operations]] - - - -{{PageNavigation}} diff --git a/internal/help/ABS_111.txt b/internal/help/ABS_111.txt deleted file mode 100644 index d8c114754..000000000 --- a/internal/help/ABS_111.txt +++ /dev/null @@ -1,41 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:54}} -The [[ABS]] function returns the unsigned numerical value of a variable or literal value. - - -{{PageSyntax}} -:{{Parameter|positive}} = [[ABS]]({{Parameter|numericalValue}}) - - -{{PageDescription}} -* [[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 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 -b = -7 -c = 8 -{{Cl|IF...THEN|IF}} a < 0 {{Cl|THEN}} a = {{Cl|ABS}}(a) -b = {{Cl|ABS}}(b) -c = {{Cl|ABS}}(c) -{{Cl|PRINT}} a, b, c -{{CodeEnd}} -{{OutputStart}} 6 7 8 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[SGN]], [[DIM]] -* [[_UNSIGNED]] -* [[_DEFINE]] -* [[Mathematical Operations]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/ACCESS_111111.txt b/internal/help/ACCESS_111111.txt deleted file mode 100644 index 26bd18809..000000000 --- a/internal/help/ACCESS_111111.txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:56}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/ALIAS_11111.txt b/internal/help/ALIAS_11111.txt deleted file mode 100644 index dad2c07e0..000000000 --- a/internal/help/ALIAS_11111.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:57}} -See page [[DECLARE LIBRARY]] diff --git a/internal/help/AND_(boolean)_111_(0000000).txt b/internal/help/AND_(boolean)_111_(0000000).txt deleted file mode 100644 index 9105e204b..000000000 --- a/internal/help/AND_(boolean)_111_(0000000).txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:59}} -The [[AND (boolean)|AND]] conditonal operator is used to include another evaluation in an [[IF...THEN]] or [[Boolean]] statement. - - - -{{PageSyntax}} -: IF {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}} - - -{{PageDescription}} -* 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. -* Statements can use parenthesis to clarify an evaluation. -* [[AND (boolean)]] and [[OR (boolean)]] cannot be used to combine command line operations. -* Not to be confused with the [[AND]] and [[OR]] numerical operations. - - -{{RelationalTable}} - - -{{PageExamples}} -''Example:'' Using AND in an IF statement. -{{CodeStart}} - -a% = 100 -b% = 50 - -{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% < 200 {{Cl|THEN}} {{Cl|PRINT}} "True" - -{{CodeEnd}} -{{OutputStart}} -True -{{OutputEnd}} -''Explanation:'' Both condition evaluations must be true for the code to be executed. - - -''Example:'' Using a AND a more complex way. -{{CodeStart}} -a% = 100 -b% = 50 -c% = 25 -d% = 50 -e% = 100 - -{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% < d% {{Cl|AND (boolean)|AND}} d% < e%) {{Cl|THEN}} -{{Cl|PRINT}} "True" -{{Cl|ELSE}} -{{Cl|PRINT}} "False" -{{Cl|END IF}} -{{CodeEnd}} -{{OutputStart}} -True -{{OutputEnd}} -''Explanation:'' The evaluations in the paranteses are evaluated first then the evaluation ''of'' the paranteses takes place, since all evaluations return True the IF...THEN evaluation returns True. If any of the evaluations returned False then the IF...THEN evaluation would also return False. - - -{{PageSeeAlso}} -* [[AND]], [[OR]] {{text|(logical operators)}} -* [[OR (boolean)]], [[XOR (boolean)]] -* [[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/AND_111.txt b/internal/help/AND_111.txt deleted file mode 100644 index d506595c2..000000000 --- a/internal/help/AND_111.txt +++ /dev/null @@ -1,78 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:58}} -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}} - - -{{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 (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. - - -{{LogicalTruthTable}} - - -{{PageExamples}} -''Example 1:'' -{{WhiteStart}} - 101 - AND - 011 - ----- - 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. - - -''Example 2:'' -{{WhiteStart}} - 11111011 - AND - 11101111 - ---------- - 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: - -::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 [[INTEGER]]s use: secondbyte = twobyteint \ 256 - - -''Example 3:'' Finding the binary bits on in an [[INTEGER]] value. -{{CodeStart}} - - DO - {{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue& - IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN {{Cl|EXIT DO}} - {{Cl|FOR...NEXT|FOR}} exponent = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 - {{Cl|IF...THEN|IF}} (INTvalue& {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0"; - {{Cl|NEXT}} - PRINT " " - LOOP UNTIL INTvalue& = 0 'zero entry quits - -{{CodeEnd}} - -:Example output for 6055. -{{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 [[LONG]] variables for input values to prevent overflow errors. - - -{{PageSeeAlso}} -* [[OR]], [[XOR]], [[NOT]] {{text|(logical operators)}} -* [[AND (boolean)]] -* [[Binary]], [[Boolean]] - - -{{PageNavigation}} diff --git a/internal/help/APPEND_111111.txt b/internal/help/APPEND_111111.txt deleted file mode 100644 index d78874d36..000000000 --- a/internal/help/APPEND_111111.txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:03}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/ASC_(statement)_111_(000000000).txt b/internal/help/ASC_(statement)_111_(000000000).txt deleted file mode 100644 index f5b65609c..000000000 --- a/internal/help/ASC_(statement)_111_(000000000).txt +++ /dev/null @@ -1,49 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:06}} -The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a character at any position of a [[STRING]] variable. - - -{{PageSyntax}} -: [[ASC (statement)|ASC]]({{Parameter|stringExpression$}}[, {{Parameter|position%}}]) = {{Parameter|code%}} - - -{{PageDescription}} -* 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" - {{Cl|ASC (statement)|ASC}}(a$) = 65 ' CHR$(65) = "A" - {{Cl|ASC (statement)|ASC}}(a$, 2) = 66 ' CHR$(66) = "B" - {{Cl|PRINT}} a$ 'ABC - - {{Cl|ASC (statement)|ASC}}(a$, 2) = 0 ' CHR$(0) = " " - {{Cl|PRINT}} a$ - - {{Cl|ASC (statement)|ASC}}(a$, 2) = {{Cl|ASC}}("S") ' get code value from ASC function - {{Cl|PRINT}} a$ -{{CodeEnd}} - -{{OutputStart}} - ABC - A C - ASC -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[ASC]] {{text|(function)}} -* [[MID$ (statement)]] -* [[_PRINTSTRING]] -* [[INKEY$]], [[ASCII]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/ASC_111.txt b/internal/help/ASC_111.txt deleted file mode 100644 index 0d97e929a..000000000 --- a/internal/help/ASC_111.txt +++ /dev/null @@ -1,170 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:05}} -The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] text character or a keyboard press. - - -{{PageSyntax}} -: {{Parameter|code%}} = [[ASC]]({{Parameter|text$}}[, {{Parameter|position%}}]) - - -* {{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$) = 0 THEN byte2 = 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''''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''' -' -'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause''' -' 27 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +133 +134 - - - -'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -''' -' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45 -''' 96 49 50 51 52 53 54 55 56 57 48 45 61'' -'''' Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/â–² 9PU + ''' -' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 +83 +79 +81 +71 +72 +73 43 -''' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 '' -'''' CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º -' - 65 83 68 70 71 72 74 75 76 58 34 13 +75 +76 +77 '''E''' -''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n''' -'''' Shift Z X C V B N M ,< .> /? Shift â–² 1End 2/â–¼ 3PD t''' -' * 90 88 67 86 66 78 77 60 62 63 * +72 +79 +80 +81 '''e''' -''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r''' -'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0Ins .Del ''' -' * - * 32 * - - * +75 +80 +77 +82 +83 13 -' '' 48 46'' -' -' ''' ''Italics'' = LCase/NumLock On ____________ + = 2 Byte: CHR$(0) + CHR$(code)''' -'{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}} -{{WhiteEnd}} - - -
'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''
- -{{WhiteStart}} '''Two Byte Characters    Key                 CHR$(0) + "?" ''' - - CHR$(0) + CHR$(16-50) [Alt] + letter - CHR$(0) + CHR$(59) [F1] ";" - CHR$(0) + CHR$(60) [F2] "<" - CHR$(0) + CHR$(61) [F3] "=" - CHR$(0) + CHR$(62) [F4] ">" - CHR$(0) + CHR$(63) [F5] "?" - CHR$(0) + CHR$(64) [F6] "@" - CHR$(0) + CHR$(65) [F7] "A" - CHR$(0) + CHR$(66) [F8] "B" - CHR$(0) + CHR$(67) [F9] "C" - CHR$(0) + CHR$(68) [F10] "D" - CHR$(0) + CHR$(71) [Home] "G" - CHR$(0) + CHR$(72) [↑] Arrow "H" - CHR$(0) + CHR$(73) [Page Up] "I" - CHR$(0) + CHR$(75) [â†] Arrow "K" - CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64) - CHR$(0) + CHR$(77) [→] Arrow "M" - CHR$(0) + CHR$(79) [End] "O" - CHR$(0) + CHR$(80) [↓] Arrow "P" - CHR$(0) + CHR$(81) [Page Down] "Q" - CHR$(0) + CHR$(82) [Insert] "R" - CHR$(0) + CHR$(83) [Delete] "S" - CHR$(0) + CHR$(84-93) [Shift] + F1-10 - CHR$(0) + CHR$(94-103) [Ctrl] + F1-10 - CHR$(0) + CHR$(104-113) [Alt] + F1-10 - CHR$(0) + CHR$(114-119) [Ctrl] + keypad - CHR$(0) + CHR$(120-129) [Alt] + number - CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "é" or "â" - CHR$(0) + CHR$(133) [F11] "à" - CHR$(0) + CHR$(134) [F12] "Ã¥" - CHR$(0) + CHR$(135) [Shift] + [F11] "ç" - CHR$(0) + CHR$(136) [Shift] + [F12] "ê" - CHR$(0) + CHR$(137) [Ctrl] + [F11] "ë" - CHR$(0) + CHR$(138) [Ctrl] + [F12] "è" - CHR$(0) + CHR$(139) [Alt] + [F11] "ï" - CHR$(0) + CHR$(140) [Alt] + [F12] "î" -{{WhiteEnd}} -: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}} {{Cl|ASC}}("A") - {{Cl|PRINT}} {{Cl|ASC}}("Be a rockstar") - {{Cl|PRINT}} {{Cl|ASC}}("QB64 is not only COMPATIBLE, it can find any part of the string!", 18) -{{CodeEnd}} - -''Returns:'' -{{OutputStart}} - 65 - 66 - 67 -{{OutputEnd}} - -''Explanation:'' The ASCII code for "A" is 65 and the ASCII code for "B" is 66, ASCII code for "C" is 67 and the "C" is at position 18 in the string. - -::''Note:'' The ASCII code for "A" and "a" are different by the value of 32, "A" + 32 is "a", 65("A") + 32 = 97("a"). - - -''Example 2:'' Reading the ASCII and two byte code combinations with ASC in '''QB64'''. - -{{CodeStart}} -Q$ = {{Cl|CHR$}}(34) ' quote character -{{Cl|COLOR}} 10: {{Cl|LOCATE}} 5, 22: {{Cl|PRINT}} "Press some keys or combinations!" -{{Cl|COLOR}} 13: {{Cl|LOCATE}} 23, 30: {{Cl|PRINT}} "Escape key Quits" -{{Cl|DO}} - {{Cl|DO}}: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ <> "" ' prevent ASC empty string read error - code% = {{Cl|ASC}}(key$): {{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 10 - {{Cl|IF...THEN|IF}} code% {{Cl|THEN}} ' ASC returns any value greater than 0 - {{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(code%)) + ")" + {{Cl|SPACE$}}(13): - {{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% < 14 {{Cl|THEN}} code% = 32 ' unprintable control codes - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} {{Cl|CHR$}}(code%) + {{Cl|SPACE$}}(13) - {{Cl|ELSE}}: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(key$, 2))) + ")" - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + " + Q$ + {{Cl|CHR$}}({{Cl|ASC}}(key$, 2)) + Q$ - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} code% = 27 '' ' - -{{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. [[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}} - {{Cl|DO}}: {{Cl|SLEEP}} ' requires a keypress to run loop once - K$ = {{Cl|INKEY$}} - code = {{Cl|ASC}}(K$) - {{Cl|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code <= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|CHR$}}(code) ' numbers only - {{Cl|IF}} code = 46 {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}} - entry$ = entry$ + K$: flag = 1: mark = {{Cl|LEN}}(entry$) ' decimal point - {{Cl|END IF}} - L = {{Cl|LEN}}(entry$) ' check entry length for possible backspace - {{Cl|IF}} code = 8 {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length - entry$ = {{Cl|MID$}}(entry$, 1, L - 1) ' remove one character from entry$ - {{Cl|IF}} L - 1 < mark {{Cl|THEN}} flag = 0 ' allow another decimal point if removed. - {{Cl|LOCATE}} 10, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|SPACE$}}(1); ' remove character from screen - {{Cl|END IF}} - {{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} entry$; - ' display present entry to user(semicolon required for correct POS return) - {{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. - - -{{Parameter|See also:'' }} -* [[ASC (statement)]] -* [[_KEYHIT]], [[_KEYDOWN]] -* [[MID$]], [[CHR$]], [[INKEY$]] -* [[VAL]], [[STRING$]] -* [[ASCII]], [[_MAPUNICODE]] -* [[Scancodes]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/AS_11.txt b/internal/help/AS_11.txt deleted file mode 100644 index b75fc8111..000000000 --- a/internal/help/AS_11.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:04}} -The [[AS]] keyword defines a variable data [[type]]. - - -{{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]] - - -===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.''' - - -{{PageSeeAlso}} -* [[DIM]], [[REDIM]] -* [[_DEFINE]] -* [[BYVAL]], [[TYPE]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/ATN_111.txt b/internal/help/ATN_111.txt deleted file mode 100644 index fa7cc3a3d..000000000 --- a/internal/help/ATN_111.txt +++ /dev/null @@ -1,90 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:08}} -The [[ATN]] or arctangent function returns the angle in radians of a numerical [[TAN|tangent]] value. - - -{{PageSyntax}} -: {{Parameter|radianAngle}} = [[ATN]]({{Parameter|tangent!}}) - - -{{Parameters}} -* The return is the {{Parameter|tangent!}}'s angle in '''radians'''. -* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi = 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)) = 1|green}}''' -* The function return value is between -ã / 2 and ã / 2. - - -{{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)) -y = 100 * {{Cl|SIN}}({{Cl|ATN}}(1)) -{{Cl|LINE}} (200, 200)-(200 + x, 200 + y) -{{CodeEnd}} - - -''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. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -x1! = 320 -y1! = 240 - -DO - {{Cl|PRESET}} (x1!, y1!), {{Cl|_RGB}}(255, 255, 255) - dummy% = {{Cl|_MOUSEINPUT}} - x2! = {{Cl|_MOUSEX}} - y2! = {{Cl|_MOUSEY}} - {{Cl|LINE}} (x1, y1)-(x2, y2), {{Cl|_RGB}}(255, 0, 0) - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} getangle(x1!, y1!, x2!, y2!) - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 200 - {{Cl|CLS}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -{{Cl|FUNCTION}} getangle# (x1#, y1#, x2#, y2#) 'returns 0-359.99... -{{Cl|IF...THEN|IF}} y2# = y1# {{Cl|THEN}} - {{Cl|IF...THEN|IF}} x1# = x2# {{Cl|THEN}} {{Cl|EXIT FUNCTION}} - {{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}} getangle# = 90 {{Cl|ELSE}} getangle# = 270 - {{Cl|EXIT FUNCTION}} -{{Cl|END IF}} -{{Cl|IF...THEN|IF}} x2# = x1# {{Cl|THEN}} - {{Cl|IF...THEN|IF}} y2# > y1# {{Cl|THEN}} getangle# = 180 - {{Cl|EXIT FUNCTION}} -{{Cl|END IF}} -{{Cl|IF...THEN|IF}} y2# < y1# {{Cl|THEN}} - {{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}} - getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 - {{Cl|ELSE}} - getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 360 - {{Cl|END IF}} -{{Cl|ELSE}} - getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 180 -{{Cl|END IF}} -{{Cl|END FUNCTION}} -{{CodeEnd}}{{small|Function by Galleon}} - - -{{PageSeeAlso}} -* [[_PI]] {{text|(QB64 function)}} -* [[TAN]] {{text|(tangent function)}} -* [[SIN]], [[COS]] -* [[Mathematical Operations]] -* [[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/Apostrophe_1000000000.txt b/internal/help/Apostrophe_1000000000.txt deleted file mode 100644 index c7f266b3c..000000000 --- a/internal/help/Apostrophe_1000000000.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:55}} -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. - - -{{PageExamples}} -{{CodeStart}} -COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!" -{{CodeEnd}} - -{{OutputStart}} -{{text|Print this....|aqua}} -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[Comma]], [[Semicolon]] -* [[REM]] - - -{{PageNavigation}} diff --git a/internal/help/BEEP_1111.txt b/internal/help/BEEP_1111.txt deleted file mode 100644 index ceda13137..000000000 --- a/internal/help/BEEP_1111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:09}} -The [[BEEP]] statement produces a beep sound through the sound card. - - -{{PageSyntax}} -: [[BEEP]] - - -{{PageDescription}} -* [[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}} -* [[SOUND]], [[PLAY]] -* [[_SNDPLAY]] {{text|(play sound files)}} -* [[_SNDRAW]] {{text|(play frequency waves)}} - - -{{PageNavigation}} diff --git a/internal/help/BINARY_111111.txt b/internal/help/BINARY_111111.txt deleted file mode 100644 index 2121e10d5..000000000 --- a/internal/help/BINARY_111111.txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:10}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/BLOAD_11111.txt b/internal/help/BLOAD_11111.txt deleted file mode 100644 index 32dad0055..000000000 --- a/internal/help/BLOAD_11111.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:11}} -[[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array. - -{{PageSyntax}} -: [[BLOAD]] {{Parameter|fileName$}}, [[VARPTR]]({{Parameter|imageArray%({{Parameter|index}})}}) - - -===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. - - -{{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 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)) -* {{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 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 [[TYPE]] arrays. [[LBOUND]] determines the starting offset of the array or another index could be used. - - -''Example 2:'' Using a QB default colored image. -{{CodeStart}} - {{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image%(0)) ' pointer to first image element of an array - {{Cl|BLOAD}} FileName$, {{Cl|VARPTR}}(Image%(0)) ' place data into array at index position 0 - {{Cl|PUT (graphics statement)|PUT}}(Col, Row), Image%(0), PSET ' Put the image on the screen from index 0 - {{Cl|DEF SEG}} -{{CodeEnd}} -: ''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)}} -* [[GET (graphics statement)]], [[PUT (graphics statement)]] -* [[VARSEG]], [[VARPTR]] -* [[DEF SEG]] -* [[Text Using Graphics]] - - -{{PageNavigation}} diff --git a/internal/help/BSAVE_11111.txt b/internal/help/BSAVE_11111.txt deleted file mode 100644 index 6cb0d3b32..000000000 --- a/internal/help/BSAVE_11111.txt +++ /dev/null @@ -1,106 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:12}} -[[BSAVE]] saves the contents of an image array to a [[BINARY]] file. - - -{{PageSyntax}} -: [[BSAVE]] {{Parameter|saveFile$}}, [[VARPTR]]({{Parameter|array(index)}}), {{Parameter|fileSize&}} - - -===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. - - -{{Parameters}} -* {{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. -* [[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 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) - bytes% = {{Cl|LEN}}(Array(LB%)) - filesize& = (({{Cl|UBOUND}}(Array) - LB%) + 1) * bytes% - {{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0)) - {{Cl|BSAVE}} filename$, {{Cl|VARPTR}}(Array(LB%)), filesize& ' changeable index - {{Cl|DEF SEG}} -{{CodeEnd}} -: ''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:'' [[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 - {{Cl|GET (graphics statement)|GET}} (0, 0)-(BMPHead.PWidth - 1, BMPHead.PDepth - 1), Image(NColors * 3) ' for 16 or 256 colors - {{Cl|FOR...NEXT|FOR}} a& = 26000 {{Cl|TO}} 0 {{Cl|STEP}} -1 - {{Cl|IF...THEN|IF}} Image(a&) {{Cl|THEN}} ArraySize& = a&: {{Cl|EXIT FOR}} - {{Cl|NEXT}} - {{Cl|BSAVE}} SaveName$, {{Cl|VARPTR}}(Image(0)), (2 * ArraySize&) + 200 'file size - {{Cl|DEF SEG}} -{{CodeEnd}} - -: ''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}} -* [[GET (graphics statement)]], [[PUT (graphics statement)]] -* [[BLOAD]], [[OPEN]], [[BINARY]] -* [[GET]], [[PUT]] {{text|(file statements)}} -* [[VARSEG]], [[VARPTR]] -* [[DEF SEG]], [[TYPE]] -* [[Text Using Graphics]] - - -{{PageNavigation}} diff --git a/internal/help/BYVAL_11111.txt b/internal/help/BYVAL_11111.txt deleted file mode 100644 index fee236b51..000000000 --- a/internal/help/BYVAL_11111.txt +++ /dev/null @@ -1,104 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:14}} -The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64. - - -{{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''' - - -{{Parameters}} -* 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=== -* '''[[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. -* '''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 (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. -* When using a procedure from an '''unsupported''' Dynamic Link Library (DLL file) use [[DECLARE DYNAMIC LIBRARY]]. - -* 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.''' - - -{{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 -{{Cl|DECLARE LIBRARY|END DECLARE}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) 'simulate screen 12 with 256 colors -{{Cl|RANDOMIZE}} {{Cl|TIMER}} - -DO - {{Cl|_DELAY}} 1 - x = {{Cl|RND}} * 640: y = {{Cl|RND}} * 480 - {{Cl|LINE}} (x, y)-{{Cl|STEP}}(10, 10), {{Cl|RND}} * 100 + 32, BF - MouseMove x + 5, y + 5 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) 'any keypress quits -{{Cl|END}} - -{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}}) -SDL_WarpMouse x, y 'call SDL library procedure -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Galleon}} -:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use. - -
'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''
-{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DECLARE LIBRARY}} - {{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -{{Cl|_DELAY}} 2 -MouseMove 100, 100 -{{Cl|_DELAY}} 2 -MouseMove 200, 200 -{{CodeEnd}} -:''Explanation:'' When a Library procedure is used to represent another procedure name use [[ALIAS]] instead. Saves creating a SUB! - - -''Example 2:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes. -{{CodeStart}} -{{Cl|DECLARE LIBRARY}} "" - {{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&) -{{Cl|END}} DECLARE -{{CodeEnd}} -:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail. - -: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.''' - - -
'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''
-
'''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.'''
- - -''See also:'' -* [[DECLARE DYNAMIC LIBRARY]] -* [[SUB]], [[FUNCTION]] -* [[BYVAL]], [[ALIAS]] -* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]] -* [[Port Access Libraries]] -* [[SQL Client]] - - -{{PageNavigation}} diff --git a/internal/help/CALL_1111.txt b/internal/help/CALL_1111.txt deleted file mode 100644 index 2555f19e3..000000000 --- a/internal/help/CALL_1111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:15}} -[[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|parameter1}}, {{Parameter|parameter2}},...)] - -===Alternative syntax=== -: {{Parameter|ProcedureName}} {{Parameter|parameter1}}, {{Parameter|parameter2}},...] - - -* 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 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 DECLAREd. - - -{{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 -{{Cl|DIM}} {{Cl|SHARED}} b {{Cl|AS}} {{Cl|INTEGER}} 'value shared with any SUB -a = 1 -b = 2 -c = 3 - -{{Cl|CALL}} helloworld (a) 'a passed to c parameter with CALL -helloworld a 'a passed to c parameter w/o CALL - -{{Cl|END}} - -{{Cl|SUB}} helloworld (c) 'SUB parameter variables are always inside of brackets in SUB code -{{Cl|PRINT}} "Hello World!" -{{Cl|PRINT}} a, b, c -a = a + 1 'a is a SUB value of 0 when printed which may increase inside SUB only -b = b + 1 'b is a shared value which can increase anywhere -c = c + 1 'c is a SUB parameter value from a in calls which may increase inside SUB only -{{Cl|END SUB}} -{{CodeEnd}} - -''Returns:'' -{{OutputStart}}Hello World! - 0 2 1 -Hello World! - 0 3 1 -{{OutputEnd}} -: ''Explanation:'' Variable '''{{Parameter|a}}''' that is outside of the subroutine isn't [[SHARED]] so it will have no effect inside the subroutine, the variable {{Parameter|a}} inside the subroutine is only valid inside the subroutine, and whatever value {{Parameter|a}} has outside of it makes no difference within the subroutine. - -:The variable '''{{Parameter|b}}''' on the other hand is [[SHARED]] with the subroutines and thus can be changed in the subroutine. The variable {{Parameter|a}} is initiated with 0 as default when created, thus it will return 0 since it wasn't changed within the subroutine. - -: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. - - -{{PageSeeAlso}} -* [[SUB]], [[FUNCTION]] - - -{{PageNavigation}} diff --git a/internal/help/CALL_ABSOLUTE_1111_11111111.txt b/internal/help/CALL_ABSOLUTE_1111_11111111.txt deleted file mode 100644 index 662ddb6bb..000000000 --- a/internal/help/CALL_ABSOLUTE_1111_11111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:55}} -[[CALL ABSOLUTE]] is used to access interrupts on the computer or execute assembly type procedures. - - -{{PageSyntax}} -: [[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, use [[_MOUSEINPUT]] and related functions. - - -{{PageDescription}} -* [[CALL]] and parameter brackets are required in the statement. -* {{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]] -* [[_MOUSEINPUT]] - - -{{PageNavigation}} diff --git a/internal/help/CASE_1111.txt b/internal/help/CASE_1111.txt deleted file mode 100644 index ac22cdee3..000000000 --- a/internal/help/CASE_1111.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:16}} -See page [[SELECT CASE]] diff --git a/internal/help/CASE_ELSE_1111_1111.txt b/internal/help/CASE_ELSE_1111_1111.txt deleted file mode 100644 index 972d3c775..000000000 --- a/internal/help/CASE_ELSE_1111_1111.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:17}} -See page [[SELECT CASE]] diff --git a/internal/help/CASE_IS_1111_11.txt b/internal/help/CASE_IS_1111_11.txt deleted file mode 100644 index e80002c74..000000000 --- a/internal/help/CASE_IS_1111_11.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:18}} -See page [[SELECT CASE]] diff --git a/internal/help/CDBL_1111.txt b/internal/help/CDBL_1111.txt deleted file mode 100644 index 220ee963e..000000000 --- a/internal/help/CDBL_1111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:19}} -[[CDBL]] converts a value to the closest [[DOUBLE]]-precision value. - - - -{{PageSyntax}} -: {{Parameter|doubleValue#}} = [[CDBL]]({{Parameter|expression}}) - - -{{Parameters}} -* {{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 [[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 - {{Cl|PRINT}} A; {{Cl|CDBL}}(A) -{{CodeEnd}} -{{OutputStart}} 454.67 454.6700134277344 -{{OutputEnd}} -: The last 11 numbers in the double-precision number change the value in this example, since A was previously defined to only two-decimal place accuracy. - - -{{PageSeeAlso}} -* [[CINT]], [[CLNG]] -* [[CSNG]], [[_ROUND]] - - -{{PageNavigation}} diff --git a/internal/help/CHAIN_11111.txt b/internal/help/CHAIN_11111.txt deleted file mode 100644 index a2fcecf94..000000000 --- a/internal/help/CHAIN_11111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:20}} -[[CHAIN]] is used to change seamlessly from one module to another one in a program. - - -{{PageSyntax}} -: [[CHAIN]] {{Parameter|moduleName$}} - - -===Legacy support=== -* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[CHAIN]] statement 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. - - -{{Parameters}} -* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension. - - -{{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. -* '''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. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]'''. - - -''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". - - -{{PageSeeAlso}} -* [[RUN]] -* [[COMMON]], [[COMMON SHARED]] -* [[SHARED]] - - -{{PageNavigation}} diff --git a/internal/help/CHDIR_11111.txt b/internal/help/CHDIR_11111.txt deleted file mode 100644 index c9633f91f..000000000 --- a/internal/help/CHDIR_11111.txt +++ /dev/null @@ -1,64 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:22}} -The [[CHDIR]] statement changes the program's location from one working directory to another by specifying a literal or variable [[STRING]] path. - - -{{PageSyntax}} -:[[CHDIR]] {{Parameter|path$}} - - -{{PageDescription}} -* {{Parameter|path$}} is the new directory path the program will work in. -* {{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 use "CD " or "CHDIR " + path$ to change directories.''' - - -{{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:'' '''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 - {{Cl|FUNCTION}} GetModuleFileNameA ({{Cl|BYVAL}} Module {{Cl|AS}} {{Cl|LONG}}, FileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -FileName$ = {{Cl|SPACE$}}(256) -Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates the current program -{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} 'Result returns the length or bytes of the string information - PATH$ = {{Cl|LEFT$}}(FileName$, Result) - start = 1 - DO - posit = {{Cl|INSTR}}(start, PATH$, "\") - {{Cl|IF...THEN|IF}} posit {{Cl|THEN}} last = posit - start = posit + 1 - {{Cl|LOOP}} {{Cl|UNTIL}} posit = 0 - TITLE$ = {{Cl|MID$}}(PATH$, last + 1) - PATH$ = {{Cl|LEFT$}}(PATH$, last) -{{Cl|ELSE}} TITLE$ = "": PATH$ = "" -{{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. - - -{{PageSeeAlso}} -* [[SHELL]], [[FILES]] -* [[MKDIR]], [[RMDIR]] -* [[$CONSOLE]] - - -{{PageNavigation}} diff --git a/internal/help/CHR$_111$.txt b/internal/help/CHR$_111$.txt deleted file mode 100644 index fecbad850..000000000 --- a/internal/help/CHR$_111$.txt +++ /dev/null @@ -1,88 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:23}} -The [[CHR$]] function returns the character associated with a certain [[ASCII|character code]] as a [[STRING]]. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[CHR$]]({{Parameter|code%}}) - - -{{PageDescription}} -* 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}} -''Example 1:'' Outputs the characters of several character codes: -{{CodeStart}}{{Cl|PRINT}} {{Cl|CHR$}}(65); {{Cl|CHR$}}(65 + 32) -{{Cl|PRINT}} {{Cl|CHR$}}(66); {{Cl|CHR$}}(66 + 32) -{{CodeEnd}} -{{OutputStart}}Aa -Bb -{{OutputEnd}} -:Explanation: 65 is the ASCII code for "A" and 65 + 32 is the ASCII code for "a". 66 is the ASCII code for "B" and 66 + 32 is the ASCII code for "b" - - -''Example 2:'' To cut down on typing CHR$(???) all day, define often used characters as variables such as Q$ = CHR$(34) as shown. -{{CodeStart}} - -{{Cl|DIM}} Q AS {{Cl|STRING}} * 1 'define as one byte string(get rid of $ type suffix too) -Q = {{Cl|CHR$}}(34) 'Q will now represent the elusive quotation mark in a string - -PRINT "This text uses "; Q; "quotation marks"; Q; " that could have caused a syntax error!" - -{{CodeEnd}} -{{OutputStart}} -This text uses "quotation marks" that could have caused a syntax error! -{{OutputEnd}} - - -''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 -Send$ = "" ' clear value -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$) - Letter$ = {{Cl|MID$}}(Text$, i, 1) ' get each character in the text - Code = {{Cl|ASC}}(Letter$) - {{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code < 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code < 123) {{Cl|THEN}} - Letter$ = {{Cl|CHR$}}(Code + 130) ' change letter's ASCII character by 130 - {{Cl|END IF}} - Send$ = Send$ + Letter$ ' reassemble string with just letters encrypted -{{Cl|NEXT}} i -{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 ' erase FileName to be encrypted -{{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' Text as one string -{{Cl|CLOSE}} #1 -{{CodeEnd}} -:''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). -{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be decrypted - Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' open Text as one string -{{Cl|CLOSE}} #1 -Send$ = "" -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$) - Letter$ = {{Cl|MID$}}(Text$, i, 1) - Code = {{Cl|ASC}}(Letter$) - {{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code < 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code < 253) {{Cl|THEN}} - Letter$ = {{Cl|CHR$}}(Code - 130) ' change back to a Letter character - {{Cl|END IF}} - Send$ = Send$ + Letter$ ' reassemble string as normal letters - {{Cl|NEXT}} i -{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 ' Erase file for decrypted text - {{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' place Text as one string -{{Cl|CLOSE}} #1 -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''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}} -* [[ASC]], [[ASC (statement)]] -* [[INKEY$]] -* [[ASCII|ASCII character codes]] - - -{{PageNavigation}} diff --git a/internal/help/CINT_1111.txt b/internal/help/CINT_1111.txt deleted file mode 100644 index 8b30d7000..000000000 --- a/internal/help/CINT_1111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:24}} -The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value. - - -{{PageSyntax}} -: {{Parameter|value%}} = [[CINT]]({{Parameter|expression}}) - - -{{Parameters}} -* {{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. -* ''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. - - -{{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}} - - -{{PageSeeAlso}} -* [[_ROUND]], [[_CEIL]] -* [[CLNG]], [[CSNG]], [[CDBL]] -* [[INT]], [[FIX]] - - -{{PageNavigation}} diff --git a/internal/help/CIRCLE_111111.txt b/internal/help/CIRCLE_111111.txt deleted file mode 100644 index 3274f5b6e..000000000 --- a/internal/help/CIRCLE_111111.txt +++ /dev/null @@ -1,146 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:25}} -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|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|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. - - -{{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|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 - -r& = 200 'radius change circle size and position here -cx& = 320 'center x horizontal -cy& = 240 'center y vertical - -DO - i = {{Cl|_MOUSEINPUT}} - x& = {{Cl|_MOUSEX}} - y& = {{Cl|_MOUSEY}} - xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem - {{Cl|IF...THEN|IF}} r& ^ 2 >= xy& {{Cl|THEN}} {{Cl|CIRCLE}} (cx&, cy&), r&, 10 {{Cl|ELSE}} {{Cl|CIRCLE}} (cx&, cy&), r&, 12 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit -{{CodeEnd}} -: ''Explanation:'' The square of the circle radius will be greater than or equal to the sum of the square of the mouse coordinates minus the center position when the pointer is inside of the circle. In this example the circle color will change from red to green. - - -''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. 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 - -'* Start at radian 2*PI and continue clockwise to radian 0 -'* Since radian 2*PI points directly right, we need to start clockcount% -'* at 15 (for 15 seconds). The {{Cl|FOR...NEXT|FOR}}/{{Cl|NEXT}} loop counts backwards in increments -'* of 60 giving us the 60 second clock points. These points are then stored -'* in the dimensioned array clock() to be used later. -'* -{{Cl|FOR...NEXT|FOR}} radian = 2 * PI {{Cl|TO}} 0 {{Cl|STEP}} -(2 * PI) / 60 - clock(clockcount%) = radian - clockcount% = clockcount% + 1 - {{Cl|IF...THEN|IF}} clockcount% = 61 {{Cl|THEN}} clockcount% = 1 -{{Cl|NEXT}} radian -'* Change to a graphics screen and draw the clock face -{{Cl|SCREEN}} 7 -{{Cl|CLS}} -{{Cl|LOCATE}} 1, 1 -{{Cl|COLOR}} 14, 0 -{{Cl|PRINT}} "Ritchie's Clock" -{{Cl|COLOR}} 9, 0 -{{Cl|PRINT}} "Uses {{Cl|CIRCLE}} to" -{{Cl|PRINT}} "draw hands!" -{{Cl|COLOR}} 8, 0 -{{Cl|CIRCLE}} (160, 100), 110, 8 'circle with radius of 110 and dark gray -{{Cl|CIRCLE}} (160, 100), 102, 8 'circle with radius of 102 and dark gray -{{Cl|PAINT}} (265, 100), 8, 8 'fill between the two dark gray circles with gray -{{Cl|CIRCLE}} (160, 100), 110, 7 'circle with radius of 110 and light gray -'* -'* Get the current time from the QuickBASIC built in variable {{Cl|TIME$}} -'* Since {{Cl|TIME$}} is a string, we need to extract the hours, minutes and -'* seconds from it using {{Cl|LEFT$}}, {{Cl|RIGHT$}} and {{Cl|MID$}}. Then, each of these -'* extractions need to be converted to a numeric value using VAL and -'* stored in their respective variables. -'* -seconds% = {{Cl|INT}}({{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2))) 'extract seconds from {{Cl|TIME$}} -{{Cl|IF...THEN|IF}} seconds% = 0 {{Cl|THEN}} seconds% = 60 'array counts 1 to 60 not 0 to 59 -previoussecond% = seconds% 'hold current second for later use -minutes% = {{Cl|INT}}({{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2))) 'extract minutes from {{Cl|TIME$}} -{{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60 'array counts 1 to 60 not 0 to 59 -previousminute% = minutes% 'hold current minute for later use -hours% = {{Cl|INT}}({{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))) 'extract hour from {{Cl|TIME$}} -{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12 'convert from military time -{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12 'count from 1 to 12 not 0 to 11 -previoushour% = hours% 'hold current hour for later use -'* -'* Start of main program loop -'* -{{Cl|DO}} - {{Cl|IF...THEN|IF}} seconds% <> previoussecond% {{Cl|THEN}} 'has a second elapsed? - {{Cl|LOCATE}} 22, 17 'print the time on the screen at - {{Cl|PRINT}} {{Cl|TIME$}}; 'position 22, 17 - '* Since a second has elapsed we need to erase the old second hand - '* position and draw the new position - - {{Cl|CIRCLE}} (160, 100), 100, 0, -clock(previoussecond%), clock(previoussecond%) - {{Cl|CIRCLE}} (160, 100), 100, 15, -clock(seconds%), clock(seconds%) - previoussecond% = seconds% 'hold current second for later use - {{Cl|IF...THEN|IF}} minutes% <> previousminute% {{Cl|THEN}} 'has a minute elapsed? - '* Since a minute has elapsed we need to erase the old hour hand position - {{Cl|CIRCLE}} (160, 100), 90, 0, -clock(previousminute%), clock(previousminute%) - previousminute% = minutes% 'hold current minute for later use - {{Cl|END IF}} - '* - '* Draw the current minute hand position - '* - {{Cl|CIRCLE}} (160, 100), 90, 14, -clock(minutes%), clock(minutes%) - {{Cl|IF...THEN|IF}} hours% <> previoushour% {{Cl|THEN}} 'has an hour elapsed? - '* Since an hour has elapsed we need to erase the old hour hand position - {{Cl|CIRCLE}} (160, 100), 75, 0, -clock(previoushour% * 5), clock(previoushour% * 5) - previoushour% = hours% 'hold current hour for later use - {{Cl|END IF}} - '* - '* Draw the current hour hand position - '* - {{Cl|CIRCLE}} (160, 100), 75, 12, -clock(hours% * 5), clock(hours% * 5) - {{Cl|END IF}} - seconds% = {{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2)) 'extract time again and do all over - {{Cl|IF...THEN|IF}} seconds% = 0 {{Cl|THEN}} seconds% = 60 - minutes% = {{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2)) - {{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60 - hours% = {{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2)) - {{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12 - {{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key -{{CodeEnd}} -{{small|code by Terry Ritchie}} - - -{{PageSeeAlso}} -* [[STEP]], [[DRAW]] -* [[LINE]], [[PSET]], [[PRESET]] -* [[SCREEN]], [[SCREEN (function)]] -* [[Alternative circle routine]] {{text|(member-contributed program)}} - -{{PageNavigation}} diff --git a/internal/help/CLEAR_11111.txt b/internal/help/CLEAR_11111.txt deleted file mode 100644 index ecccf140e..000000000 --- a/internal/help/CLEAR_11111.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:27}} -The [[CLEAR]] statement clears all variable and array element values in a program. - - -{{PageSyntax}} -: [[CLEAR]] [, {{Parameter|ignored&}} , {{Parameter|ignored&}}] - - -{{PageDescription}} -* 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. -* [[$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}} -{{Cl|DIM}} array(10) 'create a {{Cl|$STATIC}} array -array(5) = 23 - -{{Cl|PRINT}} array(5) - -{{Cl|CLEAR}} - -{{Cl|PRINT}} array(5) -{{CodeEnd}} -:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR. - - -{{PageSeeAlso}} -* [[ERASE]] -* [[REDIM]], [[_PRESERVE]] -* [[Arrays]], [[&B|_BIT arrays]] - - -{{PageNavigation}} diff --git a/internal/help/CLNG_1111.txt b/internal/help/CLNG_1111.txt deleted file mode 100644 index 4c0411f26..000000000 --- a/internal/help/CLNG_1111.txt +++ /dev/null @@ -1,38 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:28}} -The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[LONG]] integer value. - - -{{PageSyntax}} -: {{Parameter|value&}} = [[CLNG]]({{Parameter|expression}}) - - -{{Parameters}} -* {{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. -* 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}} -{{CodeEnd}} - -{{OutputStart}} - 2345679 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[CINT]], [[INT]] -* [[CSNG]], [[CDBL]] -* [[_ROUND]] - - -{{PageNavigation}} diff --git a/internal/help/CLOSE_11111.txt b/internal/help/CLOSE_11111.txt deleted file mode 100644 index 27a5eb93f..000000000 --- a/internal/help/CLOSE_11111.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:29}} -[[CLOSE]] closes an open file or port using the number(s) assigned in an [[OPEN]] statement. - - -{{PageSyntax}} -: [[CLOSE]] [{{Parameter|fileNumber}}[, ...]] - - -{{Parameters}} -* {{Parameter|fileNumber}} indicates the file or list of file numbers to close. When not specified, all open files are closed. - - -{{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]] 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}} -* [[OPEN]], [[OPEN COM]] -* [[_OPENCLIENT]], [[_OPENHOST]] -* [[_OPENCONNECTION]] -* [[_SNDCLOSE]] - - -{{PageNavigation}} diff --git a/internal/help/CLS_111.txt b/internal/help/CLS_111.txt deleted file mode 100644 index 89f0c0884..000000000 --- a/internal/help/CLS_111.txt +++ /dev/null @@ -1,60 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:30}} -The [[CLS]] statement clears the [[_DEST|current write page]]. - - -{{PageSyntax}} -: [[CLS]] [{{Parameter|method%}}] [, {{Parameter|bgColor&}}] - - -{{Parameters}} -* {{Parameter|method%}} specifies which parts of the page to clear, and can have one of the following values: -** CLS - clears the active graphics or text viewport or the entire text screen and refreshes bottom function [[KEY LIST|KEY ON]] line. -** 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'''. - - -{{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 -{{Cl|CLS}} , 15 -{{Cl|_PRINTMODE }} _KEEPBACKGROUND 'keeps the text background visible -{{Cl|COLOR}} 0: {{Cl|PRINT}} "This is black text on a white background!" -K$ = {{Cl|INPUT$}}(1 -{{CodeEnd}} -:''Explanation:'' [[_PRINTMODE]] can be used with [[PRINT]] or [[_PRINTSTRING]] to make the text or the text background transparent. - - -''Example 2:'' You don't need to do anything special to use a .PNG image with alpha/transparency. Here's a simple example: -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|CLS}} , {{Cl|_RGB}}(0, 255, 0) -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 .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]]. - - -{{PageSeeAlso}} -* [[SCREEN]] -* [[_RGB]], [[_RGBA]], [[_RGB32]], [[_RGBA32]] -* [[VIEW PRINT]], [[VIEW]] -* [[_CLEARCOLOR]] - - -{{PageNavigation}} diff --git a/internal/help/COLOR_11111.txt b/internal/help/COLOR_11111.txt deleted file mode 100644 index 364ae0e08..000000000 --- a/internal/help/COLOR_11111.txt +++ /dev/null @@ -1,195 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:31}} -The [[COLOR]] statement is used to change the foreground and background colors for printing text. - -{{PageSyntax}} -: [[COLOR]] [{{Parameter|foreground&}}][, {{Parameter|background&}}] - - -{{PageDescription}} -* {{Parameter|background&}} colors are available in all QB64 color SCREEN modes. -* [[SCREEN]] mode 10 has only 3 white foreground attributes including flashing. -* 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. -* The [[$COLOR]] metacommand adds named color constants for both text and 32-bit modes. - - -==Screen Mode Attributes== -* '''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. -* '''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 [[_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. -* '''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. -* [[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. - - -===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. [[_DONTBLEND]] disables blending. -* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.''' - -

([[#toc|Return to Table of Contents]])

- -==RGB Palette Intensities== -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 -{{Cl|PRINT}} "Attribute = Hex value Red Green Blue " -{{Cl|PRINT}} -{{Cl|COLOR}} 7 -{{Cl|FOR...NEXT|FOR}} attribute = 1 {{Cl|TO}} 15 - {{Cl|OUT}} {{Cl|&H}}3C7, attribute 'set color attribute to read - red$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4) 'convert port setting to 32 bit values - grn$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4) - blu$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4) - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(red$) = 1 {{Cl|THEN}} red$ = "0" + red$ '2 hex digits required - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(grn$) = 1 {{Cl|THEN}} grn$ = "0" + grn$ 'for low or zero hex values - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(blu$) = 1 {{Cl|THEN}} blu$ = "0" + blu$ - hex32$ = "{{Cl|&H}}" + alpha$ + red$ + grn$ + blu$ - {{Cl|_PALETTECOLOR}} attribute, {{Cl|VAL}}(hex32$) 'VAL converts hex string to a LONG 32 bit value - {{Cl|IF...THEN|IF}} attribute {{Cl|THEN}} {{Cl|COLOR}} attribute 'exclude black color print - {{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}(attribute) + " = " + hex32$, red$, grn$, blu$ 'returns closest attribute -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}Attribute Hex value Red Green Blue - -{{text|COLOR 1 = &HFF0000A8 00 00 A8|#0050A8}} -{{text|COLOR 2 = &HFF00A800 00 A8 00|#00A800}} -{{text|COLOR 3 = &HFF00A8A8 00 A8 A8|#00A8A8}} -{{text|COLOR 4 = &HFFA80000 A8 00 00|#A80000}} -{{text|COLOR 5 = &HFFA800A8 A8 00 A8|#A800A8}} -{{text|COLOR 6 = &HFFA85400 A8 54 00|#A85400}} -{{text|COLOR 7 = &HFFA8A8A8 A8 A8 A8|#A8A8A8}} -{{text|COLOR 8 = &HFF545454 54 54 54|#545454}} -{{text|COLOR 9 = &HFF5454FC 54 54 FC|#5454FC}} -{{text|COLOR 10 = &HFF54FC54 54 FC 54|#54FC54}} -{{text|COLOR 11 = &HFF5454FC 54 FC FC|#54FCFC}} -{{text|COLOR 12 = &HFFFC5454 FC 54 54|#FC5454}} -{{text|COLOR 13 = &HFFFC54FC FC 54 FC|#FC54FC}} -{{text|COLOR 14 = &HFFFCFC54 FC FC 54|#FCFC54}} -{{text|COLOR 15 = &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. - - -===Read & write color port intensities with [[INP]] & [[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 = 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 - -* 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) in QBasic's legacy 4 and 8 bit screen modes. - -

([[#toc|Return to Table of Contents]])

- - -{{PageExamples}} -''Example 1:'' Reading the default RGB color settings of color attribute 15. -{{CodeStart}} - {{Cl|OUT}} &H3C7, 15 - red% = {{Cl|INP}}(&H3C9) - green% = {{Cl|INP}}(&H3C9) - blue% = {{Cl|INP}}(&H3C9) - {{Cl|PRINT}} red%, green%, blue% -{{CodeEnd}} - -{{OutputStart}} - 63 63 63 -{{OutputEnd}} - - -''Example 2:'' Changing the color settings of attribute 0 (the background) to blue in [[SCREEN]]s 12 or 13. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|OUT}} {{Cl|&H}}3C8, 0 'set color port attribute to write -{{Cl|OUT}} {{Cl|&H}}3C9, 0 'red intensity -{{Cl|OUT}} {{Cl|&H}}3C9, 0 'green intensity -{{Cl|OUT}} {{Cl|&H}}3C9, 42 'blue intensity - -{{Cl|OUT}} {{Cl|&H}}3C7, 0 -{{Cl|PRINT}} {{Cl|INP}}({{Cl|&H}}3C9); {{Cl|INP}}({{Cl|&H}}3C9); {{Cl|INP}}({{Cl|&H}}3C9) -{{Cl|END}} -{{CodeEnd}} -{{OutputStartBG1}} 0 0 42 {{OutputEnd}} - - -''Example 3:'' Printing in fullscreen SCREEN 0 mode with a color background under the text only. -{{CodeStart}} -{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} ' used for fullscreen instead of window -{{Cl|COLOR}} 14, 6: {{Cl|LOCATE}} 4, 4: {{Cl|PRINT}} "Hello!" -{{CodeEnd}} -{{OutputStart}} - - - {{Ot|Hello!|#fcfc54|#aa5500}} -{{OutputEnd}} - - -''Example 4:'' Using [[CLS]] after setting the background color in SCREEN 0 to make the color cover the entire screen. -{{CodeStart}} -{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} -{{Cl|COLOR}} , 7: {{Cl|CLS}} -{{Cl|COLOR}} 9: {{Cl|PRINT}} "Hello" -{{CodeEnd}} -{{OutputStartBG7}} -{{Text|Hello|#5454fc}} -{{OutputEnd}} - - -''Example 5:'' Using a different foreground color for each letter: -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|COLOR}} 1: {{Cl|PRINT}} "H"; -{{Cl|COLOR}} 3: {{Cl|PRINT}} "E"; -{{Cl|COLOR}} 4: {{Cl|PRINT}} "L"; -{{Cl|COLOR}} 5: {{Cl|PRINT}} "L"; -{{Cl|COLOR}} 6: {{Cl|PRINT}} "O" -{{Cl|COLOR}} 9: {{Cl|PRINT}} "W"; -{{Cl|COLOR}} 11: {{Cl|PRINT}} "O"; -{{Cl|COLOR}} 12: {{Cl|PRINT}} "R"; -{{Cl|COLOR}} 13: {{Cl|PRINT}} "L"; -{{Cl|COLOR}} 14: {{Cl|PRINT}} "D" -{{CodeEnd}} - -{{OutputStart}} -{{text|H|#0000aa}}{{text|E|#00aaaa}}{{text|L|#aa0000}}{{text|L|#aa00aa}}{{text|O|#aa5500}} -{{text|W|#5454fc}}{{text|O|#54fcfc}}{{text|R|#fc5454}}{{text|L|#fc54fc}}{{text|D|#fcfc54}} -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[$COLOR]] (metacommand) -* [[_RGB]], [[_RGBA]], [[_RGB32]], [[RGBA32]]. -* [[_RED]], [[_GREEN]], [[_BLUE]] -* [[_RED32]], [[_GREEN32]], [[_BLUE32]] -* [[_ALPHA]], [[_ALPHA32]], [[_CLEARCOLOR]] -* [[PRINT]], [[LOCATE]], [[SCREEN]] -* [[POINT]], [[SCREEN (function)]] -* [[OUT]], [[INP]], [[PALETTE]] -* [[_BLINK]] -* [[_DEFAULTCOLOR]] -* [[_BACKGROUNDCOLOR]] -* [[_PALETTECOLOR]] -* [[Windows_Libraries#Color_Dialog_Box|Color Dialog Box]] -* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values] - - -{{PageNavigation}} diff --git a/internal/help/COMMAND$_1111111$.txt b/internal/help/COMMAND$_1111111$.txt deleted file mode 100644 index 57ebb988c..000000000 --- a/internal/help/COMMAND$_1111111$.txt +++ /dev/null @@ -1,75 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:33}} -The '''COMMAND$''' function returns the command line argument(s) passed when a program is run. - - -{{PageSyntax}} -: {{Parameter|commandLine$}} = [[COMMAND$]][(count%)] - - -{{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" - -{{Cl|LOCATE}} 23, 25: {{Cl|PRINT}} "Press any key to run ProgramB" -K$ = {{Cl|INPUT$}}(1) -{{Cl|RUN}} "ProgramB FS" 'pass FS parameter to ProgramB in QB64 or QB4.5 - -{{Cl|SYSTEM}} -{{CodeEnd}} -: ''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$}}) '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 - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} - ProgramB - - - - Parameter = FS.EXE -{{OutputEnd}} - - -''Example 2:'' Program gets the number of parameters passed to the program, and then prints those parameters to the screen one at a time. -{{CodeStart}}count = {{Cl|_COMMANDCOUNT}} -{{Cl|FOR...NEXT|FOR}} c = 1 {{Cl|TO}} count - {{Cl|PRINT}} {{Cl|COMMAND$}}(c) 'or process commands sent -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}-1 -a data file -{{OutputEnd}} -: ''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 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) - {{Cl|IF...THEN|IF}} cmd$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} 'read until an empty return - {{Cl|PRINT}} cmd$ 'or process commands sent -{{Cl|LOOP}} -count = count - 1 'save the number of parameters sent to this program when run -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[SHELL]], [[RUN]] -* [[UCASE$]], [[LCASE$]] -* [[_COMMANDCOUNT]] - - -{{PageNavigation}} diff --git a/internal/help/COMMON_111111.txt b/internal/help/COMMON_111111.txt deleted file mode 100644 index 0d18d8156..000000000 --- a/internal/help/COMMON_111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:34}} -[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules. - -{{PageSyntax}} -: [[COMMON]] [SHARED] variableList - - -===Legacy support=== -* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[COMMON]] statement 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. - - -{{PageDescription}} -* COMMON must be called before any executable statements. -* [[SHARED]] makes the variables shared within [[SUB]] and [[FUNCTION]] procedures within that module. -* 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. -* '''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.''' - - -{{PageSeeAlso}} -* [[COMMON SHARED]], [[CHAIN]] -* [[DIM]], [[REDIM]], [[SHARED]] -* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]] - -{{PageNavigation}} diff --git a/internal/help/CONST_11111.txt b/internal/help/CONST_11111.txt deleted file mode 100644 index e978aabab..000000000 --- a/internal/help/CONST_11111.txt +++ /dev/null @@ -1,73 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:35}} -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}}[, ...] - - -{{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. -** 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. - - -{{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 [[SUB]] or [[FUNCTION]] procedures are local to those procedures. -* [[CLEAR]] will not affect or change constant values. - - -{{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 - -' Declare some string constants: -{{Cl|CONST}} circumferenceText = "The circumference of the circle is" -{{Cl|CONST}} areaText = "The area of the circle is" - -{{Cl|DO...LOOP|DO}} - {{Cl|INPUT}} "Enter the radius of a circle or zero to quit"; radius - {{Cl|IF...THEN|IF}} radius = 0 {{Cl|IF...THEN|THEN}} {{Cl|END}} - {{Cl|PRINT}} circumferenceText; 2 * PI * radius - {{Cl|PRINT}} areaText; PI * radius * radius ' radius squared - {{Cl|PRINT}} -{{Cl|DO...LOOP|LOOP}} -{{CodeEnd}} -{{OutputStart}}Enter the radius of a circle or zero to quit? ''10'' -The circumference of the circle is 62.83186 -The area of the circle is 314.1593 - -Enter the radius of a circle or zero to quit? ''123.456'' -The circumference of the circle is 775.697 -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 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}} -* [[DIM]], [[SHARED]] -* [[STATIC]], [[COMMON]] -* [[_PI]], [[_RGB32]], [[_RGBA32]] -* [http://doc.pcsoft.fr/en-US/?6510001 Windows 32 API constant values] - - -{{PageNavigation}} diff --git a/internal/help/COS_111.txt b/internal/help/COS_111.txt deleted file mode 100644 index 288831705..000000000 --- a/internal/help/COS_111.txt +++ /dev/null @@ -1,108 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:36}} -The [[COS]] function returns the horizontal component or the cosine of an angle measured in radians. - - -{{PageSyntax}} -: {{Parameter|value!}} = [[COS]]({{Parameter|radianAngle!}}) - - -{{Parameters}} -* The {{Parameter|radianAngle!}} must be measured in radians. - - -{{PageDescription}} -* 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 - - -{{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) -{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI -{{Cl|PRINT}} "COS(PI) = "; {{Cl|COS}}(PI) -{{Cl|PRINT}} "SIN(PI) = "; {{Cl|SIN}}(PI) -{{Cl|DO...LOOP|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter the degree angle (0 quits): ", DEGREES% - RADIANS = DEGREES% * PI / 180 - {{Cl|PRINT}} "RADIANS = DEGREES% * PI / 180 = "; RADIANS - {{Cl|PRINT}} "X = COS(RADIANS) = "; {{Cl|COS}}(RADIANS) - {{Cl|PRINT}} "Y = SIN(RADIANS) = "; {{Cl|SIN}}(RADIANS) - {{Cl|CIRCLE}} (400, 240), 2, 12 - {{Cl|LINE}} (400, 240)-(400 + (50 * {{Cl|SIN}}(RADIANS)), 240 + (50 * {{Cl|COS}}(RADIANS))), 11 - DEGREES% = RADIANS * 180 / PI - {{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES% -{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0 -{{CodeEnd}} -{{OutputStart}} -PI = 4 * ATN(1) = 3.141593 -COS(PI) = -1 -SIN(PI) = -8.742278E-08 - -Enter the degree angle (0 quits): 45 -RADIANS = DEGREES% * PI / 180 = .7853982 -X = COS(RADIANS) = .7071068 -Y = SIN(RADIANS) = .7071068 -DEGREES% = RADIANS * 180 / PI = 45 -{{OutputEnd}} -: ''Explanation:'' When 8.742278E-08(.00000008742278) is returned by [[SIN]] or COS the value is essentially zero. - - -''Example 2:'' Creating 12 analog clock hour points using [[CIRCLE]]s and [[PAINT]] -{{CodeStart}} - PI2 = 8 * {{Cl|ATN}}(1) '2 * Ï€ - arc! = PI2 / 12 'arc interval between hour circles - {{Cl|SCREEN (statement)|SCREEN}} 12 - FOR t! = 0 TO PI2 STEP arc! - cx% = {{Cl|CINT}}({{Cl|COS}}(t!) * 70) ' pixel columns (circular radius = 70) - cy% = {{Cl|CINT}}({{Cl|SIN}}(t!) * 70) ' pixel rows - {{Cl|CIRCLE}} (cx% + 320, cy% + 240), 3, 12 - {{Cl|PAINT}} {{Cl|STEP}}(0, 0), 9, 12 - NEXT -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -''Explanation:'' The 12 circles are placed at radian angles that are 1/12 of 6.28318 or .523598 radians apart. - - -''Example 3:'' Creating a rotating spiral with COS and [[SIN]]. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) - -{{Cl|DO...LOOP|DO}} - {{Cl|LINE}} (0, 0)-(640, 480), {{Cl|_RGB}}(0, 0, 0), BF - j = j + 1 - {{Cl|PSET}} (320, 240) - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1 - {{Cl|LINE}} -(.05 * i * i * {{Cl|COS}}(j + i) + 320, .05 * i * i * {{Cl|SIN}}(j + i) + 240) - {{Cl|NEXT}} - {{Cl|PSET}} (320, 240) - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1 - {{Cl|LINE}} -(.05 * i * i * {{Cl|COS}}(j + i + 10) + 320, .05 * i * i * {{Cl|SIN}}(j + i + 10) + 240) - {{Cl|NEXT}} - {{Cl|PSET}} (320, 240) - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1 - {{Cl|PAINT}} (.05 * i * i * {{Cl|COS}}(j + i + 5) + 320, .05 * i * i * {{Cl|SIN}}(j + i + 5) + 240) - {{Cl|NEXT}} - - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INP}}({{Cl|&H}}60) = 1 'escape exit -{{CodeEnd}} -{{small|Code by Ben}} - - -{{PageSeeAlso}} -* [[_PI]] {{text|(QB64 function)}} -* [[SIN]] {{text|(sine)}} -* [[ATN]] {{text|(arctangent)}} -* [[TAN]] {{text|(tangent)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/CSNG_1111.txt b/internal/help/CSNG_1111.txt deleted file mode 100644 index c717929a0..000000000 --- a/internal/help/CSNG_1111.txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:37}} -[[CSNG]] converts a numerical value to the closest [[SINGLE]]-precision number. - - -{{PageSyntax}} -: {{Parameter|singleValue!}} = [[CSNG]]({{Parameter|expression}}) - - -{{Parameters}} -* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation. - - -{{PageDescription}} -* Returns the closest [[SINGLE]] decimal point value. -* Also used to define a value as [[SINGLE]]-precision up to 7 decimals. - - -{{PageExamples}} -{{CodeStart}} - A# = 975.3421222# - PRINT A#, CSNG(A#) -{{CodeEnd}} -{{OutputStart}}975.3421222      975.3421 -{{OutputEnd}} - - -''See also:'' -* [[CDBL]], [[CLNG]] -* [[CINT]], [[INT]] -* [[_ROUND]] - - -{{PageNavigation}} diff --git a/internal/help/CSRLIN_111111.txt b/internal/help/CSRLIN_111111.txt deleted file mode 100644 index 33f66b14c..000000000 --- a/internal/help/CSRLIN_111111.txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:39}} -The [[CSRLIN]] function returns the current text row position of the [[PRINT]] cursor. - - - -{{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 "; - Y = {{Cl|CSRLIN}} 'save the row - X = {{Cl|POS}}(0) 'save the column - LOCATE 10, 10: PRINT "WORLD" - LOCATE Y, X 'restore saved position - PRINT "GOODBYE" -{{CodeEnd}} - -{{OutputStart}} - - - - - HELLO GOODBYE - - - - - WORLD - - -{{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. - - -{{PageSeeAlso}} -* [[SCREEN]], [[LOCATE]], [[POS]] -* [[_PRINTSTRING]] (graphic print) - - -{{PageNavigation}} diff --git a/internal/help/CVDMBF_111111.txt b/internal/help/CVDMBF_111111.txt deleted file mode 100644 index b4801bec8..000000000 --- a/internal/help/CVDMBF_111111.txt +++ /dev/null @@ -1,41 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:41}} -The [[CVDMBF]] function decodes an 8-byte [[STRING]] generated by [[MKDMBF$]] (or read from a file) to [[DOUBLE]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result#}} = [[CVDMBF]]({{Parameter|stringData$}}) - - -{{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 - -Value of a# encoded using MKDmbf$: 5─câ–¼d▬æ - -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. - - -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/CVD_111.txt b/internal/help/CVD_111.txt deleted file mode 100644 index 4f85aa3aa..000000000 --- a/internal/help/CVD_111.txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:40}} -The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read from a file) to [[DOUBLE]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result#}} = [[CVD]]({{Parameter|stringData$}}) - - -{{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. - - -{{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 -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#. - - -''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. - - -{{PageSeeAlso}} -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVI]], [[CVS]], [[CVL]], [[CVSMBF]], [[CVDMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/CVI_111.txt b/internal/help/CVI_111.txt deleted file mode 100644 index 9a5ef463d..000000000 --- a/internal/help/CVI_111.txt +++ /dev/null @@ -1,67 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:42}} -The [[CVI]] function decodes a 2-byte [[STRING]] generated by [[MKI$]] (or read from a file) to [[INTEGER]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result%}} = [[CVI]]({{Parameter|stringData$}}) - - -{{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. -* Doesn't return [[_UNSIGNED]] values. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}} -{{Cl|FIELD}} #1, 2 {{Cl|AS}} N$, 12 {{Cl|AS}} B$... -{{Cl|GET}} #1 'GET does not need a position or variable with successive FIELD buffer reads -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 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 -{{Cl|DIM}} Q {{Cl|AS}} {{Cl|STRING}} * 1 -Q = {{Cl|CHR$}}(34) -' create Print using templates to align the values returned -tmp1$ = "1st character code = ### * 1 = ### " -tmp2$ = "2nd character code = ### * 256 = ##### " -tmp3$ = " & " -tmp4$ = " CVI Total = ##### " - -{{Cl|DO...LOOP|DO}} - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number% - {{Cl|IF...THEN|IF}} number% < 1 {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|CLS}} - ASCII$ = {{Cl|MKI$}}(number%) ' create the 2 byte character string - {{Cl|COLOR}} 11 - {{Cl|_PRINTSTRING}} (152, 240), "{{Cl|MKI$}} creates 2 byte ASCII string: " + Q + ASCII$ + Q ' displays character(s) - - asc1% = {{Cl|ASC}}(ASCII$) ' find the ASCII code values of each character - asc2% = {{Cl|ASC}}(ASCII$, 2) ' '''QB64''' allows ASC to read specific characters in a string - - {{Cl|LOCATE}} 18, 20: {{Cl|PRINT USING}} tmp1$; asc1%; asc1% - {{Cl|LOCATE}} 19, 20: {{Cl|PRINT USING}} tmp2$; asc2%; asc2% * 256 - {{Cl|LOCATE}} 20, 20: {{Cl|PRINT USING}} tmp3$; "-----" - {{Cl|LOCATE}} 21, 20: {{Cl|PRINT USING}} tmp4$; asc1% + (256 * asc2%) -{{Cl|LOOP}} -{{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" gets decoded to 12345). - - -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]], [[CVDMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/CVL_111.txt b/internal/help/CVL_111.txt deleted file mode 100644 index 51262cf26..000000000 --- a/internal/help/CVL_111.txt +++ /dev/null @@ -1,44 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:43}} -The [[CVL]] function decodes a 4-byte [[STRING]] generated by [[MKL$]] (or read from a file) to [[LONG]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result&}} = [[CVL]]({{Parameter|stringData$}}) - - -{{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 -{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(0) + {{Cl|CHR$}}(1) + {{Cl|STRING$}}(2, 0)) '{{Cl|ASC}}(CHR$(1)) * 256 = 256 -{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(2, 0) + {{Cl|CHR$}}(1) + {{Cl|CHR$}}(0)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 = 65536 -{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(3, 0) + {{Cl|CHR$}}(1)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 * 256 = 16777216 -{{CodeEnd}} - - -''Example 2:'' -{{CodeStart}} -{{Cl|FIELD}} #1, 4 {{Cl|AS}} N$, 12 {{Cl|AS}} B$... -{{Cl|GET}} #1 -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 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. - - -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVI]], [[CVS]], [[CVD]], [[CVDMBF]], [[CVSMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/CVSMBF_111111.txt b/internal/help/CVSMBF_111111.txt deleted file mode 100644 index 37e780216..000000000 --- a/internal/help/CVSMBF_111111.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:47}} -The [[CVDMBF]] function decodes a 4-byte [[STRING]] generated by [[MKSMBF$]] (or read from a file) to [[SINGLE]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result!}} = [[CVSMBF]]({{Parameter|stringData$}}) - - -{{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. - - -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVDMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/CVS_111.txt b/internal/help/CVS_111.txt deleted file mode 100644 index bd192153e..000000000 --- a/internal/help/CVS_111.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:46}} -The [[CVS]] function decodes a 4-byte [[STRING]] generated by [[MKS$]] (or read from a file) to [[SINGLE]] numeric values. - - -{{PageSyntax}} -: {{Parameter|result!}} = [[CVS]]({{Parameter|stringData$}}) - - -{{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|MKDMBF$}}(a!) -{{Cl|PRINT}} "Value of a# encoded using MKS$: "; b$ -{{Cl|PRINT}} "The string above, decoded using CVS:"; {{Cl|CVS}}(b$) -{{CodeEnd}} -{{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. - - -{{PageSeeAlso}} -* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]] -* [[CVI]], [[CVD]], [[CVL]], [[CVDMBF]], [[CVSMBF]] -* [[_CV]], [[_MK$]] - - -{{PageNavigation}} diff --git a/internal/help/Colon_10000.txt b/internal/help/Colon_10000.txt deleted file mode 100644 index 76933b66a..000000000 --- a/internal/help/Colon_10000.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:56}} -A '''colon''' can be used to separate two unrelated procedure statements on the same line. - - -''Usage:'' COLOR 10: PRINT "Hello "; : COLOR 12: PRINT "World" - -{{OutputStart}} -{{text|Hello |limegreen}}{{text|World|red}} -{{OutputEnd}} - - -* Use colons to combine variable definition statements or screen [[PRINT|prints]]. -* Some statements such as [[END IF]] and [[Metacommand]]s require a new code line! -* Use [[Semicolon|semicolons]] and [[Comma|commas]] where appropriate in [[PRINT]]s. -* Use an [[underscore]] at the end of a line to extend a line of code to the next line. - - -''See also:'' - -* [[Comma]], [[Semicolon]] - - -{{PageNavigation}} diff --git a/internal/help/DATA_1111.txt b/internal/help/DATA_1111.txt deleted file mode 100644 index f533b8332..000000000 --- a/internal/help/DATA_1111.txt +++ /dev/null @@ -1,83 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:48}} -The [[DATA]] statement creates a line of fixed program information separated by commas. The DATA can be later READ by the program at runtime. - - -{{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.''' -* 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 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]] 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 -{{Cl|READ}} A$, B$, C$, D$ 'read 4 string values from second DATA field -PRINT A$ + B$ + C$ + D$ 'note that quoted strings values are spaced - -{{Cl|RESTORE}} Database1 -FOR i = 1 TO 18 - {{Cl|READ}} number% 'read first DATA field 18 times only - PRINT number%; -NEXT - -END - -Database1: -{{Cl|DATA}} 1, 0, 0, 1, 1, 0, 1, 1, 1 -{{Cl|DATA}} 2, 0, 0, 2, 2, 0, 2, 2, 2 : ' DATA line comments require a colon - -Database2: -{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work! -{{CodeEnd}} -{{OutputStart}}Hello world! Goodbyework! -1 0 0 1 1 0 1 1 1 2 0 0 2 2 0 2 2 2 -{{OutputEnd}} - - -''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 -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10 - {{Cl|PRINT}} num(i); -{{Cl|NEXT}} -{{Cl|END}} - -{{Cl|SUB}} ReadData (mode) -{{Cl|IF...THEN|IF}} mode = 1 {{Cl|THEN}} {{Cl|RESTORE}} mydata1 {{Cl|ELSE}} {{Cl|RESTORE}} mydata2 -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10 - {{Cl|READ}} num(i) -{{Cl|NEXT}} - -mydata1: -{{Cl|DATA}} 1,2,3,4,5,6,7,8,9,10 -mydata2: -{{Cl|DATA}} 10,9,8,7,6,5,4,3,2,1 -{{Cl|END SUB}} -{{CodeEnd}} -{{OutputStart}} 10 9 8 7 6 5 4 3 2 1 {{OutputEnd}} - - -{{PageSeeAlso}} -* [[READ]] -* [[RESTORE]] -* [[SUB]], [[FUNCTION]] - - -{{PageNavigation}} diff --git a/internal/help/DATE$_1111$.txt b/internal/help/DATE$_1111$.txt deleted file mode 100644 index 97cf07f47..000000000 --- a/internal/help/DATE$_1111$.txt +++ /dev/null @@ -1,72 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:49}} -The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy". - - -{{PageSyntax}} -: {{Parameter|today$}} = [[DATE$]] - - -{{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$}} -month$ = {{Cl|LEFT$}}({{Cl|DATE$}}, 2): M = {{Cl|VAL}}(month$) -day$ = {{Cl|MID$}}({{Cl|DATE$}}, 4, 2): D = {{Cl|VAL}}(day$) -day$ = {{Cl|STR$}}(D) ' eliminate any leading zeros -year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$) -{{Cl|SELECT CASE}} M - {{Cl|CASE}} 1: Moon$ = "January" - {{Cl|CASE}} 2: Moon$ = "February" - {{Cl|CASE}} 3: Moon$ = "March" - {{Cl|CASE}} 4: Moon$ = "April" - {{Cl|CASE}} 5: Moon$ = "May" - {{Cl|CASE}} 6: Moon$ = "June" - {{Cl|CASE}} 7: Moon$ = "July" - {{Cl|CASE}} 8: Moon$ = "August" - {{Cl|CASE}} 9: Moon$ = "September" - {{Cl|CASE}} 10: Moon$ = "October" - {{Cl|CASE}} 11: Moon$ = "November" - {{Cl|CASE}} 12: Moon$ = "December" -{{Cl|END SELECT}} -{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10) - -{{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 -S2 = (5 * Y) \ 4 '4 year leap -S3 = 26 * (M + 1) \ 10 'days in months -WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder -{{Cl|IF}} WkDay < 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6 -{{Cl|SELECT CASE}} WkDay - {{Cl|CASE}} 0: day$ = "Sunday" - {{Cl|CASE}} 1: day$ = "Monday" - {{Cl|CASE}} 2: day$ = "Tuesday" - {{Cl|CASE}} 3: day$ = "Wednesday" - {{Cl|CASE}} 4: day$ = "Thursday" - {{Cl|CASE}} 5: day$ = "Friday" - {{Cl|CASE}} 6: day$ = "Saturday" -{{Cl|END SELECT}} -WeekDay$ = day$ -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -{{OutputStart}} -06-02-2010 -Today is Wednesday, June 2, 2010 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]] -* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]] - - - -{{PageNavigation}} diff --git a/internal/help/DECLARE_DYNAMIC_LIBRARY_1111111_1111111_1111111.txt b/internal/help/DECLARE_DYNAMIC_LIBRARY_1111111_1111111_1111111.txt deleted file mode 100644 index b135934b0..000000000 --- a/internal/help/DECLARE_DYNAMIC_LIBRARY_1111111_1111111_1111111.txt +++ /dev/null @@ -1,106 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:08}} -'''DECLARE DYNAMIC LIBRARY''' allows you to dynamically link your program to functions in dynamically linkable libraries. At present, only ''.DLL'' files are supported (support for ''.so'' will be added soon). These libraries are loaded when your program begins. - - -{{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 - - -{{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. 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]].''' -* '''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.''' - - -==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: [https://www.qb64.org/resources/Playmidi32.dll PlayMidi32.dll] -{{CodeStart}} -{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32" - {{Cl|FUNCTION}} PlayMIDI& (filename {{Cl|AS}} {{Cl|STRING}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} -result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0)) -{{Cl|PRINT}} result -{{CodeEnd}} -: '''Note:''' Filename needs to be [[CHR$]](0) terminated. QB64 [[STRING]]s are passed to external libraries as pointers to first character. - - -''Example 2:'' Using a CUSTOMTYPE LIBRARY to return the [[Unicode]] version of the current running program's name. -{{CodeStart}} -{{Cl|SCREEN}} 12 - -{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav - {{Cl|FUNCTION}} GetModuleFileNameA& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) - {{Cl|FUNCTION}} GetModuleFileNameW& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -'=== SHOW CURRENT PROGRAM -FileName$ = {{Cl|SPACE$}}(512) - -Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) -{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} {{Cl|PRINT}} "CURRENT PROGRAM (ASCII): "; {{Cl|LEFT$}}(FileName$, Result) - -'load a unicode font -f = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE") -{{Cl|_FONT}} f -Result = GetModuleFileNameW(0, FileName$, {{Cl|LEN}}(FileName$) \ 2) -{{Cl|LOCATE}} 2, 1 -{{Cl|PRINT}} QuickCP437toUTF32$("CURRENT PROGRAM (UTF): ") + QuickUTF16toUTF32$({{Cl|LEFT$}}(FileName$, Result * 2)) -{{Cl|_FONT}} 16 'restore CP437 font - -{{Cl|FUNCTION}} QuickCP437toUTF32$ (a$) -b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 4, 0) -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$) - {{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i) -{{Cl|NEXT}} -QuickCP437toUTF32$ = b$ -{{Cl|END FUNCTION}} - -{{Cl|FUNCTION}} QuickUTF16toUTF32$ (a$) -b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 2, 0) -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$) \ 2 - {{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i * 2 - 1) - {{Cl|ASC}}(b$, i * 4 - 2) = {{Cl|ASC}}(a$, i * 2) -{{Cl|NEXT}} -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". - - -
'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''
-
'''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.'''
- - -''See also:'' -* [[DECLARE LIBRARY]] -* [[SUB]], [[FUNCTION]] -* [[BYVAL]], [[ALIAS]] -* [[_OFFSET (function)]], [[_OFFSET]] {{text|(variable type)}} -* [[C Libraries]], [[SDL Libraries]], [[DLL Libraries]], [[Windows Libraries]] -* [[Port Access Libraries]] - - -{{PageNavigation}} diff --git a/internal/help/DECLARE_LIBRARY_1111111_1111111.txt b/internal/help/DECLARE_LIBRARY_1111111_1111111.txt deleted file mode 100644 index 4e4bd7a91..000000000 --- a/internal/help/DECLARE_LIBRARY_1111111_1111111.txt +++ /dev/null @@ -1,104 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:06}} -The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64. - - -{{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''' - - -{{Parameters}} -* 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=== -* '''[[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. -* '''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 (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. -* When using a procedure from an '''unsupported''' Dynamic Link Library (DLL file) use [[DECLARE DYNAMIC LIBRARY]]. - -* 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.''' - - -{{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 -{{Cl|DECLARE LIBRARY|END DECLARE}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) 'simulate screen 12 with 256 colors -{{Cl|RANDOMIZE}} {{Cl|TIMER}} - -DO - {{Cl|_DELAY}} 1 - x = {{Cl|RND}} * 640: y = {{Cl|RND}} * 480 - {{Cl|LINE}} (x, y)-{{Cl|STEP}}(10, 10), {{Cl|RND}} * 100 + 32, BF - MouseMove x + 5, y + 5 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) 'any keypress quits -{{Cl|END}} - -{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}}) -SDL_WarpMouse x, y 'call SDL library procedure -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Galleon}} -:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use. - -
'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''
-{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DECLARE LIBRARY}} - {{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -{{Cl|_DELAY}} 2 -MouseMove 100, 100 -{{Cl|_DELAY}} 2 -MouseMove 200, 200 -{{CodeEnd}} -:''Explanation:'' When a Library procedure is used to represent another procedure name use [[ALIAS]] instead. Saves creating a SUB! - - -''Example 2:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes. -{{CodeStart}} -{{Cl|DECLARE LIBRARY}} "" - {{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&) -{{Cl|END}} DECLARE -{{CodeEnd}} -:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail. - -: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.''' - - -
'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''
-
'''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.'''
- - -''See also:'' -* [[DECLARE DYNAMIC LIBRARY]] -* [[SUB]], [[FUNCTION]] -* [[BYVAL]], [[ALIAS]] -* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]] -* [[Port Access Libraries]] -* [[SQL Client]] - - -{{PageNavigation}} diff --git a/internal/help/DEFDBL_111111.txt b/internal/help/DEFDBL_111111.txt deleted file mode 100644 index 0ff17635e..000000000 --- a/internal/help/DEFDBL_111111.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:51}} -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. - - -{{PageSyntax}} -: [[DEFDBL]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...] - - -===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. - - -{{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 [[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.''' - - -==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. - - -{{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]] - - -{{PageNavigation}} diff --git a/internal/help/DEFINT_111111.txt b/internal/help/DEFINT_111111.txt deleted file mode 100644 index da51160e4..000000000 --- a/internal/help/DEFINT_111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:53}} -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. - - -{{PageSyntax}} -: [[DEFINT]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...] - - -===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. - - -{{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.''' - - -==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. - - -{{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}} diff --git a/internal/help/DEFLNG_111111.txt b/internal/help/DEFLNG_111111.txt deleted file mode 100644 index 519e27f50..000000000 --- a/internal/help/DEFLNG_111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:54}} -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. - - -{{PageSyntax}} -: [[DEFLNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...] - - -===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. - - -{{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 [[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.''' - - -==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. - - -{{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]] - - -{{PageNavigation}} diff --git a/internal/help/DEFSNG_111111.txt b/internal/help/DEFSNG_111111.txt deleted file mode 100644 index 51e5f1e5a..000000000 --- a/internal/help/DEFSNG_111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:55}} -The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables. - - -{{PageSyntax}} -: [[DEFSNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...] - - -===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. - - -{{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.''' - - -==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. - - -{{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]] - - -{{PageNavigation}} diff --git a/internal/help/DEFSTR_111111.txt b/internal/help/DEFSTR_111111.txt deleted file mode 100644 index 5abd37b33..000000000 --- a/internal/help/DEFSTR_111111.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:56}} -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. - - -{{PageSyntax}} -: [[DEFSTR]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...] - - -===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. - - -{{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 [[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 ($).''' - - -==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. - - -{{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]] - - -{{PageNavigation}} diff --git a/internal/help/DEF_SEG_111_111.txt b/internal/help/DEF_SEG_111_111.txt deleted file mode 100644 index 9222b25c8..000000000 --- a/internal/help/DEF_SEG_111_111.txt +++ /dev/null @@ -1,74 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:50}} -[[DEF SEG]] is used to define the area in memory to access QB64's emulated conventional memory. - - -{{PageSyntax}} -: [[DEF SEG]] [=][{segment|VARSEG(variable}] - - -===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.''' - - -{{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, 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.''' - - - -''See also:'' -* [[DEF SEG = 0]] -* [[VARPTR]], [[VARSEG]] -* [[PEEK]], [[POKE]] -* [[BSAVE]], [[BLOAD]] - - -{{PageNavigation}} diff --git a/internal/help/DIM_111.txt b/internal/help/DIM_111.txt deleted file mode 100644 index 3848e00d1..000000000 --- a/internal/help/DIM_111.txt +++ /dev/null @@ -1,111 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:57}} -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}} -::''To declare variables:'' -:::[[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]] - -::''To declare arrays:'' -:::[[DIM]] [{{KW|SHARED}}] ''array([lowest% {{KW|TO}}] highest%])''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...] - -::'' '''QB64''' Alternative Syntax:'' -:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''variable'' [, ''variable2''...] -:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''array([lowest% {{KW|TO}}] highest%])'' [, ''array2(elements)''...] - - -{{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. -* 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. 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 type defaults to [[SINGLE]].''' -* When using the '''AS type variable-list''' syntax, type symbols cannot be used. -* 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 ($). 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 -{{CodeEnd}} - -''Example 2:'' Dimensions and types an array. -{{CodeStart}} - {{Cl|DIM}} Image(2000) {{Cl|AS}} {{Cl|INTEGER}} -{{CodeEnd}} - -''Example 3:'' Dimensions array with an [[INTEGER]] type suffix. -{{CodeStart}} - {{Cl|DIM}} Image%(2000) -{{CodeEnd}} - -''Example 4:'' Dimensions a range of [[Arrays|array]] elements as [[SHARED]] integers. -{{CodeStart}} - {{Cl|DIM}} {{Cl|SHARED}} Image(1 {{Cl|TO}} 1000) {{Cl|AS}} {{Cl|INTEGER}} -{{CodeEnd}} - -''Example 5:'' Dimensions variable as an [[Arrays|array]] of 8 elements of the type [[UNSIGNED]] BIT. -{{CodeStart}} - {{Cl|DIM}} bit(8) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BIT}} -{{CodeEnd}} - - -''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 -{{Cl|DIM}} x {{Cl|AS}} {{Cl|LONG}} -{{Cl|PRINT}} x -{{CodeEnd}} -: ''Explanation:'' The [[SINGLE]] variable can be differentiated from the [[LONG]] x variable by using suffixes like x! or x& in later code. - - -''Example 7:'' The following code will create a "Name already in use" '''status error''' in QB64 when the variable types are the same. -{{CodeStart}} -x = 1 'x is a {{Cl|SINGLE}} variable -{{Cl|PRINT}} x -{{Cl|DIM}} x {{Cl|AS}} {{Cl|SINGLE}} -{{Cl|PRINT}} x -{{CodeEnd}} -: ''Explanation:'' QB64 gives an error because the creation of the new variable would make referring to the existing one impossible. - - -''Example 8:'' Using QB64's alternative syntax to declare multiple variables/arrays of the same type. -{{CodeStart}} -{{Cl|DIM}} {{Cl|AS}} {{Cl|LONG}} w, h, id, weight, index 'all of these variables are created as type LONG -{{Cl|DIM}} {{Cl|AS}} {{Cl|SINGLE}} x, y, z 'all of these variables are created as type SINGLE -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_DEFINE]], [[_PRESERVE]] -* [[REDIM]], [[TYPE]] -* [[ERASE]], [[CLEAR]] -* [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]] -* [[Mathematical Operations]], [[Arrays]] -* [[Variable Types]] -* [[OPTION _EXPLICIT]] - - -{{PageNavigation}} diff --git a/internal/help/DO...LOOP_11...1111.txt b/internal/help/DO...LOOP_11...1111.txt deleted file mode 100644 index 092b0f442..000000000 --- a/internal/help/DO...LOOP_11...1111.txt +++ /dev/null @@ -1,152 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:41:59}} -'''DO...LOOP''' statements are used in programs to repeat code or return to the start of a procedure. - - -{{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 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. - - -{{RelationalTable}} - - -{{PageExamples}} -''Example 1:'' Using WHILE to clear the keyboard buffer. -{{CodeStart}} - -DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code - -DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of loop code - -{{CodeEnd}} - - -''Example 2:'' Using UNTIL to clear the keyboard buffer. -{{CodeStart}} - -DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code - -DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code - -{{CodeEnd}} - - -''Example 3:'' Using a one time DO loop to exit ANY of several FOR LOOPs, without using [[GOTO]]. -:SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image. -{{CodeStart}} -{{Cl|DEFINT}} A-Z -{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$ -CheckScreen filenm$ - -{{Cl|END}} - -{{Cl|DEFINT}} A-Z -{{Cl|SUB}} CheckScreen (Filename$) 'find Screen mode (12 or 13) and image dimensions - DIM Bsv AS {{Cl|STRING}} * 1 - DIM Header AS STRING * 6 - - Scr = 0: MaxColors = 0 - {{Cl|OPEN}} Filename$ FOR {{Cl|BINARY}} AS #1 - - {{Cl|GET}} #1, , Bsv '1 check for small 2 character - GET #1, , Header '2 - 7 rest of file header - - IF Bsv <> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file - COLOR 12: LOCATE 15, 33: PRINT "Not a BSAVE file!": SLEEP 3: {{Cl|EXIT}} SUB - END IF - - GET #1, , widN '8 no color info bmp sizes - GET #1, , depN '9 " " " - -DO - IF widN > 63 OR depN > 63 THEN {{Cl|EXIT DO}} ' width and depth already found - - FOR i = 10 TO 55 'check for Screen 12 embedded colors - GET #1, , RGB - tot12& = tot12& + RGB - 'PRINT i; RGB; : SOUND 300, 1 'test sound slows loop in QB - IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}} - IF i = 55 AND tot12& = 0 THEN {{Cl|EXIT DO}} - NEXT - - GET #1, , wid12 '56 - GET #1, , dep12 '57 - IF wid12 > 63 OR dep12 > 63 THEN {{Cl|EXIT DO}} - - FOR i = 58 TO 775 'check for Screen 13 embedded colors - GET #1, , RGB - tot13& = tot13& + RGB - 'PRINT i; RGB; : SOUND 300, 1 'test - IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}} - IF i = 775 AND tot13& = 0 THEN {{Cl|EXIT DO}} - NEXT - GET #1, , wid13 '776 - GET #1, , dep13 '777 -LOOP {{Cl|UNTIL}} 1 = 1 'TRUE statement exits one-time LOOP -CLOSE #1 - -COLOR 14: LOCATE 10, 25 -{{Cl|SELECT CASE}} i - {{Cl|CASE IS}} < 56: - IF widN > 640 THEN - Scr = 13: MaxColors = 0 - PRINT "Default Screen 13:"; widN \ 8; "X"; depN - ELSE - LOCATE 10, 15 - PRINT "Screen 12 ("; widN; "X"; depN; ") OR 13 ("; widN \ 8; "X"; depN; ")" - DO: SOUND 600, 4 - COLOR 13: LOCATE 12, 23 'ask if no data found. Prevents ERROR opening in wrong mode - {{Cl|INPUT}} "Enter a Screen mode 12 or 13 : ", Scrn$ - Scr = VAL(Scrn$) - LOOP UNTIL Scr = 12 OR Scr = 13 - END IF - IF Scr = 12 THEN MaxColors = 0: PWidth = widN: PDepth = depN - IF Scr = 13 THEN MaxColors = 0: PWidth = widN \ 8: PDepth = depN - {{Cl|CASE}} 56 TO 775 - PRINT "Custom Screen 12:"; wid12; "X"; dep12 - Scr = 12: MaxColors = 16: PWidth = wid12: PDepth = dep12 - {{Cl|CASE}} 776: PRINT "Custom Screen 13:"; wid13 \ 8; "X"; dep13 - Scr = 13: MaxColors = 256: PWidth = wid13 \ 8: PDepth = dep13 -{{Cl|END SELECT}} - -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' The SUB procedure reads a file that was [[BSAVE]]d previously. If the RGB colors are stored before the image, the values can only be between 0 and 63. Higher values indicate that the image width and height are located there and that there are no stored color values to be read. SUB later displays the dimensions of the file image that [[GET (graphics statement)|GET]] placed in the file array. The loop is set to only run once by creating '''a TRUE [[UNTIL]] statement''' such as 1 = 1. When a screen mode cannot be determined, the user must select one. - -:Dimensions and location of width and height information indicates the screen mode as [[SCREEN (statement)|SCREEN]] 13 if it has 768 RGB values and dimensions of 320 X 200 max. If the file only holds 64 settings and/or is larger than 320 X 200, it uses SCREEN 12 or 9. The procedure [[EXIT]]s the DO LOOP early when the image size is found with or without custom color settings. - -: Divide SCREEN 13 [[GET (graphics statement)|GET]] widths by 8. - - -{{PageSeeAlso}} -* [[EXIT DO]] -* [[WHILE...WEND]] -* [[FOR...NEXT]] - - -{{PageNavigation}} diff --git a/internal/help/DOUBLE_111111.txt b/internal/help/DOUBLE_111111.txt deleted file mode 100644 index 36884f847..000000000 --- a/internal/help/DOUBLE_111111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:00}} -[[DOUBLE]] type floating point numerical values use 8 bytes per value. - - -{{PageSyntax}} -: [[DIM]] {{Parameter|variable}} [[AS]] [[DOUBLE]] - - -{{PageDescription}} -* Literal or variable values can range up to 15 decimal point places. -* 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]]. -* 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.''' - - -==QBasic/QuickBASIC== -* Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5. - - -{{PageSeeAlso}} -* [[DIM]], [[DEFDBL]] -* [[MKD$]], [[CVD]] -* [[SINGLE]], [[_FLOAT]] -* [[LEN]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/DRAW_1111.txt b/internal/help/DRAW_1111.txt deleted file mode 100644 index 58f8f3cba..000000000 --- a/internal/help/DRAW_1111.txt +++ /dev/null @@ -1,170 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:01}} -The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen. - - -{{PageSyntax}} -: [[DRAW]] {{Parameter|drawString$}} - - -{{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 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. -** "'''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. - -* 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}} - SCREEN 12 - octagon$ = "C12 R10 F10 D10 G10 L10 H10 U10 E10" 'create a DRAW string value - {{Cl|SCREEN (statement)|SCREEN}} 12 - FOR i% = 1 TO 11 - {{Cl|PSET}} (i% * 50, 100), 15 - {{Cl|_DELAY}} .5 ' delay for demo - {{Cl|DRAW}} octagon$ ' DRAW the octagon using variable - {{Cl|_DELAY}} .5 ' delay for demo - NEXT i% -{{CodeEnd}} -''Explanation:'' Once a DRAW string variable is created, it can be used to draw a shape throughout the program at any time. - - -''Example 2:'' Creating an analog clock's hour markers using "TA=" + [[VARPTR$]](angle). -{{CodeStart}} - SCREEN 12 - FOR angle = 0 TO 360 {{Cl|STEP}} 30 ' 360/12 hour circles = 30 degrees apart - PSET (175, 250), 6 ' stay at center point of clock - {{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(angle) + "BU100" ' move invisibly to set next circle's center point - {{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 12 ' circle placed at end of blind line - {{Cl|DRAW}} "P9, 12" ' paint inside of circle - {{Cl|SLEEP}} 1 ' slowed for demo only - 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. - - -''Example 3:'' Creating a moving second hand for the clock above (SCREEN 12). (See [[TIME$]] example 1) - -{{CodeStart}} - DO: sec$ = {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) ' get actual seconds from TIME$ function - degree$ = {{Cl|STR$}}({{Cl|VAL}}(sec$) * -6) ' 60 second moves. TA uses negative angles for clockwise moves - {{Cl|PSET}} (175, 250), 9 ' stay at clock center - DRAW "TA" + degree$ + "U90" ' up becomes TA directional line - DO: LOOP UNTIL RIGHT$(TIME$, 2) <> sec$ ' wait for a new second value - IF INKEY$ <> "" THEN {{Cl|EXIT DO}} ' any key exit - PSET (175, 250), 0 ' set at clock center to erase line - DRAW "TA" + degree$ + "U90" ' erases old second hand line using color 0 from PSET - 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. - - -''Example 4:'' Creating digital displays using DRAW format strings to create the LED segments. (See [[SELECT CASE|SELECT EVERYCASE]] example 5) -{{CodeStart}} -{{Cl|SCREEN}} 12 -DO - {{Cl|LOCATE}} 1, 1: {{Cl|INPUT}} "Enter a number 0 to 9: ", num - {{Cl|CLS}} - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0, 2, 3, 5 {{Cl|TO}} 9: {{Cl|PSET}} (20, 20), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'top horiz - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0, 4 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 20), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'left top vert - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0, 2, 6, 8: {{Cl|PSET}} (20, 54), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12, 12" 'left bot vert - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 2 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 54), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12, 12" 'middle horiz - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0 {{Cl|TO}} 4, 7 {{Cl|TO}} 9: {{Cl|PSET}} (54, 20), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'top right vert - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0, 1, 3 {{Cl|TO}} 9: {{Cl|PSET}} (54, 54), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'bottom right vert - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} num - {{Cl|CASE}} 0, 2, 3, 5, 6, 8: {{Cl|PSET}} (20, 88), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'bottom horiz - {{Cl|END SELECT}} -{{Cl|LOOP}} {{Cl|UNTIL}} num > 9 -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' The DRAW strings can be used more than once with different [[PSET]] positions to create more digits. - - -''Example 5:'' Using 32 bit or [[_RGB]] color [[STR$|string]] values when using the DRAW C text statement -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 12) -{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10) - -{{Cl|SLEEP}} - -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 32) 'comment out this line to use the non-32 bit screen mode 12 -{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10) - -{{Cl|PSET}} (400, 400), 0 ' move to 320, 240... draw will start where pset leaves off -c = 14 -{{Cl|DIM}} k {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}} -k = {{Cl|_RGB}}(80, 255, 80) -{{Cl|FOR...NEXT|FOR}} repeat = 1 {{Cl|TO}} 16 - {{Cl|FOR...NEXT|FOR}} p = 0 {{Cl|TO}} 359 - c = c + 1: d = c / 14 - {{Cl|DRAW}} "c" + {{Cl|STR$}}(k) + " ta" + {{Cl|STR$}}(p) + " bu " + {{Cl|STR$}}(d) + "l7 u7 r7 d7 bd " + {{Cl|STR$}}(d) - {{Cl|NEXT}} p -{{Cl|NEXT}} repeat -{{CodeEnd}} -: ''Explanation:'' DRAW strings will ignore spaces between letters and numbers so string trimming is not necessary. - - -{{PageSeeAlso}} -* [[LINE]], [[PSET]], [[PRESET]], [[CIRCLE]] -* [[PAINT]], [[SCREEN (statement)|SCREEN]] -* [[COLOR]], [[PLAY]] -* [[TIME$]] - - -{{PageNavigation}} diff --git a/internal/help/Dollar_Sign_100000_1000.txt b/internal/help/Dollar_Sign_100000_1000.txt deleted file mode 100644 index 56e4caa19..000000000 --- a/internal/help/Dollar_Sign_100000_1000.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:58}} -The '''$''' is used to denote QBasic [[Metacommand]]s or as a [[STRING]] variable type suffix. - - - -''Usage:'' $INCLUDE: 'QB.bi' - - -* [[$STATIC]] denotes that all arrays can only be dimensioned once using [[DIM]]. -* [[$DYNAMIC]] denotes that all arrays can be redimensioned using [[REDIM]] ONLY. -* [[$INCLUDE]] includes a BI file or QBasic Library in a program. The file name requires a comment before and after the name. -* The [[STRING|string]] variable suffix MUST be used if the variable is not dimensioned in a DIM statement. The statement can also set a fixed string [[LEN|length]]. - - -''See also: - -* [[DIM]], [[REDIM]] -* [[Metacommand]] - - -{{PageNavigation}} diff --git a/internal/help/ELSEIF_111111.txt b/internal/help/ELSEIF_111111.txt deleted file mode 100644 index 058b7f588..000000000 --- a/internal/help/ELSEIF_111111.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:05}} -[[ELSEIF]] is used in an [[IF...THEN]] block statement to offer an alternative condition. - - -{{PageSyntax}} -: [[IF]] {{Parameter|condition}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSEIF]] {{Parameter|condition2}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSE]] -:: ''{alternative-code}'' -:: ⋮ -: [[END IF]] - - -{{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), 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. - - -{{RelationalTable}} - - -{{PageExamples}} -''Example 1:'' IF statement using ELSE IF in one statement line. -{{CodeStart}} - -IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE PRINT "< 100" - -{{CodeEnd}} - - -''Example 2:'' IF statement block -{{CodeStart}} - -IF x = 100 THEN ' must place ANY code on next line! - COLOR 10: PRINT x -ELSEIF x > 100 THEN COLOR 12: PRINT x -ELSE : PRINT "< 100" -END IF - -{{CodeEnd}} - - - -{{PageSeeAlso}} -*[[ELSE]], [[END IF]] -*[[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/ELSE_1111.txt b/internal/help/ELSE_1111.txt deleted file mode 100644 index 35d337543..000000000 --- a/internal/help/ELSE_1111.txt +++ /dev/null @@ -1,64 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:03}} -[[ELSE]] is used in [[IF...THEN]] or [[SELECT CASE]] statements to offer an alternative to other conditional statements. - - -{{PageSyntax}} -''Single-line syntax:'' -: [[IF]] {{Parameter|condition}} [[THEN]] ''{code}'' [[ELSE]] ''{alternative-code}'' - - -''Block syntax:'' -: [[IF]] {{Parameter|condition}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSEIF]] {{Parameter|condition2}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSE]] -:: ''{alternative-code}'' -:: ⋮ -: [[END IF]] - - -{{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. -* Other [[IF...THEN]] statements can be inside of an ELSE statement. - - -{{PageExamples}} -''Example 1:'' One line IF statement -{{CodeStart}} - -IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100" - -{{CodeEnd}} - -''Example 2:'' Multiple line IF statement block -{{CodeStart}} - -IF x = 100 THEN ' code executed MUST be on next statement line! - PRINT "100" -ELSE PRINT "Not 100" -END IF - -{{CodeEnd}} - - -''Example 3:'' To alternate between any two values (as long as the value after ELSE is the same as the condition) -{{CodeStart}} - -IF a = 3 THEN a = 5 ELSE a = 3 - -{{CodeEnd}} - - - -{{PageSeeAlso}} -* [[ELSEIF]] -* [[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/END_111.txt b/internal/help/END_111.txt deleted file mode 100644 index 1a6062722..000000000 --- a/internal/help/END_111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:06}} -The [[END]] statement terminates a program without an immediate exit or ends a procedure or statement block. - - -{{PageSyntax}} -: [[END]] [{{Parameter|returnCode%}}] -: [[END]] [[IF...THEN|IF]] -: [[END]] [[TYPE]] -: [[END]] [[SELECT CASE|SELECT]] -: [[END]] [[SUB]] -: [[END]] [[FUNCTION]] -: END [[DECLARE LIBRARY|DECLARE]] - - -{{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}} -{{Cl|PRINT}} "Hello world!" -{{Cl|END}} -{{Cl|PRINT}} "Hello no one!" -{{CodeEnd}} - -''Returns:'' -{{OutputStart}} -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, both in QBasic and in '''QB64'''. - - - -{{PageSeeAlso}} -* [[SYSTEM]] {{text|(immediate exit)}} -* [[SHELL (function)]], [[_SHELLHIDE]] -* [[EXIT]] (statement), [[_EXIT (function)]] - - -{{PageNavigation}} diff --git a/internal/help/ENVIRON$_1111111$.txt b/internal/help/ENVIRON$_1111111$.txt deleted file mode 100644 index 47c951e50..000000000 --- a/internal/help/ENVIRON$_1111111$.txt +++ /dev/null @@ -1,129 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:09}} -The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windows'''' environmental settings list. - - -{{PageSyntax}} -: {{Parameter|setting$}} = [[ENVIRON$]]({{{Parameter|listIndex%}}|{{Parameter|systemID$}}}) - - -{{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. - -* ''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}} -{{Cl|DO}} - i = i + 1 - setting$ = {{Cl|ENVIRON$}}(i) ' get a setting from the list - {{Cl|PRINT}} setting$ - {{Cl|IF...THEN|IF}} i {{Cl|MOD}} 20 = 0 {{Cl|THEN}} {{Cl|PRINT}} "Press a key": {{Cl|SLEEP}}: {{Cl|CLS}} -{{Cl|LOOP}} {{Cl|UNTIL}} setting$ = "" -{{CodeEnd}} -{{OutputStart}} -ALLUSERSPROFILE=C:\ProgramData -COMPUTERNAME=TED-LAPTOP -ComSpec=C:\WINDOWS\system32\cmd.exe -HOMEDRIVE=C: -HOMEPATH=\Users\Ted -LOCALAPPDATA=C:\Users\Ted\AppData\Local -OS=Windows_NT -Path=C:\PROGRAMDATA\ORACLE\JAVA\JAVAPATH;C:\WINDOWS\SYSTEM32;C:\WINDOWS; -C:\WINDOWS\SYSTEM32\WBEM;C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\ -WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32 -\WindowsPowerShell\v1.0\ -PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC -PROCESSOR_ARCHITECTURE=x86 -PROCESSOR_IDENTIFIER=x86 Family 6 Model 14 Stepping 8, GenuineIntel -ProgramFiles=C:\Program Files -PROMPT=$P$G -PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\ -SystemRoot=C:\WINDOWS -TEMP=C:\Users\TED\AppData\Local\Temp -TMP=C:\Users\TED\AppData\Local\Temp -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 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! -{{CodeStart}} -'=== Enter the EXE file and ICON or BMP image for the shortcut. - -Program$ = "QB64.EXE" '<<<<<<<<<< Enter the '''exact''' program name for shortcut -ICON$ = "QB64ICON.BMP" '<<<<<<<<<< Enter icon or bitmap to use from program's folder - -DeskTopShortcut Program$, ICON$ - -{{Cl|END}} '====== END DEMO CODE ====== - -{{Cl|SUB}} DeskTopShortcut (Program$, ICON$) -f = {{Cl|FREEFILE}} -{{Cl|SHELL}} {{Cl|_HIDE}} "CD > PRGMDIR.INF" 'get the current program path -{{Cl|OPEN}} "PRGMDIR.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f -{{Cl|LINE INPUT (file statement)|LINE INPUT}} #f, PATH$ -{{Cl|CLOSE}} #f -{{Cl|KILL}} "PRGMDIR.INF" -PATH$ = PATH$ + "\": FILE$ = PATH + Program$ -PRINT PATH$ 'DEMO print -A$ = {{Cl|ENVIRON$}}("HOMEDRIVE") '=== Get Current User setting from Environment. -B$ = {{Cl|ENVIRON$}}("HOMEPATH") -C$ = A$ + B$ 'shortcut to user's desktop if found - -{{Cl|IF...THEN|IF}} C$ = "" {{Cl|THEN}} C$ = {{Cl|ENVIRON$}}("ALLUSERSPROFILE") 'try desktop for all users -PRINT C$ 'DEMO print -URLFILE$ = {{Cl|MID$}}(Program$, 1, {{Cl|INSTR}}(Program$, ".")) + "URL" 'change EXE to URL - -{{Cl|IF...THEN|IF}} C$ > "" {{Cl|THEN}} - SHORTCUT$ = C$ + "\Desktop\" + URLFILE$ 'create filename for the desktop -{{Cl|ELSE}} SHORTCUT$ = PATH$ + URLFILE$ 'if all else fails put in program folder -{{Cl|END IF}} -PRINT SHORTCUT 'DEMO print -{{Cl|OPEN}} SHORTCUT$ {{Cl|FOR (file statement)|FOR}} {{Cl|APPEND}} {{Cl|AS}} #f -{{Cl|IF...THEN|IF}} {{Cl|LOF}}(f) {{Cl|THEN}} {{Cl|CLOSE}} #f: {{Cl|EXIT SUB}} '=== if filesize is NOT Zero don't overwrite! - -Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info. -{{Cl|PRINT (file statement)|PRINT}} #f, "[InternetShortcut]" 'URL type -{{Cl|PRINT (file statement)|PRINT}} #f, "URL=" + Q$ + "file://" + FILE$ + Q$ 'URL program file -{{Cl|PRINT (file statement)|PRINT}} #f, "WorkingDirectory=" + Q$ + PATH$ + Q$ 'Working path -{{Cl|PRINT (file statement)|PRINT}} #f, "IconIndex = " + Q$ + "0" + Q$ '0 is first index -{{Cl|PRINT (file statement)|PRINT}} #f, "IconFile = " + Q$ + PATH$ + ICON$ + Q$ 'Icon path in working folder -{{Cl|CLOSE}} #f -{{Cl|END SUB}} -{{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. -:{{Text|'''NOTE:''' A temorary file named PRGMDIR.INF is created and deleted in the example above.}} - - -''See also:'' -* [[ENVIRON]] (statement) -* [[_DEVICES]], [[_DEVICE$]] -* [[_LASTBUTTON]], [[_OS$]] -* [[Windows Environment]] -* [[Windows Libraries#Windows User|Windows User Paths Library]] - - -{{PageNavigation}} diff --git a/internal/help/ENVIRON_1111111.txt b/internal/help/ENVIRON_1111111.txt deleted file mode 100644 index 712780f26..000000000 --- a/internal/help/ENVIRON_1111111.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:08}} -The [[ENVIRON]] statement is used to temporarily set or change an environmental string value. - - -{{PageSyntax}} -: [[ENVIRON]] {{Parameter|stringExpression$}} - - -{{PageDescription}} -* 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. -* Any changes made at runtime are discarded when your program ends. - - -{{PageSeeAlso}} -* [[ENVIRON$]] -* [[Windows Environment]] - - -{{PageNavigation}} diff --git a/internal/help/EOF_111.txt b/internal/help/EOF_111.txt deleted file mode 100644 index 2f46a4446..000000000 --- a/internal/help/EOF_111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:10}} -The [[EOF]] function indicates that the end of a file has been reached. - - -{{PageSyntax}} -: {{Parameter|endReached%%}} = EOF([#]{{Parameter|fileNumber&}}) - - -{{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 (true) at the end of the 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. - - -{{PageSeeAlso}} -* [[OPEN]] -* [[LOF]], [[LEN]] -* [[INPUT (file statement)]] -* [[LINE INPUT (file statement)]] -* [[GET]], [[PUT]] - - -{{PageNavigation}} diff --git a/internal/help/EQV_111.txt b/internal/help/EQV_111.txt deleted file mode 100644 index ad9d8a295..000000000 --- a/internal/help/EQV_111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:11}} -The [[EQV]] operator returns a value based on the ''equivalence'' of two conditions or values. - - -{{PageSyntax}} -: {{Parameter|result}} = {{Parameter|firstValue}} [[EQV]] {{Parameter|secondValue}} - - -{{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. - - -{{LogicalTruthTable}} - - -{{PageSeeAlso}} -* [[Binary]] -* [[Boolean]] - - -{{PageNavigation}} diff --git a/internal/help/ERASE_11111.txt b/internal/help/ERASE_11111.txt deleted file mode 100644 index 6783432dd..000000000 --- a/internal/help/ERASE_11111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:13}} -The [[ERASE]] statement is used to clear all data from an array. [[$STATIC]] [[Arrays|array]] dimensions are not affected. - - -{{PageSyntax}} -: ERASE ''arrayName'' [, ''arrayName2''...] - - -{{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 array brackets in an [[ERASE]] call. - - -{{PageSeeAlso}} -* [[DIM]], [[REDIM]] -* [[CLEAR]] -* [[STATIC]] -* [[$DYNAMIC]] -* [[Arrays]] - - -{{PageNavigation}} diff --git a/internal/help/ERL_111.txt b/internal/help/ERL_111.txt deleted file mode 100644 index 9c1048afa..000000000 --- a/internal/help/ERL_111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:14}} -The [[ERL]] function returns the closest previous line number before the last error. - - -{{PageSyntax}} -: ''lastErrorLine&'' = [[ERL]] - - -{{PageDescription}} -* Used in an error handler to report the last line number used before the error. -* If the program does not use line numbers, then ERL returns 0. -* 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 -1 -{{Cl|ERROR}} 250 -{{Cl|ERROR}} 250 - -5 {{Cl|ERROR}} 250 - -{{Cl|END}} -errorfix: -{{Cl|PRINT}} {{Cl|ERL}} -{{Cl|RESUME}} {{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}1 -1 -5 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[ERR]] -* [[ERROR]] -* [[ON ERROR]] -* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]] -* [[ERROR Codes]] - - -{{PageNavigation}} diff --git a/internal/help/ERROR_11111.txt b/internal/help/ERROR_11111.txt deleted file mode 100644 index a0cbd6514..000000000 --- a/internal/help/ERROR_11111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:16}} -The [[ERROR]] statement is used to simulate a program error or to troubleshoot error handling procedures. - - -{{PageSyntax}} -: [[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 - -{{Cl|IF...THEN|IF}} x = 0 {{Cl|THEN}} {{Cl|ERROR}} 123 -x = x + 1 -{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|ERROR}} 111 - -{{Cl|END}} - - -handler: -{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}} -{{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.''' - - -{{PageSeeAlso}} -*[[ON ERROR]] -*[[ERR]], [[ERL]] -*[[_ERRORLINE]] -*[[ERROR Codes]] (list) - - -{{PageNavigation}} diff --git a/internal/help/ERR_111.txt b/internal/help/ERR_111.txt deleted file mode 100644 index 61375c39b..000000000 --- a/internal/help/ERR_111.txt +++ /dev/null @@ -1,46 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:15}} -The [[ERR]] function returns the last QBasic error code number. - - -{{PageSyntax}} -: {{Parameter|errorNum%}} = [[ERR]] - - -{{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 - -{{Cl|IF...THEN|IF}} x = 0 {{Cl|THEN}} {{Cl|ERROR}} 111 'simulate an error code that does not exist -x = x + 1 -{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|ERROR}} 9 'simulate array boundary being exceeded - -{{Cl|END}} - -handler: -{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}} -{{Cl|BEEP}} -{{Cl|IF...THEN|IF}} {{Cl|ERR}} = 9 {{Cl|THEN}} - {{Cl|PRINT}} "The program has encountered an error and needs to close! Press a key!" - K$ = {{Cl|INPUT$}}(1) - {{Cl|SYSTEM}} -{{Cl|END IF}} -{{Cl|RESUME}} {{Cl|NEXT}} 'RESUME can only be used in error handlers -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[ON ERROR]], [[RESUME]] -* [[ERL]] -* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]] -* [[ERROR]] -* [[ERROR Codes]] - - -{{PageNavigation}} diff --git a/internal/help/EXIT_1111.txt b/internal/help/EXIT_1111.txt deleted file mode 100644 index 396b30940..000000000 --- a/internal/help/EXIT_1111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:17}} -The [[EXIT]] statement is used to exit certain QBasic procedures. - - -{{PageSyntax}} -: [[EXIT]] {DO|WHILE|FOR|SUB|FUNCTION|SELECT|CASE} - - -{{PageDescription}} -* [[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]] SELECT exits a [[SELECT CASE]] block. -** [[EXIT]] CASE does the same as EXIT SELECT unless when used in a '''SELECT EVERYCASE''' block; in such case, execution proceeds to the next CASE evaluation. -* 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 the message "Press any key to continue...", use [[END]]. -* To exit the program immediately, use [[SYSTEM]]. - - -{{PageAvailability}} -* '''EXIT SELECT/CASE''' available in: -** '''QB64 1.5 and up''' (QB64 Team) -** '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* All other variants available in all versions of QB64 - - -{{PageSeeAlso}} -* [[_EXIT (function)]] -* [[END]], [[SYSTEM]] -* [[STOP]] - - -{{PageNavigation}} diff --git a/internal/help/EXP_111.txt b/internal/help/EXP_111.txt deleted file mode 100644 index fbecd8385..000000000 --- a/internal/help/EXP_111.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:18}} -The [[EXP]] math function calculates the exponential function ('''e''' raised to the power of a {{Parameter|numericExpression}}). - - -{{PageSyntax}} -: {{Parameter|result}} = [[EXP]]({{Parameter|numericExpression}}) - - -{{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-3 = 1 / e3 = 1 / (e * e * e) - - -{{PageSeeAlso}} -*[[LOG]] -*[[Mathematical Operations]] -*[[Mathematical Operations#Derived Mathematical Functions|Derived Trigonometric Functions]] - - -{{PageNavigation}} diff --git a/internal/help/Equal_10000.txt b/internal/help/Equal_10000.txt deleted file mode 100644 index 0ca01c988..000000000 --- a/internal/help/Equal_10000.txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:11}} - - -View source for Equal -↠Equal -Jump to navigationJump to search -You do not have permission to edit this page, for the following reason: - -The action you have requested is limited to users in the group: Users. - -You can view and copy the source of this page. - -The '''=''' condition symbol denotes that a value must equal another value for the condition to be True. - - -''Example usage:'' IF x = 320 THEN PRINT "Center of screen" - - -* Statements will evaluate as True or -1 when two values are equal or False or 0 when not equal. -* More than one = symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical pairs. -:: A = B = C will be converted to A = (B = C) so if B = C then A = -1. If not, then A = 0 - - -''See also:'' - -* [[Not_Equal|<>]] -* [[Greater_Than|>]] -* [[Less_Than|<]] -* [[Relational Operations]] - - -{{PageNavigation}} - -Template used on this page: - -Template:PageNavigation (view source) -Return to Equal. - -Navigation menu -Log inPageDiscussionReadView sourceView historySearch -Search QB64 Wiki -Main page -Recent changes -Random page -Help about MediaWiki -Tools -What links here -Related changes -Special pages -Page information -Privacy policyAbout QB64 WikiDisclaimersPowered by MediaWiki diff --git a/internal/help/FIELD_11111.txt b/internal/help/FIELD_11111.txt deleted file mode 100644 index d53574574..000000000 --- a/internal/help/FIELD_11111.txt +++ /dev/null @@ -1,92 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:19}} -The [[FIELD]] statement creates a [[STRING]] type definition for a [[RANDOM|random]]-access file buffer. - - -{{PageSyntax}} -: [[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. -* 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. -* [[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'''. - - -{{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 - CName {{Cl|AS}} {{Cl|STRING}} * 30 '30 bytes - Address {{Cl|AS}} {{Cl|STRING}} * 30 '30 bytes - City {{Cl|AS}} {{Cl|STRING}} * 15 '15 bytes - State {{Cl|AS}} {{Cl|STRING}} * 2 ' 2 bytes - Zip {{Cl|AS}} {{Cl|STRING}} * 5 ' 5 bytes -{{Cl|END}} {{Cl|TYPE}} ' total size = 82 bytes -{{Cl|DIM}} Client {{Cl|AS}} ClientType -RecordLEN = {{Cl|LEN}}(Client) 'find the size of each TYPE record - -{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RecordLEN -{{Cl|RESTORE}} ClientData 'restore to start of DATA -record = 0 -{{Cl|DO}} - {{Cl|READ}} CName$, Address$, City$, State$, Zip$ 'read DATA - {{Cl|IF}} CName$ = "END" {{Cl|THEN}} {{Cl|EXIT DO}} - record = record + 1 'increment record number - Client.CName = CName$ - Client.Address = Address$ - Client.City = City$ - Client.State = State$ - Client.Zip = Zip$ - {{Cl|PUT}} #1, record, Client 'PUT by record number -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 -{{Cl|END}} - -ClientData: - {{Cl|DATA}} "Bob White","104 Birdland Rd.","Bellview","PA","15236" - {{Cl|DATA}} "Ward Cleaver","123 W. Beaver St.","Beaver","PA","15255" - {{Cl|DATA}} "Elmer Fudd","45 Wabbit St.","Bethel Park","PA","15022" - {{Cl|DATA}} "Wyley Coyote","33 Roadrunner Ave.","Clairton","PA","15122" - {{Cl|DATA}} "Jim Morrison","19 Doorway Dr.","Belleview","PA","15236" - {{Cl|DATA}} "END",0,0,0,0 -{{CodeEnd}} - -Demo using the FIELD statement to read the file: -{{CodeStart}} -{{Cl|CONST}} NM = 30, AD = 30, CT = 15, ST = 2, ZC = 5 ' Define field and record lengths with constants. -{{Cl|CONST}} RLEN = NM + AD + CY + ST + ZC -' -{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RLEN -{{Cl|FIELD}} #1, NM {{Cl|AS}} CName$, AD {{Cl|AS}} Address$, CY {{Cl|AS}} City$, ST {{Cl|AS}} State$, ZC {{Cl|AS}} Zip$ -{{Cl|FIELD}} #1, RLEN {{Cl|AS}} Clist$ 'define entire record - -{{Cl|GET}} #1, 1 'GET does not need a variable to read FIELD records! - 'Read file for zip codes from 15230 to 15239 . -{{Cl|DO}} {{Cl|WHILE}} {{Cl|NOT}} {{Cl|EOF}}(1) - ZipCheck$ = Zip$ 'read zip codes - {{Cl|IF}} (ZipCheck$ >= "15230" {{Cl|AND (boolean)|AND}} ZipCheck$ <= "15239") {{Cl|THEN}} - Info$ = Clist$ - {{Cl|PRINT}} {{Cl|LEFT$}}(Info$, 30) 'read name string - {{Cl|PRINT}} {{Cl|MID$}}(Info$, 31, 30) 'read address string - {{Cl|PRINT}} {{Cl|RIGHT$}}(Info$, 17) 'read city, state and zip code - {{Cl|PRINT}} - {{Cl|END IF}} - {{Cl|GET}} #1 'simply GET reads each FIELD record after first -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[OPEN]], [[TYPE]] -* [[GET]], [[PUT]] -* [[LSET]], [[RSET]] - - -{{PageNavigation}} diff --git a/internal/help/FILES_11111.txt b/internal/help/FILES_11111.txt deleted file mode 100644 index e406998f8..000000000 --- a/internal/help/FILES_11111.txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:20}} -The [[FILES]] statement is used to print a list of files in the current directory using a file specification. - - -{{PageSyntax}} -: [[FILES]] [{{Parameter|fileSpec$}}] - - -{{PageDescription}} -* {{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. -* 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}} - - -==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}} - {{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}} - -{{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}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''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. - - -''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. - - -{{PageSeeAlso}} -* [[SHELL]], [[SCREEN (function)]] {{text|(See Example 3)}} -* [[CHDIR]], [[MKDIR]] -* [[RMDIR]], [[KILL]] -* [[_CWD$]], [[_STARTDIR$]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[Windows_Libraries#File_Exist|Windows File Exist Library]] -* [[Windows_Libraries#File_Open_and_Save_Dialog|Windows Open and Save Dialog Boxes]] -* [[$CONSOLE]] - - -{{PageNavigation}} diff --git a/internal/help/FIX_111.txt b/internal/help/FIX_111.txt deleted file mode 100644 index 7d99bd1aa..000000000 --- a/internal/help/FIX_111.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:22}} -The [[FIX]] function rounds a numerical value to the next whole number closest to zero. - - -{{PageSyntax}} -: {{Parameter|result}} = [[FIX]]({{Parameter|expression}}) - - -{{Parameters}} -* {{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 {{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) - PRINT FIX(-2.5) -{{CodeEnd}} -{{OutputStart}}2 --2 -{{OutputEnd}} - - -''Example 2:'' The NORMAL arithmetic method (round half up) can be achieved using the function in the example code below: -{{CodeStart}} -{{Cl|PRINT}} MATHROUND(0.5) -{{Cl|PRINT}} MATHROUND(1.5) -{{Cl|PRINT}} MATHROUND(2.5) -{{Cl|PRINT}} MATHROUND(3.5) -{{Cl|PRINT}} MATHROUND(4.5) -{{Cl|PRINT}} MATHROUND(5.5) - -{{Cl|FUNCTION}} MATHROUND(n) - MATHROUND = {{Cl|FIX}}(n + 0.5 * {{Cl|SGN}}(n)) -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{OutputStart}}1 -2 -3 -4 -5 -6 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_CEIL]] -* [[INT]], [[CINT]] -* [[CLNG]], [[_ROUND]] -* [[MOD]], [[\|Integer Division]] -* [[/|Normal division]] - - -{{PageNavigation}} diff --git a/internal/help/FOR...NEXT_111...1111.txt b/internal/help/FOR...NEXT_111...1111.txt deleted file mode 100644 index f4432e5e2..000000000 --- a/internal/help/FOR...NEXT_111...1111.txt +++ /dev/null @@ -1,73 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:23}} -The [[FOR]] statement creates a counter loop using specified start and stop numerical boundaries. The default increment is + 1. - - -{{PageSyntax}} -: [[FOR]] {{Parameter|counterVariable}} = {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} [{{KW|STEP}} {{Parameter|increment}}] -:: ''{code}'' -:: ⋮ -: [[NEXT]] [{{Parameter|counterVariable}}] - - -{{Parameters}} -* 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. - - -{{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: 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 - totaleven% = i + totaleven% - PRINT totaleven%; -NEXT -PRINT "After loop, i ="; i -{{CodeEnd}} -{{OutputStart}}10 18 24 28 30 30 After loop, i = -2 -{{OutputEnd}} -:''Explanation:'' The loop counts down from 10 to every even value below it. The counter keeps stepping down until the FOR stop limit is reached or exceeded. Note that the value of i is -2 after the loop is exited. [[NEXT]] always increments the counter one last time. - - -''Example 2:'' How an entire FOR loop block is ignored when the start and stop limits do not match the default or [[STEP]] increment. -{{CodeStart}} -{{Cl|PRINT}} "hi" - -{{Cl|FOR...NEXT|FOR}} i = 10 {{Cl|TO}} 1 'requires a negative {{Cl|STEP}} value - {{Cl|PRINT}} "lo" -{{Cl|NEXT}} - -{{Cl|PRINT}} "bye" -{{CodeEnd}} -{{OutputStart}}hi -bye {{OutputEnd}} - - - - - -{{PageSeeAlso}} -* [[STEP]] -* [[DO...LOOP]], [[WHILE...WEND]] - - -{{PageNavigation}} diff --git a/internal/help/FOR_(file_statement)_111_(0000_000000000).txt b/internal/help/FOR_(file_statement)_111_(0000_000000000).txt deleted file mode 100644 index 17e2f780e..000000000 --- a/internal/help/FOR_(file_statement)_111_(0000_000000000).txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:24}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/FREEFILE_11111111.txt b/internal/help/FREEFILE_11111111.txt deleted file mode 100644 index b3edcad5f..000000000 --- a/internal/help/FREEFILE_11111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:26}} -The [[FREEFILE]] function returns a [[LONG]] value that is an unused file access number. - - -{{PageSyntax}} -: fileHandle& = [[FREEFILE]] - - -{{PageDescription}} -* [[FREEFILE]] values should be given to unique variables so that each file has a specific variable value assigned to it. -* Once the number is assigned in an [[OPEN]] statement, the file number can later be used to read, write or [[CLOSE]] that file. -* File numbers [[CLOSE]]d are made available to [[FREEFILE]] for reuse immediately. -* [[FREEFILE]] returns are normally sequential starting with 1. Only file numbers in use will not be returned. -* [[OPEN]] each file number after each [[FREEFILE]] return or the values returned may be the same. - - - -{{PageSeeAlso}} -* [[GET]], [[PUT]], [[CLOSE]] - - -{{PageNavigation}} diff --git a/internal/help/FUNCTION_11111111.txt b/internal/help/FUNCTION_11111111.txt deleted file mode 100644 index 83d3429a9..000000000 --- a/internal/help/FUNCTION_11111111.txt +++ /dev/null @@ -1,86 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:27}} -A [[FUNCTION]] block statement is used to create a function procedure to return a calculated value to a program. - - -{{PageSyntax}} -: '''FUNCTION procedureName'''[type-suffix] [(''parameters'')] -:: ''{code}'' -:: 'variable definitions and procedure statements -:: ⋮ -:: procedureName = returnValue -: '''END FUNCTION''' - - -{{PageDescription}} -* The function type can be any variable type that it will return to the program and is represented by the type suffix. -* Functions hold one return value in the function's name which is a variable type. Other values can be passed through ''parameters''. -* Functions are often referred to in program calculations, not called like SUB procedures. [[CALL]] cannot be used with functions. -* If there are no parameters passed or they are [[SHARED]] the ''parameters'' and parenthesis are not required. -* Variable names within the procedure do not have to match the names used in the reference parameters, just the value types. -* To pass parameter variables [[BYVAL|by value]] to protect the value in a call, parenthesis can be placed around each variable name also. -* To pass [[arrays]] to a sub-procedure use empty brackets after the name or indicate the index in the call. -* All [[$DYNAMIC|dynamic]] variable values return to 0 or null strings when the procedure is exited except when a variable or the entire function is [[STATIC]]. This can save program memory as all [[$DYNAMIC|dynamic]] memory used in a FUNCTION is released on procedure exit. -* FUNCTION procedure code can use [[GOSUB]] and [[GOTO]] line numbers or labels inside of the procedure when necessary. -* For early function exits use [[EXIT]] [[FUNCTION]] before [[END FUNCTION]] and [[GOSUB]] procedures using [[RETURN]]. -* '''QB64 ignores all procedural DECLARE statements.''' Define all ''parameter'' [[Data types|types]] in the FUNCTION procedure. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' -* The IDE can create the FUNCTION and END FUNCTION lines for you. Use the ''New FUNCTION...'' option in the Edit Menu. A box will come up for you to enter a name for the FUNCTION. Enter all code between the FUNCTION and [[END FUNCTION]] lines. - - -==QBasic/QuickBASIC== -* Once a FUNCTION was created and used, the QBasic IDE would DECLARE it when the file was saved. '''QB64 doesn't need these declarations.''' -* QBasic's IDE could place a [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]] or [[DEFSTR]] statement before the FUNCTION line if it is used in the main module. It may even be the wrong variable type needed. -* QBasic allowed programmers to add DATA fields anywhere because the IDE separated the main code from other procedures. - - -{{PageExamples}} -''Example 1:'' A simple function that returns the current path. Place [[FUNCTION]] or [[SUB]] procedures after the program [[END]]. -{{CodeStart}} -{{Cl|PRINT}} "Current path = "; PATH$ -{{Cl|END}} - -{{Cl|FUNCTION}} PATH$ - f% = {{Cl|FREEFILE}} - file$ = "D0Spath.inf" 'file name uses a zero to prevent an overwrite of existing file name - {{Cl|SHELL}} {{Cl|_HIDE}} "CD > " + file$ 'send screen information to a created text file - {{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f% 'file should exist with one line of text - {{Cl|LINE INPUT (file statement)|LINE INPUT}} #f%, PATH$ 'read file path text to function name - {{Cl|CLOSE}} #f% - {{Cl|KILL}} file$ -{{Cl|END FUNCTION}} -{{CodeEnd}} - - -''Example 2:'' Returns a [[LONG]] array byte size required for a certain sized graphics screen pixel area [[GET (graphics statement)|GET]]. -{{CodeStart}} -{{Cl|INPUT}} "Enter a screen mode: ", mode% -{{Cl|INPUT}} "Enter image width: ", wide& -{{Cl|INPUT}} "Enter image depth: ", deep& -IntegerArray& = ImageBufferSize&(wide&, deep&, mode%) \ 2 ' returns size of an {{Cl|INTEGER}} array. -{{Cl|PRINT}} IntegerArray& -{{Cl|END}} - -{{Cl|DEFINT}} A-Z -{{Cl|FUNCTION}} ImageBufferSize& (Wide&, Deep&, ScreenMode%) - {{Cl|SELECT CASE}} ScreenMode% - {{Cl|CASE}} 1: BPPlane = 2: Planes = 1 - {{Cl|CASE}} 2, 3, 4, 11: BPPlane = 1: Planes = 1 - {{Cl|CASE}} 7, 8, 9, 12: BPPlane = 1: Planes = 4 - {{Cl|CASE}} 10: BPPlane = 1: Planes = 2 - {{Cl|CASE}} 13: BPPlane = 8: Planes = 1 - {{Cl|CASE ELSE}}: BPPlane = 0 - {{Cl|END SELECT}} - ImageBufferSize& = 4 + {{Cl|INT}}((Wide& * BPPlane + 7) / 8) * (Deep& * Planes) 'return the value to function name. -{{Cl|END FUNCTION}} -{{CodeEnd}} -:''Explanation:'' Function calculates the array byte size required when you [[GET (graphics statement)|GET]] an area of a graphics [[SCREEN]]. Each mode may require a different sized array. Since graphics uses [[INTEGER]] arrays, 2 byte elements, the size returned is divided by 2 in the IntegerArray& calculation function reference. Function returns only 4 for [[SCREEN]] 0 which is a text only mode. - - -{{PageSeeAlso}} -* [[SUB]], [[SCREEN (statement)]] -* [[EXIT]] (statement), [[END]] -* [[_EXIT (function)]] - - -{{PageNavigation}} diff --git a/internal/help/GET_(TCP%2FIP_statement)_111_(111%2111_000000000).txt b/internal/help/GET_(TCP%2FIP_statement)_111_(111%2111_000000000).txt deleted file mode 100644 index f0737c6d4..000000000 --- a/internal/help/GET_(TCP%2FIP_statement)_111_(111%2111_000000000).txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:30}} -'''GET''' reads unformatted (raw) data from an open TCP/IP connection opened with [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]]. - - -{{PageSyntax}} -''Syntax 1:'' -: '''GET''' ''#handle'', , ''b$'' -* Reads any available data into variable length string b$ (b$'s length is adjusted to the number of bytes read, so checking EOF is unnecessary) using the handle return value from [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]]. - - -''Syntax 2:'' -: '''GET''' ''#handle'', ,''x%'' -* Reads an integer. If 2 bytes are available, they are read into x%, if not then nothing is read and [[EOF]](handle) will return -1 (and ''x%'''s value will be undefined) using the handle return value from [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]]. - - -==Communicating using unformatted/raw streamed data== -* Benefit: Communicate with any TCP/IP compatible protocol (eg. FTP, HTTP, web-pages, etc). -* Disadvantage: Streamed data has no 'message length', as such just the program deals with a continuous number of bytes in a row. Some messages get fragmented and parts of messages can (and often do) arrive at different times, due to the very nature of the TCP/IP protocol. -* The position parameter (between the commas) is not used in TCP/IP connections. -* The programmer must cater for these situations manually. - - -{{PageExamples}} -''Example:'' - -{{CodeStart}} - {{Cl|PUT|PUT #}}​c, , a$ ' sends data - {{Cl|GET|GET #}}​o, , b$ ' reads any available data into variable length string b$ - {{Cl|GET|GET #}}​o, , x% ' if 2 bytes are available, they are read into x% -{{CodeEnd}} - -''Explanation:'' -* Data could be a string, variable array, user defined [[TYPE]], etc. -* b$'s length is adjusted to the number of bytes read. Checking [[EOF]](o) is unnecessary. -* If 2 bytes are not available for the x% integer then nothing is read and [[EOF]](o) will return -1 - - - -===More examples=== -* ''See the examples in [[_OPENCLIENT]] or [[Email Demo]].'' - - - -{{PageSeeAlso}} -* [[PUT (TCP/IP statement)]] -* [[_OPENCLIENT]], [[_OPENHOST]] -* [[_OPENCONNECTION]], [[GET|GET #]] -* [https://curl.haxx.se/ cURL] (HTTP and FTP file transfer) - - -{{PageNavigation}} diff --git a/internal/help/GET_(graphics_statement)_111_(00000000_000000000).txt b/internal/help/GET_(graphics_statement)_111_(00000000_000000000).txt deleted file mode 100644 index ff4a76933..000000000 --- a/internal/help/GET_(graphics_statement)_111_(00000000_000000000).txt +++ /dev/null @@ -1,111 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:31}} -The [[GET (graphics statement)|GET]] statement is used in graphics to store a box area image of the screen into an [[INTEGER]] array. - -{{PageSyntax}} -: [[GET]] [STEP] ({{Parameter|column1}}, {{Parameter|row1}})-[STEP]({{Parameter|column2}}, {{Parameter|row2}}), {{Parameter|array}}([{{Parameter|index}}])[, {{Parameter|offscreenColor}}] - - -===Legacy support=== -* '''QB64''' can manipulate parts of an image using [[_PUTIMAGE]]. For that reason, '''GET''' isn't recommended practice anymore and is supported to maintain compatibility with legacy code. - - -{{Parameters}} -* ''column'' and ''row'' [[INTEGER]] coordinates for the box area must be on the screen except when using an ''offscreenColor''. -* [[INTEGER]] array sizes must be large enough (use width * height of the box area + 4) to hold the data or an error will occur. -* The [[arrays|array]] ''index'' offset is optional. If the offset is zero the brackets may be empty. -* The {{Parameter|offscreenColor}} pixels will be returned as the designated color when part of an image is off screen. - - -{{PageDescription}} -* The [[STEP]] keyword can be used to for coordinates relative to the last graphic coordinates used. -* A graphic screen mode must be used. See the [[SCREEN]] statement for graphic screen dimensions. -* '''QB64''' GET statements can use coordinates off of the screen when an '{{Parameter|offscreenColor}} is designated. [[STEP]] can be used for relative coordinates. -* The GET box coordinates are set just like a [[LINE]] box statement is placed. You can use a box to find the correct GET area. -* Once GET has placed the pixel image data in the array, PUT the image or BSAVE it to a file. -* Once the image is stored in an array [[PUT (graphics statement)|PUT]] can be used to place the image on the screen. -* A [[_SOURCE]] [[handle]] can be set to GET image areas other than the ones on the current screen. Use [[_DEST]] to [[PUT (graphics statement)|PUT]] images there. -* To GET more than one image to the same array, designate an offset index that is not being used and is large enough to hold the data. -* The [[INTEGER]] array size can be calculated as slightly larger than the box area width times the height. A closer estimate can be done by reading the array indices from [[UBOUND]] to [[LBOUND]] after a [[GET (graphics statement)|GET]] of a white box area. In QB64, a [[LONG]] array can be used for large or full screen images. -* RGB color settings can be embedded at the beginning of the array for transferring custom colors. Specify an ''index'' for GET image data to be stored after any extra information added to the beginning of the array. -* '''In QB64, [[_PUTIMAGE]] is recommended over PUT as it can also do the [[GET (graphics statement)|GET]] operation directly from the image source without requiring an array.''' -* '''[[PUT]] and [[GET]] file statements can also write and read image array data using [[BINARY]] files instead of using [[BSAVE]] or [[BLOAD]].''' - - -==QBasic/QuickBASIC== -* SCREEN 12 could only GET 1/3 of a full SCREEN 12 image. Rows would increment 160 each GET. '''QB64''' can save entire screen at once. - - -{{PageExamples}} -''Example 1:'' How to use GET and PUT to move a sprite with the arrow keys. -{{CodeStart}} - {{Cl|DEFINT}} A-Z - {{Cl|DIM}} BG(300), Box(300), SC(127) ' BG holds background images. Box holds the Box image. - {{Cl|SCREEN (statement)|SCREEN}} 13 ' graphic coordinate minimums are 0 to 319 column or 199 row maximums. - ' set up screen background - {{Cl|COLOR}} 4: {{Cl|LOCATE}} 10, 5: {{Cl|PRINT}} "Multikey Keyboard input routine" - {{Cl|COLOR}} 10: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Use the arrow keys to move the box." - {{Cl|LOCATE}} 13, 4: {{Cl|PRINT}} "Note that you can press two or more" - {{Cl|LOCATE}} 14, 4: {{Cl|PRINT}} "keys at once for diagonal movement!" - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 16, 4: {{Cl|PRINT}} " Also demonstrates how {{Cl|GET (graphics statement)|GET}} and PUT " - {{Cl|LOCATE}} 17, 4: {{Cl|PRINT}} "are used to preserve the background." - {{Cl|COLOR}} 11: {{Cl|LOCATE}} 20, 11: {{Cl|PRINT}} "Press [Esc] to quit" - x = 150: y = 50: PX = x: PY = y ' actual box starting position - - {{Cl|GET (graphics statement)|GET}} (x, y)-(x + 15, y + 15), BG ' {{Cl|GET (graphics statement)|GET}} original BG at start box position - {{Cl|LINE}} (x, y)-(x + 15, y + 15), 9, BF ' the plain blue box to move - {{Cl|GET (graphics statement)|GET}} (x, y)-(x + 15, y + 15), Box ' {{Cl|GET (graphics statement)|GET}} to Box Array - - {{Cl|DO...LOOP|DO}} 'main loop - t! = {{Cl|TIMER}} + .05 - {{Cl|DO...LOOP|DO}} ' 1 Tick (1/18th second) keypress scancode read loop - a$ = {{Cl|INKEY$}} ' So the keyboard buffer won't get full - code% = {{Cl|INP}}({{Cl|&H}}60) ' Get keyboard scan code from port 96 - {{Cl|IF...THEN|IF}} code% < 128 {{Cl|THEN}} SC(code%) = 1 {{Cl|ELSE}} SC(code% - 128) = 0 'true/false values to array - {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|TIMER}} > t!' loop until one tick has passed - - PX = x: PY = y ' previous coordinates - {{Cl|IF...THEN|IF}} SC(75) = 1 {{Cl|THEN}} x = x - 5: {{Cl|IF...THEN|IF}} x < 0 {{Cl|THEN}} x = 0 - {{Cl|IF...THEN|IF}} SC(77) = 1 {{Cl|THEN}} x = x + 5: {{Cl|IF...THEN|IF}} x > 304 {{Cl|THEN}} x = 304 - {{Cl|IF...THEN|IF}} SC(72) = 1 {{Cl|THEN}} y = y - 5: {{Cl|IF...THEN|IF}} y < 0 {{Cl|THEN}} y = 0 - {{Cl|IF...THEN|IF}} SC(80) = 1 {{Cl|THEN}} y = y + 5: {{Cl|IF...THEN|IF}} y > 184 {{Cl|THEN}} y = 184 - {{Cl|IF...THEN|IF}} x <> PX {{Cl|OR (boolean)|OR}} y <> PY {{Cl|THEN}} ' look for a changed coordinate value - {{Cl|WAIT}} 936, 8: {{Cl|PUT (graphics statement)|PUT}}(PX, PY), BG, {{Cl|PSET}} ' replace previous BG first - {{Cl|GET (graphics statement)|GET}} (x, y)-(x + 15, y + 15), BG ' {{Cl|GET (graphics statement)|GET}} BG at new position before box is set - {{Cl|PUT (graphics statement)|PUT}}(x, y), Box, {{Cl|PSET}} ' PUT box image at new position - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} SC(1) = 1 ' main loop until [Esc] key (scan code 1) is pressed -{{CodeEnd}} - - -''Example 2:'' How to GET graphics from an image other than the present screen using [[_SOURCE]] and [[_DEST]]ination. - -{{CodeStart}} -{{Cl|DIM}} img(20 * 20 + 4) {{Cl|AS}} {{Cl|INTEGER}} 'create img% array to hold 20 by 20 image data -a& = {{Cl|_NEWIMAGE}}(800, 600, 13) 'larger surface a& emulates screen 13 colors & resolution - -{{Cl|SCREEN (statement)|SCREEN}} 13 'program screen 13 - -{{Cl|_DEST}} a& 'set desination as the image page a& -{{Cl|CIRCLE}} (700, 300), 10, 10 'draw green circle on image page - -{{Cl|_SOURCE}} a& 'set source as image page a& -{{Cl|GET}} (690, 290)-(710, 310), img() 'GET a square screen area similar to a LINE Box. - - -{{Cl|_DEST}} 0 'set destination as the program screen -{{Cl|PUT}} (100, 100), img() 'PUT the Top Left Corner of box area to pixel 100, 100 -{{CodeEnd}} -: ''Notes:'' A [[_LOADIMAGE]] handle could also be used as a [[_SOURCE|source]] to GET a portion or all of an image file. - - -{{PageSeeAlso}} -* [[_PUTIMAGE]], [[_LOADIMAGE]] -* [[_MAPTRIANGLE]] -* [[POINT]], [[PUT (graphics statement)|PUT]], [[STEP]] -* [[BSAVE]], [[BLOAD]] -* [[Scancodes]], [[Creating Sprite Masks]] {{text|(for non-box shaped sprites)}} -* [[Bitmaps]], [[GET and PUT Demo]] - - -{{PageNavigation}} diff --git a/internal/help/GET_111.txt b/internal/help/GET_111.txt deleted file mode 100644 index 661487515..000000000 --- a/internal/help/GET_111.txt +++ /dev/null @@ -1,110 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:29}} -The [[GET #]] statement reads data from a file or port device by bytes or record positions. - - -{{PageSyntax}} -: [[GET #]]{{Parameter|fileNumber&}}, [{{Parameter|position}}][, {{{Parameter|targetVariable}}|{{Parameter|targetArray()}}}] - - -{{PageDescription}} -* {{Parameter|fileNumber&}} is the file or port number used in the [[OPEN]] AS [[BINARY]] or [[RANDOM]] statement. -* The [[INTEGER]] or [[LONG]] byte {{Parameter|position}} in a [[BINARY]] file or the record {{Parameter|position}} in a [[RANDOM]] file '''must be greater than zero'''. -* The {{Parameter|position}} can be omitted if the GET operations are consecutive based on the {{Parameter|targetVariable}} [[TYPE]] byte size. -* The {{Parameter|targetVariable}} [[Data types|type]] or [[FIELD]] ''variable'' size determines the byte size and the next {{Parameter|position}} in the file. -* The first byte position in a file is 1. -* GET does not require a byte or record {{Parameter|position}} or {{Parameter|targetVariable}} (or comma) when using a [[FIELD]] statement. -* '''QB64''' can [[PUT]] the entire contents of an array to a file and later GET those contents to a {{Parameter|targetArray()}} (include brackets). -* '''GET may ignore the end of a file and return bad data. If the [[EOF]] function returns -1 after a GET operation, it indicates that the data has ended.''' -{{TextStart}} DO UNTIL {{Cb|EOF}}(1) - {{Cb|GET}} #1, , value% - IF {{Cb|NOT}}({{Cb|EOF}}(1)) THEN {{Cb|PUT}} #2, , value% - LOOP -{{TextEnd}} - - -{{PageExamples}} -''Example 1:'' Opening a RANDOM file using LEN to calculate and LEN = to designate the file record size. -{{CodeStart}} -{{Cl|TYPE}} variabletype - x {{Cl|AS}} {{Cl|INTEGER}}' '2 bytes - y {{Cl|AS}} {{Cl|STRING}} * 10' '10 bytes - z {{Cl|AS}} {{Cl|LONG}}' '4 bytes -{{Cl|END}} {{Cl|TYPE}}' '16 bytes total -{{Cl|DIM}} record {{Cl|AS}} variabletype -{{Cl|DIM}} newrec {{Cl|AS}} variabletype - -file$ = "testrand.inf" '<<<< filename may overwrite existing file -number% = 1 '<<<<<<<<<< record number to write cannot be zero -RecordLEN% = {{Cl|LEN}}(record) -{{Cl|PRINT}} RecordLEN%; "bytes" -record.x = 255 -record.y = "Hello world!" -record.z = 65535 -{{Cl|PRINT}} record.x, record.y, record.z - -{{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RecordLEN% -{{Cl|PUT}} #1, number% , record 'change record position number to add records -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 {{Cl|LEN}} = RecordLEN% -NumRecords% = {{Cl|LOF}}(2) \ RecordLEN% -PRINT NumRecords%; "records" - -{{Cl|GET}} #2, NumRecords% , newrec 'GET last record available -{{Cl|CLOSE}} #2 -{{Cl|PRINT}} newrec.x, newrec.y, newrec.z - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} 16 bytes - 255 Hello worl 65535 - 1 records - 255 Hello worl 65535 -{{OutputEnd}} -: ''Explanation:'' The byte size of the record [[TYPE]] determines the [[LOF]] byte size of the file and can determine the number of records. -: To read the last record [[GET]] the number of records. To add a record, use the number of records + 1 to [[PUT]] new record data. - - -''Example 2:'' Placing the contents of a numerical array into a [[BINARY]] file. You may want to put the array size at the beginning too. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} array(100) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 100 - array(i) = i -{{Cl|NEXT}} -showme 'display array contents - -{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 - -{{Cl|PUT}} #1, , array() - -{{Cl|ERASE}} array 'clear element values from array and display empty -showme -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 -{{Cl|GET}} #2, , array() -{{Cl|CLOSE}} #2 -showme 'display array after transfer from file - -{{Cl|END}} - -{{Cl|SUB}} showme -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 100 - {{Cl|PRINT}} array(i); -{{Cl|NEXT}} -{{Cl|PRINT}} "done" -{{Cl|END SUB}} -{{CodeEnd}} -: ''Note:'' Use empty brackets in QB64 when using [[GET]] to create an array or [[PUT]] to create a [[BINARY]] data file. - - -{{PageSeeAlso}} -* [[PUT|PUT #]], [[SEEK]], [[SEEK (statement)]] -* [[INPUT (file statement)|INPUT #]], [[GET (TCP/IP statement)]] -* [[FIELD]], [[RANDOM]], [[BINARY]] -* [[LEN]], [[LOF]], [[EOF]] - - -{{PageNavigation}} diff --git a/internal/help/GOSUB_11111.txt b/internal/help/GOSUB_11111.txt deleted file mode 100644 index 8d6c9b534..000000000 --- a/internal/help/GOSUB_11111.txt +++ /dev/null @@ -1,79 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:32}} -[[GOSUB]] sends the program flow to a sub procedure identified by a line number or label. - - -{{PageSyntax}} -: GOSUB {{{Parameter|lineNumber}}|{{Parameter|label}}} - - -{{PageDescription}} -* Use [[RETURN]] in a sub procedure to return to the next line of code after the original [[GOSUB]] call. [[END]] or [[SYSTEM]] can also be used to end program. - -* GOSUB and GOTO can be used '''within''' [[SUB]] or [[FUNCTION]] procedures, but cannot refer to a label located outside the procedure. - - -===QBasic/QuickBASIC=== -* Too many GOSUBs without a [[RETURN]] can eventually cause "Out of Stack Errors" in QBasic as each GOSUB uses memory to store the location to return to. Each [[RETURN]] frees the memory of the GOSUB it returns to. - - -{{PageExamples}} -''Example:'' Simple usage of GOSUB -{{CodeStart}} -{{Cl|PRINT}} "1. It goes to the subroutine." -{{Cl|GOSUB}} subroutine -{{Cl|PRINT}} "3. And it returns." -{{Cl|END}} - -subroutine: -{{Cl|PRINT}} "2. It is at the subroutine." -{{Cl|RETURN}} - -{{CodeEnd}} -{{small|Code by Cyperium}} -{{OutputStart}} -1. It goes to the subroutine. -2. It is at the subroutine. -3. And it returns. -{{OutputEnd}} - - - - -''Example:'' What happens if two GOSUB executes then two RETURN's? -{{CodeStart}} -start: - -a = a + 1 -{{Cl|IF...THEN|IF}} a = 1 {{Cl|THEN}} {{Cl|GOSUB}} here: {{Cl|PRINT}} "It returned to IF a = 1": {{Cl|END}} -{{Cl|IF...THEN|IF}} a = 2 {{Cl|THEN}} {{Cl|GOSUB}} there: {{Cl|PRINT}} "It returned to IF a = 2": {{Cl|RETURN}} - - - -here: -{{Cl|PRINT}} "It went here." -{{Cl|GOTO}} start - -there: -{{Cl|PRINT}} "It went there." -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Code by Cyperium}} -{{OutputStart}} -It went here. -It went there. -It returned to IF a = 2 -It returned to IF a = 1 -{{OutputEnd}} -''Explanation:'' When a = 1 it uses GOSUB to go to "here:", then it uses GOTO to go back to "start:". a is increased by one so when a = 2 it uses GOSUB to go to "there:", and uses RETURN to go the last GOSUB (which is on the IF a = 2 line), it then encounters another RETURN which makes it return to the first GOSUB call we used on the IF a = 1 line. - - -{{PageSeeAlso}} -* [[ON...GOSUB]] -* [[ON...GOTO]], [[GOTO]] -* [[ON ERROR]], [[RESUME]] -* [[ON TIMER (n)]] -* [[Line number]] - - -{{PageNavigation}} diff --git a/internal/help/GOTO_1111.txt b/internal/help/GOTO_1111.txt deleted file mode 100644 index 95ffa529e..000000000 --- a/internal/help/GOTO_1111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:33}} -The [[GOTO]] statement sends the procedure to a line label or a line number in the program. - - -{{PageSyntax}} -: [[GOTO]] {''lineNumber''|''lineLabel''} - - -'''''IF''' Syntax:'' -: IF condition [[GOTO]] {''lineNumber''|''lineLabel''} - - -{{PageDescription}} -* ''lineNumber'' or ''lineLabel'' must already exist or an IDE status error will be displayed until it is created. -* Can be used in [[SUB]] or [[FUNCTION]] procedures using their own line labels or numbers. -* The frequent use of GOTO statements can become confusing when trying to follow the code and it could also cause endless loops. -* [[GOTO]] is an easy trap for new programmers. Use loops instead when possible. - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -1 {{Cl|PRINT}} "first line": {{Cl|GOTO}} gohere -2 {{Cl|PRINT}} "second line": {{Cl|GOTO}} 3 - -gohere: -{{Cl|PRINT}} "third line" -{{Cl|GOTO}} 2 - -3 {{Cl|END}} -{{CodeEnd}} -{{OutputStart}} -first line -third line -second line -{{OutputEnd}} - -:''Explanation:'' After it prints "first line" it goes to the line label "gohere" where it prints "third line", then it goes to the line that is numbered "2" and prints "second line" and goes to line number 3 and an [[END]] statement which ends the program. - - -{{PageSeeAlso}} -* [[GOSUB]], [[ON ERROR]] -* [[ON...GOTO]], [[ON...GOSUB]] -* [[DO...LOOP]], [[FOR...NEXT]] -* [[IF...THEN]], [[SELECT CASE]] -* [[Line number|Line numbers and labels]] - - -{{PageNavigation}} diff --git a/internal/help/Greater_Than_1000000_1000.txt b/internal/help/Greater_Than_1000000_1000.txt deleted file mode 100644 index 6e875ba21..000000000 --- a/internal/help/Greater_Than_1000000_1000.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:14}} -The '''>''' condition symbol denotes that a value must be greater than another value for the condition to be True. - - -''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right of screen" - - -* Statements will evaluate as True or -1 when the first value is greater or False or 0 when equal or the first value is less. -* More than one > symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical value. - - -''See also:'' - -* [[Equal|=]] -* [[Not_Equal|<>]] -* [[Less_Than|<]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/Greater_Than_Or_Equal_1000000_1000_10_10000.txt b/internal/help/Greater_Than_Or_Equal_1000000_1000_10_10000.txt deleted file mode 100644 index c72ed17fa..000000000 --- a/internal/help/Greater_Than_Or_Equal_1000000_1000_10_10000.txt +++ /dev/null @@ -1,17 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:16}} -The '''>=''' condition symbol denotes that a value must be greater than or equal to another value for the condition to be True. - - -''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right or center of screen" - - -''See also:'' - -* [[Equal|=]] -* [[Not_Equal|<>]] -* [[Less_Than_Or_Equal|<=]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/HEX$_111$.txt b/internal/help/HEX$_111$.txt deleted file mode 100644 index d6126e293..000000000 --- a/internal/help/HEX$_111$.txt +++ /dev/null @@ -1,79 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:35}} -This function returns the hexadecimal (base 16) representation of any numeric value. - - -{{PageSyntax}} -: {{Parameter|hexvalue$}} = [[HEX$]]({{Parameter|number}}) - - -{{PageParameters}} -* {{Parameter|number}} can be any [[INTEGER]], [[LONG]] or [[_INTEGER64]] value, positive or negative. -* {{Parameter|number}} can also be any [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] value, but only the integer part of the value is converted in that case. That is, from the value ''-123.45'' the function would convert the ''-123'' only. - - -{{PageDescription}} -* The function returns the base 16 (hexadecimal) representation of the given {{Parameter|number}} as [[STRING]]. -* Different from [[STR$]], this function does not return a leading sign placeholder space, so no [[LTRIM$]] to strip that space from positive numbers is necessary. -* [[VAL]] can convert the returned hex string value back to a decimal value by prefixing the string with "[[&H]]". -** Eg. {{InlineCode}}decimal = {{Cl|VAL}}("&H" + hexvalue$){{InlineCodeEnd}}. - - -{{PageExamples}} -;Example 1:Comparing decimal, hexadecimal, octal and binary string values from 0 to 15. -{{CodeStart}} -tabletop$ = " Decimal | Hexadecimal | Octal | Binary " -tablesep$ = "---------+-------------+-------+--------" -tableout$ = " \ \ | \\ | \\ | \ \ " 'the PRINT USING template - -{{Cl|LOCATE}} 2, 10: {{Cl|PRINT}} tabletop$ -{{Cl|LOCATE}} 3, 10: {{Cl|PRINT}} tablesep$ -{{Cl|FOR...NEXT|FOR}} n% = 0 {{Cl|TO}} 15 - {{Cl|LOCATE}} 4 + n%, 10: {{Cl|PRINT USING}} tableout$; {{Cl|STR$}}(n%); {{Cl|HEX$}}(n%); {{Cl|OCT$}}(n%); {{Cl|_BIN$}}(n%) -{{Cl|NEXT}} n% -{{CodeEnd}} -;Note:Although the decimal numbers 0-15 have a maximum width of 2 digits only, an extra space in the ''tableout$'' template is needed when using the (fixed width string) slash output format, as [[STR$]] values contain a leading sign placeholder space. -{{OutputStart}} - Decimal | Hexadecimal | Octal | Binary - ---------+-------------+-------+-------- - 0 | 0 | 0 | 0 - 1 | 1 | 1 | 1 - 2 | 2 | 2 | 10 - 3 | 3 | 3 | 11 - 4 | 4 | 4 | 100 - 5 | 5 | 5 | 101 - 6 | 6 | 6 | 110 - 7 | 7 | 7 | 111 - 8 | 8 | 10 | 1000 - 9 | 9 | 11 | 1001 - 10 | A | 12 | 1010 - 11 | B | 13 | 1011 - 12 | C | 14 | 1100 - 13 | D | 15 | 1101 - 14 | E | 16 | 1110 - 15 | F | 17 | 1111 -{{OutputEnd}} - - -;Example 2:Converting a hexadecimal value to decimal. -{{CodeStart}} -hexvalue$ = {{Cl|HEX$}}(255) -{{Cl|PRINT}} "Hex: "; hexvalue$ -{{Cl|PRINT}} "Converting Hex value to Decimal:"; {{Cl|VAL}}("&H" + hexvalue$) -{{CodeEnd}} -{{OutputStart}} -Hex: FF -Converting Hex value to Decimal: 255 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_BIN$]], [[OCT$]], [[STR$]] -* [[&B]] (binary), [[&H]] (hexadecimal), [[&O]] (octal), [[VAL]] -* [[Base Comparisons]] -* [[HEX$ 32 Bit Values]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/IF...THEN_11...1111.txt b/internal/help/IF...THEN_11...1111.txt deleted file mode 100644 index fb71b6446..000000000 --- a/internal/help/IF...THEN_11...1111.txt +++ /dev/null @@ -1,137 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:07}} -[[IF...THEN]] statements make boolean (true or false) evaluations to automate program decision making. - -{{PageSyntax}} -===Single-line=== -: [[IF]] {{Parameter|conditionStatement}} [[THEN]] ''{code}'' [[ELSE]] ''{alternativeCode}'' -: [[IF]] {{Parameter|conditionStatement}} [[GOTO]] ''lineLabel'' - - -===Block=== -: [[IF]] {{Parameter|conditionStatement}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSEIF]] {{Parameter|conditionStatement2}} [[THEN]] -:: ''{code}'' -:: ⋮ -: [[ELSE]] -:: ''{code}'' -:: ⋮ -: [[END IF]] - - -{{PageDescription}} -* The {{Parameter|conditionStatement}} evaluation by [[IF]] must be true (-1) or a '''non-zero numerical value''' for the [[THEN]] ''{code}'' to be executed. -* Multiple conditional evaluations can be made using inclusive [[AND (boolean)|AND]] or alternative [[OR (boolean)|OR]] conditional expressions. -* [[THEN]] is not required when [[GOTO]] is used to send program flow to a line number or label. -* [[IF]] statements can also have alternative evaluations using [[ELSEIF]] and [[ELSE]] conditions. -* When the [[IF]] statement and/or code to be run is more than code line, an [[END IF]] statement must be used. -* With multiple code lines to run, end the IF statement with THEN and place all of the code on lines below that line. -* Multiple code line block statements require that the [[IF...THEN]], [[ELSEIF]], [[ELSE]] and [[END IF]] be on separate lines. -* '''The IDE may return an error of ''[[NEXT]] without [[FOR]]'' or ''[[LOOP]] without [[DO...LOOP|DO]]'' when [[END IF]] does not end a statement block.''' -* The '''QB64''' IDE will indicate an error in the IF statement line until END IF closes the statement block. -* Use [[colon]]s to execute multiple statements in a single-line IF statement. -* An '''[[underscore]]''' can be used anywhere after the code on a single-line to continue it to the next line in '''QB64'''. -* '''NOTE:''' [[STRING]] values can only be evaluated in an IF statement if a value is compared to a literal or [[CHR$]] string value. '''QB64 may not compile literal IF string statements or indicate an IDE coding error.''' Use [[LEN]] or [[ASC]] to compare strings numerically. - - - -{{RelationalTable}} - - -
When evaluating a number value, no IF value > 0 operation is necessary for values not 0. Use: IF value THEN
- - -
'''Boolean Conditional Operators:'''
- - -:::::* [[AND (boolean)]] can be used to add extra conditions to a boolean statement evaluation. -:::::* [[OR (boolean)]] can be used to add alternate conditions to a boolean statement evaluation. -:::::* Parenthesis are allowed inside of boolean statements to clarify an evaluation. - - -
'''Mathematical Logical operators:'''
-
* Truth table of the 6 BASIC Logical Operators:
- - -{{LogicalTruthTable}} - -
* '''Note that Basic returns -1 for True and 0 for False.'''
- - -{{PageExamples}} -''Example 1:'' In a one line IF statement, only [[REM]] can be used to comment out the action without an [[END IF]] error: -{{CodeStart}} -{{Cl|INPUT}} "Enter a number over or under 100: ", x -{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|PRINT}} x -{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|REM}} {{Cl|PRINT}} x '' ' -{{CodeEnd}} - - -''Example 2:'' IF statement blocks require that the IF THEN and END IF statements be separate from the code executed. -{{CodeStart}} -{{Cl|INPUT}} "Enter a number over or under 100: ", x -{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} - y = 200 - {{Cl|PRINT}} y - {{Cl|PRINT}} x -{{Cl|END IF}} -{{CodeEnd}} - - -''Example 3:'' True or False evaluation of a numerical value executes only when the value is not 0. '''Cannot evaluate [[STRING]] values.''' -{{CodeStart}} -{{Cl|INPUT}} "Enter a number or just hit Enter: ", x -{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|PRINT}} x -{{CodeEnd}} -:Example will only print if a numerical value is True (positive or negative). (Equivalent to: IF x > 0 OR x < 0 THEN evaluation) - - -''Example 4:'' Multiple evaluations using parenthesis to determine the order. -{{CodeStart}} -{{Cl|INPUT}} "Enter a number over or under 100 or 50: ", value -{{Cl|IF...THEN|IF}} (value% > 100 {{Cl|AND (boolean)|AND}} value% < 200) {{Cl|OR (boolean)|OR}} value% = 50 {{Cl|THEN}} {{Cl|PRINT}} "OK" -{{CodeEnd}} - - -''Example 5:'' Using multiple IF options in a one line statement. -{{CodeStart}} -{{Cl|INPUT}} "Enter a number over or under 200: ", x -{{Cl|IF...THEN|IF}} x > 200 {{Cl|THEN}} {{Cl|PRINT}} "High" {{Cl|{{Cl|ELSEIF}}}} x < 0 {{Cl|THEN}} {{Cl|PRINT}} "Low" {{Cl|{{Cl|ELSE}}}} {{Cl|PRINT}} "OK" - -{{CodeEnd}} - - -''Example 6:'' [[STRING]] values can be compared using greater than, less than, not equal to or equal to operators only. -{{CodeStart}} -PRINT "Press a letter key: "; -Key$ = {{Cl|INPUT$}}(1) -PRINT Key$ -IF Key$ >= {{Cl|CHR$}}(65) AND Key$ <= {{Cl|CHR$}}(90) THEN PRINT "A to Z" -{{CodeEnd}} -: ''Explanation:'' Long [[STRING]] expression values are compared by their cumulative [[ASCII]] code values. - - -
'''QBasic decimal point value comparison errors'''
-* Floating decimal point numerical values may not be compared as exactly the same value. QB64 will compare them the same. -:''Example:'' QBasic would print ''unequal'' in the IF comparison code below even though it is exactly the same value printed. -{{CodeStart}} -x# = 5 / 10 -y# = 6 / 10 -z# = x# + y# -{{Cl|PRINT}} x#, y#, z# -{{Cl|IF...THEN|IF}} x# + y# = z# {{Cl|THEN}} {{Cl|PRINT}} "equal" {{Cl|ELSE}} {{Cl|PRINT}} "unequal" -{{CodeEnd}} -: Note: QB64 will make the calculation correctly and print ''equal''. Change older program code that relies on the error accordingly. - - -{{PageSeeAlso}} -* [[ELSEIF]], [[ELSE]] -* [[AND (boolean)]], [[OR (boolean)]] -* [[NOT]], [[GOTO]] -* [[SELECT CASE]] -* [[Boolean]] {{text|(numerical comparisons return a true or false value)}} - - -{{PageNavigation}} diff --git a/internal/help/IMP_111.txt b/internal/help/IMP_111.txt deleted file mode 100644 index bfd35dd53..000000000 --- a/internal/help/IMP_111.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:36}} -The [[IMP]] logical operator converts the result of two comparative values and returns a bit result. - - -{{PageSyntax}} -: {{Parameter|result}} = {{Parameter|firstValue}} [[IMP]] {{Parameter|secondValue}} - - -{{PageDescription}} -* Returns a different result from [[AND]], [[OR]] or [[XOR]] - see truth table below. -* Evaluates if {{Parameter|firstValue}} '''''imp'''lies'' {{Parameter|secondValue}}. -**If {{Parameter|firstValue}} is true then {{Parameter|secondValue}} must also be true. -**So if {{Parameter|firstValue}} is true, and {{Parameter|secondValue}} false, then the condition is false, otherwise it is true (see table below). - - -{{LogicalTruthTable}} - - -{{PageSeeAlso}} -* [[Binary]] -* [[Boolean]] - - -{{PageNavigation}} diff --git a/internal/help/INKEY$_11111$.txt b/internal/help/INKEY$_11111$.txt deleted file mode 100644 index b4b87eb96..000000000 --- a/internal/help/INKEY$_11111$.txt +++ /dev/null @@ -1,234 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:38}} -The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s) from the keyboard buffer. - - -{{PageSyntax}} -: {{Parameter|keypress$}} = [[INKEY$]] - - -{{PageDescription}} -* Returns [[ASCII]] character string values in upper or lower cases. See: [[UCASE$]] and [[LCASE$]] -* Returns "" if no key has been pressed since the last keyboard read. -* Some control keys cannot be read by INKEY$ or will return 2 byte [[ASCII]] codes. -* INKEY$ can also be used to clear a [[SLEEP]] key press or the keyboard buffer in a loop. -* Assign the INKEY$ return to a string variable to save the key entry. -* {{InlineCode}}{{Cl|LOCATE}} , , 1{{InlineCodeEnd}} displays the INKEY$ cursor. Use {{InlineCode}}{{Cl|LOCATE}} , , 0{{InlineCodeEnd}} to turn it off. -* To receive input from a [[$CONSOLE]] window, use [[_CINP]]. -* Returns can be evaluated as certain [[ASCII]] characters or codes. -{{WhiteStart}}' '''ASCII Keyboard Codes''' -' -'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause''' -' 27 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +133 +134 - - - -'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -''' -' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45 -''' 96 49 50 51 52 53 54 55 56 57 48 45 61'' -'''' Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/â–² 9PU + ''' -' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 +83 +79 +81 +71 +72 +73 43 -''' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 '' -'''' CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º -' - 65 83 68 70 71 72 74 75 76 58 34 13 +75 +76 +77 '''E''' -''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n''' -'''' Shift Z X C V B N M ,< .> /? Shift â–² 1End 2/â–¼ 3PD t''' -' * 90 88 67 86 66 78 77 60 62 63 * +72 +79 +80 +81 '''e''' -''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r''' -'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0Ins .Del ''' -' * - * 32 * - - * +75 +80 +77 +82 +83 13 -' '' 48 46'' -' -' ''' ''Italics'' = LCase/NumLock On * = 2 byte combo only, + = 2 Byte: CHR$(0) + CHR$(code)''' -' -{{WhiteEnd}} - -==Two Byte Combinations== -* INKEY$ 2 byte combinations always begin with [[CHR$]](0). [[ASC]] will always read the first byte code as zero. -* Read the second byte code using: '''{{text|code2 = ASC(press$, 2)|green}}''' - - -
'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''
- -{{WhiteStart}} '''Two Byte Characters Key CHR$(0) + "?" ''' - - CHR$(0) + CHR$(16-50) [Alt] + letter - CHR$(0) + CHR$(59) [F1] ";" - CHR$(0) + CHR$(60) [F2] "<" - CHR$(0) + CHR$(61) [F3] "=" - CHR$(0) + CHR$(62) [F4] ">" - CHR$(0) + CHR$(63) [F5] "?" - CHR$(0) + CHR$(64) [F6] "@" - CHR$(0) + CHR$(65) [F7] "A" - CHR$(0) + CHR$(66) [F8] "B" - CHR$(0) + CHR$(67) [F9] "C" - CHR$(0) + CHR$(68) [F10] "D" - CHR$(0) + CHR$(71) [Home] "G" - CHR$(0) + CHR$(72) [↑] Arrow "H" - CHR$(0) + CHR$(73) [Page Up] "I" - CHR$(0) + CHR$(75) [â†] Arrow "K" - CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64) - CHR$(0) + CHR$(77) [→] Arrow "M" - CHR$(0) + CHR$(79) [End] "O" - CHR$(0) + CHR$(80) [↓] Arrow "P" - CHR$(0) + CHR$(81) [Page Down] "Q" - CHR$(0) + CHR$(82) [Insert] "R" - CHR$(0) + CHR$(83) [Delete] "S" - CHR$(0) + CHR$(84-93) [Shift] + F1-10 - CHR$(0) + CHR$(94-103) [Ctrl] + F1-10 - CHR$(0) + CHR$(104-113) [Alt] + F1-10 - CHR$(0) + CHR$(114-119) [Ctrl] + keypad - CHR$(0) + CHR$(120-129) [Alt] + number - CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "é" or "â" - CHR$(0) + CHR$(133) [F11] "à" - CHR$(0) + CHR$(134) [F12] "Ã¥" - CHR$(0) + CHR$(135) [Shift] + [F11] "ç" - CHR$(0) + CHR$(136) [Shift] + [F12] "ê" - CHR$(0) + CHR$(137) [Ctrl] + [F11] "ë" - CHR$(0) + CHR$(138) [Ctrl] + [F12] "è" - CHR$(0) + CHR$(139) [Alt] + [F11] "ï" - CHR$(0) + CHR$(140) [Alt] + [F12] "î" -{{WhiteEnd}} -:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: '''{{text|status = _KEYDOWN(CVI(CHR$(0) + "P"))|green}}''' - - -{{PageExamples}} -''Example 1:'' Clearing the keyboard buffer after [[SLEEP]] delays for later [[INPUT]]. -{{CodeStart}}{{Cl|PRINT}} "Press any keyboard typing key to end SLEEP" -{{Cl|SLEEP}} -{{Cl|DO}}: K$ = {{Cl|INKEY$}}: {{Cl|PRINT}} K$: {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "" -{{CodeEnd}} -:''Explanation:'' [[SLEEP]] key presses will be kept in the keyboard buffer and may be added into an [[INPUT]] later. -:See also: [[_KEYCLEAR]] - - -''Example 2:'' Entering a Ctrl + letter keypress combination will print [[ASCII]] Control characters 1 to 26. . -{{CodeStart}}DO - K$ = {{Cl|INKEY$}} - {{Cl|IF...THEN|IF}} K$ <> "" {{Cl|THEN}} {{Cl|PRINT}} K$; " "; -{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) 'Esc key exit -{{CodeEnd}} -: ''Note:'' The above code will print Esc arrow, Backspace symbol, and 2 byte characters led by CHR$(0) in addition to normal keys. - - -''Example 3:'' Use [[UCASE$]](INKEY$) in a keyboard read loop looking for uppercase "Y" or "N" user inputs to avoid multiple IF statements. -{{CodeStart}} -{{Cl|DO...LOOP|DO}} - {{Cl|PRINT}} "Do you want to continue? (Y/N): "; 'semicolon saves position for user entry - {{Cl|DO...LOOP|DO}}: K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) 'change any user key press to uppercase - {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "Y" {{Cl|OR (boolean)|OR}} K$ = "N" - {{Cl|PRINT}} K$ 'print valid user entry - {{Cl|IF...THEN|IF}} K$ = "N" {{Cl|THEN}} {{Cl|END}} -{{Cl|LOOP}} -{{CodeEnd}} - - -''Example 4:'' Getting just number values entered by a user in an INKEY$ input loop. -{{CodeStart}} -{{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} "Enter a number value: "; -{{Cl|DO}}: {{Cl|SLEEP}} - K$ = {{Cl|INKEY$}} - {{Cl|IF}} K$ >= {{Cl|CHR$}}(48) {{Cl|AND (boolean)|AND}} K$ <= {{Cl|CHR$}}(57) {{Cl|THEN}} entry$ = entry$ + K$ ' numbers only - L = {{Cl|LEN}}(entry$) ' check entry length for possible backspace - {{Cl|IF}} K$ = {{Cl|CHR$}}(46) {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}} entry$ = entry$ + K$: flag = 1: mark = L ' decimal point - {{Cl|IF}} K$ = {{Cl|CHR$}}(8) {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length - entry$ = {{Cl|MID$}}(entry$, 1, L - 1) ' remove one character from entry$ - {{Cl|IF}} {{Cl|LEN}}(entry$) < mark {{Cl|THEN}} flag = 0 ' allow decimal point entry if other was removed. - {{Cl|LOCATE}} {{Cl|CSRLIN}}, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|SPACE$}}(1); ' remove end character from screen - {{Cl|END IF}} - {{Cl|LOCATE}} 10, 32: {{Cl|PRINT}} entry$; ' display entry to user (semicolon required for correct {{Cl|POS}}) -{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(13) {{Cl|AND (boolean)|AND}} L > 0 'assures something is entered -{{CodeEnd}} - -: ''Explanation:'' [[SLEEP]] waits for a keypress. It also allows background programs to share the processor and it leaves the keypress in the buffer for INKEY$. Keyboard string number characters range from [[ASCII]] codes 48 to 57. Any other entry is ignored by the IF statement. A decimal point (code 46) entry is allowed once in the input. The flag value stops further decimal point additions. Backspacing (code 8) is also allowed if the entry has at least one character. The cursor column returned by [[POS]](0) reverts too after the end of the entry when printed each loop. The loop exits when [Enter] (code 13) is pressed and the entry has a length. - - -''Example 5:'' Using arrow keys to move a text character. A change from a previous position tells program when to PRINT: -{{CodeStart}}movey = 1: movex = 1 'text coordinates can never be 0 -at$ = "@" 'text sprite could be almost any ASCII character -{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$; -DO - px = movex: py = movey 'previous positions - B$ = {{Cl|INKEY$}} - {{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) {{Cl|AND (boolean)|AND}} movey > 1 {{Cl|THEN}} movey = movey - 1 'rows 1 to 23 only - {{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(80) {{Cl|AND (boolean)|AND}} movey < 23 {{Cl|THEN}} movey = movey + 1 - {{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(75) {{Cl|AND (boolean)|AND}} movex > 1 {{Cl|THEN}} movex = movex - 1 'columns 1 to 80 only - {{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(77) {{Cl|AND (boolean)|AND}} movex < 80 {{Cl|THEN}} movex = movex + 1 - - {{Cl|IF...THEN|IF}} px <> movex {{Cl|OR (boolean)|OR}} py <> movey {{Cl|THEN}} 'only changes when needed - {{Cl|LOCATE}} py, px: {{Cl|PRINT}} {{Cl|SPACE$}}(1); 'erase old sprite - {{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$; 'show new position - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(27) 'ESCape key exit -{{Cl|END}} -{{CodeEnd}} - - -''Example 6:'' Using INKEY$ with the arrow or WASD keys to move the QB64 bee image sprite with [[_PUTIMAGE]]: -{{CodeStart}} -{{Cl|DIM}} image {{Cl|AS}} {{Cl|LONG}} -{{Cl|DIM}} x {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} y {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} Keypress {{Cl|AS}} {{Cl|STRING}} - -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) - -x = 0 -y = 0 -image = {{Cl|_LOADIMAGE}}("QB64bee.png") 'Here I actually used the QB64 icon - -DO - {{Cl|_PUTIMAGE}} (x, y), image - DO - Keypress = {{Cl|UCASE$}}({{Cl|INKEY$}}) - ' ***** The following line detects the arrow keys ***** - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(Keypress) > 1 {{Cl|THEN}} Keypress = {{Cl|RIGHT$}}(Keypress, 1) - {{Cl|LOOP}} {{Cl|UNTIL}} Keypress > "" - - {{Cl|CLS}} ' blank screen after valid key press to avoid smearing image on page - - {{Cl|SELECT CASE}} Keypress - {{Cl|CASE}} "W", "H": y = y - 10 'Up - {{Cl|CASE}} "A", "K": x = x - 10 'Left - {{Cl|CASE}} "S", "P": y = y + 10 'Down - {{Cl|CASE}} "D", "M": x = x + 10 'Right - {{Cl|CASE}} "Q", {{Cl|CHR$}}(27): {{Cl|END}} 'Q or Esc Ends prog. - {{Cl|END SELECT}} - {{Cl|_PUTIMAGE}} (x, y), image -{{Cl|LOOP}} -{{CodeEnd}} {{small|Adapted from code by Daniel}} -: ''Note:'' The image can be placed off of the screen without error. The image moves 10 pixels to move faster. [[CLS]] eliminates any background. - - -''Example 7:'' Creating upper [[ASCII]] characters in a QB program using '''Alt +''' three number keys: -{{CodeStart}} -DO - A$ = "": {{Cl|WHILE}} A$ = "": A$ = {{Cl|INKEY$}}: {{Cl|WEND}} - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(A$) = 2 {{Cl|THEN}} '2 byte INKEY$ return - B$ = {{Cl|RIGHT$}}(A$, 1) 'read second byte - b% = {{Cl|ASC}}(B$) 'read second byte code - {{Cl|IF...THEN|IF}} b% > 119 {{Cl|AND (boolean)|AND}} b% < 130 {{Cl|THEN}} ' Alt + number codes only - C% = b% - 119 ' convert to actual number - {{Cl|IF...THEN|IF}} C% > 9 {{Cl|THEN}} C% = 0 - num$ = num$ + {{Cl|LTRIM$}}({{Cl|STR$}}(C%)) - {{Cl|END IF}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}(num$) = 3 ' 3 digit codes only - -{{Cl|PRINT}} num$ -{{Cl|PRINT}} {{Cl|CHR$}}({{Cl|VAL}}(num$) -{{CodeEnd}}{{small|Code by Ted Weissgerber}} -{{OutputStart}} 155 ¢ {{OutputEnd}} -:''Explanation:'' Hold down Alt key and press 3 keyboard code number keys. '''Number pad keys may not work.''' Note that [[INKEY$]] cannot read Alt, Ctrl or Shift key presses without a key combination and the return is CHR$(0) + CHR$(code). - - - - -''See also:'' -* [[_KEYHIT]], [[_KEYDOWN]], [[_MAPUNICODE]] -* [[_KEYCLEAR]] -* [[INPUT]], [[LINE INPUT]] -* [[INPUT$]], [[INP]] -* [[CHR$]], [[ASCII]] -* [[ASC]], [[Scancodes]] (keyboard) -* [[Windows_Libraries#Hot_Keys_.28maximize.29|Windows hot keys]] - - -{{PageNavigation}} diff --git a/internal/help/INPUT$_11111$.txt b/internal/help/INPUT$_11111$.txt deleted file mode 100644 index 43c4a4774..000000000 --- a/internal/help/INPUT$_11111$.txt +++ /dev/null @@ -1,60 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:45}} -The [[INPUT$]] function is used to receive data from the user's keyboard, an open file or an open port. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[INPUT$]]({{Parameter|numberOfBytes%}}[, fileOrPortNumber]) - - -* Keyboard input is limited to the [[INTEGER]] {{Parameter|numberOfBytes%}} (characters) designated by program. -* The keyboard is the default device when a file or port number is omitted. The {{Parameter|numberOfBytes%}} is number of key presses to read. -* INPUT$ will wait until the number of bytes are read from the keyboard or port. One byte per loop is recommended with ports. -* [[RANDOM]] opened file bytes can be up to the [[LEN]] = recordLength statement, or 128 if no statement is used. -* fileOrPortNumber is the number that was used in the [[OPEN]] AS statement. -* Returns [[STRING]] values including spaces or even extended [[ASCII]] characters. -* Backspace key results in the [[CHR$]](8) character being added to an entry. -* Use {{InlineCode}}{{Cl|LOCATE}} , , 1{{InlineCodeEnd}} to view the cursor entry. Turn the cursor off using {{InlineCode}}{{Cl|LOCATE}} , , 0{{InlineCodeEnd}}. -* Use [[_DEST]] [[_CONSOLE]] before INPUT$ is used to receive input from a [[$CONSOLE|console]] window. - - -==QBasic/QuickBASIC== -* {{Parameter|numberOfBytes%}} could not exceed 32767 in [[BINARY]] files or a QBasic error would occur. -* Ctrl + Break would not interrupt the QBasic program until there was a full INPUT$ key entry. In '''QB64''' Ctrl + Break will immediately exit a running program. - - -{{PageExamples}} -''Example 1:'' A keyboard limited length entry can be made with a fixed blinking cursor. Entry must be completed before it can be shown. -{{CodeStart}} -{{Cl|LOCATE}} 10, 10, 1 'display fixed cursor at location -year$ = {{Cl|INPUT$}}(4) 'waits until all 4 digits are entered -PRINT year$ 'display the text entry -{{CodeEnd}} - - -''Example 2:'' Reading bytes from a text file for an 80 wide screen mode. -{{CodeStart}} -{{Cl|LOCATE}} 5, 5, 1 'locate and display cursor -{{Cl|OPEN}} "Diary.txt" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 'open existing text file -text$ = {{Cl|INPUT$}}(70, 1) -{{Cl|LOCATE}} 5, 6, 0: PRINT text$ 'print text and turn cursor off -{{CodeEnd}} - - -''Example 3:'' Getting the entire text file data as one string value. -{{CodeStart}} -{{Cl|OPEN}} "Diary.txt FOR {{Cl|BINARY}} AS #1 'open an existing file up to 32767 bytes -IF {{Cl|LOF}}(1) <= 32767 THEN Text$ = {{Cl|INPUT$}}(LOF(1), 1) -{{Cl|CLOSE}} #1 -{{CodeEnd}} -:''Explanation:'' The IF statement gets the entire contents when the file size is less than 32768. The program can then work with the string by using [[MID$]] or [[INSTR]]. Note: A text file string will also have '''CrLf''' line break end characters [[CHR$]](13) + [[CHR$]](10). - - -{{PageSeeAlso}} -* [[INPUT]], [[LINE INPUT]] {{text|(keyboard input)}} -* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]], [[LINE INPUT (file statement)|LINE INPUT #]] {{text|(file input)}} -* [[OPEN]], [[LOC]] {{text|(file)}} -* [[LOCATE]] {{text|(cursor on/off)}} - - -{{PageNavigation}} diff --git a/internal/help/INPUT_(file_mode)_11111_(0000_0000).txt b/internal/help/INPUT_(file_mode)_11111_(0000_0000).txt deleted file mode 100644 index 2cf5c09e3..000000000 --- a/internal/help/INPUT_(file_mode)_11111_(0000_0000).txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:42}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/INPUT_(file_statement)_11111_(0000_000000000).txt b/internal/help/INPUT_(file_statement)_11111_(0000_000000000).txt deleted file mode 100644 index 000427daf..000000000 --- a/internal/help/INPUT_(file_statement)_11111_(0000_000000000).txt +++ /dev/null @@ -1,90 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:43}} -The [[INPUT #]] file or port statement reads sequential data using one variable or a comma separated list of matching variable types. - - -{{PageSyntax}} -: [[INPUT #]]{{Parameter|fileNumber&}}, {{Parameter|variable1}}[, {{Parameter|variable2}}, ..., {{Parameter|variableN}}] - - -{{Parameters}} -* {{Parameter|fileNumber&}} is a positive [[LONG]] integer value used to [[OPEN]] the file FOR [[INPUT (file mode)|INPUT]] mode. -* The [[type]] of the ''variable'' used defines the value or list of values to be returned from the file. Numeric types must match the values returned. -* As reflected in the syntax you can list a number of variables with different types seperated by a comma and they will hold the values in the file (keep in mind that the information in the file should match the variable types used). - - -{{PageDescription}} -* The file number can be determined by the programmer or be an unused number returned by the [[FREEFILE]] function. -* Variable types must match the numerical [[type]]s being read. [[STRING]] variables can return unquoted numeric values. -* Leading or trailing spaces of [[STRING]] values must be inside of quotes. [[WRITE (file statement)|WRITE #]] writes strings inside of quotes automatically. [[PRINT (file statement)|PRINT #]] removes quotes. -* [[INPUT #]] will read each value until it encounters a comma for the next value in a list. -* Use the [[EOF]] function to avoid reading past the end of a file. -* Files created by [[WRITE (file statement)|WRITE #]] usually have the same number of values on each file line. If INPUT reads more or less values, it may read beyond the [[EOF|end of file]] or return bad data. -* Use the [[LINE INPUT (file statement)]] for files created with PRINT # or PRINT #, USING. -* '''INPUT can read Excel CSV files, but beware of unquoted text or numerical values containing commas.''' - - -{{PageExamples}} -''Example 1:'' Writes new data to a text file sequentially and reads it back to the program screen. -{{CodeStart}} -filename$ = "testfile.dat" -x = 1: y = 2: z$ = "Three" - -{{Cl|OPEN}} filename$ {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 'opens and clears an existing file or creates new empty file -{{Cl|WRITE (file statement)|WRITE}} #1, x, y, z$ -{{Cl|CLOSE}} #1 - -{{Cl|PRINT}} "File created with data. Press a key!" -K$ = {{Cl|INPUT$}}(1) 'press a key - -{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #2 'opens a file to read it -{{Cl|INPUT (file statement)|INPUT}} #2, a, b, c$ -{{Cl|CLOSE}} #2 - -{{Cl|PRINT}} a, b, c$ -{{Cl|WRITE}} a, b, c$ - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} 1 2 Three -1,2,"Three" -{{OutputEnd}} -: ''Screen output:'' [[PRINT]] string values will not display enclosing quotes. [[WRITE]] screen displays will. -{{TextStart}} -1,2,"Three" -{{TextEnd}} -: ''File content:'' [[WRITE (file statement)|WRITE]] string values will include quotation marks, but they are not required to read the file value as a string. - - -''Example 2:'' Commas inside of string values will not affect the INPUT value as those commas are not [[WRITE (file statement)|WRITE]] separators. -{{CodeStart}} -x$ = "Hello, how are you?" -y$ = "I'm fine." - -{{Cl|OPEN}} "testinp.dat" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|WRITE (file statement)|WRITE}} #1, x$, y$ -{{Cl|CLOSE}} #1 - - -{{Cl|OPEN}} "testinp.dat" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 - -{{Cl|INPUT (file statement)|INPUT}} #1, a$, b$ -{{Cl|CLOSE}} #1 - -{{Cl|PRINT}} a$, b$ -{{Cl|WRITE}} a$, b$ -{{CodeEnd}} -{{OutputStart}}Hello, how are you? I'm fine. -"Hello, how are you?","I'm fine."{{OutputEnd}} -{{TextStart}}"Hello, how are you?","I'm fine."{{TextEnd}} -: ''File content:'' Commas inside of strings delimited with quotes will be ignored. [[WRITE (file statement)|WRITE]] will always enclose string values in quotes. - - -{{PageSeeAlso}} -* [[INPUT (file mode)]], [[LINE INPUT (file statement)|LINE INPUT #]], [[INPUT$]] {{text|(file input)}} -* [[INPUT]], [[LINE INPUT]], [[INPUT$]] {{text|(keyboard input)}} -* [[PRINT (file statement)|PRINT #]], [[PRINT USING (file statement)|PRINT #, USING]] -* [[GET|GET #]] - - -{{PageNavigation}} diff --git a/internal/help/INPUT_11111.txt b/internal/help/INPUT_11111.txt deleted file mode 100644 index 4e3576f8f..000000000 --- a/internal/help/INPUT_11111.txt +++ /dev/null @@ -1,88 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:41}} -The [[INPUT]] statement requests a [[STRING]] or numerical keyboard entry from the user. - - -{{PageSyntax}} -: [[INPUT]] [;] "[Question or statement text]"{,|;} {{Parameter|variable}}[, ...] -: [[INPUT]] ; {{Parameter|variable}}[, ...] - - -{{Parameters}} -* A [[semicolon]] after the [[INPUT]] keyword keeps the entry on the same row after enter is pressed and prevents the screen contents from rolling up. -* The optional prompt "Question or statement text" must be a literal predefined [[STRING|string]]. '''The prompt cannot use a variable.''' -* [[Quotation mark]]s are required except when a semicolon follows [[INPUT]]. A question mark will appear before the cursor. -* A [[semicolon]] immediately after the text statement will display a question mark with a space after it. Use a [[comma]] for input statements. - - -{{PageDescription}} -* '''QB64''' does not return ''Redo from start'' errors like QBasic did, as user input is limited to the scope of the variable [[Data types|type]] used. -* Text entries (with a [[STRING]] variable]] can receive any characters, including numerical. '''QB64 will ignore commas in single variable text entries.''' -* The [[Data types|type]] of the {{Parameter|variable}} used to store user input determines the valid numerical range for value entries in QB64, with non-numerical characters limited to D, E, [[&H]], [[&O]] or [[&B]]. -** For example, if you use an [[INTEGER]] variable, as in {{InlineCode}}INPUT "Initial value: ", myValue%{{InlineCodeEnd}}, the valid range is -32768 to 32767. -** [[INTEGER]], [[LONG]], and [[_INTEGER64]] entries will ignore decimal points entered and will use all numbers. -* INPUT can be used to get more than one {{Parameter|variable}} value from the user. Do so by separating input variables with commas in the code. -** The program must inform the user that more than one variable is requested, in order to enter each value separated with a comma at runtime. -** [[STRING|String]] and numerical variables can both be used in multiple entry requests separated by commas. -** '''QB64''' allows comma separated entries to be skipped by the user without generating an error. -* '''Use [[LINE INPUT]] for text input entries that may contain commas such as address or name entries.''' -* The user must press enter for the INPUT procedure to end. -* [[INPUT]] accepts the [[scientific notation]] letters D or E in [[SINGLE]] or [[DOUBLE]] numerical values. -* Numerical values starting with [[&H]], [[&O]] and [[&B]] can also be entered. - -* The statement halts a program until enter is pressed, which may not be desired in programs using mouse input (see [[INKEY$]] loops). -* Use [[_DEST]] [[_CONSOLE]] before INPUT statements to receive input from a [[$CONSOLE|console]] window. - - -{{PageExamples}} -''Example 1:'' Using a variable in an input text message using PRINT. INPUT prompts cannot use variables. -{{CodeStart}} -{{Cl|INPUT}} "Enter your name: ", name$ -{{Cl|PRINT}} name$ + " please enter your age: ";: {{Cl|INPUT}} "", age% 'empty string with comma -{{Cl|PRINT}} name$ + " how much do you weigh"; : {{Cl|INPUT}} weight% 'no text adds ? -{{CodeEnd}} -:''Explanation:'' Use an empty string with a comma to eliminate the question mark that would appear without the string. - - -''Example 2:'' How QB64 avoids a ''Redo from start'' multiple entry error. Use commas between values. -{{CodeStart}} -{{Cl|DO}} - {{Cl|INPUT}} "What is your name, age, and sex(M/F)"; name$, age%, sex$ -{{Cl|LOOP}} {{Cl|UNTIL}} age% 'loop until age is not 0 -{{Cl|IF}} age% >= 21 {{Cl|THEN}} {{Cl|PRINT}} "You can drink beer!" {{Cl|ELSE}} {{Cl|PRINT}} "You cannot drink beer yet!" -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} -What is your name, age, and sex(M/F)? Tom,24,M -You can drink beer! -{{OutputEnd}} -:''Explanation:'' Try to enter text for the age value and it will not work. E or D should be allowed as decimal point numerical entries. - - -''Example 3:'' Preventing screen roll after an input entry on the bottom 2 screen rows. -{{CodeStart}} -{{Cl|SCREEN}} 12 - -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 29, 2 ' place cursor at beginning of prompt line -{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen with input to follow -{{Cl|COLOR}} 15: {{Cl|INPUT}} {{text|;|red}} "", name$ ' get search name from user -{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} {{Cl|SPC}}(78); ' erase previous prompt -n$ = {{Cl|UCASE$}}(name$) ' convert search name to upper case -{{Cl|COLOR}} 14' change foreground color to yellow -{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} "Searching..."; 'print message -{{Cl|SLEEP}} -{{CodeEnd}} -{{OutputStart}}{{text|Enter a name to search for...|#FFFF00}} â–ˆ -{{OutputEnd}} -: ''Explanation:'' The {{text|red|red}} [[semicolon]] after INPUT acts like a semicolon after a [[PRINT]], which keeps the print cursor on the same row. - - -{{PageSeeAlso}} -* [[INPUT$]], [[INKEY$]] -* [[LINE INPUT]], [[LOCATE]] -* [[INPUT (file statement)|INPUT #]], [[LINE INPUT (file statement)|LINE INPUT #]] {{text|(file input)}} -* [[_KEYHIT]], [[_KEYDOWN]] -* [[Scancodes]] - - -{{PageNavigation}} diff --git a/internal/help/INP_111.txt b/internal/help/INP_111.txt deleted file mode 100644 index 92c654596..000000000 --- a/internal/help/INP_111.txt +++ /dev/null @@ -1,122 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:39}} -[[INP]] returns a value from a computer register or port values at a specified physical address. - - -{{PageSyntax}} -: {{Parameter|i}} = [[INP]]({{Parameter|address}}) - - -* '''QB64 has limited access to registers. VGA memory and registers are emulated.''' -* Address can be a decimal or hexadecimal [[INTEGER]] value. -* [[INP]] reads directly from a register or port address. -* It does not require a [[DEF SEG]] memory segment address like [[PEEK]] or [[POKE]] do. -* Reads color port intensity settings after {{InlineCode}}[[OUT]] &H3C7, attribute{{InlineCodeEnd}} sets the starting attribute read mode. - - -{{PageExamples}} -''Example 1:'' Reading the current RGB color settings used in a bitmap to an array. -{{CodeStart}} - SCREEN 12 - {{Cl|DIM}} Colors%(47) - {{Cl|OUT}} &H3C7, 0 ' set color port for INP reads at attribute 0 to start - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 47 - Colors%(i) = {{Cl|INP}}(&H3C9) ' moves to next color attribute every 3 loops - {{Cl|NEXT}} -{{CodeEnd}} - - -''Example 2:'' Reading the keyboard Scan Codes as an alternative to [[INKEY$]] -{{CodeStart}} - {{Cl|DO}}: {{Cl|SLEEP}} - scancode% = {{Cl|INP}}(&H60) - a$ = {{Cl|INKEY$}} ' clears keyboard buffer - {{Cl|PRINT}} scancode%; - {{Cl|LOOP}} {{Cl|UNTIL}} scancode% = 1 ' [ESC] keypress exit -{{CodeEnd}} - - -''Example 3:'' A simple ping pong game using an array function to read multiple keys for two players. -{{CodeStart}} -{{Cl|DEFINT}} A-Z -{{Cl|SCREEN}} 12 -{{Cl|DIM}} ball%(100) ' Set aside enough space to hold the ball sprite -{{Cl|CIRCLE}} (4, 3), 4, 4 -{{Cl|PAINT}} (4, 3), 12, 4 ' Draw a filled circle and fill for ball -{{Cl|GET (graphics statement)|GET}} (0, 0)-(8, 7), ball%(0) ' Get the sprite into the Ball% array - -begin: -xmin = 10: ymin = 10 -xmax = 630: ymax = 470 -x = 25: y = 25 -dx = 1: dy = 1 -LTpos = 50: RTpos = 50 - -DO: {{Cl|_LIMIT}} 100 'adjust higher for faster -{{Cl|CLS}} -{{Cl|IF...THEN|IF}} ScanKey%(17) {{Cl|THEN}} LTpos = LTpos - 1 -{{Cl|IF...THEN|IF}} ScanKey%(31) {{Cl|THEN}} LTpos = LTpos + 1 -{{Cl|IF...THEN|IF}} ScanKey%(72) {{Cl|THEN}} RTpos = RTpos - 1 -{{Cl|IF...THEN|IF}} ScanKey%(80) {{Cl|THEN}} RTpos = RTpos + 1 - -{{Cl|PRINT}} "Player 1 : "; ponescore; " Player 2 : "; ptwoscore - -{{Cl|IF...THEN|IF}} x > xmax - 15 {{Cl|AND (boolean)|AND}} y >= RTpos {{Cl|AND (boolean)|AND}} y <= RTpos + 100 {{Cl|THEN}} -dx = -1 -{{Cl|ELSEIF}} x > xmax {{Cl|THEN}} -ponescore = ponescore + 1 -{{Cl|GOSUB}} begin -{{Cl|END IF}} - -{{Cl|IF...THEN|IF}} x < xmin + 15 {{Cl|AND (boolean)|AND}} y >= LTpos {{Cl|AND (boolean)|AND}} y <= LTpos + 100 {{Cl|THEN}} -dx = 1 -{{Cl|ELSEIF}} x < xmin {{Cl|THEN}} -ptwoscore = ptwoscore + 1 -{{Cl|GOSUB}} begin -{{Cl|END IF}} - -{{Cl|IF...THEN|IF}} y > ymax - 5 {{Cl|THEN}} dy = -1 -{{Cl|IF...THEN|IF}} y < ymin + 5 {{Cl|THEN}} dy = 1 -' Display the sprite elsewhere on the screen - -x = x + dx -y = y + dy - -{{Cl|PUT (graphics statement)|PUT}}(x, y), ball%(0) - - -{{Cl|LINE}} (20, LTpos)-(20, LTpos + 100) -{{Cl|LINE}} (620, RTpos)-(620, RTpos + 100) - -{{Cl|_DISPLAY}} 'shows completed screen every call - -{{Cl|LOOP}} {{Cl|UNTIL}} ScanKey%(1) -{{Cl|END}} - - -{{Cl|FUNCTION}} ScanKey% (scancode%) -{{Cl|STATIC}} Ready%, keyflags%() -{{Cl|IF...THEN|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} keyflags%(0 {{Cl|TO}} 127): Ready% = -1 -i% = {{Cl|INP}}({{Cl|&H}}60) 'read keyboard states -{{Cl|IF...THEN|IF}} (i% {{Cl|AND (boolean)|AND}} 128) {{Cl|THEN}} keyflags%(i% {{Cl|XOR (boolean)|XOR}} 128) = 0 -{{Cl|IF...THEN|IF}} (i% {{Cl|AND (boolean)|AND}} 128) = 0 {{Cl|THEN}} keyflags%(i%) = -1 -K$ = {{Cl|INKEY$}} -ScanKey% = keyflags%(scancode%) -{{Cl|END FUNCTION}} -{{CodeEnd}} -: ''Note:'' [[_KEYDOWN]] can be used to read multiple keys simultaneously and is the '''recommended practice'''. - - -{{PageSeeAlso}} -* [[OUT]] {{text|(write to register)}}, [[PEEK]] {{text|(read memory)}} -* [[INKEY$]], [[_KEYHIT]], [[_KEYDOWN]] -* [[Bitmaps]], [[Scancodes]] {{text|(keyboard)}} -* [[Port Access Libraries]] {{text|(COM or LPT registers)}} - - -===External Links=== -* [http://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers PC I/O base address device assignments] - - - -{{PageNavigation}} diff --git a/internal/help/INSTR_11111.txt b/internal/help/INSTR_11111.txt deleted file mode 100644 index 811c1ff94..000000000 --- a/internal/help/INSTR_11111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:46}} -The [[INSTR]] function searches for the first occurence of a search [[STRING]] within a base string and returns the position it was found. - - -{{PageSyntax}} -: {{Parameter|position%}} = [[INSTR]]([{{Parameter|start%}},] {{Parameter|baseString$}}, {{Parameter|searchString$}}) - - -{{Parameters}} -* The optional literal or variable [[INTEGER]] {{Parameter|start%}} indicates where in the {{Parameter|baseString$}} the search must start. -* The {{Parameter|baseString$}} is a literal or variable [[STRING]] value to be searched for an exact match including [[UCASE$|letter cases]]. -* The {{Parameter|searchString$}} is a literal or variable [[STRING]] value being searched. - - -{{PageDescription}} -* The function returns the {{Parameter|position%}} in the {{Parameter|baseString$}} where the {{Parameter|searchString$}} was found. -* {{Parameter|position%}} will be 0 if the search found no matches in the base string. -* [[INSTR]] returns 0 if an empty {{Parameter|baseString$}} is passed, and returns 1 with an empty {{Parameter|searchString$}}. -* The {{Parameter|start%}} position is useful when making multiple searches in the same string. See the example below. -* The {{Parameter|searchString$}} should be smaller or equal in [[LEN|length]] to the {{Parameter|baseString$}}, or 0 is returned. -* Non-zero {{Parameter|position%}} return values can be used as a new start position by adding 1 to re-search the base string. See the example below. -* In a loop, INSTR can search an entire file for occurences of certain words. See the [[MID$ (statement)|MID$]] statement example. - - -==QBasic/QuickBASIC== -* The {{Parameter|start%}} position had to be at least 1 or greater when used or there will be an [[ERROR Codes|Illegal function call]] error. In '''QB64''', a {{Parameter|start%}} value of 0 or negative is interpreted as 1 and doesn't generate an error. - - -{{PageExamples}} -''Example:'' Reading more than one instance of a word in a string using the INSTR return value as the start value plus 1. -{{CodeStart}} -text$ = "The cats and dogs where playing, even though dogs don't like cats." -{{Cl|DO...LOOP|DO}} - findcats% = {{Cl|INSTR}}(findcats% + 1, text$, "cats") ' find another occurance after - {{Cl|IF...THEN|IF}} findcats% {{Cl|THEN}} {{Cl|PRINT}} "There is 'cats' in the string at position:"; findcats% -{{Cl|LOOP}} {{Cl|UNTIL}} findcats% = 0 - -findmonkey% = {{Cl|INSTR}}(text$, "monkeys") ' find any occurance? -PRINT findmonkey%; "'monkeys' were found so it returned:"; findmonkey% -{{CodeEnd}} -{{OutputStart}}There is 'cats' in the string at position: 5 -There is 'cats' in the string at position: 62 - 0 'monkeys' were found so INSTR returned: 0 -{{OutputEnd}} -: ''Explanation:'' When the INSTR return value is 0 there are no more instances of a string in a string so the search loop is exited. - - -{{PageSeeAlso}} -* [[MID$]], [[MID$ (statement)]] -* [[LEFT$]], [[RIGHT$]] -* [[LCASE$]], [[UCASE$]] -* [[STRING]], [[INTEGER]] - - -{{PageNavigation}} diff --git a/internal/help/INTEGER_1111111.txt b/internal/help/INTEGER_1111111.txt deleted file mode 100644 index 86c705811..000000000 --- a/internal/help/INTEGER_1111111.txt +++ /dev/null @@ -1,63 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:48}} -[[INTEGER]] is a 2-byte number type definition that can hold whole numerical values. - - -{{PageSyntax}} -: [[DIM]] ''variable'' AS [[INTEGER]] - - -* Integers do not use decimal point values but will round those off to the nearest even whole number. -* QBasic integer values can range from -32768 to 32767 without an "overflow" error. -* For larger integer values use the [[LONG]] integer type. -* '''QB64''' [[INTEGER]] values greater than 32767 become negative signed values instead of throwing an "overflow" error, as the top bit designates a negative value. See example 1 below. -* '''QB64''' [[_UNSIGNED]] integers can range from 0 to 65535. -* '''QB64''' _UNSIGNED [[_INTEGER64]] values range from 0 to 18446744073709551615 -* Many graphic programs require [[INTEGER]] arrays. -* Variable type suffix is % or ~% for [[_UNSIGNED]]. Suffix can also be placed after a literal or hexadecimal numerical value. -* [[LONG]] integers use the '''&''' suffix and [[_INTEGER64]] use the '''&&''' suffix. -* Values can be converted to 2 byte [[ASCII]] string values using [[MKI$]] and back with [[CVI]]. -* '''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.''' - - -{{PageExamples}} -''Example 1:'' QBasic signed integers were limited from -32768 to 32767, but could not exceed 32767 or it would error: -{{CodeStart}} -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 2000 - i% = i% + 1 - {{Cl|PRINT}} i% -{{Cl|LOOP}} {{Cl|UNTIL}} i% = 0 -{{CodeEnd}} -:''Explanation:'' In '''QB64''' the count will go to 32767, then count up from -32768 to 0 before repeating the process without error. - - -''Example 2:'' When a signed '''QB64''' INTEGER value exceeds 32767, the value may become a negative value: -{{CodeStart}} -i% = 38000 -{{Cl|PRINT}} i% -{{CodeEnd}}{{OutputStart}}-27536 -{{OutputEnd}} -:''Explanation:'' Use an [[_UNSIGNED]] INTEGER or a ~% variable type suffix for only positive integer values up to 65535. - - -''Example 3:'' In '''QB64''' [[_UNSIGNED]] INTEGER values greater than 65535 cycle over again from zero: -{{CodeStart}} -i~% = 70000 -{{Cl|PRINT}} i~% -{{CodeEnd}}{{OutputStart}} 4464 -{{OutputEnd}} -:''Explanation:'' In QB64 an unsigned integer value of 65536 would be 0 with values increasing by the value minus 65536. - - -{{PageSeeAlso}} -* [[DIM]], [[DEFINT]] -* [[LONG]], [[_INTEGER64]] -* [[LEN]], [[MKI$]], [[CVI]] -* [[_DEFINE]], [[_UNSIGNED]] -* [[Variable Types]] -* [[&B]] (binary), [[&O]] (octal), [[&H]] (hexadecimal) -* [[\|Integer Division]], [[MOD]] (Integer remainder division) - - -{{PageNavigation}} diff --git a/internal/help/INTERRUPTX_1111111111.txt b/internal/help/INTERRUPTX_1111111111.txt deleted file mode 100644 index 99bad390b..000000000 --- a/internal/help/INTERRUPTX_1111111111.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:51}} -The [[INTERRUPTX]] statement is an assembly routine for accessing computer information registers. - - -{{PageSyntax}} -: [[CALL]] [[INTERRUPTX]]({{Parameter|intNum}}, {{Parameter|inRegs}}, {{Parameter|outRegs}}) - - -===Legacy support=== -* Registers are emulated in '''QB64''' to allow older programs to be compiled. To enable mouse input in your programs, the recommended practice is to use [[_MOUSEINPUT]] and related functions. - - -{{Parameters}} -* Registers are emulated in QB64 and there is no support for {{Parameter|intNum}} 33h mouse functions above 3 or {{Parameter|intNum}} requests other than 33. -* {{Parameter|inRegs}} are the values placed into the call and {{Parameter|outRegs}} are the register return values. - - -==QBasic/QuickBASIC== -* Available in QuickBASIC versions 4 and up and required an external library to be loaded. '''QB64''' emulates the statement without an external library. -* {{Parameter|intNum}} is the interrupt reference vector table address. For historic reference, see: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List] -* The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls -* INTERRUPT can use all of the below TYPE elements when they are required. -{{TextStart}} -{{Cb|TYPE}} RegTypeX - ax AS INTEGER - bx AS INTEGER - cx AS INTEGER - dx AS INTEGER - bp AS INTEGER - si AS INTEGER - di AS INTEGER - flags AS INTEGER - ds AS INTEGER - es AS INTEGER -{{Cb|END TYPE}} -{{TextEnd}} -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} inregs {{Cl|AS}} RegTypeX, outregs {{Cl|AS}} RegTypeX -{{CodeEnd}} -: QBasic's ''RegType.BI'' $INCLUDE file can be used by INTERRUPT or [[INTERRUPTX]] - - -{{PageSeeAlso}} -* [[$INCLUDE|$INCLUDE:]] -* [[QB.BI]], [[CALL ABSOLUTE]] -* [[INTERRUPT]] -* Ethan Winer's free QBasic Book and Programs: [http://www.ethanwiner.com/fullmoon.html WINER.ZIP] - - -{{PageNavigation}} diff --git a/internal/help/INTERRUPT_111111111.txt b/internal/help/INTERRUPT_111111111.txt deleted file mode 100644 index 32245400e..000000000 --- a/internal/help/INTERRUPT_111111111.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:50}} -The [[INTERRUPT]] statement is an assembly routine for accessing computer information registers. - - -{{PageSyntax}} -: [[CALL]] [[INTERRUPT]]({{Parameter|intNum}}, {{Parameter|inRegs}}, {{Parameter|outRegs}}) - - -===Legacy support=== -* Registers are emulated in '''QB64''' to allow older programs to be compiled. To enable mouse input in your programs, the recommended practice is to use [[_MOUSEINPUT]] and related functions. - - -{{Parameters}} -* Registers are emulated in QB64 and there is no support for {{Parameter|intNum}} 33h mouse functions above 3 or {{Parameter|intNum}} requests other than 33. -* {{Parameter|inRegs}} are the values placed into the call and {{Parameter|outRegs}} are the register return values. - - -==QBasic/QuickBASIC== -* Available in QuickBASIC versions 4 and up and required an external library to be loaded. '''QB64''' emulates the statement without an external library. -* {{Parameter|intNum}} is the interrupt reference vector table address. For historic reference, see: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List] -* The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls -* INTERRUPT can use all of the below TYPE elements when they are required. -{{TextStart}} -{{Cb|TYPE}} RegTypeX - ax AS INTEGER - bx AS INTEGER - cx AS INTEGER - dx AS INTEGER - bp AS INTEGER - si AS INTEGER - di AS INTEGER - flags AS INTEGER - ds AS INTEGER - es AS INTEGER -{{Cb|END TYPE}} -{{TextEnd}} -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} inregs {{Cl|AS}} RegTypeX, outregs {{Cl|AS}} RegTypeX -{{CodeEnd}} -: QBasic's ''RegType.BI'' $INCLUDE file can be used by INTERRUPT or [[INTERRUPTX]] - - -{{PageSeeAlso}} -* [[$INCLUDE|$INCLUDE:]] -* [[QB.BI]], [[CALL ABSOLUTE]] -* [[INTERRUPTX]] -* Ethan Winer's free QBasic Book and Programs: [http://www.ethanwiner.com/fullmoon.html WINER.ZIP] - - -{{PageNavigation}} diff --git a/internal/help/INT_111.txt b/internal/help/INT_111.txt deleted file mode 100644 index d3a1b9ec5..000000000 --- a/internal/help/INT_111.txt +++ /dev/null @@ -1,38 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:47}} -The [[INT]] function rounds a numeric value down to the next whole number. - - -{{PageSyntax}} -: {{Parameter|result}} = [[INT]]({{Parameter|expression}}) - - -{{Parameters}} -* {{Parameter|expression}} is any [[Data types|type]] of literal or variable numerical value or mathematical calculation. - - -{{PageDescription}} -* [[INT]] returns the first whole number [[INTEGER]] that is less than the {{Parameter|expression}} value. -* This means that [[INT]] rounds down for both positive and negative numbers. -* Use [[FIX]] to round negative values up. It is identical to [[INT]] for positive values. - - -{{PageExamples}} -''Example:'' Displaying the rounding behavior of [[INT]]. -{{CodeStart}} -PRINT INT(2.5) -PRINT INT(-2.5) -{{CodeEnd}} -{{OutputStart}} - 2 --3 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[CINT]], [[CLNG]], [[FIX]] -* [[CSNG]], [[CDBL]] -* [[_ROUND]], [[_CEIL]] - - -{{PageNavigation}} diff --git a/internal/help/KEY(n)_111(0).txt b/internal/help/KEY(n)_111(0).txt deleted file mode 100644 index 4f6397231..000000000 --- a/internal/help/KEY(n)_111(0).txt +++ /dev/null @@ -1,71 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:53}} -'''KEY(n)''' assigns, enables, disables or suspends event trapping of a keypress by setting the flag [[ON]], [[STOP]] or [[OFF]]. - - -{{PageSyntax}} -: KEY({{Parameter|number}}) {[[ON]] | [[OFF]] | [[STOP]]} - - -{{PageDescription}} -* Predefined and user defined KEY event number assignments to use with KEY(n): -{{WhiteStart}} '''1 to 10'''.............Reserved '''F1 to F10''' function keys only. - '''11, 12, 13 and 14'''...Reserved '''Up, Left, Right and Down''' numeric keypad arrows only - '''15 to 29'''............'''user-defined keys''' using value: [[CHR$]](keyflag) + [[CHR$]]([[Keyboard scancodes|scancode]]) - '''30 and 31'''...........Reserved '''F11 and F12''' function keys only. -{{WhiteEnd}} -* Keypresses can be read during [[INKEY$]], [[INPUT$]] or [[INPUT]] procedures without losing the input. -* Key event reads will also interrupt [[SLEEP]]. -* [[KEY(n)]] specific status modes are: -**'''ON''' enables specific keypress events to be monitored. -**'''STOP''' suspends specific keypress reads, but remembers them. When re-enabled the key presses will be returned. -**'''OFF''' disables specified keypress reads and will not remember the event. - - -{{PageExamples}} -''Example 1:'' How to trap the LEFT direction keys on both the dedicated cursor keypad and the numeric keypad. -{{CodeStart}} -{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(75) ' Assign trap for LEFT arrow key on the cursor keypad -{{Cl|ON KEY(n)|ON KEY(15)}} {{Cl|GOSUB}} CursorPad -{{Cl|KEY(n)|KEY(15)}} {{Cl|ON}} ' enable event trapping - -{{Cl|ON KEY(n)|ON KEY(12)}} {{Cl|GOSUB}} NumericPad ' Trap LEFT key on number pad -{{Cl|KEY(n)|KEY(12)}} {{Cl|ON}} ' enable event trapping - -DO -LOOP UNTIL UCASE$(INKEY$) = "Q" ' Idle loop for demo -{{Cl|SYSTEM}} - -CursorPad: -PRINT "Pressed LEFT key on cursor keypad." -{{Cl|RETURN}} - -NumericPad: -PRINT "Pressed LEFT key on numeric keypad." -RETURN -{{CodeEnd}} - - -''Example 2:'' Trapping the F5 keypress. -{{CodeStart}} -{{Cl|KEY(n)|KEY(5)}} {{Cl|ON}} -{{Cl|ON KEY(n)|ON KEY(5)}} {{Cl|GOSUB}} execute -{{Cl|PRINT}} "Press F5 (or ESC) to quit!)" -{{Cl|DO}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) ' idle loop -{{Cl|SYSTEM}} -execute: -PRINT "You pressed the F5 key..." -{{Cl|SLEEP}} 1 -PRINT "Press any key to continue..." -SLEEP -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[ON KEY(n)]], [[KEY n]] {{text|(softkeys)}} -* [[_KEYHIT]], [[_KEYDOWN]] -* [[Keyboard scancodes]] - - -{{PageNavigation}} diff --git a/internal/help/KEY_LIST_111_1111.txt b/internal/help/KEY_LIST_111_1111.txt deleted file mode 100644 index 0a2c0b6d9..000000000 --- a/internal/help/KEY_LIST_111_1111.txt +++ /dev/null @@ -1,215 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:54}} -The [[KEY n]] statement is used to assign a "soft key" string or a flag and scan code to a function key or display function soft key assignments. - -{{PageSyntax}} - -: '''KEY ''n%'', ''textString$''''' - -: '''KEY ''n%'', CHR$(''keyFlag%'') + CHR$(''scanCode'')''' - - -==Function Soft Key Strings (1 to 10, 30 & 31)== - -
'''Assigning "Softkey" [[STRING]] values to function key press events'''
- -* n% is the number 1 to 10 (F1 to F10), 30 or 31 (F11 or F12) of the function key to assign the soft key string. -* Instead of using an [[ON KEY(n)]] [[GOSUB]] statement, Function keys F1 to F12 can be assigned a "soft key" string value to return. -* {{InlineCode}}KEY n, text${{InlineCodeEnd}} defines a literal or variable [[STRING]] "soft key" function key return value. - -{{WhiteStart}} '''KEY 1, "Help"''' 'returns the string "Help" to [[INPUT]] variable when F1 is pressed{{WhiteEnd}} - -* [[KEY LIST]] displays each of the 12 softkey '''function key''' (F1 to F12) string values going down left side of screen. -* [[KEY LIST|KEY {ON|OFF}]] displays or hides the softkey values of function keys F1 to F10 at the bottom of the screen. - - -==Number Pad Arrow Keys (11 to 14)== - -* Arrow keys on the Number Pad are predefined KEY numbers 11 to 14 and only work with Number Lock off. -* Soft Key [[STRING]]s cannot be assigned to these key numbers! -* To use the extended arrow keys on a keyboard use the Extended Key Flag 128 with corresponding Scan code as User Defined Keys. - - -==User Defined Keys (15 to 29)== - -
'''Assigning user defined keys or combinations with: KEY n, CHR$(keyflag) + CHR$(scancode)'''
-{{WhiteStart}} '''Function Key Flag Combination Values''' - - '''0''' = no function key combination flag(single key) - '''1''' = Left Shift key flag - '''2''' = Right Shift key flag - '''4''' = Ctrl flag - '''8''' = Alt flag - '''32''' = Number Lock flag - '''64''' = Caps Lock flag - '''128''' = Extended keys (see trapping extended keys below) - - Flag values can be added to monitor multiple function key combinations. -{{WhiteEnd}} -* After the keyflag code character the [[Scancodes|scancode]] character is added using one of the two '''trapping methods''' that follow: -{{WhiteStart}}' '''Soft Key Scan Code Values''' -' -' {{text|1 2 3 4 5 6 7 8 9 10 30 31 Predefined Keys|red}} -'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause''' -' 1 59 60 61 62 63 64 65 66 67 68 87 88 -- 70 29 -' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -''' -' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 {{text|82 71 73|blue}} {{text|32|purple}}/69 {{text|53|blue}} 55 74 -' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/â–² 9/PU + ''' -' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 {{text|83 79 81|blue}} 71 {{text|11|red}}/72 73 78 -' '''CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º E''' -' {{text|64|purple}}/58 30 31 32 33 34 35 36 37 38 39 40 28 {{text|12|red}}/75 76 {{text|13|red}}/77 '''n''' -' '''Shift Z X C V B N M ,< .> /? Shift â–² 1/End 2/â–¼ 3/PD t''' -' {{text|1|purple}}/42 44 45 46 47 48 49 50 51 52 53 {{text|2|purple}}/54 {{text|72|blue}} 79 {{text|14|red}}/80 81 '''e''' -' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0/Insert ./Del r''' -' {{text|4|purple}}/29 {{text|91|orange}} {{text|8|purple}}/56 57 {{text|56|blue}} {{text|92 93|orange}} {{text|29 75 80 77|blue}} 82 83 {{text|28|blue}} -' -' '''Keyflag:''' {{text|Function(0, 1, 2, 4, 8, 32, 64)|purple}}, {{text|Extended(128)|blue}} '''Scan Code: '''1-88, {{text|QB64 only(91-93)|orange}} -' -' Reserved and function key combinations can be made using the scan code instead. -' Add function flag values to 128 for Extended key combinations. -{{WhiteEnd}}{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}} - - -
'''Trapping Ctrl, Alt and Shift key combinations'''
-:Keyboard Flag values can be added to monitor more than one control key. For example, flag combination 12 would flag both the Ctrl and Alt key presses. Since the flag already determines the function key to monitor, you don't necessarily have to use it's scancode. You can look for a key combination such as Ctrl + by using the plus key's scancode which is 13 as shown below: - -{{WhiteStart}} '''KEY 15, CHR$(4) + CHR$(13)''' 'enabled event when Ctrl and + key are pressed{{WhiteEnd}} - - -
'''Trapping Extended keys (Insert, Home, Page Up, Right Ctrl, R.Alt, and cursor arrow pad)'''
-* On a 101-key keyboard, you can trap any of the keys on the dedicated cursorpad by assigning the string to any of the keynumber values from 15 to 25 using the 128 keyboard flag. The cursor arrows are not the same as the pre-assigned number pad arrows: -{{WhiteStart}} '''KEY n, [[CHR$]](128) + [[CHR$]](scancode) ' where n = 15 to 29. See: [[Scancodes]]''' - - KEY 15, CHR$(128) + CHR$(75) 'left arrow cursor pad  - - KEY 16, CHR$(128) + CHR$(72) 'up arrow cursor pad   - - KEY 17, CHR$(128) + CHR$(77) 'right arrow cursor pad - - KEY 18, CHR$(128) + CHR$(80) 'down arrow cursor pad -{{WhiteEnd}} -
Use CHR$(0) for the first byte flag for non-function keys. You can substitute a literal [[STRING]] value to trap as shown in Example 2.
- - -

([[#toc|Return to Table of Contents]])

- - -==Examples== - - -''Example 1:'' Shows a list of all the string assignments to the function keys F1-F12 (Prints help every time F1 is pressed in the input) -{{CodeStart}} -{{Cl|KEY n|KEY}} 1, "Help" -{{Cl|KEY LIST}} -INPUT "Press F1 or to quit press ENTER: ", a$ - -{{CodeEnd}} -{{OutputStart}} -F1 Help -F2 -F3 -F4 -F5 -F6 -F7 -F8 -F9 -F10 -F11 -F12 -Press F1 or to quit press ENTER: HelpHelpHelpHelp -{{OutputEnd}} - - -''Example 2:'' Trapping the Control + key combination. Use the Control Keyboard flag 4 and + key scancode 13. -{{CodeStart}} -{{Cl|CLS}} -{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(4) + {{Cl|CHR$}}(13) 'scancode for "=" or "+" key is 13 -{{Cl|ON KEY (n)|ON KEY}}(15) {{Cl|GOSUB}} control 'action of user defined key press -{{Cl|KEY(n)|KEY}}(15) ON 'turn ON event trapping for key combination -{{Cl|PRINT}} "Press Ctrl and plus key combination, escape quits!" -{{Cl|DO}}: {{Cl|SLEEP}} -count = count + 1 -{{Cl|PRINT}} count; -{{Cl|IF}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) {{Cl|THEN}} {{Cl|END}} 'escape key exit -{{Cl|LOOP}} - -control: 'NUMBER LOCK MUST BE OFF! -{{Cl|PRINT}} "Control and + keys pressed!"; -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} - - -''Example 3:'' Differentiating the extended cursor keypad arrows from the predefined Number Pad arrow keys. -{{CodeStart}} -'predefined keys 11 to 14 for number pad arrows only -{{Cl|ON KEY(n)|ON KEY}}(11) {{Cl|GOSUB}} UpNum: {{Cl|KEY(n)|KEY}}(11) ON 'up -{{Cl|ON KEY(n)|ON KEY}}(12) {{Cl|GOSUB}} LNum: {{Cl|KEY(n)|KEY}}(12) ON 'left -{{Cl|ON KEY(n)|ON KEY}}(13) {{Cl|GOSUB}} RNum: {{Cl|KEY(n)|KEY}}(13) ON 'right -{{Cl|ON KEY(n)|ON KEY}}(14) {{Cl|GOSUB}} DnNum: {{Cl|KEY(n)|KEY}}(14) ON 'down -'user defined keys use extended key flag 128 + scan code -{{Cl|ON KEY(n)|ON KEY}}(15) {{Cl|GOSUB}} UpPad -{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(72): {{Cl|KEY(n)|KEY}}(15) ON 'cursor up -{{Cl|ON KEY(n)|ON KEY}}(16) {{Cl|GOSUB}} LPad -{{Cl|KEY n|KEY}} 16, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(75): {{Cl|KEY(n)|KEY}}(16) ON 'cursor left -{{Cl|ON KEY(n)|ON KEY}}(17) {{Cl|GOSUB}} RPad -{{Cl|KEY n|KEY}} 17, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(77): {{Cl|KEY(n)|KEY}}(17) ON 'cursor right -{{Cl|ON KEY(n)|ON KEY}}(18) {{Cl|GOSUB}} DnPad -{{Cl|KEY n|KEY}} 18, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(80): {{Cl|KEY(n)|KEY}}(18) ON 'cursor down - -{{Cl|DEF SEG}} = 0 -DO - numL = {{Cl|PEEK}}(1047) {{Cl|AND (boolean)|AND}} 32 '32 if on - capL = {{Cl|PEEK}}(1047) {{Cl|AND (boolean)|AND}} 64 '64 on - {{Cl|IF...THEN|IF}} numL {{Cl|OR (boolean)|OR}} capL {{Cl|THEN}} - {{Cl|COLOR}} 12: {{Cl|LOCATE}} 13, 50: {{Cl|PRINT}} "Turn Num or Cap Lock OFF!" - {{Cl|ELSE}} : {{Cl|COLOR}} 10: {{Cl|LOCATE}} 13, 50: {{Cl|PRINT}} "Number and Cap Lock OK! " - {{Cl|SLEEP}} ' {{Cl|KEY n|KEY}} or {{Cl|TIMER}} event breaks a sleep - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|DEF SEG}} - -{{Cl|KEY(n)|KEY}}(15) OFF: {{Cl|KEY(n)|KEY}}(16) OFF: {{Cl|KEY(n)|KEY}}(17) OFF: {{Cl|KEY(n)|KEY}}(18) OFF -{{Cl|KEY(n)|KEY}}(11) OFF: {{Cl|KEY(n)|KEY}}(12) OFF: {{Cl|KEY(n)|KEY}}(13) OFF: {{Cl|KEY(n)|KEY}}(14) OFF -{{Cl|END}} - -UpPad: -COLOR 14: LOCATE 11, 26: PRINT " Up cursor pad " -{{Cl|RETURN}} -LPad: -COLOR 14: LOCATE 11, 26: PRINT "Left cursor pad " -{{Cl|RETURN}} -RPad: -COLOR 14: LOCATE 11, 26: PRINT "Right cursor pad" -{{Cl|RETURN}} -DnPad: -COLOR 14: LOCATE 11, 26: PRINT "Down cursor pad " -{{Cl|RETURN}} -UpNum: -COLOR 11: LOCATE 11, 26: PRINT " Up number pad " -{{Cl|RETURN}} -LNum: -COLOR 11: LOCATE 11, 26: PRINT "Left number pad " -{{Cl|RETURN}} -RNum: -COLOR 11: LOCATE 11, 26: PRINT "Right number pad" -{{Cl|RETURN}} -DnNum: -COLOR 11: LOCATE 11, 26: PRINT "Down number pad " -{{Cl|RETURN}} -{{CodeEnd}} -: ''Explanation:'' The Number Lock or Caps Lock keys ON may hinder extended key reads in QBasic but not QB64! - - -

([[#toc|Return to Table of Contents]])

- - -{{PageSeeAlso}} -* [[KEY LIST]], [[ON KEY(n)]] -* [[KEY(n)]], [[INKEY$]] -* [[_KEYHIT]], [[_KEYDOWN]] -* [[Keyboard scancodes]] - - -{{PageNavigation}} diff --git a/internal/help/KEY_n_111_0.txt b/internal/help/KEY_n_111_0.txt deleted file mode 100644 index 8f6716cf8..000000000 --- a/internal/help/KEY_n_111_0.txt +++ /dev/null @@ -1,215 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:52}} -The [[KEY n]] statement is used to assign a "soft key" string or a flag and scan code to a function key or display function soft key assignments. - -{{PageSyntax}} - -: '''KEY ''n%'', ''textString$''''' - -: '''KEY ''n%'', CHR$(''keyFlag%'') + CHR$(''scanCode'')''' - - -==Function Soft Key Strings (1 to 10, 30 & 31)== - -
'''Assigning "Softkey" [[STRING]] values to function key press events'''
- -* n% is the number 1 to 10 (F1 to F10), 30 or 31 (F11 or F12) of the function key to assign the soft key string. -* Instead of using an [[ON KEY(n)]] [[GOSUB]] statement, Function keys F1 to F12 can be assigned a "soft key" string value to return. -* {{InlineCode}}KEY n, text${{InlineCodeEnd}} defines a literal or variable [[STRING]] "soft key" function key return value. - -{{WhiteStart}} '''KEY 1, "Help"''' 'returns the string "Help" to [[INPUT]] variable when F1 is pressed{{WhiteEnd}} - -* [[KEY LIST]] displays each of the 12 softkey '''function key''' (F1 to F12) string values going down left side of screen. -* [[KEY LIST|KEY {ON|OFF}]] displays or hides the softkey values of function keys F1 to F10 at the bottom of the screen. - - -==Number Pad Arrow Keys (11 to 14)== - -* Arrow keys on the Number Pad are predefined KEY numbers 11 to 14 and only work with Number Lock off. -* Soft Key [[STRING]]s cannot be assigned to these key numbers! -* To use the extended arrow keys on a keyboard use the Extended Key Flag 128 with corresponding Scan code as User Defined Keys. - - -==User Defined Keys (15 to 29)== - -
'''Assigning user defined keys or combinations with: KEY n, CHR$(keyflag) + CHR$(scancode)'''
-{{WhiteStart}} '''Function Key Flag Combination Values''' - - '''0''' = no function key combination flag(single key) - '''1''' = Left Shift key flag - '''2''' = Right Shift key flag - '''4''' = Ctrl flag - '''8''' = Alt flag - '''32''' = Number Lock flag - '''64''' = Caps Lock flag - '''128''' = Extended keys (see trapping extended keys below) - - Flag values can be added to monitor multiple function key combinations. -{{WhiteEnd}} -* After the keyflag code character the [[Scancodes|scancode]] character is added using one of the two '''trapping methods''' that follow: -{{WhiteStart}}' '''Soft Key Scan Code Values''' -' -' {{text|1 2 3 4 5 6 7 8 9 10 30 31 Predefined Keys|red}} -'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause''' -' 1 59 60 61 62 63 64 65 66 67 68 87 88 -- 70 29 -' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -''' -' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 {{text|82 71 73|blue}} {{text|32|purple}}/69 {{text|53|blue}} 55 74 -' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/â–² 9/PU + ''' -' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 {{text|83 79 81|blue}} 71 {{text|11|red}}/72 73 78 -' '''CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º E''' -' {{text|64|purple}}/58 30 31 32 33 34 35 36 37 38 39 40 28 {{text|12|red}}/75 76 {{text|13|red}}/77 '''n''' -' '''Shift Z X C V B N M ,< .> /? Shift â–² 1/End 2/â–¼ 3/PD t''' -' {{text|1|purple}}/42 44 45 46 47 48 49 50 51 52 53 {{text|2|purple}}/54 {{text|72|blue}} 79 {{text|14|red}}/80 81 '''e''' -' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0/Insert ./Del r''' -' {{text|4|purple}}/29 {{text|91|orange}} {{text|8|purple}}/56 57 {{text|56|blue}} {{text|92 93|orange}} {{text|29 75 80 77|blue}} 82 83 {{text|28|blue}} -' -' '''Keyflag:''' {{text|Function(0, 1, 2, 4, 8, 32, 64)|purple}}, {{text|Extended(128)|blue}} '''Scan Code: '''1-88, {{text|QB64 only(91-93)|orange}} -' -' Reserved and function key combinations can be made using the scan code instead. -' Add function flag values to 128 for Extended key combinations. -{{WhiteEnd}}{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}} - - -
'''Trapping Ctrl, Alt and Shift key combinations'''
-:Keyboard Flag values can be added to monitor more than one control key. For example, flag combination 12 would flag both the Ctrl and Alt key presses. Since the flag already determines the function key to monitor, you don't necessarily have to use it's scancode. You can look for a key combination such as Ctrl + by using the plus key's scancode which is 13 as shown below: - -{{WhiteStart}} '''KEY 15, CHR$(4) + CHR$(13)''' 'enabled event when Ctrl and + key are pressed{{WhiteEnd}} - - -
'''Trapping Extended keys (Insert, Home, Page Up, Right Ctrl, R.Alt, and cursor arrow pad)'''
-* On a 101-key keyboard, you can trap any of the keys on the dedicated cursorpad by assigning the string to any of the keynumber values from 15 to 25 using the 128 keyboard flag. The cursor arrows are not the same as the pre-assigned number pad arrows: -{{WhiteStart}} '''KEY n, [[CHR$]](128) + [[CHR$]](scancode) ' where n = 15 to 29. See: [[Scancodes]]''' - - KEY 15, CHR$(128) + CHR$(75) 'left arrow cursor pad  - - KEY 16, CHR$(128) + CHR$(72) 'up arrow cursor pad   - - KEY 17, CHR$(128) + CHR$(77) 'right arrow cursor pad - - KEY 18, CHR$(128) + CHR$(80) 'down arrow cursor pad -{{WhiteEnd}} -
Use CHR$(0) for the first byte flag for non-function keys. You can substitute a literal [[STRING]] value to trap as shown in Example 2.
- - -

([[#toc|Return to Table of Contents]])

- - -==Examples== - - -''Example 1:'' Shows a list of all the string assignments to the function keys F1-F12 (Prints help every time F1 is pressed in the input) -{{CodeStart}} -{{Cl|KEY n|KEY}} 1, "Help" -{{Cl|KEY LIST}} -INPUT "Press F1 or to quit press ENTER: ", a$ - -{{CodeEnd}} -{{OutputStart}} -F1 Help -F2 -F3 -F4 -F5 -F6 -F7 -F8 -F9 -F10 -F11 -F12 -Press F1 or to quit press ENTER: HelpHelpHelpHelp -{{OutputEnd}} - - -''Example 2:'' Trapping the Control + key combination. Use the Control Keyboard flag 4 and + key scancode 13. -{{CodeStart}} -{{Cl|CLS}} -{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(4) + {{Cl|CHR$}}(13) 'scancode for "=" or "+" key is 13 -{{Cl|ON KEY (n)|ON KEY}}(15) {{Cl|GOSUB}} control 'action of user defined key press -{{Cl|KEY(n)|KEY}}(15) ON 'turn ON event trapping for key combination -{{Cl|PRINT}} "Press Ctrl and plus key combination, escape quits!" -{{Cl|DO}}: {{Cl|SLEEP}} -count = count + 1 -{{Cl|PRINT}} count; -{{Cl|IF}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) {{Cl|THEN}} {{Cl|END}} 'escape key exit -{{Cl|LOOP}} - -control: 'NUMBER LOCK MUST BE OFF! -{{Cl|PRINT}} "Control and + keys pressed!"; -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} - - -''Example 3:'' Differentiating the extended cursor keypad arrows from the predefined Number Pad arrow keys. -{{CodeStart}} -'predefined keys 11 to 14 for number pad arrows only -{{Cl|ON KEY(n)|ON KEY}}(11) {{Cl|GOSUB}} UpNum: {{Cl|KEY(n)|KEY}}(11) ON 'up -{{Cl|ON KEY(n)|ON KEY}}(12) {{Cl|GOSUB}} LNum: {{Cl|KEY(n)|KEY}}(12) ON 'left -{{Cl|ON KEY(n)|ON KEY}}(13) {{Cl|GOSUB}} RNum: {{Cl|KEY(n)|KEY}}(13) ON 'right -{{Cl|ON KEY(n)|ON KEY}}(14) {{Cl|GOSUB}} DnNum: {{Cl|KEY(n)|KEY}}(14) ON 'down -'user defined keys use extended key flag 128 + scan code -{{Cl|ON KEY(n)|ON KEY}}(15) {{Cl|GOSUB}} UpPad -{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(72): {{Cl|KEY(n)|KEY}}(15) ON 'cursor up -{{Cl|ON KEY(n)|ON KEY}}(16) {{Cl|GOSUB}} LPad -{{Cl|KEY n|KEY}} 16, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(75): {{Cl|KEY(n)|KEY}}(16) ON 'cursor left -{{Cl|ON KEY(n)|ON KEY}}(17) {{Cl|GOSUB}} RPad -{{Cl|KEY n|KEY}} 17, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(77): {{Cl|KEY(n)|KEY}}(17) ON 'cursor right -{{Cl|ON KEY(n)|ON KEY}}(18) {{Cl|GOSUB}} DnPad -{{Cl|KEY n|KEY}} 18, {{Cl|CHR$}}(128) + {{Cl|CHR$}}(80): {{Cl|KEY(n)|KEY}}(18) ON 'cursor down - -{{Cl|DEF SEG}} = 0 -DO - numL = {{Cl|PEEK}}(1047) {{Cl|AND (boolean)|AND}} 32 '32 if on - capL = {{Cl|PEEK}}(1047) {{Cl|AND (boolean)|AND}} 64 '64 on - {{Cl|IF...THEN|IF}} numL {{Cl|OR (boolean)|OR}} capL {{Cl|THEN}} - {{Cl|COLOR}} 12: {{Cl|LOCATE}} 13, 50: {{Cl|PRINT}} "Turn Num or Cap Lock OFF!" - {{Cl|ELSE}} : {{Cl|COLOR}} 10: {{Cl|LOCATE}} 13, 50: {{Cl|PRINT}} "Number and Cap Lock OK! " - {{Cl|SLEEP}} ' {{Cl|KEY n|KEY}} or {{Cl|TIMER}} event breaks a sleep - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|DEF SEG}} - -{{Cl|KEY(n)|KEY}}(15) OFF: {{Cl|KEY(n)|KEY}}(16) OFF: {{Cl|KEY(n)|KEY}}(17) OFF: {{Cl|KEY(n)|KEY}}(18) OFF -{{Cl|KEY(n)|KEY}}(11) OFF: {{Cl|KEY(n)|KEY}}(12) OFF: {{Cl|KEY(n)|KEY}}(13) OFF: {{Cl|KEY(n)|KEY}}(14) OFF -{{Cl|END}} - -UpPad: -COLOR 14: LOCATE 11, 26: PRINT " Up cursor pad " -{{Cl|RETURN}} -LPad: -COLOR 14: LOCATE 11, 26: PRINT "Left cursor pad " -{{Cl|RETURN}} -RPad: -COLOR 14: LOCATE 11, 26: PRINT "Right cursor pad" -{{Cl|RETURN}} -DnPad: -COLOR 14: LOCATE 11, 26: PRINT "Down cursor pad " -{{Cl|RETURN}} -UpNum: -COLOR 11: LOCATE 11, 26: PRINT " Up number pad " -{{Cl|RETURN}} -LNum: -COLOR 11: LOCATE 11, 26: PRINT "Left number pad " -{{Cl|RETURN}} -RNum: -COLOR 11: LOCATE 11, 26: PRINT "Right number pad" -{{Cl|RETURN}} -DnNum: -COLOR 11: LOCATE 11, 26: PRINT "Down number pad " -{{Cl|RETURN}} -{{CodeEnd}} -: ''Explanation:'' The Number Lock or Caps Lock keys ON may hinder extended key reads in QBasic but not QB64! - - -

([[#toc|Return to Table of Contents]])

- - -{{PageSeeAlso}} -* [[KEY LIST]], [[ON KEY(n)]] -* [[KEY(n)]], [[INKEY$]] -* [[_KEYHIT]], [[_KEYDOWN]] -* [[Keyboard scancodes]] - - -{{PageNavigation}} diff --git a/internal/help/KILL_1111.txt b/internal/help/KILL_1111.txt deleted file mode 100644 index 20cc9b040..000000000 --- a/internal/help/KILL_1111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:56}} -The [[KILL]] statement deletes a file designated by a [[STRING]] value or variable. - - -{{PageSyntax}} -: [[KILL]] {{Parameter|fileSpec$}} - - -* {{Parameter|fileSpec$}} is a literal or variable string path and filename. Wildcards * and ? can be used with caution. -::'''*''' denotes one or more wildcard letters of a name or extension -::'''?''' denotes one wildcard letter of a name or extension - -* {{Parameter|fileSpec$}} can include a path that can be either relative to the program's current location or absolute, from the root drive. -* [[KILL]] cannot remove an [[OPEN]] file. The program must [[CLOSE]] it first. -* If the path or file does not exist, a "File not found" or "Path not found" [[ERROR Codes|error]] will result. See [[_FILEEXISTS]]. -* {{InlineCode}}[[SHELL]] "DEL /Q " + fileName${{InlineCodeEnd}} does the same without a prompt or verification for wildcard deletions. -* {{InlineCode}}[[SHELL]] "DEL /P " + fileName${{InlineCodeEnd}} will ask for user verification. -* Cannot delete folders or directories. Use [[RMDIR]] to remove empty folders. -* '''Warning: files deleted with [[KILL]] will not go to the Recycle Bin and they cannot be restored.''' - - -{{PageExamples}} -{{CodeStart}} -KILL "C:\QBasic\data\2000data.dat" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[RMDIR]], [[FILES]], [[SHELL]], [[OPEN]] -* [[CHDIR]], [[MKDIR]], [[NAME]] -* [[_FILEEXISTS]], [[_DIREXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/Keyword_Reference_-_Alphabetical_1000000_100000000_-_100000000000.txt b/internal/help/Keyword_Reference_-_Alphabetical_1000000_100000000_-_100000000000.txt deleted file mode 100644 index 19bed1f4c..000000000 --- a/internal/help/Keyword_Reference_-_Alphabetical_1000000_100000000_-_100000000000.txt +++ /dev/null @@ -1,1247 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:52}} -__NOTOC__ -

'''Alphabetical QB64 Keyword Listings'''

    '''[[#QB64 specific keywords|QB64:]]'''  [[#uA|_A]] [[#uB|_B]] [[#uC|_C]] [[#uD|_D]] [[#uE|_E]] [[#uF|_F]] [[#uG|_G]] [[#uH|_H]] [[#uI|_I]] [[#uK|_K]] [[#uL|_L]] [[#uM|_M]] [[#uN|_N]] [[#uO|_O]] [[#uP|_P]] [[#uR|_R]] [[#uS|_S]] [[#uT|_T]] [[#uU|_U]] [[#uV|_V]] [[#uW|_W]]                

'''[[#Original QBasic keywords|QBasic:]]'''  [[#A|A]]   [[#B|B]]   [[#C|C]]   [[#D|D]]   [[#E|E]]    [[#F|F]]   [[#G|G]]   [[#H|H]]    [[#I| I]]    [[#K|K]]   [[#L|L]]   [[#M|M]]   [[#N|N]]    [[#O|O]]   [[#P|P]]    [[#R|R]]   [[#S|S]]    [[#T|T]]   [[#U|U]]   [[#V|V]]   [[#W|W]]   [[#X|X]]   

'''[[#OpenGL specific keywords|OpenGL:]]'''   [[#glA|A]]    [[#glB|B]]    [[#glC|C]]    [[#glD|D]]    [[#glE|E]]     [[#glF|F]]    [[#glG|G]]    [[#glH|H]]    [[#glI| I  ]]   [[#glL|L]]    [[#glM|M]]    [[#glN|N]]     [[#glO|O]]    [[#glP|P]]     [[#glR|R]]    [[#glS|S]]     [[#glT|T]]    [[#glV|V]]      

[[#Symbols|Symbols]] '''   -   ''' [[#References|References]]


- - -
[[QB64 FAQ|Go to Frequently Asked Questions about QB64]]
- -
[[Keyword Reference - By usage|Go to keywords by Usage]]
- -
Keywords beginning with _underscores are QB64 specific. '''To use them without the prefix, use [[$NOPREFIX]].'''
- -
[[Keywords currently not supported by QB64]]
- -
[[Keywords currently not supported by QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keywords Not Supported in Linux or MAC versions]]
- -
Keywords without the underscore at the beginning should work with both QB 4.5 and QB64.
- -
For comments or suggestions about this WIKI goto the [https://qb64phoenix.com/forum/forumdisplay.php?fid=25 Wiki Discussion Forum].
- -
[[Main_Page|Main Page with Articles and Tutorials]]
- - -== QB64 specific keywords == -
'''The underscore prefix is reserved for QB64 _KEYWORDS only.'''
- - ----- -
_A
-* [[_ACCEPTFILEDROP]] (statement) {{text|turns a program window into a valid drop destination for dragging files from Windows Explorer.}} -* [[_ACOS]] (function) {{text|arccosine function returns the angle in radians based on an input [[COS]]ine value range from -1 to 1.}} -* [[_ACOSH]] (function) {{text|Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.}} -* [[_ALLOWFULLSCREEN]] (statement) {{text|allows setting the behavior of the ALT+ENTER combo.}} -* [[_ALPHA]] (function) {{text|returns the alpha channel transparency level of a color value used on a screen page or image.}} -* [[_ALPHA32]] (function) {{text|returns the alpha channel transparency level of a color value used on a 32 bit screen page or image.}} -* [[Mathematical Operations#Derived Mathematical Functions|_ARCCOT]] (function) {{text|is the inverse function of the cotangent.}} -* [[Mathematical Operations#Derived Mathematical Functions|_ARCCSC]] (function) {{text|is the inverse function of the cosecant.}} -* [[Mathematical Operations#Derived Mathematical Functions|_ARCSEC]] (function) {{text|is the inverse function of the secant.}} -* [[_ASIN]] (function) {{text|Returns the principal value of the arc sine of x, expressed in radians.}} -* [[_ASINH]] (function) {{text|Returns the arc hyperbolic sine of x, expressed in radians.}} -* [[_ASSERT]] (statement) {{text|Performs debug tests.}} -* [[$ASSERTS]] (metacommand) {{text|enables debug tests with the [[_ASSERT]] macro.}} -* [[_ATAN2]] (function) {{text|Returns the principal value of the [[ATN|arc tangent]] of y/x, expressed in radians.}} -* [[_ATANH]] (function) {{text|Returns the arc hyperbolic tangent of x, expressed in radians.}} -* [[_AUTODISPLAY]] (statement) {{text|enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]].}} -* [[_AUTODISPLAY (function)]] {{text|returns the current display mode as true (-1) if automatic or false (0) if per request using [[_DISPLAY]].}} -* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from the device axis center, 0.}} - -
([[#toc|Return to Table of Contents]])
----- -
_B
-* [[_BACKGROUNDCOLOR]] (function) {{text|returns the current [[SCREEN|screen page]] background color.}} -* [[_BIT]] (` numerical type) {{text|can return only signed values of 0 (bit off) and -1 (bit on). Unsigned 0 or 1.}} -* [[_BIN$]] (function) {{text|returns the binary (base 2) [[STRING]] representation of the [[INTEGER]] part of any value.}} -* [[_BLEND]] (statement) {{text|statement turns on 32 bit alpha blending for the current image or screen mode and is default.}} -* [[_BLEND (function)]] {{text|returns -1 if enabled or 0 if disabled by [[_DONTBLEND]] statement.}} -* [[_BLINK]] (statement) {{text|statement turns blinking colors on/off in SCREEN 0}} -* [[_BLINK (function)]] {{text|returns -1 if enabled or 0 if disabled by [[_BLINK]] statement.}} -* [[_BLUE]] (function) {{text|function returns the palette or the blue component intensity of a 32-bit image color.}} -* [[_BLUE32]] (function) {{text|returns the blue component intensity of a 32-bit color value.}} -* [[_BUTTON]] (function) {{text|returns -1 when a controller device button is pressed and 0 when button is released.}} -* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}} -* [[_BYTE]] (%% numerical type) {{text|can hold signed values from -128 to 127 (one byte or _BIT * 8). Unsigned from 0 to 255.}} - -
([[#toc|Return to Table of Contents]])
----- -
_C
-* [[_CAPSLOCK (function)]] {{text|returns -1 when Caps Lock is on}} -* [[_CAPSLOCK]] (statement) {{text|sets Caps Lock key state}} -* [[$CHECKING]] (QB64 C++ [[Metacommand]]) {{text|turns event and error checking OFF or ON.}} -* [[_CEIL]] (function) {{text|Rounds x upward, returning the smallest integral value that is not less than x.}} -* [[_CINP]] (function) {{text|Returns a key code from $CONSOLE input}} -* [[_CLEARCOLOR (function)]] {{text|returns the current transparent color of an image.}} -* [[_CLEARCOLOR]] (statement) {{text|sets a specific color index of an image to be transparent}} -* [[_CLIP]] ([[PUT (graphics statement)|PUT]] graphics option) {{text|allows placement of an image partially off of the screen.}} -* [[_CLIPBOARD$]] (function) {{text|returns the operating system's clipboard contents as a [[STRING]].}} -* [[_CLIPBOARD$ (statement)]] {{text|sets and overwrites the [[STRING]] value in the operating system's clipboard.}} -* [[_CLIPBOARDIMAGE (function)]] {{text|pastes an image from the clipboard into a new QB64 image in memory.}} -* [[_CLIPBOARDIMAGE]] {{text|(statement) copies a valid QB64 image to the clipboard.}} -* [[$COLOR]] (metacommand) {{text|includes named color constants in a program.}} -* [[_COMMANDCOUNT]] (function) {{text|returns the number of arguments passed to the compiled program from the command line.}} -* [[_CONNECTED]] (function) {{text|returns the status of a TCP/IP connection handle.}} -* [[_CONNECTIONADDRESS$]] (TCP/IP function) {{text|returns a connected user's STRING IP address value using the handle.}} -* [[$CONSOLE]] (QB64 [[Metacommand]]) {{text|creates a console window that can be used throughout a program.}} -* [[_CONSOLE]] (statement) {{text|used to turn a console window OFF or ON or to designate [[_DEST]] _CONSOLE for output.}} -* [[_CONSOLEINPUT]] (function) {{text|fetches input data from a [[$CONSOLE]] window to be read later (both mouse and keyboard)}} -* [[_CONSOLETITLE]] (statement) {{text|creates the title of the console window using a literal or variable [[STRING|string]].}} -* [[_CONTINUE]] (statement) {{text|skips the remaining lines in a control block (DO/LOOP, FOR/NEXT or WHILE/WEND)}} -* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]] (default) can use them as commands.}} -* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}} -* [[_COPYIMAGE]] (function) {{text|copies an image handle value to a new designated handle.}} -* [[_COPYPALETTE]] (statement) {{text|copies the color palette intensities from one 4 or 8 BPP image to another image.}} -* [[Mathematical Operations#Derived Mathematical Functions|_COT]] (function) {{text|the mathematical function cotangent defined by 1/TAN.}} -* [[Mathematical Operations#Derived Mathematical Functions|_COTH]] (function) {{text|Returns the hyperbolic cotangent.}} -* [[Mathematical Operations#Derived Mathematical Functions|_COSH]] (function) {{text|Returns the hyperbolic cosine of x radians.}} -* [[Mathematical Operations#Derived Mathematical Functions|_CSC]] (function) {{text|the mathematical function cosecant defined by 1/SIN.}} -* [[Mathematical Operations#Derived Mathematical Functions|_CSCH]] (function) {{text|Returns the hyperbolic cosecant.}} -* [[_CV]] (function) {{text|converts any [[_MK$]] [[STRING]] value to the designated numerical type value.}} -* [[_CWD$]] (function) {{text|returns the current working directory as a [[STRING]] value.}} - -
([[#toc|Return to Table of Contents]])
----- -
_D
-* [[_D2G]] (function) {{text|converts degrees to gradient angle values.}} -* [[_D2R]] (function) {{text|converts degrees to radian angle values.}} -* [[$DEBUG]] (metacommand) {{text|enables debugging features, allowing you to step through your code line by line.}} -* [[DECLARE LIBRARY|DECLARE LIBRARY (QB64 statement block)]] {{text|declares a C++, SDL or Operating System [[SUB]] or [[FUNCTION]] to be used.}} -* [[DECLARE DYNAMIC LIBRARY|DECLARE DYNAMIC LIBRARY (QB64 statement)]] {{text|declares DYNAMIC, CUSTOMTYPE or STATIC library (DLL) [[SUB]] or [[FUNCTION]].}} -* [[_DEFAULTCOLOR]] (function) {{text|returns the current default text color for an image handle or page.}} -* [[_DEFINE]] (statement) {{text|defines a range of variable names according to their first character as a data type.}} -* [[_DEFLATE$]] (function) {{text|compresses a string}} -* [[_DELAY]] (statement) {{text|suspends program execution for a [[SINGLE]] number of seconds.}} -* [[_DEPTHBUFFER]] (statement) {{text|enables, disables, locks or clears depth buffering.}} -* [[_DESKTOPHEIGHT]] (function) {{text|returns the height of the desktop (not program window).}} -* [[_DESKTOPWIDTH]] (function) {{text|returns the width of the desktop (not program window).}} -* [[_DEST]] (statement) {{text|sets the current write image or [[SCREEN]] page destination for prints or graphics.}} -* [[_DEST (function)]] {{text|returns the current destination screen page or image handle value.}} -* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing a designated numbered input device name and types of input.}} -* [[_DEVICEINPUT]] (function) {{text|returns the [[_DEVICES]] number of an [[_AXIS]], [[_BUTTON]] or [[_WHEEL]] event.}} -* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system including the keyboard and mouse.}} -* [[_DIR$]] (function) {{text|returns common paths in Windows only, like My Documents, My Pictures, My Music, Desktop.}} -* [[_DIREXISTS]] (function) {{text|returns -1 if the Directory folder name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[_DISPLAY]] (statement) {{text|turns off the [[_AUTODISPLAY|automatic display]] while only displaying the screen changes when called.}} -* [[_DISPLAY (function)]] {{text|returns the handle of the current image that is displayed on the screen.}} -* [[_DISPLAYORDER]] (statement) {{text|designates the order to render software, hardware and custom-opengl-code.}} -* [[_DONTBLEND]] (statement) {{text|statement turns off default [[_BLEND]] 32 bit [[_ALPHA|alpha]] blending for the current image or screen.}} -* [[_DONTWAIT]] ([[SHELL]] action) {{text|specifies that the program should not wait until the shelled command/program is finished.}} -* [[_DROPPEDFILE]] (function) {{text| returns the list of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.}} - -
([[#toc|Return to Table of Contents]])
----- -
_E
-* [[_ECHO]] (statement) {{text|used in conjunction with $IF for the precompiler.}} -* [[$ELSE]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with [[$IF]] for the precompiler.}} -* [[$ELSEIF]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with [[$IF]] for the precompiler.}} -* [[$END IF]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with [[$IF]] for the precompiler.}} -* [[_ENVIRONCOUNT]] (function) {{text|returns the number of key/value pairs currently exist in the environment table.}} -* [[$ERROR]] (precompiler [[metacommand]]) {{text|used to trigger compiler errors from within the precompiling pass.}} -* [[_ERRORLINE]] (function) {{text|returns the source code line number that caused the most recent runtime error.}} -* [[_ERRORMESSAGE$]] (function) {{text|returns a human-readable message describing the most recent runtime error.}} -* [[$EXEICON]] (QB64 [[Metacommand]]) {{text|used with a .ICO icon file name to embed the image into the QB64 executable.}} -* [[_EXIT (function)]] {{text|prevents a user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}} - -
([[#toc|Return to Table of Contents]])
----- -
_F
-* [[_FILEEXISTS]] (function) {{text|returns -1 if the file name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[_FINISHDROP]] (statement) {{text| resets [[_TOTALDROPPEDFILES]] and clears the [[_DROPPEDFILE]] list of items (files/folders).}} -* [[_FLOAT]] (numerical type ##) {{text|offers the maximum floating-point decimal precision available using QB64.}} -* [[_FONT]] (statement) {{text|sets the current font handle to be used by PRINT or [[_PRINTSTRING]].}} -* [[_FONT (function)]] {{text|creates a new font handle from a designated image handle.}} -* [[_FONTHEIGHT]] (function) {{text|returns the current text or font height.}} -* [[_FONTWIDTH]] (function) {{text|returns the current text or font width.}} -* [[_FREEFONT]] (statement) {{text|releases the current font handle from memory.}} -* [[_FREEIMAGE]] (statement) {{text|releases a designated image handle from memory.}} -* [[_FREETIMER]] (function) {{text|returns an unused timer number value to use with [[ON TIMER(n)]].}} -* [[_FULLSCREEN]] (statement) {{text|sets the program window to full screen or OFF. Alt + Enter does it manually.}} -* [[_FULLSCREEN (function)]] {{text|returns the fullscreen mode in use by the program.}} - -
([[#toc|Return to Table of Contents]])
----- -
_G
-* [[_G2D]] (function) {{text|converts gradient to degree angle values.}} -* [[_G2R]] (function) {{text|converts gradient to radian angle values.}} -* [[_GLRENDER]] (statement) {{text|sets whether context is displayed, on top of or behind the software rendering.}} -* [[_GREEN]] (function) {{text|function returns the palette or the green component intensity of a 32-bit image color.}} -* [[_GREEN32]] (function) {{text|returns the green component intensity of a 32-bit color value.}} - -
([[#toc|Return to Table of Contents]])
----- -
_H
-* [[_HEIGHT]] (function) {{text|returns the height of a designated image handle.}} -* [[_HIDE]] ([[SHELL]] action) {{text| hides the command line display during a shell.}} -* [[_HYPOT]] (function) {{text|Returns the hypotenuse of a right-angled triangle whose legs are x and y.}} - -
([[#toc|Return to Table of Contents]])
----- -
_I
-* [[$IF]] (Pre-Compiler [[Metacommand]]) {{text|used to set an [[IF]] condition for the precompiler.}} -* [[_ICON]] (statement) {{text|designates a [[_LOADIMAGE]] image file handle to be used as the program's icon or loads the embedded icon (see [[$EXEICON]]).}} -* [[_INCLERRORFILE$]] {function) {{text|returns the name of the original source code $INCLUDE module that caused the most recent error.}} -* [[_INCLERRORLINE]] (function) {{text|returns the line number in an included file that caused the most recent error.}} -* [[_INFLATE$]] (function) {{text|decompresses a string}} -* [[_INSTRREV]] (function) {{text|allows searching for a substring inside another string, but unlike [[INSTR]] it returns the last occurrence instead of the first one.}} -* [[_INTEGER64]] (&& numerical type) {{text|can hold whole numerical values from -9223372036854775808 to 9223372036854775807.}} - -
([[#toc|Return to Table of Contents]])
----- -
_K
-*[[_KEYCLEAR]] (statement) {{text|clears the keyboard buffers for INKEY$, _KEYHIT, and INP.}} -*[[_KEYHIT]] (function) {{text|returns [[ASCII]] one and two byte, SDL Virtual Key and [[Unicode]] keyboard key press codes.}} -*[[_KEYDOWN]] (function) {{text|returns whether CTRL, ALT, SHIFT, combinations and other keys are pressed.}} - -
([[#toc|Return to Table of Contents]])
----- -
_L
-* [[$LET]] (Pre-Compiler [[Metacommand]]) {{text|used to set a variable for the precompiler.}} -* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}} -* [[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}} -* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}} -* [[_LIMIT]] (statement) {{text|sets the loops per second rate to slow down loops and limit CPU usage.}} -* [[_LOADFONT]] (function) {{text|designates a [[_FONT|font]] TTF file to load and returns a handle value.}} -* [[_LOADIMAGE]] (function) {{text|designates an image file to load and returns a handle value.}} - -
([[#toc|Return to Table of Contents]])
----- -
_M
-* [[_MAPTRIANGLE]] (statement) {{text|maps a triangular image source area to put on a destination area.}} -* [[_MAPUNICODE]] (statement) {{text|maps a [[Unicode]] value to an [[ASCII]] code number.}} -* [[_MAPUNICODE (function)]] {{text|returns the [[Unicode]] (UTF32) code point value of a mapped [[ASCII]] character code.}} -* [[_MEM (function)]] {{text|returns [[_MEM]] block referring to the largest continuous memory region beginning at a designated variable's offset.}} -* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}} -* [[_MEMCOPY]] (statement) {{text|copies a value from a designated OFFSET and SIZE [[TO]] a block of memory at a designated OFFSET.}} -* [[_MEMELEMENT]] (function) {{text|returns a [[_MEM]] block referring to a variable's memory (but not past it).}} -* [[_MEMEXISTS]] (function) {{text|verifies that a memory block exists for a memory variable name or returns zero.}} -* [[_MEMFILL]] (statement) {{text|fills a designated memory block OFFSET with a certain SIZE and TYPE of value.}} -* [[_MEMFREE]] (statement) {{text|frees a designated memory block in a program. Only free memory blocks once.}} -* [[_MEMGET]] (statement) {{text|reads a value from a designated memory block at a designated OFFSET}} -* [[_MEMGET (function)]] {{text|returns a value from a designated memory block and OFFSET using a designated variable [[TYPE]].}} -* [[_MEMIMAGE]] (function) {{text|returns a [[_MEM]] block referring to a designated image handle's memory}} -* [[_MEMNEW]] (function) {{text|allocates new memory with a designated SIZE and returns a [[_MEM]] block referring to it.}} -* [[_MEMPUT]] (statement) {{text|places a designated value into a designated memory block OFFSET}} -* [[_MEMSOUND]] (function) {{text|returns a [[_MEM]] block referring to a designated sound handle's memory}} -* [[_SCREENMOVE|_MIDDLE]] (_SCREENMOVE parameter) {{text|centers the program window on the desktop in any screen resolution.}} -* [[_MK$]] (function) {{text|converts a numerical value to a designated [[ASCII]] [[STRING]] value.}} -* [[_MOUSEBUTTON]] (function) {{text|returns the status of a designated mouse button.}} -* [[_MOUSEHIDE]] (statement) {{text|hides the mouse pointer from view}} -* [[_MOUSEINPUT]] (function) {{text|returns a value if the mouse status has changed since the last read.}} -* [[_MOUSEMOVE]] (statement) {{text|moves the mouse pointer to a designated position on the program [[SCREEN]].}} -* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor compared to the previous position.}} -* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor compared to the previous position.}} -* [[_MOUSESHOW]] (statement) {{text|displays the mouse cursor after it has been hidden or can change the cursor shape.}} -* [[_MOUSEWHEEL]] (function) {{text|returns the number of mouse scroll wheel "clicks" since last read.}} -* [[_MOUSEX]] (function) {{text|returns the current horizontal position of the mouse cursor.}} -* [[_MOUSEY]] (function) {{text|returns the current vertical position of the mouse cursor.}} - -
([[#toc|Return to Table of Contents]])
----- -
_N
-* [[_NEWIMAGE]] (function) {{text|creates a designated size program [[SCREEN]] or page image and returns a handle value.}} -* [[$NOPREFIX]] (metacommand) {{text|allows QB64-specific keywords to be used without the underscore prefix.}} -* [[_NUMLOCK (function)]] {{text|returns -1 when Num Lock is on}} -* [[_NUMLOCK]] (statement) {{text|sets Num Lock key state}} - -
([[#toc|Return to Table of Contents]])
----- -
_O
-* [[_OFFSET (function)]] {{text|returns the memory offset of a variable when used with [[DECLARE LIBRARY]] or [[_MEM]] only.}} -* [[_OFFSET]] (%& numerical type) {{text|can be used store the value of an offset in memory when using [[DECLARE LIBRARY]] or [[MEM]] only.}} -* [[_OPENCLIENT]] (TCP/IP function) {{text|connects to a Host on the Internet as a Client and returns the Client status handle.}} -* [[_OPENCONNECTION]] (TCP/IP function) {{text|open's a connection from a client that the host has detected and returns a status handle.}} -* [[_OPENHOST]] (TCP/IP function) {{text|opens a Host and returns a Host status handle.}} -* [[OPTION _EXPLICIT]] (Pre-compiler directive) {{text|instructs the compiler to require variable declaration with [[DIM]] or an equivalent statement.}} -* [[OPTION _EXPLICITARRAY]] (Pre-compiler directive) {{text|instructs the compiler to require array declaration with [[DIM]] or an equivalent statement.}} -* [[_OS$]] (function) {{text|returns the QB64 compiler version in which the program was compiled as [WINDOWS], [LINUX] or [MACOSX] and [32BIT] or [64BIT].}} - -
([[#toc|Return to Table of Contents]])
----- -
_P
-* [[_PALETTECOLOR]] (statement) {{text|sets the color value of a palette entry of an image using 256 colors or less palette modes.}} -* [[_PALETTECOLOR (function)]] {{text|return the 32 bit attribute color setting of an image or screen page handle's palette.}} -* [[_PI]] (function) {{text|returns the value of '''Ï€''' or parameter multiples for angle or [[CIRCLE|circle]] calculations.}} -* [[_PIXELSIZE]] (function) {{text|returns the pixel palette mode of a designated image handle.}} -* [[_PRESERVE]] ([[REDIM]] action) {{text|preserves the data presently in an array when [[REDIM]] is used.}} -* [[_PRINTIMAGE]] (statement) {{text|sends an image to the printer that is stretched to the current printer paper size.}} -* [[_PRINTMODE]] (statement) {{text|sets the text or _FONT printing mode on a background when using PRINT or [[_PRINTSTRING]].}} -* [[_PRINTMODE (function)]] {{text|returns the present [[_PRINTMODE]] value number.}} -* [[_PRINTSTRING]] (statement) {{text|locates and prints a text [[STRING|string]] using graphic coordinates.}} -* [[_PRINTWIDTH]] (function) {{text|returns the pixel width of a text string to be printed using [[_PRINTSTRING]].}} -* [[_PUTIMAGE]] (statement) {{text|maps a rectangular image source area to an image destination area.}} - -
([[#toc|Return to Table of Contents]])
----- -
_R
-* [[_R2D]] (function) {{text|converts radians to degree angle values.}} -* [[_R2G]] (function) {{text|converts radians to gradient angle values.}} -* [[_RED]] (function) {{text|function returns the palette or the red component intensity of a 32-bit image color.}} -* [[_RED32]] (function) {{text|returns the red component intensity of a 32-bit color value.}} -* [[_READBIT]] (function) {{text|returns the state of the specified bit of an integer variable.}} -* [[_RESETBIT]] (function) {{text|is used to set the specified bit of an integer variable to 0.}} -* [[$RESIZE]] ([[Metacommand]]) {{text|used with ON allows a user to resize the program window where OFF does not.}} -* [[_RESIZE]] (statement) {{text|sets resizing of the window ON or OFF and sets the method as _STRETCH or _SMOOTH.}} -* [[_RESIZE (function)]] {{text|returns -1 when a program user wants to resize the program screen.}} -* [[_RESIZEHEIGHT]] (function) {{text|returns the requested new user screen height when [[$RESIZE]]:ON allows it.}} -* [[_RESIZEWIDTH]] (function) {{text|returns the requested new user screen width when [[$RESIZE]]:ON allows it.}} -* [[_RGB]] (function) {{text|returns the closest palette index OR the [[LONG]] 32 bit color value in 32 bit screens.}} -* [[_RGB32]] (function) {{text|returns the [[LONG]] 32 bit color value in 32 bit screens only}} -* [[_RGBA]] (function) {{text|returns the closest palette index OR the [[LONG]] 32 bit color value in 32 bit screens with the [[ALPHA]]}} -* [[_RGBA32]] (function) {{text|returns the [[LONG]] 32 bit color value in 32 bit screens only with the [[ALPHA]]}} -* [[_ROUND]] (function) {{text|rounds to the closest [[INTEGER]], [[LONG]] or [[_INTEGER64]] numerical value.}} - -
([[#toc|Return to Table of Contents]])
----- -
_S
-* [[Mathematical Operations#Derived Mathematical Functions|_SEC]] (function) {{text|the mathematical function secant defined by 1/COS.}} -* [[Mathematical Operations#Derived Mathematical Functions|_SECH]] (function) {{text|Returns the hyperbolic secant.}} -* [[_SCREENCLICK]] (statement) {{text|simulates clicking on a point on the desktop screen with the left mouse button.}} -* [[_SCREENEXISTS]] (function) {{text|returns a -1 value once a screen has been created.}} -* [[$SCREENHIDE]] ([QB64 [Metacommand]]) {{text|hides the program window from view.}} -* [[_SCREENHIDE]] (statement) {{text|hides the program window from view.}} -* [[_SCREENICON (function)]] {{text|returns -1 or 0 to indicate if the window has been minimized to an icon on the taskbar.}} -* [[_SCREENICON]] (statement) {{text|minimizes the program window to an icon on the taskbar.}} -* [[_SCREENIMAGE]] (function) {{text|creates an image of the current desktop and returns an image handle.}} -* [[_SCREENMOVE]] (statement) {{text|positions program window on the desktop using designated coordinates or the _MIDDLE option.}} -* [[_SCREENPRINT]] (statement) {{text|simulates typing text into a Windows program using the keyboard.}} -* [[$SCREENSHOW]] (QB64 [[Metacommand]]) {{text|displays the program window after it was hidden.}} -* [[_SCREENSHOW]] (statement) {{text|displays the program window after it has been hidden by [[_SCREENHIDE]].}} -* [[_SCREENX]] (function) {{text|returns the program window's upper left corner horizontal position on the desktop.}} -* [[_SCREENY]] (function) {{text|returns the program window's upper left corner vertical position on the desktop.}} -* [[_SCROLLLOCK (function)]] {{text|returns -1 when Scroll Lock is on}} -* [[_SCROLLLOCK]] (statement) {{text|sets Scroll Lock key state}} -* [[_SETALPHA]] (statement) {{text|sets the alpha channel transparency level of some or all of the pixels of an image.}} -* [[_SETBIT]] (function) {{text|is used to set the specified bit of an integer variable to 1.}} -* [[_SHELLHIDE]] (function) {{text|returns the code sent by a program exit using [[END]] or [[SYSTEM]] followed by an [[INTEGER]] value.}} -* [[_SHL]] (function) {{text|used to shift the bits of a numerical value to the left}} -* [[_SHR]] (function) {{text|used to shift the bits of a numerical value to the right.}} -* [[Mathematical Operations#Derived Mathematical Functions|_SINH]] (function) {{text|Returns the hyperbolic sine of x radians.}} -* [[_SNDBAL]] (statement) {{text|attempts to set the balance or 3D position of a sound file.}} -* [[_SNDCLOSE]] (statement) {{text|frees and unloads an open sound using the sound handle created by [[_SNDOPEN]].}} -* [[_SNDCOPY]] (function) {{text|copies a sound handle value to a new designated handle.}} -* [[_SNDGETPOS]] (function) {{text|returns the current playing position in seconds from a sound file.}} -* [[_SNDLEN]] (function) {{text|returns the length of a sound in seconds from a sound file.}} -* [[_SNDLIMIT]] (statement) {{text|stops playing a sound after it has been playing for a set number of seconds.}} -* [[_SNDLOOP]] (statement) {{text|plays a sound repeatedly until [[_SNDSTOP]] is used.}} -* [[_SNDOPEN]] (function) {{text|loads a sound file and returns a sound handle.}} -* [[_SNDOPENRAW]] (function) {{text|opens a new channel to shove [[_SNDRAW]] content into without mixing.}} -* [[_SNDPAUSE]] (statement) {{text|stops playing a sound file until resumed.}} -* [[_SNDPAUSED]] (function) {{text|returns the current pause status of a sound file handle.}} -* [[_SNDPLAY]] (statement) {{text|plays a sound file handle that was created by [[_SNDOPEN]] or [[_SNDCOPY]].}} -* [[_SNDPLAYCOPY]] (statement) {{text|copies a sound handle, plays it and automatically closes the copy when done.}} -* [[_SNDPLAYFILE]] (statement) {{text|directly plays a designated sound file.}} -* [[_SNDPLAYING]] (function) {{text|returns the current playing status of a sound handle.}} -* [[_SNDRATE]] (function) {{text|returns the sound card sample rate to set [[_SNDRAW]] durations.}} -* [[_SNDRAW]] (statement) {{text|creates mono or stereo sounds from calculated wave frequency values.}} -* [[_SNDRAWDONE]] (statement) {{text|pads a [[_SNDRAW]] stream so the final (partially filled) buffer section is played.}} -* [[_SNDRAWLEN]] (function) {{text|returns a value until the [[_SNDRAW]] buffer is empty.}} -* [[_SNDSETPOS]] (statement) {{text|sets the playing position of a sound handle.}} -* [[_SNDSTOP]] (statement) {{text|stops playing a sound handle.}} -* [[_SNDVOL]] (statement) {{text|sets the volume of a sound file handle.}} -* [[_SOURCE]] (statement) {{text|sets the source image handle.}} -* [[_SOURCE (function)]] {{text|returns the present source image handle value.}} -* [[_STARTDIR$]] (function) {{text|returns the user's program calling path as a [[STRING]].}} -* [[_STRCMP]] (function) {{text|compares the relationship between two strings.}} -* [[_STRICMP]] (function) {{text|compares the relationship between two strings, without regard for case-sensitivity.}} - -
([[#toc|Return to Table of Contents]])
----- -
_T
-* [[Mathematical Operations#Derived Mathematical Functions|_TANH]] (function) {{text|Returns the hyperbolic tangent of x radians.}} -* [[_TITLE]] (statement) {{text|sets the program title [[STRING|string]] value.}} -* [[_TITLE$]] (function) {{text|gets the program title [[STRING|string]] value.}} -* [[_TOGGLEBIT]] (function) {{text|is used to toggle the specified bit of an integer variable from 1 to 0 or 0 to 1.}} -* [[_TOTALDROPPEDFILES]] (function) {{text| returns the number of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.}} -* [[_TRIM$]] (function) {{text|shorthand to [[LTRIM$]]([[RTRIM$]]("text"))}} - -
([[#toc|Return to Table of Contents]])
----- -
_U
-* [[_UNSIGNED]] (numerical type) {{text|expands the positive range of numerical [[INTEGER]], [[LONG]] or [[_INTEGER64]] values returned.}} - -
([[#toc|Return to Table of Contents]])
----- -
_V
-* [[$VERSIONINFO]] ([[Metacommand]]) {{text|adds metadata to Windows only binaries for identification purposes across the OS.}} -* [[$VIRTUALKEYBOARD]] ([[Metacommand]]) ({{text|deprecated|red}}) {{text|turns the virtual keyboard ON or OFF for use in touch-enabled devices.}} - -
([[#toc|Return to Table of Contents]])
----- -
_W
-* [[_WHEEL]] (function) {{text|returns -1 when a control device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}} -* [[_WIDTH (function)]] {{text|returns the width of a [[SCREEN]] or image handle.}} -* [[_WINDOWHANDLE]] (function) {{text|returns the window handle assigned to the current program by the OS. Windows-only.}} -* [[_WINDOWHASFOCUS]] (function) {{text|returns true (-1) if the current program's window has focus. Windows-only.}} - -
([[#toc|Return to Table of Contents]])
- -
([[#QB64 specific keywords|Go to Top of QB64 specific keywords]])
- - -== Original QBasic keywords == -
'''These QBasic keywords (with a few noted exceptions) will work in all versions of QB64.'''
- - ----- -
A
-* [[ABS]] (function) {{text|converts any negative numerical value to a positive value.}} -* [[CALL ABSOLUTE|ABSOLUTE]] (statement) {{text|is used to access computer interrupt registers.}} -* [[ACCESS]] (file statement) {{text|sets the read and write access of a file when opened.}} -* [[ALIAS]] (QB64 [[DECLARE LIBRARY]] statement) {{text|denotes the actual name of an imported [[FUNCTION]] or [[SUB]] procedure.}} -* [[AND]] (logical operator) {{text|is used to compare two numerical values bitwise.}} -* [[AND (boolean)]] {{text| conditonal operator is used to include another evaluation in an [[IF...THEN]] or [[Boolean]] statement.}} -* [[APPEND]] (file mode) {{text|creates a new file or allows an existing file to have data added using [[WRITE (file statement)|WRITE]] or [[PRINT (file statement)|PRINT]]}} -* [[AS]] {{text|is used to denote a variable type or file number.}} -* [[ASC]] (function) {{text|returns the [[ASCII]] code number of a text [[STRING|string]] character.}} -* [[ASC (statement)]] (QB64 only) {{text|sets the code value of an [[ASCII]] text character at a designated [[STRING|string]] position.}} -* [[ATN]] (function) {{text|or arctangent returns the angle in radians of a numerical [[TAN|tangent]] value.}} - -
([[#toc|Return to Table of Contents]])
----- -
B
-* [[BEEP]] (statement) {{text|creates an error sound of a fixed duration.}} -* [[BINARY]] (file mode) {{text|creates or opens an existing file for [[GET|read]] and [[PUT|write]] byte-wise access.}} -* [[BLOAD]] (statement) {{text|transfers the contents of a [[BINARY]] [[BSAVE]] file to a specific [[Arrays|array]].}} -* [[BSAVE]] (statement) {{text|transfers the contents of an [[Arrays|array]] to a specified size [[BINARY]] file.}} -* [[BYVAL]] (statement) {{text|assigns a numerical variable value by its value, not the name.}} - -
([[#toc|Return to Table of Contents]])
----- -
C
-* [[CALL]] (statement) {{text|optional statement that sends the program to a [[SUB]] procedure. Requires parameters be enclosed in brackets(parenthesis).}} -* [[CALL ABSOLUTE]] (statement) {{text|is used to access computer interrupt registers.}} -* [[CASE]] ([[SELECT CASE]] condition) {{text|designates specific conditions in a [[SELECT CASE]] statement block.}} -* [[CASE ELSE]] ([[SELECT CASE]] condition) {{text|designates an alternative condition to be evaluated in a [[SELECT CASE]] statement block.}} -* [[CASE IS]] ([[SELECT CASE]] condition) {{text|designates specific conditions in a [[SELECT CASE]] statement block.}} -* [[CDBL]] (function) {{text|returns the closest [[DOUBLE]] value of a number.}} -* [[CHAIN]] (statement) {{text|sends a program to another specified program module or compiled program.}} -* [[CHDIR]] (statement) {{text|changes the current program path for file access.}} -* [[CHR$]] (function) {{text|returns a text [[STRING|string]] character by the specified [[ASCII]] code number.}} -* [[CINT]] (function) {{text|returns the closest [[INTEGER]] value of a numerical value.}} -* [[CIRCLE]] (statement) {{text|creates a circle, ellipse or arc at a designated graphical coordinate position.}} -* [[CLEAR]] (statement) {{text|sets all variable and array values to zero number values or empty [[STRING]]s.}} -* [[CLNG]] (function) {{text|returns the closest [[LONG]] value of a numerical value.}} -* [[CLOSE]] (statement) {{text|closes specific file number(s) or all files when a number is not specified.}} -* [[CLS]] (statement) {{text|clears a program [[SCREEN|screen]], [[VIEW]] port or [[WINDOW]].}} -* [[COLOR]] (statement) {{text|sets the current text foreground and/or background color to be used.}} -* [[COMMAND$]] (function) {{text|returns the command line arguments passed when a program is run.}} -* [[COMMON]] (statement) {{text|sets a variable name as shared by [[CHAIN]]ed program modules.}} -* [[CONST]] (statement) {{text|sets a variable name and its value as a constant value to be used by all procedures.}} -* [[COS]] (function) {{text|returns the cosine of a radian angle value.}} -* [[CSNG]] (function) {{text|returns the closest [[SINGLE]] value of a numerical value.}} -* [[CSRLIN]] (function) {{text|returns the present [[PRINT]] cursor text row [[SCREEN]] coordinate position.}} -* [[CVD]] (function) {{text|returns the [[DOUBLE]] numerical value of an 8 byte [[MKD$]] [[STRING|string]].}} -* [[CVDMBF]] (function) {{text|returns the [[DOUBLE]] numerical value of a [[MKDMBF$|Microsoft Binary Format]] [[STRING|string]].}} -* [[CVI]] (function) {{text|returns the [[INTEGER]] numerical value of a 2 byte [[MKI$]] [[STRING|string]].}} -* [[CVL]] (function) {{text|returns the [[LONG]] numerical value of a 4 byte [[MKL$]] [[STRING|string]].}} -* [[CVS]] (function) {{text|returns the [[SINGLE]] numerical value of a 4 byte [[MKS$]] [[STRING|string]].}} -* [[CVSMBF]] (function) {{text|returns the [[SINGLE]] numerical value of a [[MKSMBF$|Microsoft Binary Format]] [[STRING|string]].}} - -
([[#toc|Return to Table of Contents]])
----- -
D
-* [[DATA]] (statement) {{text|creates a line of fixed program information separated by commas.}} -* [[DATE$]] (function) {{text|returns the present Operating System date [[STRING|string]] formatted as mm-dd-yyyy.}} -* [[DECLARE LIBRARY|DECLARE LIBRARY (QB64 statement block)]] {{text|declares a C++, SDL or Operating System [[SUB]] or [[FUNCTION]] to be used.}} -* [[DECLARE DYNAMIC LIBRARY|DECLARE DYNAMIC LIBRARY (QB64 statement)]] {{text|declares DYNAMIC, CUSTOMTYPE or STATIC library(DLL) [[SUB]] or [[FUNCTION]].}} -* [[DEF SEG]] (statement) {{text|defines a segment in memory to be accessed by a memory procedure.}} -* [[DEFDBL]] (statement) {{text|defines a set of undefined variable name starting letters as [[DOUBLE]] type numerical values.}} -* [[DEFINT]] (statement) {{text|defines a set of undefined variable name starting letters as [[INTEGER]] type numerical values.}} -* [[DEFLNG]] (statement) {{text|defines a set of undefined variable name starting letters as [[LONG]] type numerical values.}} -* [[DEFSNG]] (statement) {{text|defines a set of undefined variable name starting letters as [[SINGLE]] type numerical values.}} -* [[DEFSTR]] (statement) {{text|defines a set of undefined variable name starting letters as [[STRING]] type values.}} -* [[DIM]] (statement) {{text|defines a variable as a specified type and can size a [[STATIC]] array.}} -* [[DO...LOOP]] (statement) {{text|sets a recursive procedure loop that can be ignored or exited using conditional arguments.}} -* [[DOUBLE]] (numerical type #) {{text|8 byte value limited to values up to 15 decimal places.}} -* [[DRAW]] (statement) {{text|uses a special [[STRING|string]] format that draws graphical lines in specific directions.}} -* [[$DYNAMIC]] ([[Metacommand]]) {{text|used at the start of a program to set all program arrays as changeable in size using [[REDIM]].}} - -
([[#toc|Return to Table of Contents]])
----- -
E
-* [[ELSE]] ([[IF...THEN]] statement) {{text|is used to direct program flow when no other condition is evaluated as true.}} -* [[ELSEIF]] ([[IF...THEN]] statement) {{text|is used with [[THEN]] to set alternate conditional evaluations.}} -* [[END]] (statement) {{text|sets the end of a program, sub-procedure, statement block, [[DECLARE LIBRARY]] or [[TYPE]] definition.}} -* [[IF...THEN|END IF]] (statement) {{text|[[END]]s an IF...THEN conditional block statement using more than one line of code.}} -* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/pair value.}} -* [[ENVIRON$]] (function) {{text|returns a specified string setting or numerical position as an environmental [[STRING]] value.}} -* [[EOF]] (file function) {{text|returns -1 when a file [[INPUT (file statement)|INPUT]] or [[GET]] has reached the end of a file.}} -* [[EQV]] (logic operator) {{text|is used to compare two numerical values bitwise.}} -* [[ERASE]] (statement) {{text|clears the values from [[$STATIC]] arrays and completely removes [[$DYNAMIC]] arrays.}} -* [[ERL]] (error function) {{text|returns the closest line number before an error occurred if line numbers are used.}} -* [[ERR]] (function) {{text|returns the [[ERROR Codes|ERROR code]] when a program error occurs.}} -* [[ERROR]] (statement) {{text|sets a specific [[ERROR Codes|ERROR code]] to be simulated.}} -* [[EXIT]] (statement) {{text|immediately exits a program [[FOR...NEXT]], [[DO...LOOP]], [[SUB]] or [[FUNCTION]] procedure.}} -* [[EXP]] (function) {{text|returns the value of e to the exponential power specified.}} - -
([[#toc|Return to Table of Contents]])
----- -
F
-* [[FIELD]] (statement) {{text|defines the variable sizes to be written or read from a file.}} -* [[FILES]] (statement) {{text|returns a list of files in the current directory path to the [[SCREEN]].}} -* [[FIX]] (function) {{text|returns the rounded [[INTEGER]] value of a numerical value.}} -* [[FOR...NEXT]] (statement) {{text|creates a recursive loop procedure that loop a specified number of times.}} -* [[FOR (file statement)]] {{text|used in an [[OPEN]] file or device statement to indicate the access mode.}} -* [[TIMER (statement)|FREE (QB64 TIMER statement)]] {{text|frees a numbered TIMER event in QB64.}} -* [[FREEFILE]] (file function) {{text|returns a file number that is currently not in use by the Operating System.}} -* [[FUNCTION]] (procedure block) {{text|sub-procedure that can calculate and return one value to a program in its name.}} - -
([[#toc|Return to Table of Contents]])
----- -
G
-* [[GET]] (file statement) {{text|reads a file sequencially or at a specific position and returns the value as the variable type used.}} -* [[GET (TCP/IP statement)|GET (QB64 TCP/IP statement)]] {{text|reads a connection port to return a value.}} -* [[GET (graphics statement)]] {{text|maps an area the current [[SCREEN|screen's]] video information and places it in an [[INTEGER]] [[arrays|array]].}} -* [[GOSUB]] (statement) {{text|sends the program to a designated line label procedure in the main program.}} -* [[GOTO]] (statement) {{text|sends the program to a designated line number or line label in a procedure.}} - -
([[#toc|Return to Table of Contents]])
----- -
H
-* [[HEX$]] (function) {{text|returns the hexadecimal (base 16) [[STRING]] representation of the [[INTEGER]] part of any value.}} - -
([[#toc|Return to Table of Contents]])
----- -
I
-* [[IF...THEN]] (statement) {{text|a conditional block statement used control program flow.}} -* [[IMP]] (logic operator) {{text|is used to compare two numerical values bitwise.}} -* [[$INCLUDE]] ([[Metacommand]]) {{text|designates a text code library file to include with the program.}} -* [[INKEY$]] (function) [[ASCII]] {{text|returns a [[STRING|string]] value entry from the keyboard.}} -* [[INP]] (function) {{text|returns a numerical value from a specified port register address. See [[Keyboard scancodes]]}} -* [[INPUT]] (statement) {{text|a user input that returns a value to one or more specified variable(s).}} -* [[INPUT (file mode)]] {{text|[[OPEN]] statement that only allows an existing file to be read using [[INPUT (file statement)]] or [[INPUT$]].}} -* [[INPUT (file statement)]] {{text|reads a file sequentially using the variable types designated.}} -* [[INPUT$]] (function) {{text|returns a designated number of [[STRING|string]] bytes from the keyboard entry or a file number.}} -* [[INSTR]] (function) {{text|returns the position in a text [[STRING|string]] where a character sequence match starts.}} -* [[INT]] (function) {{text|rounds a numerical value to an [[INTEGER]] value by removing the decimal point fraction.}} -* [[INTEGER]] (% numerical type) {{text|2 byte whole values from -32768 to 32767.}} -* [[INTERRUPT]] (statement) {{text|is used to access computer interrupt registers.}} -* [[INTERRUPTX]] (statement) {{text|is used to access computer interrupt registers.}} - -
([[#toc|Return to Table of Contents]])
----- -
K
-* [[KEY n]] (statement) {{text|used with [[ON KEY(n)]] events to assign a "softkey" string to a key or create a user defined key.}} -* [[KEY(n)]] (statement) {{text|used with [[ON KEY(n)]] events to assign, enable, disable or suspend event trapping.}} -* [[KEY LIST]] (statement) {{text|lists the 12 Function key soft key string assignments going down left side of screen.}} -* [[KILL]] (statement) {{text|deletes the specified file without a warning. Remove empty folders with [[RMDIR]].}} - -
([[#toc|Return to Table of Contents]])
----- -
L
-* [[LBOUND]] (function) {{text|returns the lower boundary of the specified array.}} -* [[LCASE$]] (function) {{text|returns the lower case value of a [[STRING]].}} -* [[LEFT$]] (function) {{text|returns the specified number of text characters from the left end of a [[STRING]].}} -* [[LEN]] (function) {{text|returns the length or number of characters in a [[STRING]] value in bytes.}} -* [[LET]] (statement) {{text|assigns a variable a literal value. Not required.}} -* [[LINE]] (statement) {{text|creates a graphic line or box on the [[SCREEN]].}} -* [[LINE INPUT]] (statement) {{text|user input can be any text character including commas and quotes as a [[STRING]] value only.}} -* [[LINE INPUT (file statement)]] {{text|returns an entire text file line and returns it as a [[STRING]] value.}} -* [[KEY LIST|LIST]] {{text|displays the current [[ON KEY(n)]] function key (F1 to F10) "soft key" settings.}} -* [[LOC]] (function) {{text|returns the present file byte position or number of bytes in the [[OPEN COM]] buffer.}} -* [[LOCATE]] (statement) {{text|sets the text cursor's row and column position for a [[PRINT]] or [[INPUT]] statement.}} -* [[LOCK]] (statement) {{text|restricts access to portions or all of a file by other programs or processes.}} -* [[LOF]] (function) {{text|returns the size of an [[OPEN]] file in bytes.}} -* [[LOG]] (function) {{text|returns the natural logarithm of a specified numerical value}} -* [[LONG]] (& numerical type) {{text|4 byte whole values from -2147483648 to 2147483647.}} -* [[DO...LOOP|LOOP]] (block statement) {{text|bottom end of a recursive DO loop.}} -* [[LPOS]] (function) {{text|returns the printer head position.}} -* [[LPRINT]] (statement) {{text|sends [[STRING]] data to the default LPT or USB printer.}} -* [[LPRINT USING]] (statement) {{text|sends template formatted text to the default LPT or USB printer.}} -* [[LSET]] (statement) {{text|left justifies the text in a string so that there are no leading spaces.}} -* [[LTRIM$]] (function) {{text|returns a [[STRING|string]] value with no leading spaces.}} - -
([[#toc|Return to Table of Contents]])
----- -
M
-* [[MID$]] (function) {{text|returns a designated portion of a [[STRING]].}} -* [[MID$ (statement)]] {{text|redefines existing characters in a [[STRING]].}} -* [[MKD$]] (function) {{text|returns an 8 byte [[ASCII]] [[STRING|string]] representation of a [[DOUBLE]] numerical value.}} -* [[MKDIR]] (statement) {{text|creates a new folder in the current or designated program path.}} -* [[MKDMBF$]] (function) {{text|returns an 8 byte Microsoft Binary Format [[STRING]] representation of a [[DOUBLE]] numerical value.}} -* [[MKI$]] (function) {{text|returns a 2 byte [[ASCII]] [[STRING|string]] representation of an [[INTEGER]].}} -* [[MKL$]] (function) {{text|returns a 4 byte [[ASCII]] [[STRING|string]] representation of a [[LONG]] numerical value.}} -* [[MKS$]] (function) {{text|returns a 4 byte [[ASCII]] [[STRING|string]] representation of a [[SINGLE]] numerical value.}} -* [[MKSMBF$]] (function) {{text|returns an 8 byte Microsoft Binary Format [[STRING]] representation of a [[DOUBLE]] numerical value.}} -* [[MOD]] (math operator) {{text|performs integer remainder division on a numerical value.}} - -
([[#toc|Return to Table of Contents]])
----- -
N
-* [[NAME]] (statement) {{text|names an existing file name [[AS]] a new file name.}} -* [[NEXT]] (statement) {{text|bottom end of a [[FOR...NEXT]] counter loop to returns to the start or a [[RESUME|RESUME NEXT]] error.}} -* [[NOT]] (logical operator) {{text|inverts the value of a logic operation or returns True when a [[boolean]] evaluation is False.}} - -
([[#toc|Return to Table of Contents]])
----- -
O
-* [[OCT$]] (function) {{text|returns the octal (base 8) [[STRING]] representation of the [[INTEGER]] part of any value.}} -* [[OFF]] (event statement) {{text|turns off all [[ON]] event checking.}} -* [[ON COM(n)]] (statement) {{text|sets up a COM port event procedure call.}} -* [[ON ERROR]] (statement) {{text|sets up and activates an error event checking procedure call. Use to avoid program errors.}} -* [[ON KEY(n)]] (statement) {{text|sets up a keyboard key entry event procedure.}} -* [[ON PEN]] (statement) {{text|sets up a pen event procedure call.}} -* [[ON PLAY(n)]] (statement) {{text|sets up a [[PLAY]] event procedure call.}} -* [[ON STRIG(n)]] (statement) {{text|sets up a joystick button event procedure call.}} -* [[ON TIMER(n)]] (statement) {{text|sets up a timed event procedure call.}} -* [[ON UEVENT]] (statement) '''{{text|Not implemented in QB64.}}''' -* [[ON...GOSUB]] (statement) {{text|sets up a numerical event procedure call.}} -* [[ON...GOTO]] (statement) {{text|sets up a numerical event procedure call.}} -* [[OPEN]] (file statement) {{text|opens a file name for an access mode with a specific file number.}} -* [[OPEN COM]] (statement) {{text|opens a serial communication port for access at a certain speed and mode.}} -* [[OPTION BASE]] (statement) {{text|can set the lower boundary of all arrays to 1.}} -* [[OR]] (logic operator) {{text|is used to compare two numerical values bitwise.}} -* [[OR (boolean)]] {{text| conditonal operator is used to include an alternative evaluation in an [[IF...THEN]] or [[Boolean]] statement.}} -* [[OUT]] (statement) {{text|writes numerical data to a specified register port.}} -* [[OUTPUT]] (file mode) {{text|creates a new file or clears all data from an existing file to acess the file sequencially.}} - -
([[#toc|Return to Table of Contents]])
----- -
P
-* [[PAINT]] (statement) {{text|fills an enclosed area of a graphics [[SCREEN|screen]] with a color until it encounters a specific colored border.}} -* [[PALETTE]] (statement) {{text|sets the Red, Green and Blue color attribute intensities using a RGB multiplier calculation.}} -* [[PALETTE USING]] (statement) {{text|sets the color intensity settings using a designated [[arrays|array]].}} -* [[PCOPY]] (statement) {{text|swaps two designated memory page images when page swapping is enabled in the [[SCREEN]] statement.}} -* [[PEEK]] (function) {{text|returns a numerical value from a specified segment address in memory.}} -* [[PEN]] (function) {{text|returns requested information about the lightpen device used.}} -* [[PEN (statement)]] {{text|enables/disables or suspends event trapping of a lightpen device.}} -* [[PLAY(n)]] (function) {{text|returns the number of notes currently in the background music queue.}} -* [[PLAY]] (statement) {{text|uses a special [[STRING|string]] format that can produce musical tones and effects.}} -* [[PMAP]] (function) {{text|returns the physical or WINDOW view graphic coordinates.}} -* [[POINT]] (function) {{text|returns the color attribute number or 32 bit [[_RGB32]] value.}} -* [[POKE]] (statement) {{text|writes a numerical value to a specified segment address in memory.}} -* [[POS]] (function) {{text|returns the current text column position of the text cursor.}} -* [[PRESET]] (statement) {{text|sets a pixel coordinate to the background color unless one is specified.}} -* [[PRINT]] (statement) {{text|prints text [[STRING|strings]] or numerical values to the [[SCREEN]].}} -* [[PRINT (file statement)]] {{text|prints text [[STRING|strings]] or numerical values to a file.}} -* [[PRINT USING]] (statement) {{text|prints a template formatted [[STRING|string]] to the [[SCREEN]].}} -* [[PRINT USING (file statement)]] {{text|prints a template formatted [[STRING|string]] to a file.}} -* [[PSET]] (statement) {{text|sets a pixel coordinate to the current color unless a color is designated.}} -* [[PUT]] (file I/O statement) {{text|writes data sequencially or to a designated position using a variable value.}} -* [[PUT (TCP/IP statement)|PUT (QB64 TCP/IP statement)]] {{text|sends raw data to a user's connection handle.}} -* [[PUT (graphics statement)]] {{text|places pixel data stored in an [[INTEGER]] array to a specified area of the [[SCREEN]].}} - -
([[#toc|Return to Table of Contents]])
----- -
R
-* [[RANDOM]] (file mode) {{text|creates a file or opens an existing file to [[GET|read]] and [[PUT|write]] records of a set byte size.}} -* [[RANDOMIZE]] (statement) {{text|sets the random seed value for a specific sequence of random [[RND]] values.}} -* [[RANDOMIZE|RANDOMIZE USING (QB64 statement)]] {{text|restarts the designated seed value's random sequence of values from the beginning.}} -* [[READ]] (statement) {{text|reads values from a [[DATA]] field. [[ACCESS]] READ is used with the [[OPEN]] statement.}} -* [[REDIM]] (statement) {{text|creates a new [[$DYNAMIC|dynamic]] array or resizes one without losing data when [[_PRESERVE]] is used.}} -* [[REM]] (statement) {{text|or an apostrophe tells the program to ignore statements following it on the same line.}} -* [[RESET]] (statement) {{text| closes all files and writes the directory information to a diskette before it is removed from a disk drive.}} -* [[RESTORE]] (statement) {{text|resets the [[DATA]] pointer to the start of a designated field of data.}} -* [[RESUME]] (statement) {{text|an [[ERROR Codes|error]] handling procedure exit that can send the program to a line number or the [[NEXT]] code line.}} -* [[RETURN]] (statement) {{text|returns the program to the code immediately following a [[GOSUB]] call.}} -* [[RIGHT$]] (function) {{text|returns a specific number of text characters from the right end of a [[STRING]].}} -* [[RMDIR]] (statement) {{text|removes an empty folder from the current path or the one designated.}} -* [[RND]] (function) {{text|returns a random number value from 0 to .9999999.}} -* [[RSET]] (statement) {{text|right justifies a string value so that any end spaces are moved to the beginning.}} -* [[RTRIM$]] (function) {{text|returns a [[STRING|string]] with all spaces removed from the right end.}} -* [[RUN]] (statement) {{text|clears and restarts the program currently in memory or executes another specified program.}} - -
([[#toc|Return to Table of Contents]])
----- -
S
-* [[SADD]] (function) {{text|returns the address of a STRING variable as an offset from the current data segment.}} -* [[SCREEN (function)]] {{text|can return the [[ASCII]] character code or color of the text at a text designated coordinate.}} -* [[SCREEN]] (statement) {{text|sets the display mode and size of the program window.}} -* [[SEEK]] (function) {{text|returns the present byte position in an [[OPEN|opened]] file.}} -* [[SEEK (statement)]] {{text|moves to a specified position in an [[OPEN|opened]] file.}} -* [[SELECT CASE]] (statement) {{text|a program flow block that can handle numerous conditional evaluations.}} -* [[SGN]] (function) {{text|returns -1 for negative, 0 for zero, and 1 for positive numerical values.}} -* [[SHARED]] (statement) {{text|designates that a variable can be used by other procedures or the main procedure when in a sub-procedure.}} -* [[SHELL]] (statement) {{text|sends [[STRING]] commands to the command line. SHELL calls will not affect the current path.}} -* [[SHELL (function)|SHELL (QB64 function)]] {{text|executes an external command or calls another program. Returns codes sent by [[END]] or [[SYSTEM]].}} -* [[SIN]] (function) {{text|returns the sine of a radian angle.}} -* [[SINGLE]] (! numerical type) {{text|4 byte floating decimal point values up to 7 decimal places.}} -* [[SLEEP]] (statement) {{text|pauses the program for a designated number of seconds or until a key is pressed.}} -* [[SOUND]] (statement) {{text|creates a sound of a specified frequency and duration.}} -* [[SPACE$]] (function) {{text|returns a designated number of spaces to a [[STRING]].}} -* [[SPC]] (function) {{text|moves the text cursor a number of spaces on the [[SCREEN]].}} -* [[SQR]] (function) {{text|returns the square root of a non-negative number.}} -* [[STATIC]] (statement) {{text|creates a [[SUB]] or [[FUNCTION]] variable that retains its value.}} -* [[$STATIC]] ([[Metacommand]]) {{text|used at the start of a program to set all program arrays as unchangeable in size using [[DIM]].}} -* [[STEP]] (keyword) {{text|move relatively from one graphic position or change the counting increment in a [[FOR...NEXT]] loop.}} -* [[STICK]] (function) {{text|returns the present joystick position.}} -* [[STOP]] (statement) {{text|stops a program when troubleshooting or stops an [[ON]] event.}} -* [[STR$]] (function) {{text|returns a [[STRING|string]] value of a number with a leading space when it is positive.}} -* [[STRIG]] (function) {{text|returns the joystick button press values when read.}} -* [[STRIG(n)]] (statement) -* [[STRING]] ($ variable type) {{text|one byte text variable with [[ASCII]] code values from 0 to 255.}} -* [[STRING$]] (function) {{text|returns a designated number of string characters.}} -* [[SUB]] (procedure block) {{text|sub-procedure that can calculate and return multiple parameter values.}} -* [[SWAP]] (statement) {{text|swaps two [[STRING|string]] or numerical values.}} -* [[SYSTEM]] (statement) {{text|ends a program immediately.}} - -
([[#toc|Return to Table of Contents]])
----- -
T
-* [[TAB]] (function) {{text|moves a designated number of columns on the [[SCREEN|screen]].}} -* [[TAN]] (function) {{text|returns the ratio of [[SIN]]e to [[COS]]ine or tangent value of an angle measured in radians.}} -* [[THEN]] ([[IF...THEN]] keyword) {{text|must be used in a one line [[IF...THEN]] program flow statement.}} -* [[TIME$]] (function) {{text|returns the present time setting of the Operating System as a format hh:mm:ss [[STRING]].}} -* [[TIMER]] (function) {{text|returns the number of seconds since midnight as a [[SINGLE]] value.}} -* [[TIMER (statement)]] {{text|events based on the designated time interval and timer number.}} -* [[TO]] {{text|indicates a range of numerical values or an assignment of one value to another.}} -* [[TYPE]] (definition) {{text|defines a variable type or file record that can include any [[STRING]] or numerical types.}} - -
([[#toc|Return to Table of Contents]])
----- -
U
-* [[UBOUND]] (function) {{text|returns the upper-most index number of a designated [[arrays|array]].}} -* [[UCASE$]] (function) {{text|returns an uppercase representation of a specified [[STRING]].}} -* [[UEVENT]] (statement) '''{{text|Not implemented in QB64.}}''' -* [[UNLOCK]] (statement) {{text|unlocks a designated file or portions of it.}} -* [[UNTIL]] (condition) {{text|evaluates a [[DO...LOOP]] condition until it is True.}} - -
([[#toc|Return to Table of Contents]])
----- -
V
-* [[VAL]] (function) {{text|returns the numerical value of a [[STRING|string]] number.}} -* [[VARPTR]] (function) {{text|returns the [[segment]] pointer address in memory.}} -* [[VARPTR$]] (function) {{text|returns the string value of a numerical value in memory.}} -* [[VARSEG]] (function) {{text|returns the [[segment]] address of a value in memory.}} -* [[VIEW]] (graphics statement) {{text|sets up a graphic view port area of the [[SCREEN|screen]].}} -* [[VIEW PRINT]] (statement) {{text|sets up a text viewport area of the [[SCREEN|screen]].}} - -
([[#toc|Return to Table of Contents]])
----- -
W
-* [[WAIT]] (statement) {{text|waits until a vertical retrace is started or a [[SCREEN|screen]] draw ends.}} -* [[WEND]] (statement) {{text|the bottom end of a [[WHILE...WEND]] loop.}} -* [[WHILE]] (condition) {{text|evaluates a [[DO...LOOP]] or [[WHILE...WEND]] condition until it is False.}} -* [[WHILE...WEND]] (statement) {{text|sets a recursive procedure loop that can only be exited using the [[WHILE]] conditional argument.}} -* [[WIDTH]] (statement) {{text|sets the text column and row sizes in several [[SCREEN]] modes.}} -* [[WINDOW]] (statement) {{text|maps a window size different from the program's window size.}} -* [[WRITE]] (screen I/O statement) {{text|prints variable values to the screen with commas separating each value.}} -* [[WRITE (file statement)]] {{text|writes data to a file with each variable value separated by commas.}} - -
([[#toc|Return to Table of Contents]])
----- -
X
-* [[XOR]] (logic operator) {{text|is used to compare two numerical values bitwise.}} - -
([[#toc|Return to Table of Contents]])
- -
([[#Original QBasic keywords|Go to Top of Original QBasic keywords]])
- - -== OpenGL specific keywords == -
'''All QB64 OpenGL keywords must use the underscore _gl prefix with the alphabetically listed function names.'''
-
Use [[$NOPREFIX]] to enable these to be used without the leading underscore.
- -* Important: See [[_GL|SUB _GL]] - - ----- -
_glA
-* [[_glAccum]] (statement) {{text|operates on the accumulation buffer}} -* [[_glAlphaFunc]] (statement) {{text|enables your application to set the alpha test function.}} -* [[_glAreTexturesResident]] (function) {{text|determines whether specified texture objects are resident in texture memory.}} -* [[_glArrayElement]] (statement) {{text|specifies the array elements used to render a vertex.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glB
-* [[_glBegin]] (statement) {{text|the '''_glBegin''' and '''_glEnd''' statements delimit the vertices of a primitive or a group of like primitives.}} -* [[_glBindTexture]] (statement) {{text|enables the creation of a named texture that is bound to a texture target}} -* [[_glBitmap]] (statement) {{text|draws a bitmap.}} -* [[_glBlendFunc]] (statement) {{text|specifies pixel arithmetic.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glC
-* [[_glCallList]] (statement) {{text|executes a display list.}} -* [[_glCallLists]] (statement) {{text|executes a list of display lists.}} -* [[_glClear]] (statement) {{text|clears buffers to preset values.}} -* [[_glClearAccum]] (statement) {{text|specifies the clear values for the accumulation buffer.}} -* [[_glClearColor]] (statement) {{text|specifies clear values for the color buffers.}} -* [[_glClearDepth]] (statement) {{text|specifies the clear value for the depth buffer.}} -* [[_glClearIndex]] (statement) {{text|specifies the clear value for the color-index buffers.}} -* [[_glClearStencil]] (statement) {{text|specifies the clear value for the stencil buffer.}} -* [[_glClipPlane]] (statement) {{text|specifies a plane against which all geometry is clipped.}} -'''----- Set three component (RGB) colors sort by used data type. -----''' -* [[_glColor3b]] (statement) {{text|sets the current color.}} -* [[_glColor3bv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3d]] (statement) {{text|sets the current color.}} -* [[_glColor3dv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3f]] (statement) {{text|sets the current color.}} -* [[_glColor3fv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3i]] (statement) {{text|sets the current color.}} -* [[_glColor3iv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3s]] (statement) {{text|sets the current color.}} -* [[_glColor3sv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3ub]] (statement) {{text|sets the current color.}} -* [[_glColor3ubv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3ui]] (statement) {{text|sets the current color.}} -* [[_glColor3uiv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor3us]] (statement) {{text|sets the current color.}} -* [[_glColor3usv]] (statement) {{text|sets the current color from an already existing array of color values.}} -'''----- Set four component (RGBA) colors sort by used data type. -----''' -* [[_glColor4b]] (statement) {{text|sets the current color.}} -* [[_glColor4bv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4d]] (statement) {{text|sets the current color.}} -* [[_glColor4dv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4f]] (statement) {{text|sets the current color.}} -* [[_glColor4fv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4i]] (statement) {{text|sets the current color.}} -* [[_glColor4iv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4s]] (statement) {{text|sets the current color.}} -* [[_glColor4sv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4ub]] (statement) {{text|sets the current color.}} -* [[_glColor4ubv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4ui]] (statement) {{text|sets the current color.}} -* [[_glColor4uiv]] (statement) {{text|sets the current color from an already existing array of color values.}} -* [[_glColor4us]] (statement) {{text|sets the current color.}} -* [[_glColor4usv]] (statement) {{text|sets the current color from an already existing array of color values.}} -'''----- End of set colors. -------------------------------------------''' -* [[_glColorMask]] (statement) {{text|enables and disables writing of frame-buffer color components.}} -* [[_glColorMaterial]] (statement) {{text|causes a material color to track the current color.}} -* [[_glColorPointer]] (statement) {{text|defines an array of colors.}} -* [[_glCopyPixels]] (statement) {{text|copies pixels in the framebuffer.}} -* [[_glCopyTexImage1D]] (statement) {{text|copies pixels from the framebuffer into a one-dimensional texture image.}} -* [[_glCopyTexImage2D]] (statement) {{text|copies pixels from the framebuffer into a two-dimensional texture image.}} -* [[_glCopyTexSubImage1D]] (statement) {{text|copies a sub-image of a one-dimensional texture image from the framebuffer.}} -* [[_glCopyTexSubImage2D]] (statement) {{text|copies a sub-image of a two-dimensional texture image from the framebuffer.}} -* [[_glCullFace]] (statement) {{text|specifies whether front-facing or back-facing facets can be culled.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glD
-* [[_glDeleteLists]] (statement) {{text|deletes a contiguous group of display lists.}} -* [[_glDeleteTextures]] (statement) {{text|deletes named textures.}} -* [[_glDepthFunc]] (statement) {{text|specifies the value used for depth-buffer comparisons.}} -* [[_glDepthMask]] (statement) {{text|enables or disables writing into the depth buffer.}} -* [[_glDepthRange]] (statement) {{text|specifies the mapping of z values from normalized device coordinates to window coordinates.}} -* [[_glDisable]] (statement) {{text|the '''_glEnable''' and '''_glDisable''' statements enable or disable OpenGL capabilities.}} -* [[_glDisableClientState]] (statement) {{text|the '''_glEnableClientState''' and '''_glDisableClientState''' statements enable and disable arrays respectively.}} -* [[_glDrawArrays]] (statement) {{text|specifies multiple primitives to render.}} -* [[_glDrawBuffer]] (statement) {{text|specifies which color buffers are to be drawn into.}} -* [[_glDrawElements]] (statement) {{text|renders primitives from array data.}} -* [[_glDrawPixels]] (statement) {{text|writes a block of pixels to the framebuffer.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glE
-* [[_glEdgeFlag]] (statement) {{text|flags edges as either boundary or nonboundary.}} -* [[_glEdgeFlagv]] (statement) {{text|flags edges as either boundary or nonboundary.}} -* [[_glEdgeFlagPointer]] (statement) {{text|defines an array of edge flags.}} -* [[_glEnable]] (statement) {{text|the '''_glEnable''' and '''_glDisable''' statements enable or disable OpenGL capabilities.}} -* [[_glEnableClientState]] (statement) {{text|the '''_glEnableClientState''' and '''_glDisableClientState''' statements enable and disable arrays respectively.}} -* [[_glEnd]] (statement) {{text|the '''_glBegin''' and '''_glEnd''' statements delimit the vertices of a primitive or a group of like primitives.}} -* [[_glEndList]] (statement) {{text|the '''_glNewList''' and '''_glEndList''' statements create or replace a display list.}} -* [[_glEvalCoord1d]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord1dv]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord1f]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord1fv]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord2d]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord2dv]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord2f]] (statement) {{text|OpenGL command}} -* [[_glEvalCoord2fv]] (statement) {{text|OpenGL command}} -* [[_glEvalMesh1]] (statement) {{text|OpenGL command}} -* [[_glEvalMesh2]] (statement) {{text|OpenGL command}} -* [[_glEvalPoint1]] (statement) {{text|OpenGL command}} -* [[_glEvalPoint2]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glF
-* [[_glFeedbackBuffer]] (statement) {{text|controls feedback mode.}} -* [[_glFinish]] (statement) {{text|blocks until all OpenGL execution is complete.}} -* [[_glFlush]] (statement) {{text|forces execution of OpenGL functions in finite time.}} -* [[_glFogf]] (statement) {{text|OpenGL command}} -* [[_glFogfv]] (statement) {{text|OpenGL command}} -* [[_glFogi]] (statement) {{text|OpenGL command}} -* [[_glFogiv]] (statement) {{text|OpenGL command}} -* [[_glFrontFace]] (statement) {{text|defines front-facing and back-facing polygons.}} -* [[_glFrustum]] (statement) {{text|multiplies the current matrix by a perspective matrix.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glG
-* [[_glGenLists]] (statement) {{text|OpenGL command}} -* [[_glGenTextures]] (statement) {{text|generates texture names.}} -* [[_glGetBooleanv]] (statement) {{text|OpenGL command}} -* [[_glGetClipPlane]] (statement) {{text|OpenGL command}} -* [[_glGetDoublev]] (statement) {{text|OpenGL command}} -* [[_glGetError]] (function) {{text|returns error information.}} -* [[_glGetFloatv]] (statement) {{text|OpenGL command}} -* [[_glGetIntegerv]] (statement) {{text|OpenGL command}} -* [[_glGetLightfv]] (statement) {{text|OpenGL command}} -* [[_glGetLightiv]] (statement) {{text|OpenGL command}} -* [[_glGetMapdv]] (statement) {{text|OpenGL command}} -* [[_glGetMapfv]] (statement) {{text|OpenGL command}} -* [[_glGetMapiv]] (statement) {{text|OpenGL command}} -* [[_glGetMaterialfv]] (statement) {{text|OpenGL command}} -* [[_glGetMaterialiv]] (statement) {{text|OpenGL command}} -* [[_glGetPixelMapfv]] (statement) {{text|OpenGL command}} -* [[_glGetPixelMapuiv]] (statement) {{text|OpenGL command}} -* [[_glGetPixelMapusv]] (statement) {{text|OpenGL command}} -* [[_glGetPointerv]] (statement) {{text|OpenGL command}} -* [[_glGetPolygonStipple]] (statement) {{text|OpenGL command}} -* [[_glGetString]] (function) {{text|returns a string describing the current OpenGL connection.}} -* [[_glGetTexEnvfv]] (statement) {{text|OpenGL command}} -* [[_glGetTexEnviv]] (statement) {{text|OpenGL command}} -* [[_glGetTexGendv]] (statement) {{text|OpenGL command}} -* [[_glGetTexGenfv]] (statement) {{text|OpenGL command}} -* [[_glGetTexGeniv]] (statement) {{text|OpenGL command}} -* [[_glGetTexImage]] (statement) {{text|returns a texture image.}} -* [[_glGetTexLevelParameterfv]] (statement) {{text|OpenGL command}} -* [[_glGetTexLevelParameteriv]] (statement) {{text|OpenGL command}} -* [[_glGetTexParameterfv]] (statement) {{text|OpenGL command}} -* [[_glGetTexParameteriv]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glH
-* [[_glHint]] (statement) {{text|specifies implementation-specific hints.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glI
-* [[_glIndexMask]] (statement) {{text|OpenGL command}} -* [[_glIndexPointer]] (statement) {{text|OpenGL command}} -* [[_glIndexd]] (statement) {{text|OpenGL command}} -* [[_glIndexdv]] (statement) {{text|OpenGL command}} -* [[_glIndexf]] (statement) {{text|OpenGL command}} -* [[_glIndexfv]] (statement) {{text|OpenGL command}} -* [[_glIndexi]] (statement) {{text|OpenGL command}} -* [[_glIndexiv]] (statement) {{text|OpenGL command}} -* [[_glIndexs]] (statement) {{text|OpenGL command}} -* [[_glIndexsv]] (statement) {{text|OpenGL command}} -* [[_glIndexub]] (statement) {{text|OpenGL command}} -* [[_glIndexubv]] (statement) {{text|OpenGL command}} -* [[_glInitNames]] (statement) {{text|OpenGL command}} -* [[_glInterleavedArrays]] (statement) {{text|OpenGL command}} -* [[_glIsEnabled]] (function) {{text|tests whether a capability is enabled.}} -* [[_glIsList]] (statement) {{text|OpenGL command}} -* [[_glIsTexture]] (function) {{text|determines if a name corresponds to a texture.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glL
-* [[_glLightModelf]] (statement) {{text|OpenGL command}} -* [[_glLightModelfv]] (statement) {{text|OpenGL command}} -* [[_glLightModeli]] (statement) {{text|OpenGL command}} -* [[_glLightModeliv]] (statement) {{text|OpenGL command}} -* [[_glLightf]] (statement) {{text|OpenGL command}} -* [[_glLightfv]] (statement) {{text|OpenGL command}} -* [[_glLighti]] (statement) {{text|OpenGL command}} -* [[_glLightiv]] (statement) {{text|OpenGL command}} -* [[_glLineStipple]] (statement) {{text|OpenGL command}} -* [[_glLineWidth]] (statement) {{text|specifies the width of rasterized lines.}} -* [[_glListBase]] (statement) {{text|OpenGL command}} -* [[_glLoadIdentity]] (statement) {{text|OpenGL command}} -* [[_glLoadMatrixd]] (statement) {{text|OpenGL command}} -* [[_glLoadMatrixf]] (statement) {{text|OpenGL command}} -* [[_glLoadName]] (statement) {{text|OpenGL command}} -* [[_glLogicOp]] (statement) {{text|specifies a logical pixel operation for color index rendering.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glM
-* [[_glMap1d]] (statement) {{text|OpenGL command}} -* [[_glMap1f]] (statement) {{text|OpenGL command}} -* [[_glMap2d]] (statement) {{text|OpenGL command}} -* [[_glMap2f]] (statement) {{text|OpenGL command}} -* [[_glMapGrid1d]] (statement) {{text|OpenGL command}} -* [[_glMapGrid1f]] (statement) {{text|OpenGL command}} -* [[_glMapGrid2d]] (statement) {{text|OpenGL command}} -* [[_glMapGrid2f]] (statement) {{text|OpenGL command}} -* [[_glMaterialf]] (statement) {{text|OpenGL command}} -* [[_glMaterialfv]] (statement) {{text|OpenGL command}} -* [[_glMateriali]] (statement) {{text|OpenGL command}} -* [[_glMaterialiv]] (statement) {{text|OpenGL command}} -* [[_glMatrixMode]] (statement) {{text|OpenGL command}} -* [[_glMultMatrixd]] (statement) {{text|OpenGL command}} -* [[_glMultMatrixf]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glN
-* [[_glNewList]] (statement) {{text|the '''_glNewList''' and '''_glEndList''' statements create or replace a display list.}} -* [[_glNormal3b]] (statement) {{text|OpenGL command}} -* [[_glNormal3bv]] (statement) {{text|OpenGL command}} -* [[_glNormal3d]] (statement) {{text|OpenGL command}} -* [[_glNormal3dv]] (statement) {{text|OpenGL command}} -* [[_glNormal3f]] (statement) {{text|OpenGL command}} -* [[_glNormal3fv]] (statement) {{text|OpenGL command}} -* [[_glNormal3i]] (statement) {{text|OpenGL command}} -* [[_glNormal3iv]] (statement) {{text|OpenGL command}} -* [[_glNormal3s]] (statement) {{text|OpenGL command}} -* [[_glNormal3sv]] (statement) {{text|OpenGL command}} -* [[_glNormalPointer]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glO
-* [[_glOrtho]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glP
-* [[_glPassThrough]] (statement) {{text|OpenGL command}} -* [[_glPixelMapfv]] (statement) {{text|OpenGL command}} -* [[_glPixelMapuiv]] (statement) {{text|OpenGL command}} -* [[_glPixelMapusv]] (statement) {{text|OpenGL command}} -* [[_glPixelStoref]] (statement) {{text|OpenGL command}} -* [[_glPixelStorei]] (statement) {{text|OpenGL command}} -* [[_glPixelTransferf]] (statement) {{text|OpenGL command}} -* [[_glPixelTransferi]] (statement) {{text|OpenGL command}} -* [[_glPixelZoom]] (statement) {{text|OpenGL command}} -* [[_glPointSize]] (statement) {{text|specifies the diameter of rasterized points.}} -* [[_glPolygonMode]] (statement) {{text|selects a polygon rasterization mode.}} -* [[_glPolygonOffset]] (statement) {{text|sets the scale and units OpenGL uses to calculate depth values.}} -* [[_glPolygonStipple]] (statement) {{text|OpenGL command}} -* [[_glPopAttrib]] (statement) {{text|OpenGL command}} -* [[_glPopClientAttrib]] (statement) {{text|OpenGL command}} -* [[_glPopMatrix]] (statement) {{text|OpenGL command}} -* [[_glPopName]] (statement) {{text|OpenGL command}} -* [[_glPrioritizeTextures]] (statement) {{text|OpenGL command}} -* [[_glPushAttrib]] (statement) {{text|OpenGL command}} -* [[_glPushClientAttrib]] (statement) {{text|OpenGL command}} -* [[_glPushMatrix]] (statement) {{text|OpenGL command}} -* [[_glPushName]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glR
-* [[_glRasterPos2d]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2dv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2f]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2fv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2i]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2iv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2s]] (statement) {{text|OpenGL command}} -* [[_glRasterPos2sv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3d]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3dv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3f]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3fv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3i]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3iv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3s]] (statement) {{text|OpenGL command}} -* [[_glRasterPos3sv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4d]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4dv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4f]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4fv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4i]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4iv]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4s]] (statement) {{text|OpenGL command}} -* [[_glRasterPos4sv]] (statement) {{text|OpenGL command}} -* [[_glReadBuffer]] (statement) {{text|selects a color buffer source for pixels.}} -* [[_glReadPixels]] (statement) {{text|reads a block of pixels from the framebuffer.}} -* [[_glRectd]] (statement) {{text|OpenGL command}} -* [[_glRectdv]] (statement) {{text|OpenGL command}} -* [[_glRectf]] (statement) {{text|OpenGL command}} -* [[_glRectfv]] (statement) {{text|OpenGL command}} -* [[_glRecti]] (statement) {{text|OpenGL command}} -* [[_glRectiv]] (statement) {{text|OpenGL command}} -* [[_glRects]] (statement) {{text|OpenGL command}} -* [[_glRectsv]] (statement) {{text|OpenGL command}} -* [[_glRenderMode]] (statement) {{text|OpenGL command}} -* [[_glRotated]] (statement) {{text|OpenGL command}} -* [[_glRotatef]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glS
-* [[_glScaled]] (statement) {{text|OpenGL command}} -* [[_glScalef]] (statement) {{text|OpenGL command}} -* [[_glScissor]] (statement) {{text|defines the scissor box.}} -* [[_glSelectBuffer]] (statement) {{text|OpenGL command}} -* [[_glShadeModel]] (statement) {{text|OpenGL command}} -* [[_glStencilFunc]] (statement) {{text|sets the function and reference value for stencil testing.}} -* [[_glStencilMask]] (statement) {{text|controls the writing of individual bits in the stencil planes.}} -* [[_glStencilOp]] (statement) {{text|sets the stencil test actions.}} - -
([[#toc|Return to Table of Contents]])
----- -
_glT
-* [[_glTexCoord1d]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1dv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1f]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1fv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1i]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1iv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1s]] (statement) {{text|OpenGL command}} -* [[_glTexCoord1sv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2d]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2dv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2f]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2fv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2i]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2iv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2s]] (statement) {{text|OpenGL command}} -* [[_glTexCoord2sv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3d]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3dv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3f]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3fv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3i]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3iv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3s]] (statement) {{text|OpenGL command}} -* [[_glTexCoord3sv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4d]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4dv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4f]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4fv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4i]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4iv]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4s]] (statement) {{text|OpenGL command}} -* [[_glTexCoord4sv]] (statement) {{text|OpenGL command}} -* [[_glTexCoordPointer]] (statement) {{text|OpenGL command}} -* [[_glTexEnvf]] (statement) {{text|OpenGL command}} -* [[_glTexEnvfv]] (statement) {{text|OpenGL command}} -* [[_glTexEnvi]] (statement) {{text|OpenGL command}} -* [[_glTexEnviv]] (statement) {{text|OpenGL command}} -* [[_glTexGend]] (statement) {{text|OpenGL command}} -* [[_glTexGendv]] (statement) {{text|OpenGL command}} -* [[_glTexGenf]] (statement) {{text|OpenGL command}} -* [[_glTexGenfv]] (statement) {{text|OpenGL command}} -* [[_glTexGeni]] (statement) {{text|OpenGL command}} -* [[_glTexGeniv]] (statement) {{text|OpenGL command}} -* [[_glTexImage1D]] (statement) {{text|specifies a one-dimensional texture image.}} -* [[_glTexImage2D]] (statement) {{text|specifies a two-dimensional texture image.}} -* [[_glTexParameterf]] (statement) {{text|OpenGL command}} -* [[_glTexParameterfv]] (statement) {{text|OpenGL command}} -* [[_glTexParameteri]] (statement) {{text|OpenGL command}} -* [[_glTexParameteriv]] (statement) {{text|OpenGL command}} -* [[_glTexSubImage1D]] (statement) {{text|specifies a portion of an existing one-dimensional texture image.}} -* [[_glTexSubImage2D]] (statement) {{text|specifies a portion of an existing one-dimensional texture image.}} -* [[_glTranslated]] (statement) {{text|OpenGL command}} -* [[_glTranslatef]] (statement) {{text|OpenGL command}} - -
([[#toc|Return to Table of Contents]])
----- -
_glV
-* [[_glVertex2d]] (statement) {{text|OpenGL command}} -* [[_glVertex2dv]] (statement) {{text|OpenGL command}} -* [[_glVertex2f]] (statement) {{text|OpenGL command}} -* [[_glVertex2fv]] (statement) {{text|OpenGL command}} -* [[_glVertex2i]] (statement) {{text|OpenGL command}} -* [[_glVertex2iv]] (statement) {{text|OpenGL command}} -* [[_glVertex2s]] (statement) {{text|OpenGL command}} -* [[_glVertex2sv]] (statement) {{text|OpenGL command}} -* [[_glVertex3d]] (statement) {{text|OpenGL command}} -* [[_glVertex3dv]] (statement) {{text|OpenGL command}} -* [[_glVertex3f]] (statement) {{text|OpenGL command}} -* [[_glVertex3fv]] (statement) {{text|OpenGL command}} -* [[_glVertex3i]] (statement) {{text|OpenGL command}} -* [[_glVertex3iv]] (statement) {{text|OpenGL command}} -* [[_glVertex3s]] (statement) {{text|OpenGL command}} -* [[_glVertex3sv]] (statement) {{text|OpenGL command}} -* [[_glVertex4d]] (statement) {{text|OpenGL command}} -* [[_glVertex4dv]] (statement) {{text|OpenGL command}} -* [[_glVertex4f]] (statement) {{text|OpenGL command}} -* [[_glVertex4fv]] (statement) {{text|OpenGL command}} -* [[_glVertex4i]] (statement) {{text|OpenGL command}} -* [[_glVertex4iv]] (statement) {{text|OpenGL command}} -* [[_glVertex4s]] (statement) {{text|OpenGL command}} -* [[_glVertex4sv]] (statement) {{text|OpenGL command}} -* [[_glVertexPointer]] (statement) {{text|OpenGL command}} -* [[_glViewport]] (statement) {{text|sets the viewport.}} - -
([[#toc|Return to Table of Contents]])
- -
([[#OpenGL specific keywords|Go to Top of OpenGL specific keywords]])
- - -== Symbols == -
'''QB64 and QB Symbols:'''
- -
''[Note: All symbols below can also be used inside of literal quoted strings except for quotation marks.]''
- - -:'''Print, Input or File Formatting''' -* [[Semicolon|; Semicolon]] after a [[PRINT]] stops invisible cursor at end of printed value. Can prevent screen rolling. A [[Semicolon]] after the [[INPUT]] prompt text will display a question mark after the text. -* [[Comma|, Comma]] after a [[PRINT]] tabs invisible cursor past end of printed value. After the [[INPUT]] prompt text a [[comma]] displays no [[Question mark]]. -* [[Quotation mark|" Quotation mark]] delimits the ends of a literal [[STRING]] value in a [[PRINT]], [[INPUT]] or [[LINE INPUT]] statement. -* [[Question mark|? Question mark]] is a shortcut substitute for the [[PRINT]] keyword. Will change to PRINT when cursor leaves the code line. -
([[#toc|Return to Table of Contents]])
- -:'''Program Code Markers''' -* [[Apostrophe|' Apostrophe]] ignores a line of code or program comment and MUST be used before a [[Metacommand]]. Same as using [[REM]]. -* [[Comma|, Comma]] is used to separate [[DATA]], [[SUB]] or [[FUNCTION]] parameter variables. -* [[Colon|: Colon]]s can be used to separate two procedure statements on one code line. -* [[Dollar_Sign|$ Dollar sign]] prefix denotes a QBasic [[Metacommand]]. -* [[Parenthesis|( ) Parenthesis]] enclose a math or conditional procedure order, [[SUB]] or [[FUNCTION]] parameters or to pass by value. -* [[+|+ Plus]] [[concatenation]] operator MUST be used to combine literal string values in a variable definition. -* [[Quotation mark|" Quotation mark]] designates the ends of a literal [[STRING]] value. Use [[CHR$]](34) to insert quotes in a text [[STRING]]. -* [[Underscore|_ Underscore]] can be used to continue a line of code to the next program line in '''QB64'''. -
([[#toc|Return to Table of Contents]])
- -:'''Variable Name Type Suffixes''' -* [[STRING|$ STRING]] text character type: 1 byte -* [[SINGLE|! SINGLE]] floating decimal point numerical type (4 bytes) -* [[DOUBLE|# DOUBLE]] floating decimal point numerical type (8 bytes) -* [[_FLOAT|## _FLOAT]] '''QB64''' decimal point numerical type (32 bytes) -* [[_UNSIGNED|~ _UNSIGNED]] '''QB64''' [[INTEGER|whole]] positive numerical type when it precedes the 6 numerical suffixes below: -* [[INTEGER|% INTEGER]] [[INTEGER|whole]] numerical type (2 bytes) -* [[LONG|& LONG]] [[INTEGER|whole]] numerical type (4 bytes} -* [[_INTEGER64|&& _INTEGER64]] '''QB64''' [[INTEGER|whole]] numerical type (8 bytes) -* [[_BIT|` _BIT]] '''QB64''' [[INTEGER|whole]] numerical type (1 bit) (Key below tilde (~) or [[CHR$]](96)) -* [[_BYTE|%% _BYTE]] '''QB64''' [[INTEGER|whole]] numerical type (1 byte) -* [[_OFFSET|%& _OFFSET]] '''QB64''' [[INTEGER|whole]] numerical pointer address type (any byte size required) -
([[#toc|Return to Table of Contents]])
- -:'''Numerical Base Prefixes''' -* [[&B|&B Binary]] Base 2: Digits 0 or 1 ['''QB64'''] -* [[&O|&O Octal]] Base 8: Digits 0 to 7 -* [[&H|&H Hexadecimal]] Base 16: Digits 0 to F -
([[#toc|Return to Table of Contents]])
- -:'''[[Mathematical Operations]]''' -*[[+|+ Addition]] operator or sign -*[[-|- Subtraction]] operator or sign -*[[*|* Multiplication]] operator -*[[/|/ Division]] (floating decimal point) operator -*[[\|\ Integer division]] operator -*[[^|^ Exponential]] operator -*[[MOD|MOD Integer Remainder division]] operator -
([[#toc|Return to Table of Contents]])
- -:'''[[Relational Operations]]''' -* [[Equal|=]] Equal to condition -* [[Not_Equal|<>]] Not equal condition -* [[Greater_Than|>]] Greater than condition -* [[Less_Than|<]] Less than condition -* [[Greater_Than_Or_Equal|>=]] Greater than or equal to condition -* [[Less_Than_Or_Equal|<=]] Less than or equal to condition -
([[#toc|Return to Table of Contents]])
- - -== References == - -
'''WIKI Pages'''
- -
[[#QB64 specific keywords|Go to Top of QB64 specific keywords]]
- -
[[#Original QBasic keywords|Go to Top of Original QBasic keywords]]
- -
[[#OpenGL specific keywords|Go to Top of OpenGL specific keywords]]
- -
[[Keyword Reference - By usage|Go to keywords by Usage]]
- -
[[Main_Page|Main Page with Articles and Tutorials]]
- - -
'''Got a question about something?'''
- -
[[QB64 FAQ|Visit the QB64 FAQ]]
- -
[http://qb64phoenix.com Visit the QB64-PE Main Site]
- -
[http://qb64phoenix.com/forum/index.php Visit QB64-PE Community Forum]
- - -
'''Links to other QBasic Sites:'''
- -
[http://www.petesqbsite.com/phpBB3/ Pete's QBasic Forum]
- -
[http://www.petesqbsite.com/downloads/downloads.shtml Pete's QBasic Downloads]
- - -
([[#toc|Return to Table of Contents]])
diff --git a/internal/help/Keyword_Reference_-_By_usage_1000000_100000000_-_10_00000.txt b/internal/help/Keyword_Reference_-_By_usage_1000000_100000000_-_10_00000.txt deleted file mode 100644 index 95fc8a86c..000000000 --- a/internal/help/Keyword_Reference_-_By_usage_1000000_100000000_-_10_00000.txt +++ /dev/null @@ -1,1146 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:56}} -__NOEDITSECTION__ -{|align="Right" -|__TOC__ -|} - - - -[[QB64 FAQ|Go to Frequently Asked Questions about QB64]] - -[[Keyword Reference - Alphabetical|Go to Alphabetical keywords]] - -[[Keywords currently not supported by QB64]] - -[[Keywords currently not supported by QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keywords Not Supported in Linux or MAC versions]] - - -== [[Arrays]] and Data Storage == - -
'''Arrays'''
-* [[_DEFINE]] (statement) {{text|defines a range of untyped variable names according to their first character as a datatype.}} -* [[_PRESERVE]] ([[REDIM]] option) {{text|preserves the existing element values when an array is resized.}} -* [[CLEAR]] (statement) {{text|resets all variable values and array element values to 0 or null [[STRING|strings]] and closes all open files.}} -* [[DIM]] (statement) {{text|dimensions(sizes) a [[STATIC|static]] array and defines the type.}} -* [[$DYNAMIC]] (metacommand) {{text|defines that all arrays are dynamic or changeable in size.}} -* [[ERASE]] (array statement) {{text|clears a [[STATIC|static]] array of all values and totally removes a [[$DYNAMIC|dynamic]] array.}} -* [[LBOUND]] (array function) {{text|returns the lowest valid index (lower boundary) of an [[arrays|array]].}} -* [[OPTION BASE]] (statement) {{text|sets the default starting index of an array to 0 or 1.}} -* [[REDIM]] (statement) {{text|re-dimensions the number of elements in a [[$DYNAMIC|dynamic]](resizeable) [[arrays|array]] and defines the type.}} -* [[SHARED]] (statement) {{text|designates variable values that can be shared with sub-procedures without using parameters.}} -* [[STATIC]] (statement) {{text|defines a variable or list of variables that will retain their values after the sub-procedure is exited.}} -* [[$STATIC]] (metacommand) {{text|defines that all arrays are static or unchangeable in size.}} -* [[SWAP]] (statement) {{text|trades the values of two numerical or string values or array elements.}} -* [[UBOUND]] (array function) {{text|returns the highest valid index (upper boundary) of an [[arrays|array]].}} - -: See also: [[Arrays]] - - -
'''Fixed Program DATA'''
-* [[DATA]] (statement) {{text|creates a field of built-in program data values separated by commas.}} -* [[READ]] (statement) {{text|reads the DATA from the data field sequentially.}} -* [[RESTORE]] (statement) {{text|sets the data pointer to the start of all DATA or a specified DATA field.}} - - -

([[#toc|Return to Table of Contents]])

- -== [[COLOR|Colors]] and Transparency == - -* [[_ALPHA]] (function) {{text|returns the alpha channel transparency level of a color value used on a screen page or image.}} -* [[_ALPHA32]] (function) {{text|function returns the alpha channel level of a 32 bit color value only.}} -* [[_BACKGROUNDCOLOR]] (function) {{text|returns the current background color.}} -* [[_BLEND]] (statement) {{text|turns on alpha blending for the current image or a specific one.}} -* [[_BLEND (function)]] {{text|returns if blending is enabled or disabled for the current window or a specified image handle.}} -* [[_BLINK]] (statement) {{text|statement turns blinking colors on/off in SCREEN 0}} -* [[_BLINK (function)]] {{text|returns -1 if enabled or 0 if disabled by [[_BLINK]] statement.}} -* [[_BLUE]] (function) {{text|returns the palette intensity OR the blue component intensity of a 32-bit image color.}} -* [[_BLUE32]] (function) {{text|returns the blue component intensity of a 32-bit image color.}} -* [[_CLEARCOLOR]] (statement) {{text|sets a specific color to be treated as transparent in an image}} -* [[_CLEARCOLOR (function)]] {{text|returns the current transparent color of an image.}} -* [[_COPYPALETTE]] (statement) {{text|copies the color palette intensities from one image to another image or screen page.}} -* [[_DEFAULTCOLOR]] (function) {{text|returns the current default text color for an image handle or page.}} -* [[_DONTBLEND]] (statement) {{text|turns off alpha blending for an image handle.}} -* [[_GREEN]] (function) {{text|returns the palette index OR the green component intensity of a 32-bit image.}} -* [[_GREEN32]] (function) {{text|returns the green component intensity of a 32-bit image color.}} -* [[_NEWIMAGE]] (function) {{text|prepares a custom sized program [[SCREEN]] or page surface that can use 256 or 32 bit colors.}} -* [[_PALETTECOLOR]] (statement) {{text|sets the color value of a palette entry of an image using 256 color modes or less (4 or 8 BPP).}} -* [[_PALETTECOLOR (function)]] {{text|returns the 32 bit attribute color setting of an image or screen page handle's palette.}} -* [[_PIXELSIZE]] (function) {{text|returns the color depth (Bits Per Pixel) of an image.}} -* [[_RED]] (function) {{text|returns the palette index OR the red component intensity of a 32-bit screen.}} -* [[_RED32]] (function) {{text|returns the red component intensity of a 32-bit image color.}} -* [[_RGB]] (function) {{text|returns the closest palette attribute index OR the [[LONG]] 32 bit color value in 32 bit screens.}} -* [[_RGB32]] (function) {{text|returns the [[LONG]] 32 bit color value only.}} -* [[_RGBA]] (function) {{text|returns the closest palette attribute index OR the [[LONG]] 32 bit color value in [[_ALPHA]] screens.}} -* [[_RGBA32]] (function) {{text|returns the [[LONG]] 32 bit [[_ALPHA]] color value only.}} -* [[_SETALPHA]] (statement) {{text|sets the alpha channel transparency level of some or all of the pixel colors of an image.}} - - -* [[CLS]] (statement) {{text|clears the screen and can set the background color in QB64.}} -* [[COLOR]] (statement) {{text|sets the current text color attribute or [[_RGB]] value to be used or background colors in some screen modes.}} -* [[INP]] (function) {{text|returns the RGB color intensity values from color port register &H3C9 for a specific attributes.}} -* [[OUT]] (statement) {{text|sets the color port access mode and sets the RGB color intensity values using &H3C9.}} -* [[PALETTE]] (statement) {{text|sets the Red, Green and Blue color attribute intensities using a RGB multiplier calculation.}} -* [[PALETTE USING]] (statement) {{text|sets the color intensity settings using a designated [[arrays|array]].}} -* [[POINT]] (function) {{text|returns a pixel coordinate color attribute or the [[LONG]] [[_RGB]] color value of a 32 bit color.}} -* [[PRESET]] (statement) {{text|sets a pixel coordinate to the background color or a color specified.}} -* [[PSET]] (statement) {{text|sets a pixel coordinate a specified color or uses the current color when not designated.}} -* [[SCREEN]] {{text|sets the screen mode of a program which may determine the number of colors available in legacy modes.}} - -

([[#toc|Return to Table of Contents]])

- -==[[Console Window]]== -* [[$CONSOLE]] (QB64 [[Metacommand]]) {{text|creates a console window throughout the program.}} -* [[_CONSOLE]] (statement) {{text|can be used to turn the console window OFF or ON or designate it as [[_DEST]] _CONSOLE for output.}} -* [[_CONSOLETITLE]] (statement) {{Text|creates a title for the console window using a literal or variable [[STRING|string]].}} -* [[$SCREENHIDE]] (QB64 [[Metacommand]]) {{text|hides the program window throughout the program until [[$SCREENSHOW]] is used.}} -* [[_SCREENHIDE]] {{text|hides the main program window in a section of code until [[_SCREENSHOW]] is used.}} -* [[$SCREENSHOW]] (QB64 [[Metacommand]]) {{text|displays the main program window throughout the program after [[$SCREENHIDE]] has been used.}} -* [[_SCREENSHOW]] {{text|displays the main program window in a section of code after [[_SCREENHIDE]] has been used.}} -* [[SHELL (function)|SHELL (QB64 function)]] {{text|executes a DOS command or calls another program. Returns codes sent by [[END]] or [[SYSTEM]].}} -* [[_SHELLHIDE]] (function) {{text|hides a DOS command or call to another program. Returns codes sent by [[END]] or [[SYSTEM]].}} - - -

([[#toc|Return to Table of Contents]])

- -== Conditional Operations == - - -* [[AND (boolean)]] {{text|returns True if all of the arguments are True.}} -* [[NOT]] (boolean) {{text|returns the opposite condition of an argument.}} -* [[OR (boolean)]] {{text|returns True if one of the arguments is True.}} -* [[XOR (boolean)]] {{text|returns True if only one of two arguments are True.}} - - -{{RelationalOperationsTable}} - - -
See also: [[#Logical Bitwise Operations|Logical Operations]] and [[Relational Operations]]
- - -

([[#toc|Return to Table of Contents]])

- -== Definitions and Variable Types == - -* [[_BIT]] {` numerical [[TYPE|type]]) {{text|values of 0 (bit off) or -1 (bit on). [[_UNSIGNED|Unsigned]] of 0 or 1.}} -* [[_BYTE]] {%% numerical [[TYPE|type]]) {{text|values from -128 to 127 (one byte or 8 [[_BIT]]s). [[_UNSIGNED|Unsigned]] from 0 to 255.}} -* [[_DEFINE]] (statement) {{text|defines a range of untyped variable names according to their first character as a datatype.}} -* [[_FLOAT]] {## numerical [[TYPE|type]]) {{text|values offer the maximum floating-point decimal precision available using QB64.}} -* [[_INTEGER64]] (&& numerical [[TYPE|type]]) {{text|values -9223372036854775808 to 9223372036854775807. [[_UNSIGNED|Unsigned]] to 18446744073709551615.}} -* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}} -* [[_OFFSET]](%& variable type) {{text|can store any memory offset integer value when using [[DECLARE LIBRARY]] or [[_MEM]]ory only.}} -* [[_UNSIGNED]] {~ numerical [[TYPE|type]]) {{text|defines an integer numerical value as being positive only in QB64.}} -* [[COMMON]] (statement) {{text|shares common variable values with other Linked or [[CHAIN]]ed programs.}} -* [[COMMON SHARED]] (statement) {{text|shares common variable values with all sub-procedures and other Linked or CHAINed programs.}} -* [[CONST]] (statement) {{text|defines one or more named numeric or string shared values which can not change in a program.}} -* [[DEFDBL]] (statement) {{text|defines undefined variable starting letters AS [[DOUBLE]] variables instead of the [[SINGLE]] type default.}} -* [[DEFINT]] (statement) {{text|defines undefined variable starting letters AS [[INTEGER]] variables instead of the [[SINGLE]] type default.}} -* [[DEFLNG]] (statement) {{text|defines undefined variable starting letters AS [[LONG]] variables instead of the [[SINGLE]] type default.}}}} -* [[DEFSNG]] (statement) {{text|defines undefined variable starting letters AS [[SINGLE]] variables instead of the [[SINGLE]] type default.}} -* [[DEFSTR]] (statement) {{text|defines undefined variable starting letters AS [[STRING]] variables instead of the [[SINGLE]] type default.}} -* [[DIM]] {{text|defines a variable or size a [[$STATIC|static]] array and can define the type of value it returns.}} -* [[DOUBLE]] {# numerical [[TYPE|type]]) {{text|an 8 byte floating decimal variable type with numerical values up to 15 decimal places.}} -* [[INTEGER]] {% numerical [[TYPE|type]]) {{text|a two byte variable type with values from -32768 to 32767. [[_UNSIGNED|Unsigned]] to 65535.}} -* [[LONG]] {& numerical [[TYPE|type]]) {{text|Integer values can be from -2147483648 to 2147483647. [[_UNSIGNED]] values to 4294967295.}} -* [[OPTION BASE]] (statement) {{text|sets the default starting index of an [[arrays|array]] to 0 or 1.}} -* [[REDIM]] {{text|defines and sizes a [[$DYNAMIC|dynamic]](changeable) array and can define the type of value returned.}} -* [[SHARED]] (statement) {{text|designates variable values that can be shared with sub-procedures without using [[SUB]] parameters.}} -* [[SINGLE]] (! numerical [[TYPE|type]]) {{text|a 4 byte floating decimal variable type with numerical values up to 7 decimal places.}} -* [[STATIC]] (statement) {{text|defines a variable or list of variables that will retain their values after the sub-procedure is exited.}} -* [[STRING]] ($ variable type) {{text|one byte text variable with [[ASCII]] code values from 0 to 255.}} -* [[TYPE]] (statement) {{text|defines variable types that can hold more than one variable type value of a fixed byte length.}} - - -
See also: [[Variable Types|QB64 Variable Types]] and [[Libraries#C.2B.2B_Variable_Types|C++ Variable Types]]
- -

([[#toc|Return to Table of Contents]])

- -== External Disk and API calls == -* [[_ACCEPTFILEDROP]] (statement) {{text|turns a program window into a valid drop destination for dragging files from Windows Explorer.}} -* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing device names and input types of system input devices.}} -* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system.}} -* [[_DIREXISTS]] (function) {{text|returns -1 if the directory folder name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[_DROPPEDFILE]] (function) {{text| returns the list of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.}} -* [[_CLIPBOARD$ (statement)]] {{text|sends [[STRING]] data to the Clipboard.}} -* [[_CLIPBOARD$]] (function) {{text|returns the current contents of the Clipboard as a [[STRING|string]].}} -* [[_CLIPBOARDIMAGE (function)]] {{text|pastes an image from the clipboard into a new QB64 image in memory.}} -* [[_CLIPBOARDIMAGE]] (statement) {{text|copies a valid QB64 image to the clipboard.}} -* [[_CWD$]] (function) {{text|returns the current working directory path as a [[STRING]].}} -* [[_DONTWAIT]] (SHELL action) {{text|allows the program to continue without waiting for the other program to close.}} -* [[_FILEEXISTS]] (function) {{text|returns -1 if the file name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[_FINISHDROP]] (statement) {{text| resets [[_TOTALDROPPEDFILES]] and clears the [[_DROPPEDFILE]] list of items (files/folders).}} -* [[_HIDE]] (SHELL action) {{text|hides the DOS screen output during a shell.}} -* [[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}} -* [[_OS$]] (function) {{text| returns the QB64 compiler version in which the program was compiled as [WINDOWS], [LINUX] or [MACOSX] and [32BIT] or [64BIT].}} -* [[_SCREENCLICK]] {{text|simulates clicking the mouse at a position on the screen to get focus.}} -* [[_SCREENIMAGE]] {{text|captures the current desktop screen image.}} -* [[_SCREENPRINT]] {{text|simulates keyboard entries on the desktop.}} -* [[_SHELLHIDE]] (function) {{text|executes a DOS command or calls another program. Returns codes sent by [[END]] or [[SYSTEM]].}} -* [[_STARTDIR$]] (function) {{text|returns the user's program calling path as a [[STRING]].}} -* [[_TOTALDROPPEDFILES]] (function) {{text| returns the number of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.}} - - -* [[CHDIR]] (statement) {{text|changes the program path to a new path.}} -* [[COMMAND$]] (function) {{text|returns command line parameters sent when a program is started.}} -* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/pair value.}} -* [[ENVIRON$]] (function) {{text|returns the environmental settings of the computer.}} -* [[_ENVIRONCOUNT]] (function) {{text|returns the number of key/value pairs currently exist in the environment table.}} -* [[FILES]] (statement) {{text|displays a specified list of files.}} -* [[MKDIR]] (statement) {{text|creates a new directory folder in the designated path.}} -* [[NAME]] (statement) {{text|renames a file.}} -* [[RMDIR]] (statement) {{text|removes an empty directory folder from the specified path.}} -* [[SHELL]] (statement) {{text|performs a command line operation in DOS.}} -* [[SHELL (function)|SHELL (QB64 function)]] {{text|executes a DOS command or calls another program. Returns codes sent by [[END]] or [[SYSTEM]].}} - - -

([[#toc|Return to Table of Contents]])

- -== Error Codes == - -The following table describes the error codes that are reported by the '''QB64''' compiler, as well as possible causes and solutions: - -{| border="1" cellpadding="2" -|- -! colspan="6"|QB/64 Error Codes -|- -! Code || Description || Common cause/Resolution || QB64 Differences -|- -| 1 || [[NEXT]] without [[FOR]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none -|- -| 2 || Syntax error || Mistyped keyword statements or puctuation errors can create syntax errors. || none -|- -| 3 || [[RETURN]] without [[GOSUB]] || Place sub-procedure line label after program [[END]] or [[EXIT]] in a [[SUB]]-procedure.|| none -|- -| 4 || Out of DATA || A [[READ]] has read past the end of [[DATA]]. Use [[RESTORE]] to reset to data start. . || none -|- -| 5 || Illegal function call || A parameter passed does not match the function type or exceeds certain function limitations. See [[Illegal Function]]. || none -|- -| 6 || Overflow || A numerical value has exceeded the limitations of a [[Variable Types|variable type]]. || none -|- -| 7 || Out of memory || A module has exceeded the 64K memory limitation of QB. Try breaking the code up to smaller modules.|| no limit -|- -| 8 || Label not defined || [[GOTO]] or [[GOSUB]] tries to branch to a label that doesn't exist. || none -|- -| 9 || Subscript out of range || An [[Arrays|array's]] [[UBOUND|upper]] or [[LBOUND|lower]] [[DIM|dimensioned]] boundary has been exceeded. || none -|- -| 10 || Duplicate definition || You can't define a variable twice with [[DIM]], the first time a variable is used it is also defined. || none -|- -| 11 || Division by zero || You cannot divide any value by zero! Even using [[MOD]]. || none -|- -| 12 || Illegal in direct mode || A statement (like [[DIM]]) in the Immediate window wasn't allowed. || N/A -|- -| 13 || Type mismatch || A [[SUB]] or [[FUNCTION]] parameter does not match the procedure Declaration. || none -|- -| 14 || Out of [[STRING|string]] space || A module has exceeded the 32767 text character limit. Use SUB print procedures. || no limit. -|- -| 16 || String formula too complex. || A string formula was too long or [[INPUT]] statement requested more than 15 strings || N/A -|- -| 17 || Cannot continue. || The program while debugging has changed in a way that it cannot continue. || no debug -|- -| 18 || Function not defined. || The function used by the program must be defined. Did you include the .bi file while using a library? || none -|- -| 19 || No [[RESUME]]. || Use [[RESUME]] at the end of the [[ON ERROR]] [[GOTO]] routine, not [[RETURN]]. || none -|- -| 20 || RESUME without error. || [[RESUME]] can only be used in an error handler called by [[ON ERROR]] [[GOTO]]. || none -|- -| 24 || Device timeout. || Use DS0 (DSzero)in the [[OPEN COM]] statement to avoid modem timeouts. || none -|- -| 25 || Device fault. || Device not connected or does not exist. || none -|- -| 26 || [[FOR]] without [[NEXT]]. || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none -|- -| 27 || Out of paper || A printer paper error when using [[LPRINT]]. || none -|- -| 29 || [[WHILE]] without [[WEND]]. || [[WEND]] must end a [[WHILE]] loop. Otherwise look for missing [[END IF]] or [[END SELECT]] || none -|- -| 30 || [[WEND]] without [[WHILE]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none -|- -| 33 || Duplicate label || Line numbers or labels cannot be used twice in a procedure. || none -|- -| 35 || Subprogram not defined. || Often occurs when the Quickbasic Library is not used with [[CALL ABSOLUTE]] or [[INTERRUPT]] or a [[SUB]] or [[FUNCTION]] procedure has not been created for a [[CALL]]. || none -|- -| 37 || Argument-count mismatch || The number of sub-procedure [[parameters]] do not match the call. || none -|- -| 38 || Array not defined || [[Arrays]] using more than 10 elements must be [[DIM|DIMensioned]]. || none -|- -| 40 || Variable required. || [[LEN]] cannot read literal numerical values. A [[GET]] or [[PUT]] statement must specify a variable when reading or writing a file opened in [[BINARY]] mode. || none -|- -| 50 || [[FIELD]] overflow. || A [[FIELD]] statement tried to allocate more bytes than were specified for the record length of a random access file. || none -|- -| 51 || Internal error. || An internal malfunction occured in QuickBASIC or QB64. || none -|- -| 52 || Bad file name or number. || The filename must follow the rules for filenames in the OS and use filenumbers from 1 and 255. Use [[FREEFILE]] to avoid duplicate [[OPEN]] file numbers. || none -|- -| 53 || File not found. || File not in current directory or path. Use [[_FILEEXISTS]] to verify file names. || none -|- -| 54 || Bad file mode. || File access mode does not match a current [[OPEN]] file procedure. || none -|- -| 55 || File already open. || [[CLOSE]] a file to open it in a different mode. || none -|- -| 56 || FIELD statement active. || '''WRITEME''' || N/A -|- -| 57 || Device I/O error. || '''WRITEME''' || N/A -|- -| 58 || File already exists. || The filename specified in the [[NAME]] statement was identical to a file that already exists. || none -|- -| 59 || Bad record length. || Record length exceeds 32767 bytes or is 0 || none -|- -| 61 || Disk full. || The amount of data to write to the disk was more than the free space available, remove some files you don't need and try again. || none -|- -| 62 || Input past end of file. || Check for the end of file with [[EOF]] when reading from a file. || none -|- -| 63 || Bad record number. || [[GET]] read exceeds number of records in a [[RANDOM]] file. || none -|- -| 64 || Bad file name || File name contains illegal characters or exceeds 12 characters. || none -|- -| 67 || Too many files || Over 15 files are open in QBasic. || none -|- -| 68 || Device unavailable. || Device does not exist, busy or not connected. || none -|- -| 69 || Communication-buffer overflow. || '''WRITEME''' || N/A -|- -| 70 || Permission denied || A file or port is in use on a network, blocked, read only or locked. || none -|- -| 71 || Disk not ready. || Disk is busy or has no media. || none -|- -| 72 || Disk-media error. || Improper media format or bad data. || none -|- -| 73 || Feature unavailable. || Based on the DOS version available. || none -|- -| 74 || Rename across disks. || '''WRITEME''' || N/A -|- -| 75 || Path/File access error. || File or path cannot be accessed. || none -|- -| 76 || Path not found. || Path is not access-able or does not exist. Use [[_DIREXISTS]] to check paths.|| none -|- -| 97 || (no error message) || Can be used to trigger an error trap event with [[ERROR]] 97, nothing else will cause this error, so create your own errors for [[ON ERROR]]. || none -|- -|} -
'''N/A means Not Available or Not Applicable to QB64.'''
- - -{| border="1" cellpadding="2" -! colspan="6"|QB64 Error Codes -|- -! Code || Description || Common cause/resolution || QB Differences -|- -| 258 || Invalid handle || Zero or bad handle values cannot be used by the QB64 procedure creating the error. || N/A -|} - - -

([[#toc|Return to Table of Contents]])

- -== Error Trapping == - - -* [[_ASSERT]] (statement) {{text|Performs debug tests.}} -* [[$ASSERTS]] (metacommand) {{text|Enables the [[_ASSERT]] macro}}* [[$CHECKING]] ([[Metacommand]]) {{text|turns off or on error event checking and strips error code from compiled programs.}} -* [[_ERRORLINE]] (function) {{text|returns the actual text code line where a program error occurred.}} -* [[ERR]] (function) {{text|returns the error code number of the last error to occur.}} -* [[ERROR]] (statement) {{text|simulates a program error based on the error code number used.}} -* [[ERL]] (function) {{text|returns the closest line number before an error occurred if the program uses them.}} -* [[ON ERROR]] (statement) [[GOTO]] {{text|sends the program to a line number or label when an error occurs. Use to avoid program errors.}} -* [[RESUME]] (statement) {{text|error statement sends the program to the [[NEXT]] code line or a designated line number or label .}} - - -
See the [[ERROR Codes|Error Code Table]] reference.
- - -

([[#toc|Return to Table of Contents]])

- -== Event Trapping == - -* [[_AUTODISPLAY]] (statement) {{text|enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]].}} -* [[_DELAY]] (statement) {{text|suspends program execution for a [[SINGLE]] value of seconds down to milliseconds.}} -* [[_DISPLAY]] (statement) {{text|turns off automatic display while only displaying the screen changes when called.}} -*[[_EXIT (function)]] {{text|prevents a user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}} -*[[_FREETIMER]] (function) {{text|returns a free TIMER number for multiple [[ON TIMER(n)]] events.}} -* [[_MOUSEINPUT]] (function) {{text|reports any changes to the mouse status and MUST be used to read those changes.}} -* [[_SHELLHIDE]] (function) {{text|returns the code sent by a program exit using [[END]] or [[SYSTEM]] followed by an [[INTEGER]] value.}} - - -* [[OFF]] {{text|turns event checking off and does not remember subsequent events.}} -* [[ON]] {{text|turns event checking on.}} -* [[ON ERROR]] [[GOTO]] (event statement) {{text|executes when a program error occurs}} -* [[ON KEY(n)]] (event statement) {{text|executes when a keypress or keypress combination occurs.}} -* [[ON TIMER(n)]] (event statement) {{text|executes when a timed event occurs. QB64 can use multiple numbered timers.}} -* [[ON...GOSUB]] (event statement) {{text|branches to a line number or label according to a numerical ordered list of labels.}} -* [[ON...GOTO]] (event statement) {{text|branches to a line number or label according to a numerical ordered list of labels.}} -* [[STOP]] {{text|suspends event checking and remembers subsequent events that are executed when events are turned back on.}} -* [[TIMER]] (function) {{text|returns the number of seconds past the previous midnite down to a QB64 accuracy of one millisecond.}} -* [[TIMER (statement)]] {{text|enables, turns off or stops timer event trapping. In QB64 TIMER(n) FREE can free multiple timers. }} -* [[WAIT]] (statement) {{text|normally used to delay program display execution during or after vertical retrace periods.}} - -

([[#toc|Return to Table of Contents]])

- -== File Input and Output == - -* [[_DIREXISTS]] (function) {{text|returns -1 if the directory folder name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[_FILEEXISTS]] (function) {{text|returns -1 if the file name [[STRING|string]] parameter exists. Zero if it does not.}} -* [[ACCESS]] (clause) {{text|used in a networking [[OPEN]] statement to allow READ or WRITE access to files.}} -* [[APPEND]] (file mode) {{text|opens or creates a file that can be appended with data at the end.}} -* [[BINARY]] (file mode) {{text|opens or creates a file that can be byte accessed using both [[GET]] and [[PUT]].}} -* [[BLOAD]] (statement) {{text|opens a binary file and loads the contents to a specific array.}} -* [[BSAVE]] (statement) {{text|creates a binary file that holds the contents of a specified array.}} -* [[CHDIR]] (statement) {{text|changes the program path to a new path.}} -* [[CLOSE]] (statement) {{text|closes a specified file or all open files.}} -* [[EOF]] (file function) {{text|returns -1 when the end of a file has been read.}} -* [[FIELD]] (statement) {{text|creates a [[STRING]] type definition for a random-access file buffer.}} -* [[FILEATTR]] (function) {{text|can return a file's current file mode or DOS handle number.}} -* [[FILES]] (statement) {{text|displays a specified list of files.}} -* [[FREEFILE]] (file function) {{text|returns a file access number that is currently not in use.}} -* [[GET]] (file I/O statement) {{text|reads file data by byte or record positions.}} -* [[INPUT (file mode)]] {{text|only [[OPEN]]s existing sequential files for program INPUT.}} -* [[INPUT (file statement)]] {{text|reads sequential file data that was created using PRINT # or WRITE #. }} -* [[INPUT$]] (function) {{text|reads a specific number of bytes from random or binary files.}} -* [[KILL]] (statement) {{text|deletes a specified file without asking for verification. Remove empty folders with [[RMDIR]].}} -* [[LINE INPUT (file statement)]] {{text|reads an entire text row of printed sequential file data.}} -* [[LOC]] (function) {{text|finds the current file location or size of a [[COM]] port receive buffer.}} -* [[LOCK]] (statement) {{text|prevents access to a file.}} -* [[LOF]] (file function) {{text|returns the size of a file in bytes.}} -* [[MKDIR]] (statement) {{text|creates a new folder in the designated path.}} -* [[NAME]] (statement) {{text|renames a file [[AS]] a new file name.}} -* [[OPEN]] (file I/O statement) {{text|opens a specified file FOR an access mode with a set reference number.}} -* [[OUTPUT]] (file mode) {{text|opens or creates a new file that holds no data.}} -* [[PRINT (file statement)]] {{text|writes text and numerical data into a file.}} -* [[PRINT USING (file statement)]] {{text|writes template formatted text into a file.}} -* [[PUT]] (file I/O statement) {{text|writes data into a [[RANDOM]] or [[BINARY]] file by byte or record position.}} -* [[RANDOM]] (file mode) {{text|opens or creates a file that can be accessed using both [[GET]] and [[PUT]].}} -* [[RESET]] (statement) {{text|closes all files and writes the directory information to a diskette.}} -* [[RMDIR]] (statement) {{text|removes an empty folder from the specified path.}} -* [[SEEK]] (function) {{text|returns the current read or write byte position in a file.}} -* [[SEEK (statement)]] {{text|sets the current read or write byte position in a file.}} -* [[UNLOCK]] (statement) {{text|unlocks access to a file.}} -* [[WIDTH]] (statement) {{text|sets the text width of a file.}} -* [[WRITE (file statement)]] {{text|writes numerical and string data to a sequential file using comma separators.}} - -

([[#toc|Return to Table of Contents]])

- -== Fonts == - -* [[_FONT (function)]] {{text|creates a new alphablended font handle from a designated image handle}} -* [[_FONT]] (statement) {{text|sets the current [[_LOADFONT]] function font handle to be used by [[PRINT]] or [[_PRINTSTRING]].}} -* [[_FONTHEIGHT]] (function) {{text|returns the font height of a font handle created by [[_LOADFONT]].}} -* [[_FONTWIDTH]] (function) {{text|returns the font width of a MONOSPACE font handle created by [[_LOADFONT]].}} -* [[_FREEFONT]] (statement) {{text|frees a font handle value from memory}} -* [[_LOADFONT]] (function) {{text|loads a TrueType font (.TTF) file of a specific size and style and returns a font handle value.}} -* [[_MAPUNICODE]] (statement) {{text|maps a [[Unicode]] value to an [[ASCII]] character code value.}} -* [[_PRINTMODE (function)]] {{text|returns the present _PRINTMODE status as a numerical value.}} -* [[_PRINTMODE]] (statement) {{text|sets the text or [[_FONT]] printing mode on a background image when using [[PRINT]] or [[_PRINTSTRING]].}} -:*_KEEPBACKGROUND {{text|(1): Text background transparent. Only the text is displayed over anything behind it.}} -:*_ONLYBACKGROUND {{text|(2): Text background is only displayed. Text is transparent to anything behind it.}} -:*_FILLBACKGROUND {{text|(3): Text and background block anything behind them like a normal [[PRINT]]. Default setting.}} -* [[_PRINTSTRING]] (statement) {{text|prints text or custom font strings using graphic column and row coordinate positions.}} -* [[_PRINTWIDTH]] (function) {{text|returns the width in pixels of the [[_FONT]] or text [[STRING|string]] that a program will print.}} -* [[PRINT]] (statement) {{text|prints numeric or [[STRING|string]] expressions to the program screen.}} -* [[PRINT USING]] (statement) {{text|prints template formatted numeric or string values to the program screen.}} -* [[WRITE]] (screen I/O statement) {{text|writes a comma-separated list of values to the screen.}} - - -

([[#toc|Return to Table of Contents]])

- -== Game Controller Input (Joystick) == -* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from device axis center 0.}} -* [[_BUTTON]] (function) {{text|returns -1 when a device button is pressed and 0 when button is released.}} -* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}} -* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing a designated numbered input device name and types of input.}} -* [[_DEVICEINPUT]] (function) {{text|returns the [[_DEVICES]] number of an [[_AXIS]], [[_BUTTON]] or [[_WHEEL]] event.}} -* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system including the keyboard and mouse.}} -* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}} -* [[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}} -* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}} -* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor compared to the previous position.}} -* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor compared to the previous position.}} -* [[_WHEEL]] (function) {{text|returns -1 when a device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}} -* [[ON STRIG(n)]] (event statement) {{text|directs program flow upon a button press event of a game controller device.}} -* [[STICK]] (function) {{text|returns the directional axis coordinate values from 1 to 254 of game port (&H201) or USB controller devices.}} -* [[STRIG]] (function) {{text|returns the True or False button press status of game port (&H201) or USB controller devices.}} -* [[STRIG(n)]] (statement) {{text|enables, suspends or disables event trapping of STRIG button return values.}} - - -

([[#toc|Return to Table of Contents]])

- -== Graphic Commands == - -* [[_COPYIMAGE]] (function) {{text|can copy a software surface to a hardware accelerated surface handle using mode 33.}} -* [[_DISPLAY]] (statement) {{text|renders surfaces visible in the [[_DISPLAYORDER]] previously set in the QB64 program.}} -* [[_DISPLAYORDER]] {{text|sets the rendering order of _SOFTWARE, _HARDWARE and _GLRENDER with [[_DISPLAY]].}} -* [[_LOADIMAGE]] (function) {{text|can load images as hardware accelerated using mode 33.}} -* [[_MOUSESHOW]] (statement) {{text|a special string parameter after command in GL allows some special cursor shapes.}} -* [[_PUTIMAGE]] (statement) {{text|can place GL surfaces and allows the _SMOOTH action to blend stretched surfaces.}} - -

([[#toc|Return to Table of Contents]])

- -== Graphics and Imaging: == - -* [[_AUTODISPLAY]] (statement) {{text|enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]].}} -* [[_CLIP]] ([[PUT (graphics statement)|PUT]] action) {{text|allows placement of an image partially off of the screen.}} -* [[_COPYIMAGE]] (function) {{text|function duplicates an image handle from a designated handle.}} -* [[_COPYPALETTE]] (statement) {{text|copies the color palette intensities from one image to another image or screen page.}} -* [[_DEST]] (statement) {{text|sets the current write image or page. All graphics will go to this image.}} -* [[_DEST (function)]] {{text|returns the current write destination image or page.}} -* [[_DISPLAY]] (statement) {{text|turns off automatic display while only displaying the screen changes when called.}} -* [[_DISPLAY (function)]] {{text|returns the handle of the current image that is displayed on the screen.}} -* [[_FULLSCREEN (function)]] {{text|returns the present full screen mode setting of the screen window.}} -* [[_FULLSCREEN]] (statement) {{text|sets the full screen mode of the screen window. Alt + Enter can do it manually.}} -* [[_FREEIMAGE]] (statement) {{text|releases an image handle value from memory when no longer needed.}} -* [[_HEIGHT]] (function) {{text|returns the height of an image handle or current write page.}} -* [[_ICON]] (function) {{text|places an image in the title bar using a [[_LOADIMAGE]] handle.}} -* [[_LOADIMAGE]] (function) {{text|loads a graphic file image into memory and returns an image handle.}} -* [[_MAPTRIANGLE]] (statement) {{text|maps a triangular portion of an image to a destination image or screen page.}} -* [[_NEWIMAGE]] (function) {{text|prepares a window image or page surface and returns the handle value.}} -* [[_PIXELSIZE]] (function) {{text|returns the color depth (Bits Per Pixel) of an image.}} -* [[_PRINTSTRING]] (statement) {{text|prints text or custom font strings using graphic column and row coordinate positions.}} -* [[_PUTIMAGE]] (statement) {{text|maps a rectangular area of a source image to an area of a destination image in one operation}} -* [[_SCREENIMAGE]] (function) {{text|creates an image of the current desktop and returns an image handle.}} -* [[_SOURCE]] (statement) {{text|establishes the image SOURCE using a designated image handle}} -* [[_SOURCE (function)]] {{text|returns the present image _SOURCE handle value.}} -* [[_WIDTH (function)]] {{text|returns the width of an image handle or current write page.}} - - -* [[CIRCLE]] (statement) {{text|is used in graphics SCREEN modes to create circles, arcs or ellipses.}} -* [[CLS]] (statement) {{text|clears a screen page or the program [[SCREEN]]. QB64 can clear with a color.}} -* [[COLOR]] (statement) {{text|sets the current text color attribute or [[_RGB]] value to be used or background colors in some screen modes.}} -* [[DRAW]] (statement) {{text|uses a special type of [[STRING|string]] expression to draw lines on the screen.}} -* [[GET (graphics statement)]] {{text|used to store a box area image of the screen into an [[INTEGER]] array.}} -* [[LINE]] (statement) {{text|used in graphic [[SCREEN]] modes to create lines or boxes.}} -* [[PAINT]] (statement) {{text|used to color enclosed graphic objects with a designated fill color and border color.}} -* [[PALETTE]] (statement) {{text|can swap color settings, set colors to default or set the Red, Green, Blue color palette.}} -* [[PALETTE USING]] (statement) {{text|sets all RGB screen color intensities using values from an array.}} -* [[PCOPY]] (statement) {{text|copies one source screen page to a destination page in memory.}} -* [[PMAP]] (function) {{text|returns the physical or [[WINDOW]] view coordinates.}} -* [[POINT]] (function) {{text|returns the pixel [[COLOR]] attribute or [[_RGB]] value at a specified graphics coordinate.}} -* [[PRESET]] (statement) {{text|sets a pixel coordinate to the background color or a designated color.}} -* [[PSET]] (statement) {{text|sets a pixel coordinate to the default color or designated color attribute.}} -* [[PUT (graphics statement)]] {{text|statement is used to place [[GET (graphics statement)|GET]] saved or [[BSAVE]]d images stored in an array.}} -* [[SCREEN]] {{text|sets the screen mode of a program. No statement defaults the program to SCREEN 0 text only mode.}} -* [[STEP]] (relational statement) {{text|is used to step through FOR loop values or use relative graphical coordinates.}} -* [[VIEW]] (graphics statement) {{text|creates a graphics view port area by defining the coordinate limits to be viewed.}} -* [[WINDOW]] (statement) {{text|defines the coordinate dimensions of the current graphics viewport.}} - - -
'''See also: [[Bitmaps]], [[Icons and Cursors]], [[SAVEIMAGE]], [[GIF Images]]'''
- -

([[#toc|Return to Table of Contents]])

- -== Keyboard Input == -* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}} -* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}} -* [[_EXIT (function)]] {{text|prevents a program user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}} -* [[_KEYDOWN]] (function) {{text|returns whether modifying keys like CTRL, ALT, SHIFT, and any other keys are pressed.}} -* [[_KEYHIT]] (function) {{text|returns ASCII one and two byte, SDL Virtual Key and Unicode keyboard key press codes.}} -* [[_SCREENPRINT]] (statement) {{text|simulates typing text into another OS program using the keyboard.}} - - -* [[INKEY$]] (function) {{text|returns the [[ASCII]] [[STRING|string]] character of a keypress.}} -* [[INPUT]] (statement) {{text|requests a [[STRING]] or numerical keyboard entry from a program user.}} -* [[INPUT$]] (function) {{text|used to get a set number of keypress characters or bytes from a file.}} -* [[INP]] (function) {{text|returns a scan code value from keyboard register &H60(96) to determine key presses.}} -* [[KEY n]] (event statement) {{text|is used to assign a "softkey" string to a key and/or display them.}} -* [[KEY(n)]] (event statement) {{text|assigns, enables, disables or suspends event trapping of a keypress.}} -* [[KEY LIST]] (statement) {{text|lists the 12 Function key soft key string assignments going down left side of screen.}} -* [[LINE INPUT]] (statement) {{text|requests a [[STRING]] keyboard entry from a program user.}} -* [[ON KEY(n)]] (event statement) {{text|defines a line number or label to go to when a specified key is pressed.}} -* [[SLEEP]] (statement) {{text|pauses the program for a specified number of seconds or a until a key press.}} - - -
See also: [[Keyboard scancodes]], [[ASCII|ASCII Codes]] references or [[Windows_Libraries#Hot_Keys_.28maximize.29|Hot Keys for Windows]].
- - -

([[#toc|Return to Table of Contents]])

- -== [[Libraries]] == - -* [[_OFFSET (function)]] {{text|returns the memory offset of a variable when used with [[DECLARE DYNAMIC LIBRARY]] only.}} -* [[_OFFSET]](variable type) {{text|can be used store the value of an offset in memory when using [[DECLARE DYNAMIC LIBRARY]] only.}} - - -* [[ALIAS]] (statement) {{text|tells the program that you will use a different name than the name used in the Library file.}} -* [[BYVAL]] (statement) {{text|used to pass a parameter's value with sub-procedures from a Library.}} -* [[DECLARE LIBRARY]] {{text|allows the use of OS specific, SDL or C++ external library [[SUB]] and [[FUNCTION]] procedures}} -* [[DECLARE DYNAMIC LIBRARY]] {{text|declares DYNAMIC, CUSTOMTYPE or STATIC library(DLL) [[SUB]]s or [[FUNCTION]]s.}} -* [[DECLARE LIBRARY| END DECLARE]] {{text|required at the END of the block of Library declarations in QB64.}} - - -
'''QB64 also supports [[$INCLUDE]] text code file Libraries. QB64 does not support QLB Libraries or OBJ files.'''
- - -
See also: [[Libraries#C++_Variable_Types|C++ Variable Types]]
- - -

([[#toc|Return to Table of Contents]])

- -== Logical Bitwise Operations == - -* [[AND]] (operator) {{text|the bit is set when both bits are set.}} -* [[EQV]] (operator) {{text|the bit is set when both are set or both are not set.}} -* [[IMP]] (operator) {{text|the bit is set when both are set or both are unset or the second condition bit is set.}} -* [[OR]] (operator) {{text|the bit is set when either bit is set.}} -* [[NOT]] (operator) {{text|the bit is set when a bit is not set and not set when a bit is set.}} -* [[XOR]] (operator) {{text|the bit is set when just one of the bits are set.}} - - -{{LogicalTruthTable}} - - -

([[#toc|Return to Table of Contents]])

- -== Mathematical Functions and Operations == - -* [[_ROUND]] (function) {{text|rounds to the closest EVEN [[INTEGER]], [[LONG]] or [[_INTEGER64]] numerical value.}} - - -* [[+|+ addition operation]] -* [[-|- subtraction or negation operation]] -* [[*|* multiplication operation]] -* [[/|/ decimal point division operation]] -* [[\|\ integer division operation]] -* [[^|^ exponential operation]] -* [[MOD|MOD integer remainder operation]] - - -* [[ABS]] (function) {{text|returns the the positive value of a variable or literal numerical value.}} -* [[ATN]] (function) {{text|or arctangent returns the angle in radians of a numerical [[TAN|tangent]] value.}} -* [[CDBL]] (function) {{text|closest double rounding function}} -* [[CINT]] (function) {{text|closest integer rounding function}} -* [[CLNG]] (function) {{text|closest long integer rounding function}} -* [[COS]] (function) {{text|cosine of a radian angle}} -* [[CSNG]] (function) {{text|closest single rounding function}} -* [[EXP]] (function) {{text|returns the value of e to the power of the parameter used.}} -* [[FIX]] (function) {{text|rounds positive or negative values to integer values closer to 0}} -* [[INT]] (function) {{text|rounds to lower integer value}} -* [[LOG]] (function) {{text|natural logarithm of a specified numerical value.}} -* [[SIN]] (function) {{text|sine of a radian angle.}} -* [[SQR]] (function) {{text|square root of a positive number.}} -* [[TAN]] (function) {{text|returns the ratio of [[SIN]]e to [[COS]]ine or tangent value of an angle measured in radians.}} - - -
See also: [[Mathematical Operations]] and [[#Logical Bitwise Operations:|Logical Operations:]]
- -

([[#toc|Return to Table of Contents]])

- -== Memory Handling and Clipboard == - -* [[_CLIPBOARD$]] (function) {{text|returns the current [[STRING]] contents of the system Clipboard.}} -* [[_CLIPBOARD$ (statement)]] {{text|sets and overwrites the [[STRING]] contents of the current system Clipboard.}} -* [[_MEM (function)]] {{text|returns _MEM block referring to the largest continuous memory region beginning at a designated variable's offset.}} -* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}} -* [[_MEMCOPY]] (statement) {{text|copies a value from a designated OFFSET and SIZE [[TO]] a block of memory at a designated OFFSET.}} -* [[_MEMELEMENT]] (function) {{text|returns a [[_MEM]] block referring to a variable's memory (but not past it).}} -* [[_MEMEXISTS]] (function) {{text|verifies that a memory block exists for a memory variable name or returns zero.}} -* [[_MEMFILL]] (statement) {{text|fills a designated memory block OFFSET with a certain SIZE and TYPE of value.}} -* [[_MEMFREE]] (statement) {{text|frees a designated memory block in a program. Only free memory once!}} -* [[_MEMGET]] (statement) {{text|reads a designated value from a designated memory OFFSET}} -* [[_MEMGET (function)]] {{text|returns a value from a designated memory block and OFFSET using a designated variable [[TYPE]].}} -* [[_MEMIMAGE]] (function) {{text|returns a [[_MEM]] block referring to a designated image handle's memory}} -* [[_MEMNEW]] (function) {{text|allocates new memory with a designated SIZE and returns a [[_MEM]] block referring to it.}} -* [[_MEMPUT]] (statement) {{text|places a designated value into a designated memory [[_OFFSET]]}} -* [[_MEMSOUND]] (function) {{text|returns a [[_MEM]] block referring to a designated sound handle's memory}} -* [[_OFFSET (function)]] {{text|returns the memory offset of a variable when used with [[DECLARE LIBRARY]] or [[_MEM]] only.}} -* [[_OFFSET]](%& numerical type) {{text|can be used store the value of an offset in memory when using [[DECLARE LIBRARY]] or [[_MEM]] only.}} - - -
'''Functions and statements using QB64's emulated 16 bit memory'''
-* [[DEF SEG]] (statement) {{text|defines the segment address in memory.}} -* [[PEEK]] (function) {{text|returns the value that is contained at a certain memory address offset.}} -* [[POKE]] (statement) {{text|sets the value of a specified memory address offset.}} -* [[SADD]] (function) {{text|returns the address of a STRING variable as an offset from the current data segment.}} -* [[VARPTR]] (function) {{text|returns an [[INTEGER]] value that is the offset pointer of the memory address within it's [[segment]].}} -* [[VARPTR$]] (function) {{text|returns a STRING representation of a variable's memory address value}} -* [[VARSEG]] (function) {{text|returns an [[INTEGER]] value that is the [[segment]] part of a variable or array memory address.}} - -
See also: [[Screen Memory]] or [[Using _OFFSET]]
- -

([[#toc|Return to Table of Contents]])

- -== Metacommands == -:Metacommands are commands that affect a program globally after they are in used. Error checking can be turned [[OFF]] or [[ON]]. -
'''QB64 [[Metacommand]]s do NOT allow commenting or [[REM]]!'''
- -* [[$CHECKING]]:OFF/ON {{text|(QB64 only) turns event and error checking ON and OFF. ON (default) can only be used after it is OFF.}} -* [[$CONSOLE]] {{text|creates a console window throughout the program.}} -* [[$SCREENHIDE]] {{text|hides the program window throughout the program until [[$SCREENSHOW]] is used.}} -* [[$SCREENSHOW]] {{text|displays the main program window throughout the program only after [[$SCREENHIDE]] or [[_SCREENHIDE]] has been used.}} - - -
'''QBasic [[Metacommand]]s do not require commenting or [[REM]] in QB64!'''
-* '[[$DYNAMIC]] {{text|defines that all arrays are dynamic or changeable in size using [[DIM]] or [[REDIM]].}} -* '[[$INCLUDE]]: 'filename$' {{text|includes a text library file with procedures to be used in a program. Comment both sides of file name also.}} -* '[[$STATIC]] {{text|defines that all arrays are static or unchangeable in size using [[DIM]].}} - - -

([[#toc|Return to Table of Contents]])

- -== Mouse Input == -* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distances from device center 0.}} -* [[_BUTTON]] (function) {{text|returns -1 when a device button is pressed and 0 when button is released. 2 is the mouse center or scroll button}} -* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}} -* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing device names and input types of system input devices.}} -* [[_DEVICEINPUT]] (function) {{text|returns the [[_DEVICES]] number of an [[_AXIS]], [[_BUTTON]] or [[_WHEEL]] event. Mouse is normally _DEVICEINPUT(2).}} -* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system. The mouse is normally device 2.}} -* [[_EXIT (function)]] {{text|prevents a program user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}} -* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}} -*[[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}} -* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}} -* [[_MOUSEBUTTON]] (function) {{text|returns whether a specified mouse button number has been clicked. 3 is the mouse center or scroll button}} -* [[_MOUSEHIDE]] (statement) {{text|hides the OS mouse pointer from view.}} -* [[_MOUSEINPUT]] (function) {{text|must be used to monitor and read all changes in the mouse status.}} -* [[_MOUSEMOVE]] (statement) {{text|moves the mouse cursor pointer to a designated coordinate.}} -* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor.}} -* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor.}} -* [[_MOUSESHOW]] (statement) {{text|displays(default) the mouse cursor after it has been hidden.}} -* [[_MOUSEWHEEL]] (function) {{text|returns a positive or negative count the mouse scroll wheel clicks since the last read.}} -* [[_MOUSEX]] (function) {{text|indicates the current horizontal position of the mouse pointer.}} -* [[_MOUSEY]] (function) {{text|indicates the current vertical position of the mouse pointer.}} -* [[_SCREENCLICK]] {{text|simulates clicking the mouse at a position on the screen to get focus.}} -* [[_WHEEL]] (function) {{text|returns -1 when a device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}} - - -* [[CALL ABSOLUTE|CALL ABSOLUTE]] (statement) {{text|used to access Interrupt vector &H33 to work with the mouse. Functions 0 to 3 implemented.}} -* [[INTERRUPT]] (statement) {{text|used to access Interrupt vector &H33 to work with the mouse. Functions 0 to 3 implemented. }} - - -

([[#toc|Return to Table of Contents]])

- -== Numerical Manipulation and Conversion == - -* [[_CV]] (function) {{text|used to convert [[_MK$]] [[ASCII]] [[STRING|string]] values to specified numerical value types.}} -* [[_MK$]] (function) {{text|converts a specified numerical type into an [[ASCII]] [[STRING|string]] value that must be converted back using [[_CV]].}} -* [[_PRESERVE]] ([[REDIM]] action) {{text|preserves the current contents of an [[arrays|array]], when re-dimensioning it.}} -* [[_UNSIGNED]] {numerical [[TYPE|type]]) {{text|defines a numerical value as being positive only using QB64.}} - - -* [[ABS]] (function) {{text|returns the the positive value of a variable or literal numerical value.}} -* [[ASC]] (function) {{text|returns the [[ASCII]] code number of a certain [[STRING]] text character or a keyboard press.}} -* [[_BIN$]] (function) {{text|converts the [[INTEGER]] part of any value to binary [[STRING]] number value.}} -* [[CDBL]] (function) {{text|converts a numerical value to the closest [[DOUBLE]]-precision value.}} -* [[CHR$]] (function) {{text|returns the character associated with a certain [[ASCII]] character code as a [[STRING]].}} -* [[CINT]] (function) {{text|returns the closest [[INTEGER]] value of a number.}} -* [[CLEAR]] (statement) {{text|clears all variable values to 0 or null [[STRING|strings]] and closes all open files.}} -* [[CLNG]] (function) {{text| rounds decimal point numbers up or down to the nearest [[LONG]] integer value.}} -* [[CSNG]] (function) {{text|converts a numerical value to the closest [[SINGLE]]-precision number.}} -* [[CVD]] (function) {{text|converts [[STRING]] values to [[DOUBLE]] numerical values.}} -* [[CVDMBF]] (function) {{text|converts a 8-byte Microsoft Binary format [[STRING|string]] value to a [[DOUBLE]] precision number.}} -* [[CVI]] (function) {{text|converts 2 byte STRING values to [[INTEGER]] numerical values.}} -* [[CVL]] (function) {{text|converts 4 byte STRING values to [[LONG]] numerical values.}} -* [[CVS]] (function) {{text|converts 4 byte STRING values to [[SINGLE]] numerical values.}} -* [[CVSMBF]] (function) {{text|converts a 4-byte Microsoft Binary format [[STRING|string]] value to a [[SINGLE]]-precision number.}} -* [[DIM]] (statement) {{text|used to declare a variable type or dimension a [[STATIC]] array.}} -* [[ERASE]] (array statement) {{text|clears a [[STATIC]] array of all values and totally removes a [[$DYNAMIC]] array.}} -* [[HEX$]] (function) {{text|converts the [[INTEGER]] part of any value to hexadecimal [[STRING]] number value.}} -* [[INT]] (function) {{text|rounds a numeric value down to the next whole number or [[INTEGER]] value.}} -* [[LEN]] (function) {{text|returns the byte size of strings or numerical variables.}} -* [[OCT$]] (function) {{text|converts the [[INTEGER]] part of any value to octal [[STRING]] number value.}} -* [[RANDOMIZE]] (statement) {{text|seeds the [[RND]] random number generation sequence.}} -* [[REDIM]] (statement) {{text|re-dimensions the number of elements in a [[$DYNAMIC|dynamic]](resizeable) [[arrays|array]].}} -* [[RND]] (function) {{text|returns a randomly generated number from 0 to .9999999}} -* [[SGN]] (function) {{text|returns the sign as -1 for negative, zero for 0 and 1 for positive numerical values.}} -* [[STR$]] (function) {{text|converts a numerical value to a [[STRING]] value.}} -* [[SWAP]] (statement) {{text|trades the values of two numerical types or [[STRING|strings]].}} -* [[VAL]] (function) {{text|converts number [[STRING|strings]] into numerical values until it runs into a non-numeric character.}} - - -

([[#toc|Return to Table of Contents]])

- -== Port Input and Output (COM and LPT) == - -* [[COM(n)]] (statement) {{text|used in an OPEN COM statement to open "COM1" or "COM2".}} - - -* [[GET]] (file I/O statement) {{text|reads port data data by byte or record positions.}} -* [[LOC]] (function) {{text|finds the current file location or size of a [[COM]] port receive buffer.}} - - -* [[ON COM(n)]] (event statement) {{text|branches to a line number or label when there is a value in the serial port specified.}} -* [[OPEN COM]] (statement) {{text|opens a computer serial COMmunications port.}} -* [[OUT]] (statement) {{text|sends values to register or port hardware addresses (emulated - limited access).}} - - -* [[PRINT (file statement)]] {{text|writes text and numerical data to a port transmit buffer.}} -* [[PUT]] (file I/O statement) {{text|writes data into a [[RANDOM]] or [[BINARY]] port by byte or record position.}} - - -
'''See [[Port Access Libraries]] for other ways to access COM and LPT ports.'''.
- - -

([[#toc|Return to Table of Contents]])

- -== Print formatting == - -* [[LPRINT USING]] (statement) {{text|prints template formatted [[STRING]] text to an LPT or USB printer page.}} -* [[PRINT USING]] (statement) {{text|prints template formatted [[STRING]] text to the screen.}} -* [[PRINT USING (file statement)]] {{text|prints template formatted [[STRING]] text to a text file.}} - - -{{PrintUsingTable}} - - -

([[#toc|Return to Table of Contents]])

- -== Printer Output (LPT and USB) == - -* [[_PRINTIMAGE]] (statement) {{text|prints an image stretched to the size of the paper setting of an LPT or USB printer.}} - - -* [[LPOS]] (function) {{text|returns the current parallel(LPT) printer head position.}} -* [[LPRINT]] (statement) {{text|prints text to an LPT or USB printer page.}} -* [[LPRINT USING]] (statement) {{text|prints template formatted [[STRING]] text to an LPT or USB printer page.}} - - -
'''QB64 will use the default system printer selected. [[_PRINTIMAGE]] images will be stretched to the paper size setting.'''
- - -

([[#toc|Return to Table of Contents]])

- -== Program Flow and Loops == -* [[_CONTINUE]] (statement) {{text|skips the remaining lines in a control block (DO/LOOP, FOR/NEXT or WHILE/WEND)}} -* [[_DEST]] (statement) {{text|sets the current write image or page. All graphics will go to this image.}} -* [[_DEST (function)]] {{text|returns the current write destination image or page.}} -* [[_EXIT (function)]] {{text|prevents a user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}} -* [[_SOURCE]] (statement) {{text|establishes the image SOURCE using a designated image handle}} -* [[_SOURCE (function)]] {{text|returns the present image _SOURCE handle value.}} -* [[_SHELLHIDE]] (function) {{text|returns the code sent by a program exit using [[END]] or [[SYSTEM]] followed by an [[INTEGER]] value.}} - - -* [[CALL]] (statement) {{text|sends code execution to a subroutine procedure in a program.}} -* [[CASE]] ([[SELECT CASE]] statement) {{text|used within a SELECT CASE block to specify a conditional value of the compared variable.}} -* [[CASE ELSE]] ([[SELECT CASE]] statement) {{text|used in a SELECT CASE block to specify an alternative to other CASE values.}} -* [[CASE IS]] ([[SELECT CASE]] statement) {{text|used within a SELECT CASE block to specify a conditional value of the compared variable.}} -* [[DO...LOOP]] (loop statement) {{text|used in programs to repeat code or return to the start of a procedure.}} -* [[ELSE]] (statement) {{text|used in [[IF...THEN]] statements to offer an alternative to other conditional statements.}} -* [[ELSEIF]] (statement) {{text|used in [[IF...THEN]] block statements to offer an alternative conditional statement.}} -* [[END]] (statement) {{text|ENDs a conditional block statement, a sub-procedure or ends the program with "Press any key..."}} -* [[END IF]] (IF statement end) {{text|ENDs an IF statement block.}} -* [[ERROR]] (error statement) {{text|used to simulate an error in a program.}} -* [[EXIT]] (statement) {{text|exits a loop, function or sub-procedure early.}} -* [[FOR...NEXT]] (statement) {{text|a counter loop procedure that repeats code a specified number of times.}} -* [[GOSUB]] (statement) {{text|send the program to a designated line label procedure in the main module or a [[SUB]] procedure.}} -* [[GOTO]] (statement) {{text|sends the program to a designated line number or label.}} -* [[IF...THEN]] (statement) {{text|a conditional flow statement or block of statements.}} -* [[LOOP]] {{text|end of a DO...LOOP procedure that repeats code until or while a condition is true.}} -* [[RESUME]] (error statement) {{text|an error statement that can return the program to the NEXT code line or a specific line number.}} -* [[RETURN]] (statement) {{text|a sub-procedure statement that returns the program to the code immediately after the procedure call.}} -* [[RUN]] (statement) {{text|clears and restarts the program currently in memory or executes another specified program.}} -* [[SELECT CASE]] (statement) {{text|determines the program flow by comparing the value of a variable to specific values.}} -* [[SHELL]] (DOS statement) {{text|directly accesses the Operating System's command line procedures.}} -* [[SLEEP]] (statement) {{text|stops program progression for a specific number of seconds or until a keypress is made.}} -* [[STEP]] (relational statement) {{text|is used to step through FOR loop values or use relative graphical coordinates.}} -* [[STOP]] (statement) {{text|is used when troubleshooting a program to stop the program at a specified code line.}} -* [[SYSTEM]] (statement) {{text|immediately exits a program and closes the program window.}} -* [[UNTIL]] (conditional statement) {{text|continues a DO LOOP procedure until a condition is true.}} -* [[WHILE]] (statement) {{text|continues a DO LOOP procedure while a condition is true.}} -* [[WHILE...WEND]] (statement) {{text|a loop procedure that repeats code while a condition is true.}} - -

([[#toc|Return to Table of Contents]])

- -== Sounds and Music == - -* [[_SNDBAL]] (statement) {{text|sets the balance or 3D position of a sound.}} -* [[_SNDCLOSE]] (statement) {{text|frees and unloads an open sound using a _SNDOPEN or _SNDCOPY handle.}} -* [[_SNDCOPY]] (function) {{text|copies a sound to a new handle so that two or more of the same sound can be played at once.}} -* [[_SNDGETPOS]] (function) {{text|returns the current playing position in seconds of a designated sound handle.}} -* [[_SNDLEN]] (function) {{text|returns the length of a sound in seconds of a designated sound handle.}} -* [[_SNDLIMIT]] (statement) {{text|stops playing a sound after it has been playing for a set number of seconds.}} -* [[_SNDLOOP]] (statement) {{text|loops the playing of a specified sound handle.}} -* [[_SNDOPEN]] (function) {{text|loads a sound file with certain capabilities and returns a handle value.}} -* [[_SNDPAUSE]] (statement) {{text|pauses a specified sound handle if it is playing.}} -* [[_SNDPAUSED]] (function) {{text|returns the pause status of a specified sound handle.}} -* [[_SNDPLAY]] (statement) {{text|plays a designated sound file handle.}} -* [[_SNDPLAYCOPY]] (statement) {{text|copies a sound, plays it and automatically closes the copy using a handle parameter}} -* [[_SNDPLAYFILE]] (statement) {{text|a simple command to play a sound file with limited options.}} -* [[_SNDPLAYING]] (function) {{text|returns whether a sound handle is being played.}} -* [[_SNDRATE]] (function) {{text|returns the sample rate frequency per second of the current computer's sound card.}} -* [[_SNDRAW]] (statement) {{text|plays sound wave sample frequencies created by a program.}} -* [[_SNDRAWDONE]] (statement) {{text|pads a [[_SNDRAW]] stream so the final (partially filled) buffer section is played.}} -* [[_SNDRAWLEN]] (function) {{text|returns the length, in seconds, of a _SNDRAW sound currently queued.}} -* [[_SNDOPENRAW]] (function) {{text|returns a handle to a new, separate [[_SNDRAW]] audio stream.}} -* [[_SNDSETPOS]] (statement) {{text|changes the current/starting playing position of a sound in seconds.}} -* [[_SNDSTOP]] (statement) {{text|stops a playing or paused sound handle.}} -* [[_SNDVOL]] (statement) {{text|sets the volume of a sound handle being played.}} - - -* [[BEEP]] (statement) {{text|makes a beep sound when called or CHR$(7) is printed.}} -* [[PLAY]] (music statement) {{text|uses a custom string statement to play musical notes.}} -* [[SOUND]] (statement) {{text|creates sounds of a specified frequency for a set duration.}} - -

([[#toc|Return to Table of Contents]])

- -== String Text Manipulation and Conversion == - -* [[_CLIPBOARD$]] (function) {{text|returns the current [[STRING]] contents of the system Clipboard.}} -* [[_CLIPBOARD$ (statement)]] {{text|sets the [[STRING]] contents of the current system Clipboard.}} -* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}} -* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}} -* [[_CV]] (function) {{text|used to convert [[_MK$]] [[ASCII]] [[STRING|string]] values to numerical values.}} -* [[_MK$]] (function) {{text|converts any numerical type into an [[ASCII]] [[STRING|string]] value that must be converted back using [[_CV]].}} - - -* [[ASC (statement)]] {{text|allows a QB64 program to change a character at any position of a predefined STRING.}} -* [[HEX$]] (function) {{text|returns the base 16 hexadecimal representation of an [[INTEGER]] value as a [[STRING]].}} -* [[INSTR]] (function) {{text|searches for the first occurance of a search STRING within a string and returns the position.}} -* [[LCASE$]] (function) {{text|changes the uppercase letters of a STRING to lowercase.}} -* [[LEFT$]] (function) {{text|returns a part of a STRING from the start a designated number of character places.}} -* [[LEN]] (function) {{text|returns the number of bytes or characters in a [[STRING]] value.}} -* [[LSET]] (statement) {{text|left-justifies a fixed length string expression based on the size of the STRING.}} -* [[LTRIM$]] (function) {{text|returns a string with all leading spaces removed.}} -* [[MID$ (statement)]] {{text|returns a portion of a string from the start position a designated number of characters.}} -* [[MKD$]] (function) {{text|converts a [[DOUBLE]] numerical value into an 8 byte [[ASCII]] [[STRING]] value.}} -* [[MKDMBF$]] (function) {{text|converts a double-precision number to a string containing a value in Microsoft Binary format.}} -* [[MKI$]] (function) {{text|converts a numerical [[INTEGER]] value to a 2 byte [[ASCII]] string value.}} -* [[MKL$]] (function) {{text|converts a numerical [[LONG]] value to a 4 byte [[ASCII]] string value.}} -* [[MKS$]] (function) {{text|converts a numerical [[SINGLE]] value to a 4 byte [[ASCII]] string value.}} -* [[MKSMBF$]] (function) {{text|converts a single-precision number to a string containing a value in Microsoft Binary format.}}}} -* [[OCT$]] (function) {{text|returns the base 8 Octal representation of an INTEGER value.}} -* [[RIGHT$]] (function) {{text|returns a set number of characters in a STRING variable starting from the end.}} -* [[RSET]] (statement) {{text|right-justifies a string according to length of the string expression.}} -* [[RTRIM$]] (function) {{text|returns a string with all of the spaces removed at the right end of a string.}} -* [[SPACE$]] (function) {{text|returns a STRING consisting of a number of space characters.}} -* [[STR$]] (function) {{text|converts a numerical value to a [[STRING]].}} -* [[STRING]] ($ variable type) {{text|one byte text variable with [[ASCII]] code values from 0 to 255.}} -* [[STRING$]] (function) {{text|returns a STRING consisting of a single character repeated a set number of times.}} -* [[SWAP]] (statement) {{text|used to exchange two string variable or array element values.}} -* [[UCASE$]] (function) {{text|returns a string with all letters as uppercase.}} -* [[VAL]] (function) {{text|converts a string number value to a numerical value.}} - - -

([[#toc|Return to Table of Contents]])

- -== Sub procedures and Functions == - -
'''QBasic and QB64'''
-* [[CALL]] (statement) {{text|sends code execution to a [[SUB]] procedure in a program. Parameter brackets are required when used.}} -* [[CALL ABSOLUTE|CALL ABSOLUTE]] (statement) {{text|used to access Interrupts on the computer or execute assembly type procedures.}} -* [[CHAIN]] (statement) {{text|changes seamlessly from one program module to another.}} -* DECLARE (BASIC statement) {{text|used to tell that a SUB or FUNCTION is created to be used in the program. NOT USED by QB64!}} -* [[END]] (statement) {{text|ends a [[SUB]] or [[FUNCTION]] procedure.}} -* [[EXIT]] (statement) {{text|exits a [[SUB]] or [[FUNCTION]] procedure early.}} -* [[FUNCTION]] (statement) {{text|a procedure that holds ONE return value in the function's name which is a variable type. }} -* [[GOSUB]] (statement) {{text|sends the program to a sub program that uses a line number or label.}} -* [[$INCLUDE]] (metacommand) {{text|used to insert a source code text file into your program at the point of the insertion.}} -* [[INTERRUPT]] (statement) {{text|a built in assembly routine for accessing computer information registers.}} -* [[RETURN]] (statement) {{text|used in GOSUB procedures to return to the original call code line.}} -* [[RUN]] (statement) {{text| flow statement that clears and restarts the program currently in memory or executes another specified program.}} -* [[SHARED]] (statement) defines a variable or list of variables as shared with the main program module.}} -* [[SHELL]] (statement) {{text|allows a program to use OS command lines.}} -* [[STATIC]] (statement) {{text|defines a variable or list of variables that will retain their values after the sub-procedure is exited.}} -* [[SUB]] (statement) {{text|procedures are programs within programs that can return multiple calculations.}} - -

([[#toc|Return to Table of Contents]])

- -== TCP/IP Networking and Email == - -
'''All Statements and Functions Compile in QB64 Only!'''
- - -* [[_CONNECTED]] (function) {{text|returns the connection status of a TCP/IP connection handle.}} -* [[_CONNECTIONADDRESS$]] (function) {{text| function returns a connected user's [[STRING]] IP address value.}} - - -* [[_OPENCLIENT]] (function) {{text|connects to a Host on the Internet as a Client and returns the Client status handle.}} -* [[_OPENCONNECTION]] (function) {{text|open's a connection from a client that the host has detected and returns a status handle.}} -* [[_OPENHOST]] (function) {{text|opens a Host which listens for new connections and returns a Host status handle.}} - - -* [[CLOSE]] (statement) {{text|closes an opened internet connection using the handle assigned in an OPEN statement.}} - - -* [[GET (TCP/IP statement)]] {{text|reads unformatted(raw) data from an opened connection using the connection handle.}} - -* [[PUT (TCP/IP statement)]] {{text|sends unformatted(raw) data to an open connection using a user's handle.}} - - -
See also: [[Downloading Files]]
- - -

([[#toc|Return to Table of Contents]])

- -== Text on Screen == -* [[_CONTROLCHR]] {{text|[[OFF]] allows [[ASCII]] characters 0 to 31 to be used as text characters. [[ON]](default) resets to default usage.}} -* [[_FONT (function)]] {{text|creates a new alphablended font handle from a designated image handle}} -* [[_FONT]] (statement) {{text|sets the current [[_LOADFONT]] function font handle to be used by [[PRINT]] or [[_PRINTSTRING]].}} -* [[_MAPUNICODE]] (statement) {{text|maps a [[Unicode]] value to an [[ASCII]] character code value.}} -* [[_PRINTSTRING]] (statement) {{text|prints text or custom font strings using graphic column and row coordinate positions.}} -* [[_SCREENPRINT]] (statement) {{text|simulates typing text into a Windows program using the keyboard.}} - - -* [[CHR$]] (function) {{text|returns the text character associated with a certain [[ASCII]] character code as a one byte [[STRING]].}} -* [[CLS]] (statement) {{text|clears a screen page or the program [[SCREEN]]. QB64 can clear with a color.}} -* [[COLOR]] (statement) {{text|used to change the color of the text and background in some legacy screen modes.}} -* [[CSRLIN]] (function) {{text|returns the current print cursor row position on the screen.}} -* [[INPUT]] (statement) {{text|requests a [[STRING]] or numerical keyboard entry from a program user.}} -* [[KEY LIST]] (statement) {{text|vertically lists all the [[ON KEY(n)]] softkey strings associated with each function key F1 to F12.}} -* [[LINE INPUT]] (statement) {{text|requests a [[STRING]] keyboard entry from a program user.}} -* [[LOCATE]] (statement) {{text|locates the screen text row and column positions for a [[PRINT]] or [[INPUT]] procedure.}} -* [[POS]] (function) {{text|returns the current print cursor column position.}} -* [[PRINT]] (statement) {{text|prints numeric or [[STRING|string]] expressions to the program screen.}} -* [[PRINT USING]] (statement) {{text|prints template formatted numeric or string values to the program screen.}} -* [[SCREEN]] (statement) {{text|sets the screen mode of a program. No statement defaults the program to SCREEN 0 text mode.}} -* [[SCREEN (function)]] {{text|returns the [[ASCII]] code of a text character or the color attribute at a set text location on the screen.}} -* [[SPACE$]] (function) {{text|returns a [[STRING|string]] consisting of a number of space characters.}} -* [[SPC]] (function) {{text|used in [[PRINT]] and [[LPRINT]] statements to print or output a number of space characters.}} -* [[STR$]] (function) {{text|returns the [[STRING]] representation of a numerical value.}} -* [[STRING$]](function) {{text| returns a [[STRING]] consisting of a single character repeated a set number of times.}} -* [[TAB]] (function) {{text|used in [[PRINT]] and [[LPRINT]] statements to move to a specified text column position.}} -* [[VIEW PRINT]] (statement) {{text|defines the boundaries of a text viewport [[PRINT]] area.}} -* [[WIDTH]] (statement) {{text|changes the text dimensions of certain [[SCREEN]] modes or printer page widths}} -* [[WRITE]] (screen I/O statement) {{text|writes a comma-separated list of values to the screen.}} - - -
See also: [[#Fonts and Unicode:|Fonts and Unicode]] or [[ASCII|ASCII Code Table]]
- -

([[#toc|Return to Table of Contents]])

- -== Time, Date and Timing == - -* [[_AUTODISPLAY]] (statement) {{text|enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]].}} -* [[_DELAY]] (statement) {{text|suspends program execution for a [[SINGLE]] value of seconds down to milliseconds.}} -* [[_DISPLAY]] (statement) {{text|turns off automatic display while only displaying the screen changes when called.}} -*[[_FREETIMER]] (function) {{text|returns a free TIMER number for multiple [[ON TIMER(n)]] events.}} -* [[_KEYDOWN]] (function) {{text|returns whether modifying keys like CTRL, ALT, SHIFT, and any other keys are pressed.}} -* [[_KEYHIT]] (function) {{text|returns ASCII one and two byte, SDL Virtual Key and Unicode keyboard key press codes.}} -* [[_LIMIT]] (statement) {{text|sets the loop repeat rate of a program to so many per second, relinquishing spare cpu cycles.}} - - -* [[DATE$]] (function) {{text|returns the present computer date in a mm-dd-yyyy [[STRING|string]] format}} - -* [[INKEY$]] (function) {{text| can be used in a loop to wait for a keypress or a [Ctrl] + letter key combination.}} -* [[INPUT]] (statement) {{text|can be used to wait for an [Enter] key press or a text or numerical menu entry.}} -* [[INPUT$]] (function) {{text|can be used to wait for a key press or a fixed length text entry.}} -* [[ON KEY(n)]] (event statement) {{text|executes when a keypress or keypress combination occurs.}} -* [[ON TIMER(n)]] (event statement) {{text|executes when a timed event occurs. QB64 can use multiple numbered timer events.}} - -* [[SLEEP]] (statement) {{text|pauses the program for a specified number of seconds or a until a key press is made.}} -* [[TIME$]] (function) {{text|returns the present computer time in a hh:mm:ss 24 hour [[STRING|string]] format}} - -* [[TIMER]] (function) {{text|returns the number of seconds past the previous midnite down to a QB64 accuracy of one millisecond.}} -* [[TIMER (statement)]] {{text|enables, turns off or stops timer event trapping. In QB64 TIMER(n) FREE can free multiple timers. }} - -* [[WAIT]] (statement) {{text|normally used to delay program display execution during or after vertical retrace periods.}} - -

([[#toc|Return to Table of Contents]])

- -== Window and Desktop == - -
'''All Statements and Functions except [[SCREEN]] Compile in QB64 Only!'''
- -* [[_FULLSCREEN (function)]] {{text|returns the present full screen mode setting number of the screen window.}} -* [[_FULLSCREEN]] (statement) {{text|sets the full screen mode of the screen window. Alt + Enter can do it manually.}} -* [[_HEIGHT]] (function) {{text|returns the height of a [[_SCREENIMAGE]] handle to get the desktop resolution.}} -* [[_ICON]] (statement) {{text|creates a program icon from an image file handle created by [[_LOADIMAGE]]. Cannot use .ICO files!}} -* [[_NEWIMAGE]] (statement) {{text|function prepares a window image surface and returns the handle value.}} -* [[$RESIZE]] ([[Metacommand]]) {{text|used with ON allows a user to resize the program window where OFF does not.}} -* [[_RESIZE (function)]] {{text|returns -1 when a program user attempts to resize the program screen.}} -* [[_RESIZEHEIGHT]] (function) {{text|returns the requested new user screen height when [[$RESIZE]]:ON allows it.}} -* [[_RESIZEWIDTH]] (function) {{text|returns the requested new user screen width when [[$RESIZE]]:ON allows it.}} -* [[_SCREENCLICK]] {{text|simulates clicking the mouse at a position on the screen to get focus.}} -* [[_SCREENEXISTS]] (function) {{text|returns a -1 value once a screen has been created.}} -* [[$SCREENHIDE]] (QB64 [[Metacommand]]) {{text|hides the program window throughout the program until [[$SCREENSHOW]] is used.}} -* [[_SCREENHIDE]] (statement) {{text|hides the main program window in a section of code until [[_SCREENSHOW]] is used.}} -* [[_SCREENIMAGE]] (function) {{text|creates an image of the current desktop and returns an image handle.}} -* [[_SCREENMOVE]] (statement) {{text|positions the program window on the desktop using designated coordinates or _MIDDLE.}} -* [[_SCREENPRINT]] (statement) {{text|simulates typing text into a Windows program using the keyboard.}} -* [[$SCREENSHOW]] (QB64 [[Metacommand]]) {{text|displays the main program window throughout the program after [[$SCREENHIDE]].}} -* [[_SCREENSHOW]] (statement) {{text|displays the main program window in a section of code after [[_SCREENHIDE]] has been used.}} -* [[_SCREENX]] (function) {{text|returns the current program window's upper left corner column position on the desktop.}} -* [[_SCREENY]] (function) {{text|returns the current program window's upper left corner row position on the desktop.}} -* [[_TITLE]] (statement) {{text|sets the program name [[STRING|string]] in the title bar of the program window.}} -* [[_WIDTH (function)]] {{text|returns the width of a [[_SCREENIMAGE]] handle to get the desktop resolution.}} - - -* [[SCREEN]] {{text|sets the screen mode of a program. No statement defaults the program to SCREEN 0 text mode.}} - - -
''See also:'' [[C_Libraries#Console_Window|Console Window]], [[Windows_Libraries#Hot_Keys_.28maximize.29|Windows Hot Keys]] or [[Windows_Libraries#Focus|Focus on Program]].
- -

([[#toc|Return to Table of Contents]])

- -== QB64 Programming Symbols == - -
'''QB64 and QB Symbols'''
- -
''[Note: All symbols below can also be used inside of literal quoted strings except for quotation marks.]''
- - -:'''Print, Input or File Formatting''' -* [[Semicolon|; Semicolon]] after a [[PRINT]] stops the invisible cursor at end of the printed value. Can prevent screen rolling! -* [[Comma|, Comma]] after a [[PRINT]] tabs the invisible cursor past the end of the printed value. -* [[Quotation mark|" Quotation mark]] delimits the ends of a literal [[STRING]] value in a [[PRINT]], [[INPUT]] or [[LINE INPUT]] statement. -* [[Question mark|? Question mark]] is a shortcut substitute for the [[PRINT]] keyword. Will change to PRINT when cursor leaves the code line. - - -:'''Program Code Markers''' -* [[Apostrophe|' Apostrophe]] denotes a program comment, to ignore a code line or a QBasic [[Metacommand]]. Same as using [[REM]]. -* [[Comma|, Comma]] is a statement variable or [[DATA]], [[SUB]] or [[FUNCTION]] parameter separator. -* [[: Colon]]s can be used to separate two procedure statements on one code line. -* [[Dollar_Sign|$ Dollar sign]] prefix denotes a QBasic [[Metacommand]]. Only '''QB64''''s event [[$CHECKING]] should NOT be commented. -* [[Parenthesis|( ) Parenthesis]] enclose a math or conditional procedure order, [[SUB]] or [[FUNCTION]] parameters or to pass by value. -* [[+|+ Plus]] [[concatenation]] operator MUST be used to combine literal string values in a variable definition. -* [[Quotation mark|" Quotation mark]] delimits the ends of a literal [[STRING]] value. Use [[CHR$]](34) to insert quotes in a text [[STRING]]. -* [[REM]] or apostrophe are used to make comments or ignore code or precedes a [[Metacommand]]. -* [[Underscore|_ Underscore]] at the end of a code line is used to continue a line of code to the next program line in '''QB64 only'''. - -

([[#toc|Return to Table of Contents]])

- -:'''Variable Name Type Suffixes''' -* [[STRING|$ STRING]] text character type: 1 byte -* [[SINGLE|! SINGLE]] floating decimal point numerical type (4 bytes) -* [[DOUBLE|# DOUBLE]] floating decimal point numerical type (8 bytes) -* [[_FLOAT|## _FLOAT]] '''QB64''' decimal point numerical type (32 bytes) -* [[_UNSIGNED|~ _UNSIGNED]] '''QB64''' [[INTEGER|whole]] positive numerical type when it precedes the 6 numerical suffixes below: -* [[INTEGER|% INTEGER]] [[INTEGER|whole]] numerical type (2 bytes) -* [[LONG|& LONG]] [[INTEGER|whole]] numerical type (4 bytes} -* [[_INTEGER64|&& _INTEGER64]] '''QB64''' [[INTEGER|whole]] numerical type (8 bytes) -* [[_BIT|` _BIT]] '''QB64''' [[INTEGER|whole]] numerical type (1 bit)(Key below tilde(~) or [[CHR$]](96)) -* [[_BYTE|%% _BYTE]] '''QB64''' [[INTEGER|whole]] numerical type (1 byte) -* [[_OFFSET|%& _OFFSET]] '''QB64''' [[INTEGER|whole]] numerical pointer address type (any byte size required) - -

([[#toc|Return to Table of Contents]])

-:'''Numerical Base Prefixes''' -* [[&B|&B Binary]] base 2 Digits 0 or 1 ['''QB64'''] -* [[&O|&O Octal]] base 8 Digits 0 to 7 -* [[&H|&H Hexadecimal]] base 16: Digits 0 to F - - -:'''[[Mathematical Operations]]''' -*[[+|+ Addition]] operator or sign -*[[-|- Subtraction]] operator or sign -*[[*|* Multiplication]] operator -*[[/|/ Division]] (floating decimal point) operator -*[[\|\ Integer division]] operator -*[[^|^ Exponential]] operator -*[[MOD|MOD Integer Remainder division]] operator - - -:'''[[Relational Operations]]''' -* [[Equal|=]] (Equal to condition) -* [[Greater_Than|>]] (Greater than condition) -* [[Less_Than|<]] (Less than condition) -* [[Not_Equal|<>]] (Not equal to condition) -* [[Greater_Than_Or_Equal|>=]] (Greater than or equal to condition) -* [[Less_Than_Or_Equal|<=]] (Less than or equal to condition) - -

([[#toc|Return to Table of Contents]])

- -== QB64 Programming References == - -
'''WIKI Pages''' - -[[Keyword Reference - Alphabetical#QB64 specific keywords:|Go to QB64 specific keywords]] - -[[Keyword Reference - Alphabetical#Original QBasic keywords:|Go to Top of Original QB keywords]] - -[[Keyword Reference - Alphabetical|Go to Alphabetical keywords]] - -[[Main_Page#Appendix:|Main Page with Appendix and Tutorials]] - - -'''Got a question about something?''' - -[[QB64 FAQ|Visit the QB64 FAQ]] - -[http://qb64phoenix.com Visit the QB64 Main Site] - -[http://qb64phoenix.com/forum/index.php Visit QB64 Community Forum] - - -

([[#toc|Return to Table of Contents]])

diff --git a/internal/help/LBOUND_111111.txt b/internal/help/LBOUND_111111.txt deleted file mode 100644 index 8ccb40398..000000000 --- a/internal/help/LBOUND_111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:57}} -The [[LBOUND]] function returns the smallest valid index (lower bound) of an array dimension. - - -{{PageSyntax}} -:{{Parameter|result%}} = [[LBOUND]]({{Parameter|arrayName}}[, {{Parameter|dimension%}}]) - - -{{PageDescription}} -* {{Parameter|arrayName}} specifies the name of the array. -* {{Parameter|dimension%}} specifies the dimension number, starting with '''1''' for the first dimension. -** If omitted, {{Parameter|dimension%}} is assumed to be '''1'''. -** If {{Parameter|dimension%}} is less than '''1''' or is greater than the number of dimensions, a [[ERROR Codes|subscript out of range]] error occurs. -* [[LBOUND]] and [[UBOUND]] are used to determine the range of valid indexes of an array. - - -{{PageExamples}} -{{CodeStart}}{{Cl|DIM}} myArray(5) {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} myOtherArray(1 to 2, 3 to 4) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|PRINT}} {{Cl|LBOUND}}(myArray) -{{Cl|PRINT}} {{Cl|LBOUND}}(myOtherArray, 2) -{{CodeEnd}} -{{OutputStart}} 0 - 3 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[Arrays]], [[UBOUND]] -* [[DIM]], [[COMMON]], [[STATIC]], [[SHARED]] - - -{{PageNavigation}} diff --git a/internal/help/LCASE$_11111$.txt b/internal/help/LCASE$_11111$.txt deleted file mode 100644 index 09c81d2ce..000000000 --- a/internal/help/LCASE$_11111$.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:58}} -The [[LCASE$]] function outputs an all-lowercase version of a [[STRING]]. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[LCASE$]]({{Parameter|text$}}) - - -{{PageDescription}} -* Normally used to guarantee that user input is not capitalized. -* Does not affect non-alphabetical characters. - - -{{PageExamples}} -''Example:'' The following code guarantees that all user letter entries will be lower case: -{{CodeStart}}{{Cl|PRINT}} "Do you want to continue? (y/n)" - -{{Cl|DO...LOOP|DO}} - K$ = {{Cl|LCASE$}}({{Cl|INKEY$}}) -{{Cl|DO...LOOP|LOOP}} {{Cl|DO...LOOP|UNTIL}} K$ = "y" {{Cl|OR}} K$ = "n" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[UCASE$]] {{text|(upper case)}} -* [[INKEY$]] -* [[INPUT$]] - - -{{PageNavigation}} diff --git a/internal/help/LEFT$_1111$.txt b/internal/help/LEFT$_1111$.txt deleted file mode 100644 index efcbec2f4..000000000 --- a/internal/help/LEFT$_1111$.txt +++ /dev/null @@ -1,71 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:59}} -The [[LEFT$]] string function returns a number of characters from the left of a [[STRING]]. - - -{{PageSyntax}} -: [[LEFT$]]({{Parameter|stringValue$}}, {{Parameter|numberOfCharacters%}}) - - -{{Parameters}} -* {{Parameter|stringValue$}} can be any [[STRING]] literal or variable. -* {{Parameter|numberOfCharacters%}} [[INTEGER]] determines the number of characters to return from left of string. - - -{{PageDescription}} -* If the number of characters exceeds the string length the entire string is returned. Use [[LEN]] to determine a string's length. -* [[LEFT$]] returns always start at the first character of the string, even if it's a space. [[LTRIM$]] can remove leading spaces. -* '''{{Parameter|numberOfCharacters%}} cannot be a negative value.''' - - -{{PageExamples}} -''Example 1:'' Getting the left portion of a string value. -{{CodeStart}} -name$ = "Tom Williams" - -First$ = LEFT$(name$, 3) - -PRINT First$ -{{CodeEnd}} -{{OutputStart}}Tom {{OutputEnd}} - - -''Example 2:'' A replace function using LEFT$ and [[RIGHT$]] with [[INSTR]] to insert a different length word into an existing string. -{{CodeStart}} -text$ = "This is my sentence to change my words." -{{Cl|PRINT}} text$ -oldword$ = "my" -newword$ = "your" - -x = Replace(text$, oldword$, newword$) -{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|PRINT}} text$; x - -{{Cl|END}} - -{{Cl|FUNCTION}} Replace (text$, old$, new$) 'can also be used as a {{Cl|SUB}} without the count assignment -{{Cl|DO...LOOP|DO}} - find = {{Cl|INSTR}}(start + 1, text$, old$) 'find location of a word in text - {{Cl|IF...THEN|IF}} find {{Cl|THEN}} - count = count + 1 - first$ = {{Cl|LEFT$}}(text$, find - 1) 'text before word including spaces - last$ = {{Cl|RIGHT$}}(text$, {{Cl|LEN}}(text$) - (find + {{Cl|LEN}}(old$) - 1)) 'text after word - text$ = first$ + new$ + last$ - {{Cl|END IF}} - start = find -{{Cl|LOOP}} {{Cl|WHILE}} find -Replace = count 'function returns the number of replaced words. Comment out in SUB -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{OutputStart}}This is my sentence to change my words. -This is your sentence to change your words.{{OutputEnd}} -: ''Note:'' The [[MID$ (statement)|MID$]] statement can only substitute words or sections of the original string length. It cannot change the string length. - - -{{PageSeeAlso}} -* [[RIGHT$]], [[MID$]] -* [[LTRIM$]], [[RTRIM$]] -* [[MID$ (statement)]] -* [[INSTR]], [[LEN]] - - -{{PageNavigation}} diff --git a/internal/help/LEN_111.txt b/internal/help/LEN_111.txt deleted file mode 100644 index 1e559e9bf..000000000 --- a/internal/help/LEN_111.txt +++ /dev/null @@ -1,122 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:00}} -The [[LEN]] function returns the number of bytes used by a variable value and the number of characters in a [[STRING]]. - - -{{PageSyntax}} -: {{Parameter|length%}} = [[LEN]]({{Parameter|literalTextOrVariable}}) - - - -* Literal or variable [[STRING]] values return the number of string bytes which is the same as the number of string characters. -* A numerical ''variable'' will return the number of bytes used by a numerical variable type. -** [[_BYTE]] variable types return 1 byte. -** [[INTEGER]] variable types return 2 bytes. -** [[SINGLE]] and [[LONG]] integer variable types return 4 bytes. -** [[DOUBLE]] and [[_INTEGER64]] variable types return 8 bytes. -** [[_FLOAT]] variable types return 32 bytes. -** [[_OFFSET]] and [[_MEM]] variable types return varying byte sizes. -** ''Note:'' [[_BIT]] variable types and bit multiples '''cannot be measured in bytes'''. -* '''LEN cannot return lengths of literal numerical values and will create a "variable required" status error in the IDE.''' -* '''LEN =''' can be used with a user defined [[TYPE]] variable to determine the number of bytes used in [[RANDOM]] file records: -:::: {{InlineCode}}[[OPEN]] file$ FOR [[RANDOM]] AS #n LEN = LEN(recordTypeVariable){{InlineCodeEnd}}''' -:* If a LEN = statement is not used, [[RANDOM]] default record length is 128 or sequencial is 512 up to a maximum of 32767 bytes. -:* [[BINARY]] OPEN statements will ignore LEN = statements. The byte size of a [[GET|read]] or [[PUT|write]] is determined by the [[Variable Types|variable type]]. - - -{{PageExamples}} -''Example 1:'' With a string variable the byte size is the same as the number of characters. -{{CodeStart}} -LastName$ = "Williams" -PRINT {{Cl|LEN}}(LastName$); "bytes" -{{CodeEnd}} -{{OutputStart}} 8 bytes -{{OutputEnd}} - - -''Example 2:'' Testing [[INPUT]] for numerical [[STRING]] entries from a user. -{{CodeStart}} -{{Cl|INPUT}} "number: ", num$ - -value$ = {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|VAL}}(num$))) -L = {{Cl|LEN}}(value$) - -{{Cl|PRINT}} {{Cl|LEN}}(num$), L -{{CodeEnd}} -: ''Note:'' [[&H]], [[&O]], D and E will also be accepted as numerical type data in a [[VAL]] conversion, but will add to the entry length. - - -''Example 3:'' With numerical value types you MUST use a variable to find the inherent byte length when using LEN. -{{CodeStart}} -DIM I AS INTEGER -PRINT "INTEGER ="; LEN(I); "bytes" -DIM L AS LONG -PRINT "LONG ="; LEN(L); "bytes" -DIM I64 AS _INTEGER64 -PRINT "_INTEGER64 ="; LEN(I64); "bytes" -DIM S AS SINGLE -PRINT "SINGLE ="; LEN(S); "bytes" -DIM D AS DOUBLE -PRINT "DOUBLE ="; LEN(D); "bytes" -DIM F AS _FLOAT -PRINT "_FLOAT ="; LEN(F); "bytes" -{{CodeEnd}} -{{OutputStart}}INTEGER = 2 bytes -LONG = 4 bytes -_INTEGER64 = 8 bytes -SINGLE = 4 bytes -DOUBLE = 8 bytes -_FLOAT = 32 bytes -{{OutputEnd}} - - -''Example 4:'' Opening a RANDOM file using LEN to calculate and LEN = to designate the file record size. -{{CodeStart}} -{{Cl|TYPE}} variabletype - x {{Cl|AS}} {{Cl|INTEGER}}' '2 bytes - y {{Cl|AS}} {{Cl|STRING}} * 10' '10 bytes - z {{Cl|AS}} {{Cl|LONG}}' '4 bytes -{{Cl|END}} {{Cl|TYPE}}' '16 bytes total -{{Cl|DIM}} record {{Cl|AS}} variabletype -{{Cl|DIM}} newrec {{Cl|AS}} variabletype - -file$ = "testrand.inf" '<<<< filename may overwrite existing file -number% = 1 '<<<<<<<<<< record number to write cannot be zero -RecordLEN% = {{Cl|LEN}}(record) -{{Cl|PRINT}} RecordLEN%; "bytes" -record.x = 255 -record.y = "Hello world!" -record.z = 65535 -{{Cl|PRINT}} record.x, record.y, record.z - -{{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RecordLEN% -{{Cl|PUT}} #1, number% , record 'change record position number to add records -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 {{Cl|LEN}} = RecordLEN% -NumRecords% = {{Cl|LOF}}(2) \ RecordLEN% -PRINT NumRecords%; "records" - -{{Cl|GET}} #2, NumRecords% , newrec 'GET last record available -{{Cl|CLOSE}} #2 -{{Cl|PRINT}} newrec.x, newrec.y, newrec.z - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} 16 bytes - 255 Hello worl 65535 - 1 records - 255 Hello worl 65535 -{{OutputEnd}} -: ''Explanation:'' The byte size of the record [[TYPE]] determines the [[LOF]] byte size of the file and can determine the number of records. -: To read the last record [[GET]] the number of records. To add a record, use the number of records + 1 to [[PUT]] new record data. - - -{{PageSeeAlso}} -* [[LOF]], [[EOF]] -* [[AS]], [[TYPE]] -* [[RANDOM]], [[BINARY]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/LET_111.txt b/internal/help/LET_111.txt deleted file mode 100644 index d9f7b70a5..000000000 --- a/internal/help/LET_111.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:01}} -[[LET]] is a (more or less) needless statement designed for the very early BASIC dialects. - - -{{PageSyntax}} -: [[LET]] {{Parameter|variable}} = {{Parameter|expression}} - - -{{PageDescription}} -* {{InlineCode}}{{Cl|LET}} a = 12{{InlineCodeEnd}} is the very same as {{InlineCode}}a = 12{{InlineCodeEnd}}, but wastes 4 extra bytes of program space. -* That said, [[LET]] is '''optional''', it's the only keyword where the '''entire keyword''' is optional.😀 - - -{{PageSeeAlso}} -* [[Variable]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/LINE_1111.txt b/internal/help/LINE_1111.txt deleted file mode 100644 index 25a5acb34..000000000 --- a/internal/help/LINE_1111.txt +++ /dev/null @@ -1,90 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:02}} -The [[LINE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes to create lines or boxes. - - -{{PageSyntax}} -: [[LINE]] [STEP] ['''('''''column1''''',''' ''row1''''')''']'''-'''[STEP] '''('''''column2'', ''row2'''''),''' ''color''[, [{B|BF}], {{Parameter|style%}}] - - -{{Parameters}} -* The [[STEP]] keyword make ''column'' and ''row'' coordinates relative to the previously coordinates set by any graphic statement. -* The optional parameters (''column1'', ''row1'') set the line's starting point. -* The dash and second coordinate parameters (''column2'', ''row2'') must be designated to complete the line or box. -* The [[INTEGER]] ''color'' attribute or [[LONG]] [[_RGB32]] 32 bit color value sets the drawing color. If omitted, the current [[_DEST|destination]] page's [[_DEFAULTCOLOR]] is used. -* Optional '''B''' keyword creates a rectangle ('''b'''ox) using the start and end coordinates as diagonal corners. '''BF''' creates a '''b'''ox '''f'''illed. -* The ''style%'' signed [[INTEGER]] value sets a dotted pattern to draw the line or rectangle outline. - - -{{PageDescription}} -* Creates a colored line between the given coordinates. Can be drawn partially off screen. -* '''B''' creates a box outline with each side parallel to the program screen sides. '''BF''' creates a filled box. -* {{Parameter|style%}} can be used to create a dotted pattern to draw the line. -** '''B''' can be used with a ''style%'' to draw the rectangle outline using the desired pattern. -** '''BF''' ignores the {{Parameter|style%}} parameter. See examples 2, 3 and 4 below. -* The graphic cursor is set to the center of the program window on program start. Using the [[STEP]] keyword makes the coordinates relative to the current graphic cursor. -* [[LINE]] '''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:'' Following one line with another by omitting the second line's first coordinate parameter bracket entirely: -{{CodeStart}}{{Cl|SCREEN}} 12 - -{{Cl|LINE}} (100, 100)-(200, 200), 10 'creates a line -{{Cl|LINE}} -(400, 200), 12 'creates a second line from end of first - -{{Cl|END}} -{{CodeEnd}} -:''Explanation:'' The full equivalent LINE statement would be: '''{{text|LINE(200, 200)-(400, 200), 12|green}}''' - - -''Example 2:'' Creating styled lines and boxes with the LINE statement. Different style values create different dashed line spacing. -{{CodeStart}}{{Cl|SCREEN}} 12 - -{{Cl|LINE}} (100, 100)-(300, 300), 10, , 63 'creates a styled line -{{Cl|LINE}} (100, 100)-(300, 300), 12, B, 255 'creates styled box shape - -{{Cl|END}} -{{CodeEnd}} -:''Explanation:'' The first diagonal dashed green line bisects the red dashed square from Top Left to Bottom Right Corners. - - -''Example 3:'' The ''style'' value sets each 16 pixel line section as the value's bits are set on or off: -{{CodeStart}}{{Cl|SCREEN}} 13 -{{Cl|_FULLSCREEN}} 'required in QB64 only -{{Cl|_DELAY}} 5 -{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} 2 ^ 15 'use exponential value instead of -32768 - {{Cl|COLOR}} 15:{{Cl|LOCATE}} 10, 5: {{Cl|PRINT}} i%; - {{Cl|LINE}} (10, 60)-(300, 60), 0 'erase previous lines - {{Cl|LINE}} (10, 60)-(300, 60), 12, , i% - tmp$ = "" - {{Cl|FOR...NEXT|FOR}} b% = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 'create binary text value showing bits on as {{text|█|red}}, off as space - {{Cl|IF...THEN|IF}} i% {{Cl|AND}} 2 ^ b% {{Cl|THEN}} tmp$ = tmp$ + {{Cl|CHR$}}(219) {{Cl|ELSE}} tmp$ = tmp$ + {{Cl|SPACE$}}(1) - {{Cl|NEXT}} - {{Cl|COLOR}} 12:{{Cl|LOCATE}} 10, 20: {{Cl|PRINT}} tmp$; - {{Cl|IF...THEN|IF}} {{Cl|INKEY$}} <> "" {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'any key exit - {{Cl|_DELAY}} .001 'set delay time as required -{{Cl|NEXT}} -{{CodeEnd}} -: ''Explanation:'' The ''style'' value's Most Significant Bit (MSB) is set to the left with LSB on right as 16 text blocks are set on or off. - - -''Example 4:'' Using [[&B|binary code]] to design a style pattern: -{{CodeStart}}{{Cl|SCREEN}} 12 - -{{Cl|LINE}} (100, 100)-(300, 100), 10, , &B0000111100001111 '16-bits -{{Cl|LINE}} (100, 110)-(300, 110), 11, , &B0011001100110011 -{{Cl|LINE}} (100, 120)-(300, 120), 12, , &B0101010101010101 -{{Cl|LINE}} (100, 130)-(300, 130), 13, , &B1000100010001000 -{{CodeEnd}} -:''Explanation:'' The binary pattern created with 0s and 1s using the [[&B]] number prefix define the pattern to draw the colored lines. - - -{{PageSeeAlso}} -* [[SCREEN (statement)|SCREEN]], [[COLOR]] -* [[DRAW]], [[CIRCLE]], [[STEP]] -* [[PSET]], [[PRESET]] -* [[AND]], [[OR]] {{text|(logical operators)}} - - -{{PageNavigation}} diff --git a/internal/help/LINE_INPUT_(file_statement)_1111_11111_(0000_000000000).txt b/internal/help/LINE_INPUT_(file_statement)_1111_11111_(0000_000000000).txt deleted file mode 100644 index 78c79e78d..000000000 --- a/internal/help/LINE_INPUT_(file_statement)_1111_11111_(0000_000000000).txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:05}} -The '''LINE INPUT #''' file statement reads an entire line from a text file into a string variable. - - -{{PageSyntax}} -: '''LINE INPUT''' '''#'''{{Parameter|fileNumber&}}''',''' ''stringVariable$'' - - -{{Parameters}} -* {{Parameter|fileNumber&}} is the [[INTEGER]] number of the file previously opened with the [[OPEN]] statement. -* {{Parameter|stringVariable$}} holds the text line read from the file. - - -{{PageDescription}} -* Reads a file using the {{Parameter|fileNumber&}} [[OPEN]]ed in the [[INPUT (file mode)]] or [[BINARY]] file mode as one file line text string. -* '''NOTE:''' [[LINE INPUT (file statement)|LINE INPUT]] will work faster in [[BINARY]] mode than in [[INPUT (file mode)|INPUT]] mode. -** Using '''LINE INPUT #''' in [[BINARY]] mode is possible in '''version 1.000 and up''' -* Can be used with [[EOF]] to count the number of lines of data (records) in a file using a loop. -* Use the [[EOF]] function to avoid going past the end of a file and creating an error. -* '''LINE INPUT #''' can even retain the original quotation marks in text. -* '''Note: QB64''' will not remove CHR$(0) from the end of '''LINE INPUT #''' string return values like QBasic did. - - -{{PageErrors}} -* '''If an "Input past End of file" error occurs, check for CHR$(26) (end of file character) in the files being read.''' -* '''Warning: files must exist to be opened in '''INPUT''' mode. Use [[_FILEEXISTS]] to avoid program [[ERROR Codes|errors]].''' - - -{{PageExamples}} -''Example:'' Finding the number of filenames listed in a file to dimension an array to hold them. -{{CodeStart}} -{{Cl|REDIM}} FileArray$(100) 'create {{Cl|$DYNAMIC|dynamic}} array -{{Cl|SHELL}} {{Cl|_HIDE}} "DIR /B *.* > D0S-DATA.INF" -{{Cl|IF...THEN|IF}} {{Cl|_FILEEXISTS}}("D0S-DATA.INF") THEN - {{Cl|OPEN}} "D0S-DATA.INF" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 - DO UNTIL {{Cl|EOF}}(1) - {{Cl|LINE INPUT}} #1, file$ 'read entire text file line - filecount% = filecount% + 1 - LOOP - {{Cl|CLOSE}} #1 -{{Cl|END IF}} -{{Cl|REDIM}} FileArray$(filecount%) -{{Cl|PRINT}} filecount% -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[OPEN]], [[CLOSE]] -* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]], [[INPUT$]] {{text|(file input)}} -* [[INPUT]], [[LINE INPUT]], [[INPUT$]] {{text|(keyboard input)}} -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[FILELIST$]] (member-contributed function replacement for [[FILES]]) - - -{{PageNavigation}} diff --git a/internal/help/LINE_INPUT_1111_11111.txt b/internal/help/LINE_INPUT_1111_11111.txt deleted file mode 100644 index f58d6d7f6..000000000 --- a/internal/help/LINE_INPUT_1111_11111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:04}} -The [[LINE INPUT]] statement requests a [[STRING]] keyboard entry from a program user. - - -{{PageSyntax}} -: [[LINE INPUT]] [;] "[text prompt or question]"{,|;} {{Parameter|stringVariable$}} -: [[LINE INPUT]] ; {{Parameter|stringVariable$}} - - -{{Parameters}} -* A [[semicolon]] immediately after LINE INPUT stops the cursor after the entry and prevents screen roll on the lowest two screen rows. -* ''text prompt or question'' is optional, but quotes are necessary unless just a semicolon is used before the {{Parameter|stringVariable$}}. -* Requires only one [[STRING|string]] variable to hold the entire text entry. - - -{{PageDescription}} -* Cannot use numerical [[type]] variables or [[comma]] separated variable lists for multiple entries. -* Allows [[comma]]s and [[quotation mark]]s in the user input, unlike [[INPUT]] where commas denote extra input values and quotes delimit strings. -* The statement halts the program until an entry is made. Pressing Enter ends the entry and code execution resumes. -* LINE INPUT does not trim off leading or trailing spaces in the string entry like [[INPUT]] string returns. -* Use [[VAL]] to convert string numbers and [[&O]] (octal), [[&H]] (hexadecimal) or [[&B]] (binary) prefixed entries into numerical values. -* Use [[_DEST]] [[_CONSOLE]] before LINE INPUT statements to receive input from a [[$CONSOLE|console]] window. -* '''Note: QB64''' will not remove CHR$(0) from the end of LINE INPUT string return values like QBasic did. - - -{{PageExamples}} -''Example:'' Preventing screen roll after an input entry on the bottom 2 screen rows. -{{CodeStart}} -{{Cl|SCREEN}} 12 - -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 29, 2 ' place dursor at beginning of prompt liine -{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen -{{Cl|COLOR}} 15: {{Cl|LINE INPUT}} {{text|;|red}} "", name$ ' get search name from user -{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} {{Cl|SPC}}(78); ' erase previous prompt -n$ = {{Cl|UCASE$}}(name$) ' convert search name to upper case -{{Cl|COLOR}} 14' change foreground color to yellow -{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} "Searching..."; 'print message -{{Cl|SLEEP}} -{{CodeEnd}} -{{OutputStart}}{{text|Enter a name to search for...|#FFFF00}} █ -{{OutputEnd}} -: ''Explanation:'' The {{text|red|red}} [[semicolon]] after LINE INPUT acts like a semicolon after a [[PRINT]], which keeps the print cursor on the same row. - - -''See also:'' -* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]], [[LINE INPUT (file statement)|LINE INPUT #]] -* [[INPUT]], [[INPUT$]] {{text|(keyboard input)}} -* [[COLOR]], [[LOCATE]] -* [[INKEY$]] -* [[_KEYHIT]], [[_KEYDOWN]] - - -{{PageNavigation}} diff --git a/internal/help/LOCATE_111111.txt b/internal/help/LOCATE_111111.txt deleted file mode 100644 index 813059621..000000000 --- a/internal/help/LOCATE_111111.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:07}} -The [[LOCATE]] statement locates the screen text row and column positions for a [[PRINT]] or [[INPUT]] procedure. - - -{{PageSyntax}} -: [[LOCATE]] [{{Parameter|row%}}][, {{Parameter|column%}}] [, {{Parameter|cursor%}}][, {{Parameter|cursorStart%}}, {{Parameter|cursorStop%}}] - - -{{Parameters}} -* optional text {{Parameter|row%}} [[INTEGER]] values are from 1 to 25, 43 or 50 in [[SCREEN]] 0 and 25 in most other legacy graphic screen modes, except screens 11 and 12 which can have 30 or 60 rows. -* optional {{Parameter|column%}} [[INTEGER]] values are from 1 to 40 or 80 in [[SCREEN]] 0 and 80 in all other legacy screen modes. -* optional {{Parameter|cursor%}} value can be 0 to turn displaying the cursor off or 1 to turn it on. -* optional {{Parameter|cursorStart%}} and {{Parameter|cursorStop%}} values define the shape of the cursor by setting the start and stop scanline (values range from 0 to 31) for the cursor character. - - -{{PageDescription}} -* [[WIDTH]] statement can be used to determine the text width and height in [[SCREEN]] 0 and height of 30 or 60 in [[SCREEN]] 11 or 12. -* In [[_NEWIMAGE]] graphic screen the number of text ''rows'' are calculated as [[_HEIGHT]] \ 16 except when a [[_FONT]] is used. Use [[_FONTHEIGHT]] to calculate font rows. -* [[_NEWIMAGE]] graphic screen text ''columns'' are calculated as [[_WIDTH (function)|_WIDTH]] \ 8 except when a [[_FONT]] is used. Use [[_PRINTWIDTH]] to measure a line of font text. -* The text ''row'' position is not required if the [[PRINT]] is going to be on the next row. The [[comma]] and a ''column'' value are required to set the column. -* If only the ''row'' parameter is given, then the column position remains the same. '''Neither ''row'' or ''column'' parameter can be 0.''' -* When [[PRINT]]ing on the bottom 2 ''rows'', use a [[semicolon]] after the PRINT expression to avoid a screen roll. -* If the {{Parameter|cursorStart%}} line is given, the {{Parameter|cursorStop%}} line must also be given. A wider range between them produces a taller cursor. -* If you use LOCATE beyond the current number of rows in text mode, QB64 will try to adapt the screen instead of tossing an error. - - -{{PageExamples}} -''Example:'' Moving the cursor around (now you can finally create a Commodore 64 emulator!). '''Default SCREEN 0 only:''' -{{CodeStart}} -crx = 10 -cry = 10 -DO - {{Cl|LOCATE}} cry, crx, 1, 0, 8 - a$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} a$ - {{Cl|CASE}} {{Cl|CHR$}}(0) + "H": {{Cl|IF...THEN|IF}} cry > 1 {{Cl|THEN}} cry = cry - 1 'up - {{Cl|CASE}} {{Cl|CHR$}}(0) + "P": {{Cl|IF...THEN|IF}} cry < 25 {{Cl|THEN}} cry = cry + 1 'down - {{Cl|CASE}} {{Cl|CHR$}}(0) + "K": {{Cl|IF...THEN|IF}} crx > 1 {{Cl|THEN}} crx = crx - 1 'left - {{Cl|CASE}} {{Cl|CHR$}}(0) + "M": {{Cl|IF...THEN|IF}} crx < 80 {{Cl|THEN}} crx = crx + 1 'right - {{Cl|CASE}} {{Cl|CHR$}}(27): {{Cl|END}} - {{Cl|END SELECT}} -LOOP -{{CodeEnd}} - -: Explanation: The CHR$(0) + "H", "P", "K", "M" represents the cursor arrow keys. start = 0, stop = 8 is the tallest cursor, experiment with the start and stop values for different effects (start = 8, stop = 8 is the default producing a _ cursor). - - - -{{PageSeeAlso}} -* [[CSRLIN]], [[POS]] {{text|(cursor position)}} -* [[SCREEN]], [[PRINT]], [[COLOR]] -* [[INPUT]], [[LINE INPUT]], [[INPUT$]] {{text|(keyboard input)}} -* [[WIDTH]], [[INPUT$]], [[INKEY$]] - - -{{PageNavigation}} diff --git a/internal/help/LOCK_1111.txt b/internal/help/LOCK_1111.txt deleted file mode 100644 index 8b9778f7a..000000000 --- a/internal/help/LOCK_1111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:08}} -The [[LOCK]] statement restricts access to parts of a file by other programs or processes. - - -{{PageSyntax}} -:[[LOCK]] [#]{{Parameter|fileNumber%}} -:[[LOCK]] [#]{{Parameter|fileNumber%}}, {{Parameter|record&}} -:[[LOCK]] [#]{{Parameter|fileNumber%}}, [{{Parameter|firstRecord&}}] TO {{Parameter|lastRecord&}} - - -{{PageDescription}} -* {{Parameter|fileNumber%}} is the file number of the file to lock. -* In the first syntax, the entire file is locked. -* In the second syntax, {{Parameter|record&}} is the record number of the file to lock. -* In the third syntax, the records or bytes in the range [{{Parameter|firstRecord&}},{{Parameter|lastRecord&}}] are locked. If {{Parameter|firstRecord&}} is omitted, it is assumed to be one (the first record or byte). -* For files opened in [[BINARY]] mode, each record corresponds to a single byte. -* [[LOCK]] and [[UNLOCK]] statements are always used in pairs and each statement must match the other one. -* Files must be unlocked using [[UNLOCK]] before other programs can access them, and before the file is closed. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not supported in Linux or macOS versions]] - - -==QBasic/QuickBASIC== -* Required DOS '''SHARED.EXE''' to be run for QBasic to use networking access modes. No longer required. - - -{{PageSeeAlso}} -* [[UNLOCK]] -* [[OPEN]] -* [[ACCESS]] - - -{{PageNavigation}} diff --git a/internal/help/LOC_111.txt b/internal/help/LOC_111.txt deleted file mode 100644 index b951dcec5..000000000 --- a/internal/help/LOC_111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:06}} -The [[LOC]] function returns the status of a serial (COM) port received buffer or the current byte position in an open file. - - -{{PageSyntax}} -: {{Parameter|bytes%}} = LOC({{Parameter|fileOrPortNumber%}}) - - -* {{Parameter|fileOrPortNumber%}} is the number used in the port [[OPEN]] AS statement. -* Returns 0 if the buffer is empty. Any value above 0 indicates the COM port has received data. -* Use it in conjunction with [[INPUT$]] to get the data bytes received. -* Can also be used to read the current position in a file routine. See [[SEEK]]. - - -{{PageExamples}} -''Example:'' Reading and writing from a COM port opened in Basic. -{{CodeStart}} -{{Cl|OPEN}} "{{Cl|OPEN_COM|COM}}1: 9600,N,8,1,OP0" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = 2048 ' random mode = input and output - {{Cl|DO}}: t$ = {{Cl|INKEY$}} ' get any transmit keypresses from user - {{Cl|IF}} {{Cl|LEN}}(t$) {{Cl|THEN}} {{Cl|PRINT (file statement)|PRINT}} #1, t$ ' send keyboard byte to transmit buffer - bytes% = {{Cl|LOC}}(1) ' bytes in buffer - {{Cl|IF}} bytes% {{Cl|THEN}} ' check receive buffer for data" - r$ = {{Cl|INPUT$}}(bytes%, 1) ' get bytes in the receive buffer - {{Cl|PRINT}} r$; ' print byte strings consecutively to screen" - {{Cl|END IF}} - {{Cl|LOOP}} {{Cl|UNTIL}} t$ = {{Cl|CHR$}}(27) 'escape key exit -{{Cl|CLOSE}} # -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[PRINT]], [[OPEN COM]], [[PRINT (file statement)]] -* [[SEEK]] - -{{PageNavigation}} diff --git a/internal/help/LOF_111.txt b/internal/help/LOF_111.txt deleted file mode 100644 index 520b06716..000000000 --- a/internal/help/LOF_111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:09}} -The [[LOF]] function is used to find the length of an [[OPEN]] file in bytes. - - - -{{PageSyntax}} -: ''totalBytes&'' = [[LOF]]([#]{{Parameter|fileNumber}}) - - -{{PageDescription}} -* LOF returns the number of bytes in an [[OPEN]]ed designated {{Parameter|fileNumber}}. File is empty if it returns 0. -* {{Parameter|fileNumber}} is the number of the opened file. '''#''' is not required. -* Often used to determine the number of records in a [[RANDOM]] access file. -* Can also be used to avoid reading an empty file, which would create an error. -* LOF in '''QB64''' can return up to 9 GB (9,223,372,036 bytes) file sizes. - - -{{PageExamples}} -''Example:'' Finding the number of records in a RANDOM file using a [[TYPE]] variable. - -{{CodeStart}} - OPEN file$ FOR RANDOM AS #1 LEN = {{Cl|LEN}}(Type_variable) - NumRecords% = {{Cl|LOF}}(1) \ RecordLEN% -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[LEN]], [[EOF]], [[BINARY]], [[RANDOM]], [[TYPE]] - - -{{PageNavigation}} diff --git a/internal/help/LOG_111.txt b/internal/help/LOG_111.txt deleted file mode 100644 index 5f3e8d24d..000000000 --- a/internal/help/LOG_111.txt +++ /dev/null @@ -1,47 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:10}} -The [[LOG]] math function returns the natural logarithm of a specified numerical value. - - -{{PageSyntax}} -: {{Parameter|logarithm!}} = [[LOG]]({{Parameter|value}}) - - -{{PageDescription}} -* {{Parameter|value}} MUST be greater than 0. [[ERROR Codes|"Illegal function call" error]] occurs if negative or zero values are used. -* The natural logarithm is the logarithm to the base '''e = 2.718282''' (approximately). -* The natural logarithm of ''a'' is defined as the integral from 1 to ''a'' of dx/x. -* Returns are default [[SINGLE]] precision unless the value parameter uses [[DOUBLE]] precision. - - -{{PageExamples}} -''Example 1:'' [[FUNCTION]] to find the base ten logarithm of a numerical value. -{{CodeStart}} - FUNCTION Log10#(value AS DOUBLE) {{Cl|STATIC}} - Log10# = LOG(value) / LOG(10.#) - END FUNCTION -{{CodeEnd}} - -:''Explanation:'' The natural logarithm of the value is divided by the base 10 logarithm. The LOG of ten is designated as a DOUBLE precision return by using # after the Log10 value. The return tells you the number of times 10 goes into a value. - - -''Example 2:'' A binary FUNCTION to convert [[INTEGER]] values using LOG to find the number of digits the return will be. -{{CodeStart}} -FUNCTION BIN$ (n&) - IF n& < 0 THEN EXIT FUNCTION 'positive numbers only! negative error! - FOR p% = 0 TO INT({{Cl|LOG}}(n& + .1) / {{Cl|LOG}}(2)) ' added +.1 to get 0 to work - IF n& {{Cl|AND}} 2 ^ p% THEN s$ = "1" + s$ ELSE s$ = "0" + s$ 'find bits on - NEXT p% - IF s$ = "" THEN BIN$ = "&B0" ELSE BIN$ = "&B" + s$ 'check for zero return -END FUNCTION - -{{CodeEnd}} -: ''Explanation:'' The LOG of a '''positive''' [[INTEGER]] value is divided by the LOG of 2 to determine the number of binary digits that will be returned. The FOR loop compares the value with the exponents of two and determines if a bit is ON or OFF as "1" or "0". - - -{{PageSeeAlso}} -*[[EXP]], [[&B]] (binary number) -*[[Mathematical Operations#Derived Mathematical Functions|Derived Trigonometric Functions]] - - -{{PageNavigation}} diff --git a/internal/help/LONG_1111.txt b/internal/help/LONG_1111.txt deleted file mode 100644 index 39a5a9d1f..000000000 --- a/internal/help/LONG_1111.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:11}} -[[LONG]] defines a variable as a 4 byte number type definition for larger [[INTEGER]] values. - - -{{PageSyntax}} -: [[DIM]] {{Parameter|variable}} AS [[LONG]] - - -* [[LONG]] integer values range from -2147483648 to 2147483647. -* '''QB64''''s [[_UNSIGNED]] [[LONG]] integer values range from 0 to 4294967295. -* '''QB64''' [[_UNSIGNED]] [[_INTEGER64]] values range from 0 to 18446744073709551615. -* Decimal point values assigned to a [[LONG]] variable will be rounded to the nearest whole number. -* The LONG variable type suffix is & or ~& for [[_UNSIGNED]]. Suffix can also be placed after a literal or hexadecimal numerical value. -* [[_INTEGER64]] uses the '''&&''' or '''~&&''' [[_UNSIGNED]] suffix. -* Values can be converted to 4 byte [[ASCII]] string values using [[MKL$]] and back with [[CVL]]. -* '''When a variable has not been assigned or has no type suffix, the type defaults to [[SINGLE]].''' -* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' - - -{{PageSeeAlso}} -* [[DIM]], [[DEFLNG]] -* [[LEN]], [[CLNG]] -* [[MKL$]], [[CVL]] -* [[INTEGER]], [[_INTEGER64]] -* [[SINGLE]], [[DOUBLE]] -* [[_DEFINE]], [[_UNSIGNED]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/LPOS_1111.txt b/internal/help/LPOS_1111.txt deleted file mode 100644 index 8fd0e1321..000000000 --- a/internal/help/LPOS_1111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:15}} -The [[LPOS]] function returns the current LPT printer head position. - - -{{PageSyntax}} -: {{Parameter|result%}} = [[LPOS]]({{Parameter|index%}}) - - -{{PageDescription}} -* {{Parameter|index%}} is the index of the printer, which can have the following values: -** 0 - LPT1: -** 1 - LPT1: -** 2 - LPT2: -** 3 - LPT3: -* The LPOS function does not necessarily give the physical position of the print head because it does not expand tab characters. In addition, some printers may buffer characters. - - -{{PageExamples}} -:Prompts the user for team names and the names of players on each team. It then prints the players and their teams on the printer. -{{CodeStart}}{{Cl|CLS}} -{{Cl|LPRINT}} "Team Members"; {{Cl|TAB}}(76); "TEAM" : {{Cl|LPRINT}} -{{Cl|INPUT}} "How many teams"; TEAMS -{{Cl|INPUT}} "How many players per team";PPT -{{Cl|PRINT}} -{{Cl|FOR}} T = 1 TO TEAMS - {{Cl|INPUT}} "Team name: ", TEAM$ - {{Cl|FOR}} P = 1 TO PPT - {{Cl|INPUT}} " Enter player name: ", PLAYER$ - {{Cl|LPRINT}} PLAYER$; - {{Cl|IF...THEN|IF}} P < PPT {{Cl|THEN}} - {{Cl|IF...THEN|IF}} {{Cl|LPOS}}(0) > 55 {{Cl|THEN}} ' Print a new line if print head past column 55. - {{Cl|LPRINT}} : {{Cl|LPRINT}} {{Cl|SPACE$}}(5); - {{Cl|ELSE}} - {{Cl|LPRINT}} ", "; 'Otherwise, print a comma. - {{Cl|END}} IF - {{Cl|END}} IF - {{Cl|NEXT}} P -{{Cl|LPRINT}} {{Cl|STRING$}}(80 - {{Cl|LPOS}}(0) - {{Cl|LEN}}(TEAM$),"."); TEAM$ -{{Cl|NEXT}} T -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[LPRINT]] - - -{{PageNavigation}} diff --git a/internal/help/LPRINT_111111.txt b/internal/help/LPRINT_111111.txt deleted file mode 100644 index 80bd6d5a1..000000000 --- a/internal/help/LPRINT_111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:16}} -The [[LPRINT]] statement sends string text or numerical values to a parallel port (LPT1) printer in QBasic or a USB printer in '''QB64'''. - - -{{PageSyntax}} -:[[LPRINT]] [{{Parameter|expression}}] [{;|,}] - - -{{PageDescription}} -* {{Parameter|expression}} is one or more text or numerical expressions separated by a semi-colon (;) or comma (,). -* Syntax is the same as [[PRINT]], but cannot use a port number. -* Program does not have to [[OPEN]] the LPT1: parallel port. -* Assumes a 80 character wide page. '''[[Keywords currently not supported by QB64|WIDTH LPRINT is not supported in QB64.]]''' -* [[LPRINT USING]] can print formatted text data to a page identically to how [[PRINT USING]] formats a program screen. -* [[COLOR]]ed text and images can be printed using [[_PRINTIMAGE]] which stretches them to fit the default printer's paper size. -* LPRINT will only print to the default USB or LPT printer set up in Windows. '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]''' -* Note: Printer ''escape codes'' starting with [[CHR$]](27) will not work with LPRINT and may produce text printing errors. - - -{{PageSeeAlso}} -* [[LPRINT USING]] -* [[_PRINTIMAGE]] {{text|(prints color images to page size)}} -* [[PRINT]], [[PRINT USING]] -* [[Windows Printer Settings]] - - -{{PageNavigation}} diff --git a/internal/help/LPRINT_USING_111111_11111.txt b/internal/help/LPRINT_USING_111111_11111.txt deleted file mode 100644 index 936f1b823..000000000 --- a/internal/help/LPRINT_USING_111111_11111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:18}} -The [[LPRINT USING]] statement sends formatted data to LPT1, the parallel port printer. - - -{{PageSyntax}} -: '''LPRINT''' [''text$''{;|,}] '''USING''' {{Parameter|template$}}; {{Parameter|variable}}[; ...][{;|,}] - - -{{Parameters}} -* Literal or variable [[STRING]] ''text$'' can be placed between [[LPRINT]] and USING or it can be included in the {{Parameter|template$}}. -* A [[semicolon]] or [[comma]] may follow the {{Parameter|text$}} to stop or tab the print cursor before the {{Parameter|template$}} [[LPRINT]]. -* The literal or variable [[STRING]] {{Parameter|template$}} should use the template symbols to display each variable [[type]] in the list following it. -* The list of data ''variables'' used in the {{Parameter|template$}} are '''separated by semicolons''' after the template string value. -* A [[semicolon]] or [[comma]] may follow the variable list to stop or tab the print cursor for pending prints. - - -{{PageDescription}} -* The ''variable'' list should be listed in the order that they are used in the template from left to right. -* '''If the ''template'' string is omitted or symbols don't match the ''variable(s)'' an "Illegal Function Call" [[ERROR Codes|ERROR]] will occur.''' -* No more than 25 # digit places are allowed in a template number or an [[ERROR Codes|error]] will occur. -* Can convert numerical exponential or [[scientific notation]] values to normal decimal point values using less digits. -* '''NOTE:''' If the numerical value exceeds the template's digit range a % symbol will appear in the leftmost digit area. - - -{{PrintUsingTable}} - - -{{PageSeeAlso}} -* [[PRINT USING]] -* [[LPRINT]] -* [[PRINT]] - - -{{PageNavigation}} diff --git a/internal/help/LSET_1111.txt b/internal/help/LSET_1111.txt deleted file mode 100644 index 9e3d8d58f..000000000 --- a/internal/help/LSET_1111.txt +++ /dev/null @@ -1,63 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:19}} -[[LSET]] left-justifies a fixed length string expression based on the size of the [[STRING]] variable and string expression. - - -{{PageSyntax}} -: [[LSET]] {stringVariable = stringExpression | stringExpression1 = stringExpression2} - - -{{PageDescription}} -* If the string expression is longer than a fixed length string variable the value is truncated from the right side in LSET or [[RSET]]. -* If the LSET string expression is smaller, spaces will occupy the extra positions to the right in the string. -* LSET can be used with a [[FIELD]] or [[TYPE]] definition to set the buffer position before a [[PUT]]. - - -{{PageExamples}} -''Example 1:'' Using LSET with a [[FIELD]] definition. Note: May create an empty (unchanged) file that can be deleted. -{{CodeStart}} -{{Cl|OPEN}} "testfile.dat" FOR {{Cl|RANDOM}} AS #1 {{Cl|LEN}} = 15 -{{Cl|FIELD}} 1, 6 {{Cl|AS}} a$, 9 {{Cl|AS}} other$ -{{Cl|FIELD}} 1, 2 {{Cl|AS}} b$, 13 {{Cl|AS}} another$ -{{Cl|LSET}} a$ = "1234567890" -{{Cl|LSET}} other$ = "1234567890" -{{Cl|PRINT}} a$, b$, other$, another$ -{{Cl|CLOSE}} #1 - -{{CodeEnd}} -{{OutputStart}} -123456 12 123456789 3456123456789 -{{OutputEnd}} - - -''Example 2:'' How LSET can define two different string length values in one statement. -{{CodeStart}} - -{{Cl|TYPE}} ninestring -head {{Cl|AS}} {{Cl|STRING}} * 9 -{{Cl|END TYPE}} - -{{Cl|TYPE}} fivestring -head AS {{Cl|STRING}} * 5 -{{Cl|END TYPE}} - -{{Cl|DIM}} me {{Cl|AS}} ninestring, you {{Cl|AS}} fivestring -me.head = "ACHES NOT" -{{Cl|CLS}} - -{{Cl|LSET}} you.head = me.head -{{Cl|PRINT}} "me.head: "; me.head -{{Cl|PRINT}} "you.head: "; you.head -{{CodeEnd}} -{{OutputStart}} -me.head: ACHES NOT -you.head: ACHES -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[RSET]], [[RTRIM$]] -* [[FIELD]], [[TYPE]] - - -{{PageNavigation}} diff --git a/internal/help/LTRIM$_11111$.txt b/internal/help/LTRIM$_11111$.txt deleted file mode 100644 index f79f64a74..000000000 --- a/internal/help/LTRIM$_11111$.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:20}} -The [[LTRIM$]] function removes leading space characters from a [[STRING]] value. - - -{{PageSyntax}} -:{{Parameter|return$}} = [[LTRIM$]]({{Parameter|text$}}) - - -{{PageDescription}} -* {{Parameter|text$}} is the [[STRING]] value to trim. -* If {{Parameter|text$}} contains no leading space characters, it is returned unchanged. -* Convert fixed length [[STRING]] values by using a different {{parameter|return$}} variable. -* Can be used to trim the leading space of a positive numerical value converted to a string value by [[STR$]]. - - -{{PageExamples}} -''Example 1:'' Trimming a positive string number. -{{CodeStart}} -value = 12345 -number$ = {{Cl|LTRIM$}}({{Cl|STR$}}(value)) 'converting number to string removes right PRINT space -{{Cl|PRINT}} "[" + number$ + "]" -{{CodeEnd}} -{{OutputStart}}[12345] -{{OutputEnd}} - - -''Example 2:'' Trimming leading spaces from text strings. -{{CodeStart}} -{{Cl|PRINT}} {{Cl|LTRIM$}}("some text") -{{Cl|PRINT}} {{Cl|LTRIM$}}(" some text") -{{CodeEnd}} -{{OutputStart}}some text -some text -{{OutputEnd}} - - -''Example 3:'' A TRIM$ function to trim spaces off of both ends of a string. -{{codeStart}} -text$ = " Text String " -trimmed$ = TRIM$(text$) -{{Cl|PRINT}} {{Cl|CHR$}}(26) + trimmed$ + {{Cl|CHR$}}(27) -{{Cl|FUNCTION}} TRIM$(text$) -TRIM$ = {{Cl|LTRIM$}}({{Cl|RTRIM$}}(text$)) -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{OutputStart}}→Text String↠-{{OutputEnd}} - - -{{PageSeeAlso}} -* [[RTRIM$]], [[STR$]] -* [[LEFT$]], [[RIGHT$]] -* [[HEX$]], [[MID$]] - - -{{PageNavigation}} diff --git a/internal/help/Less_Than_1000_1000.txt b/internal/help/Less_Than_1000_1000.txt deleted file mode 100644 index 6e7d5884e..000000000 --- a/internal/help/Less_Than_1000_1000.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:15}} -The '''<''' condition symbol denotes that a value must be less than another value for the condition to be True. - - -''Example usage:'' IF x [[Less_Than|<]] 320 THEN PRINT "Left of screen" - - -* Statements will evaluate as True or -1 when the first value is less or False or 0 when the first value is equal or greater. -* More than one < symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical value. - - -''See also:'' - -* [[Equal|=]] -* [[Not_Equal|<>]] -* [[Greater_Than|>]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/Less_Than_Or_Equal_1000_1000_10_10000.txt b/internal/help/Less_Than_Or_Equal_1000_1000_10_10000.txt deleted file mode 100644 index 4c4d24b5c..000000000 --- a/internal/help/Less_Than_Or_Equal_1000_1000_10_10000.txt +++ /dev/null @@ -1,17 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:17}} -The '''<=''' condition symbol denotes that a value must be less than or equal to another value for the condition to be True. - - -''Example usage:'' IF x [[Less_Than_Or_Equal|<=]] 320 THEN PRINT "Left or center of screen" - - -''See also:'' - -* [[Equal|=]] -* [[Not_Equal|<>]] -* [[Greater_Than_Or_Equal|>=]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/MID$_(statement)_111$_(000000000).txt b/internal/help/MID$_(statement)_111$_(000000000).txt deleted file mode 100644 index 2cf6dff3b..000000000 --- a/internal/help/MID$_(statement)_111$_(000000000).txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:22}} -The [[MID$]] statement substitutes one or more new characters for existing characters of a previously defined [[STRING]]. - - - -{{PageSyntax}} -: [[MID$]]({{Parameter|baseString$}}, {{Parameter|startPosition%}}[, {{Parameter|bytes%}}]) = {{Parameter|replacementString$}} - - -{{PageDescription}} -* The {{Parameter|baseString$}} variable must exist and be large enough to contain the {{Parameter|replacementString$}}. -* {{Parameter|startPosition%}} specifies the string character position to start the overwrite. -* {{Parameter|bytes%}} or number of characters is optional. Excess byte lenghts are ignored. -* The {{Parameter|replacementString$}} should be as long as the byte length reserved. -* The length of the original string is not changed in any case. If {{Parameter|replacementString$}} is longer, it gets clipped. - - -{{PageExamples}} -''Example:'' Using [[INSTR]] to locate the string positions and a [[MID$ (statement)|MID$]] statement to change the words. - -{{CodeStart}} - text$ = "The cats and dogs were playing, even though dogs don't like cats." - PRINT text$ - start% = 1 ' start cannot be 0 when used in the INSTR function! - {{Cl|DO...LOOP|DO}} - position% = {{Cl|INSTR}}(start%, text$, "dog") - IF position% THEN ' when position is a value greater than 0 - {{Cl|MID$}}(text$, position%, 3) = "rat" ' changes "dog" to "rat" when found - start% = position% + 1 ' advance one position to search rest of string - END IF - LOOP UNTIL position% = 0 ' no other matches found - PRINT text$ -{{CodeEnd}} -{{OutputStart}} -The cats and dogs were playing, even though dogs don't like cats. -The cats and rats were playing, even though rats don't like cats. -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[MID$]] {{text|(function)}} -* [[LEFT$]], [[RIGHT$]] -* [[INSTR]], [[ASCII]], [[STR$]], [[HEX$]], [[Bitmaps]] (example) -* [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]] - - -{{PageNavigation}} diff --git a/internal/help/MID$_111$.txt b/internal/help/MID$_111$.txt deleted file mode 100644 index a25b2d19c..000000000 --- a/internal/help/MID$_111$.txt +++ /dev/null @@ -1,111 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:21}} -The [[MID$]] function returns a portion of a [[STRING|string]]. - - -{{PageSyntax}} -: {{Parameter|portion$}} = [[MID$]]({{Parameter|stringValue$}}, {{Parameter|startPosition%}}[, {{Parameter|bytes%}}]) - - -{{Parameters}} -* {{Parameter|stringValue$}} can be any literal or variable non-empty [[STRING]] value. Use [[LEN]] to check the length of a string. -* {{Parameter|startPosition%}} designates the non-zero position of the first character to be returned by the function. -* {{Parameter|bytes%}} (optional) tells the function how many characters to return including the first character at {{Parameter|startPosition%}}. - - -{{PageDescription}} -* When the {{Parameter|bytes%}} value is not passed, the function returns the remainder of the string from the starting character position. -* Number of character {{Parameter|bytes%}} should be within the string's [[LEN|length]] from the start position, but will only return the string's remainder when exceeded. -* If the {{Parameter|bytes%}} value is 0 or the {{Parameter|startPosition%}} is 0 or greater than the [[LEN|length]] of the string, an empty string is returned (no error is triggered). -* In '''QB64''', [[ASC]] string byte position reads are about '''5 times faster''' than MID$ when parsing strings. See ''Example 2'' below. - - -==QBasic/QuickBASIC== -* In QBasic the {{Parameter|startPosition%}} could not be zero (0) or an [[ERROR Codes|Illegal function call error]] would occur. - - -{{PageExamples}} -''Example 1:'' Getting the hour and minutes from [[TIME$]] -{{CodeStart}} -{{Cl|PRINT}} {{Cl|TIME$}} - -hour$ = {{Cl|LEFT$}}({{Cl|TIME$}}, 2) -minutes$ = {{Cl|MID$}}({{Cl|TIME$}}, 4, 2) ' skip hours and the colon (first 3 characters) - -{{Cl|PRINT}} "hour = "; hour$; ": minutes = "; minutes$ -{{CodeEnd}} -{{OutputStart}}11:23:30 -hour = 11: minutes = 23 -{{OutputEnd}} - - -''Example 2:'' Comparing MID$, the '''QB64''' byte position version of [[ASC]] and [[_MEMGET]] speeds parsing string characters: -{{CodeStart}} -{{Cl|_TITLE}} "String Speed Test" -{{Cl|DEFLNG}} A-Z - -'First let's build a string for testing. -Limit = 100000 'the size of the string -LoopCount = 1000 'the number of times we want to deconstruct it - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit - t$ = t$ + {{Cl|CHR$}}({{Cl|RND}} * 255) -{{Cl|NEXT}} - -'now for some times - -t1# = {{Cl|TIMER}} -{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount - {{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit - m$ = {{Cl|MID$}}(t$, i, 1) - {{Cl|NEXT}} -{{Cl|NEXT}} -t2# = {{Cl|TIMER}} -{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount - {{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit - m = {{Cl|ASC}}(t$, i) - {{Cl|NEXT}} -{{Cl|NEXT}} - -t3# = {{Cl|TIMER}} -{{Cl|$CHECKING}}:OFF -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}, m1 {{Cl|AS}} {{Cl|STRING}} * 1, m2 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} -m = {{Cl|_MEMNEW}}(Limit) 'create new memory space for string -{{Cl|_MEMPUT}} m, m.OFFSET, t$ 'put string t$ into memory space -{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount - {{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit - {{Cl|_MEMGET}} m, m.OFFSET + i - 1, m1 - {{Cl|NEXT}} -{{Cl|NEXT}} -t4# = {{Cl|TIMER}} -{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount - {{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit - {{Cl|_MEMGET}} m, m.OFFSET + i - 1, m2 - {{Cl|NEXT}} -{{Cl|NEXT}} -t5# = {{Cl|TIMER}} - -'results - -{{Cl|PRINT USING}} "##.###### seconds for MID$"; t2# - t1# -{{Cl|PRINT USING}} "##.###### seconds for ASC"; t3# - t2# -{{Cl|PRINT USING}} "##.###### seconds for _MEMGET String"; t4# - t3# -{{Cl|PRINT USING}} "##.###### seconds for _MEMGET Byte"; t5# - t4# -{{CodeEnd}} {{small|Code by Steve McNeill}} -{{OutputStart}}6.593750 seconds for MID$ -1.044922 seconds for ASC -0.494141 seconds for _MEMGET String -0.494141 seconds for _MEMGET Byte -{{OutputEnd}} -: ''Note:'' [[_MEMGET]] can be used with [[$CHECKING]]:OFF to cut the parsing speed even more. [[STRING]] * 1 or [[_BYTE]] are similar speeds. - - -''See also:'' -* [[MID$ (statement)]], [[ASC]] -* [[LEFT$]], [[RIGHT$]] -* [[LTRIM$]], [[RTRIM$]] -* [[INSTR]], [[LEN]] -* [[_MEMPUT]], [[_MEMGET]] - - -{{PageNavigation}} diff --git a/internal/help/MKD$_111$.txt b/internal/help/MKD$_111$.txt deleted file mode 100644 index a005336b1..000000000 --- a/internal/help/MKD$_111$.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:24}} -The [[MKD$]] function encodes a [[DOUBLE]] numerical value into an 8-byte [[ASCII]] [[STRING]] value. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKD$]]({{Parameter|doublePrecisionVariableOrLiteral#}}) - - -{{PageDescription}} -* {{Parameter|doublePrecisionVariableOrLiteral#}} is converted to eight ASCII characters. To see this in action, try {{InlineCode}}PRINT MKD$(12345678){{InlineCodeEnd}}. -* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken. -* The string value can be converted back to a DOUBLE numerical value using [[CVD]]. -* [[DOUBLE]] numerical variable values [[PUT]] into a [[BINARY]] file are automatically placed as an MKD$ [[ASCII]] string value. - - -{{PageSeeAlso}} -* [[MKI$]], [[MKS$]], [[MKL$]] -* [[CVD]], [[CVI]], [[CVS]], [[CVL]] -* [[_MK$]], [[_CV]] - -{{PageNavigation}} diff --git a/internal/help/MKDIR_11111.txt b/internal/help/MKDIR_11111.txt deleted file mode 100644 index 18fae9ee6..000000000 --- a/internal/help/MKDIR_11111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:25}} -The [[MKDIR]] statement creates a new folder ('''dir'''ectory) at a specified path. - - -{{PageSyntax}} -: [[MKDIR]] pathSpec$ - - -{{PageDescription}} -* The path specification (pathSpec$) is a literal or variable [[STRING]] expression that also specifies the new folder's name. -* If no path is given the directory will become a sub-directory of the present directory where the program is currently running. -* '''QB64''' can use both long or short path and file names with spaces when required. -* The new folder will be created without a user prompt or verification. -* If a path is specified, the path must exist or a [[ERROR Codes|"Path not found" error]] will occur. See [[_DIREXISTS]]. -* [[SHELL]] can use the DOS command "MD " or "MKDIR " + path$ + newfolder$ to do the same thing. - - -{{PageSeeAlso}} -* [[SHELL]], [[CHDIR]], [[FILES]] -* [[NAME]], [[KILL]], [[RMDIR]] -* [[_DIREXISTS]] -* [[Windows_Libraries#File_Dialog_Boxes|Windows Open and Save Dialog Boxes]] - - -{{PageNavigation}} diff --git a/internal/help/MKDMBF$_111111$.txt b/internal/help/MKDMBF$_111111$.txt deleted file mode 100644 index 94e1a719d..000000000 --- a/internal/help/MKDMBF$_111111$.txt +++ /dev/null @@ -1,20 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:26}} -The [[MKDMBF$]] function encodes a double-precision IEEE number to a string value in the Microsoft Binary format. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKDMBF$]]({{Parameter|doublePrecisionVariableOrLiteral#}}) - - -{{PageDescription}} -* Encodes [[DOUBLE]] values to [[STRING|string]] values in Microsoft Binary format. -* The resulting string value can be decoded using [[CVDMBF]]. - - -{{PageSeeAlso}} -* [[MKSMBF$]] -* [[CVDMBF]], [[CVSMBF]] - - -{{PageNavigation}} diff --git a/internal/help/MKI$_111$.txt b/internal/help/MKI$_111$.txt deleted file mode 100644 index f19ba7f48..000000000 --- a/internal/help/MKI$_111$.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:27}} -The [[MKI$]] function encodes an [[INTEGER]] numerical value into a 2-byte [[ASCII]] [[STRING]] value. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKI$]]({{Parameter|integerVariableOrLiteral%}}) - - -{{PageDescription}} -* {{Parameter|integerVariableOrLiteral%}} is converted to two ASCII characters. -* [[INTEGER]] values can range from -32768 to 32767. -* MKI$ string values can be converted back to numerical INTEGER values using [[CVI]]. -* The function takes up less byte space in a file than using the text numerical value when the value is over 2 digits. -* When a variable value is used with [[PUT]] a numerical value is converted automatically in [[RANDOM]] and [[BINARY]] files. - - -{{PageExamples}} -''Example:'' How MKI$ creates a two byte string integer value to save file space. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 '_PRINTSTRING requires a graphic screen mode -DO - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number% - {{Cl|IF...THEN|IF}} number% < 1 {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|CLS}} - A$ = {{Cl|CHR$}}(number% {{Cl|MOD}} 256) 'first digit(0 to 255) - B$ = {{Cl|CHR$}}(number% \ 256) 'second digit(0 to 127) - - MKIvalue$ = A$ + B$ - Q$ = {{Cl|CHR$}}(34) - strng$ = "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(number% {{Cl|MOD}} 256)) + ") + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(number% \ 256)) + ")" - {{Cl|COLOR}} 11 - {{Cl|_PRINTSTRING}} (222, 252), {{Cl|STR$}}(number%) + " = " + strng$ - {{Cl|_PRINTSTRING}} (252, 300), "{{Cl|MKI$}} value = " + Q$ + MKIvalue$ + Q$ 'print ASCII characters -{{Cl|LOOP}} -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' INPUT in QB64 limits integer entries to 32767 maximum. MOD 256 finds the part of a value from 0 to 255 while the second value is the number of times that 256 can go into the value. [[_PRINTSTRING]] can print all of the [[ASCII]] characters. - - -{{PageSeeAlso}} -* [[MKD$]], [[MKS$]], [[MKL$]] -* [[CVD]], [[CVI]], [[CVS]], [[CVL]] -* [[_MK$]], [[_CV]] - - -{{PageNavigation}} diff --git a/internal/help/MKL$_111$.txt b/internal/help/MKL$_111$.txt deleted file mode 100644 index e89575f07..000000000 --- a/internal/help/MKL$_111$.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:28}} -The [[MKL$]] function encodes a [[LONG]] numerical value into a 4-byte [[ASCII]] [[STRING]] value. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKL$]]({{Parameter|longVariableOrLiteral&}}) - - -{{PageDescription}} -* {{Parameter|longVariableOrLiteral&}} is converted to four ASCII characters. To see this in action, try {{InlineCode}}PRINT MKL$(12345678){{InlineCodeEnd}}. -* The numerical data usually takes up less bytes than printing the [[LONG]] number to a file. -* [[LONG]] integer values can range from -2147483648 to 2147483647. -* 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. -* [[CVL]] can convert the value back to a [[LONG]] numerical value. -* [[LONG]] numerical variable values [[PUT]] into a [[BINARY]] file are automatically placed as an MKL$ [[ASCII]] string value. - - -{{PageExamples}} -See examples in: -* [[SAVEIMAGE]] -* [[SaveIcon32]] - - -{{PageSeeAlso}} -* [[MKI$]], [[MKS$]], [[MKD$]] -* [[CVD]], [[CVI]], [[CVS]], [[CVL]] -* [[_MK$]], [[_CV]] - - -{{PageNavigation}} diff --git a/internal/help/MKS$_111$.txt b/internal/help/MKS$_111$.txt deleted file mode 100644 index 182b38ed6..000000000 --- a/internal/help/MKS$_111$.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:29}} -The [[MKS$]] function encodes a [[SINGLE]] numerical value into a 4-byte [[ASCII]] [[STRING]] value. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKS$]]({{Parameter|singlePrecisionVariableOrLiteral#}}) - - -{{PageDescription}} -* {{Parameter|singlePrecisionVariableOrLiteral#}} is converted to four ASCII characters. To see this in action, try {{InlineCode}}PRINT MKS$(1345678){{InlineCodeEnd}}. -* [[SINGLE]] values can range up to 7 decimal point digits. Decimal point accuracy depends on whole value places taken. -* [[MKS$]] string values can be converted back to SINGLE numerical values using the [[CVS]] function. -* [[SINGLE]] numerical variable values [[PUT]] into a [[BINARY]] file are automatically placed as an [[MKS$]] [[ASCII]] string value. - - -{{PageSeeAlso}} -* [[MKI$]], [[MKD$]], [[MKL$]] -* [[CVD]], [[CVI]], [[CVS]], [[CVL]] -* [[_MK$]], [[_CV]] - - -{{PageNavigation}} diff --git a/internal/help/MKSMBF$_111111$.txt b/internal/help/MKSMBF$_111111$.txt deleted file mode 100644 index 676808c25..000000000 --- a/internal/help/MKSMBF$_111111$.txt +++ /dev/null @@ -1,20 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:30}} -The [[MKSMBF$]] function encodes a single-precision IEEE number to a string value in the Microsoft Binary format. - - -{{PageSyntax}} -: {{Parameter|result$}} = [[MKSMBF$]]({{Parameter|singlePrecisionVariableOrLiteral!}}) - - -{{PageDescription}} -* Encodes [[SINGLE]] values to [[STRING|string]] values in Microsoft Binary format. -* The resulting string value can be decoded using [[CVSMBF]]. - - -{{PageSeeAlso}} -* [[MKDMBF$]] -* [[CVDMBF]], [[CVSMBF]] - - -{{PageNavigation}} diff --git a/internal/help/MOD_111.txt b/internal/help/MOD_111.txt deleted file mode 100644 index 5b55315a7..000000000 --- a/internal/help/MOD_111.txt +++ /dev/null @@ -1,105 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:31}} -The [[MOD]] operator gives the remainder after division of one number by another (sometimes called modulus). - - -{{PageSyntax}} -: {{Parameter|remainder}} = {{Parameter|numerator}} [[MOD]] {{Parameter|divisor}} - - -{{Parameters}} -* Returns the integer division remainder as a whole [[INTEGER]], [[LONG]] or [[_INTEGER64]] value. -* {{Parameter|numerator}} is the [[INTEGER]] value to divide. -* {{Parameter|divisor}} is the [[INTEGER]] value to divide by. - - -{{PageDescription}} -* Floating decimal point ''numerator'' and ''divisor'' values are [[CINT]] rounded (e.g. {{InlineCode}}19 MOD 6.7{{InlineCodeEnd}} returns 5 just like {{InlineCode}}19 MOD 7{{InlineCodeEnd}} would). -* MOD returns 0 if a number is evenly divisible by integer division ( [[\]] ) or the number divided is 0. -* '''{{Parameter|divisor}} (second value) must not be between 0 and .5'''. This will create a [[ERROR Codes|"Division by zero" error]] due to [[CINT]] rounding the value to 0. -* The result has the same sign as the numerator (e.g. {{InlineCode}}-1 MOD 7{{InlineCodeEnd}} returns -1, not 6). -* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}} - I% = 100 {{Cl|\}} 9 - R% = 100 {{Cl|MOD}} 9 - PRINT "Integer division ="; I%, "Remainder ="; R% -{{CodeEnd}} -{{OutputStart}} - Integer division = 11 Remainder = 1 -{{OutputEnd}} - -''Explanation:'' Integer division 100 \ 9 returns 11. 11 [[*]] 9 = 99. So the remainder must be 1 as 100 - 99 = 1. Normal decimal point division would return 11.11111. - - -''Example 2:'' Comparing normal, integer and remainder division. -{{CodeStart}} -tmp1$ = " Normal: ####.# / #### = ##.### " -tmp2$ = " Integer: ####.# \ #### = ### " -tmp3$ = " Remainder: ####.# MOD #### = #### " -FOR i = 1 TO 6 - SELECT CASE i - CASE 1: numerator = 1: divisor = 5 - CASE 2: numerator = 13: divisor = 10 - CASE 3: numerator = 990: divisor = 100 - CASE 4: numerator = 1100: divisor = 100 - CASE 5: numerator = 4501: divisor = 1000 - CASE 6: numerator = 50.6: divisor = 10 - END SELECT -LOCATE 5, 20: PRINT USING tmp1$; numerator; divisor; numerator / divisor -LOCATE 7, 20: PRINT USING tmp2$; numerator; divisor; numerator \ divisor -LOCATE 9, 20: PRINT USING tmp3$; numerator; divisor; numerator MOD divisor -DO: SLEEP: LOOP UNTIL INKEY$ <> "" -NEXT -{{CodeEnd}} - - -''Example 3:'' Integer division and MOD can be used to convert values to different base numbering systems from base 2 to 36 as [[STRING|strings]]: -{{CodeStart}} -{{Cl|CLS}} -DO - {{Cl|INPUT}} "Enter a base number system 2 to 36: ", b% - {{Cl|IF...THEN|IF}} b% < 2 {{Cl|OR (boolean)|OR}} b% > 36 {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|PRINT}} "Enter a positive value to convert: "; - num$ = "" - {{Cl|DO...LOOP|DO}}: K$ = {{Cl|INKEY$}} - num$ = num$ + K$ - {{Cl|LOCATE}} {{Cl|CSRLIN}}, {{Cl|POS}}(0): {{Cl|PRINT}} K$; - {{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(13) - n& = {{Cl|VAL}}(num$) - {{Cl|IF...THEN|IF}} n& = 0 {{Cl|THEN}} {{Cl|EXIT DO}} - Bnum$ = BASEN$(n&, b%) - {{Cl|PRINT}} Bnum$ ', {{Cl|VAL}}("{{Cl|&H}}" + Bnum$) 'tests hexadecimal base 16 only -{{Cl|LOOP}} - -{{Cl|END}} - -{{Cl|FUNCTION}} BASEN$ (number&, basenum%) -{{Cl|IF...THEN|IF}} basenum% < 2 {{Cl|OR (boolean)|OR}} basenum% > 36 {{Cl|OR (boolean)|OR}} number& = 0 {{Cl|THEN}} {{Cl|EXIT FUNCTION}} -num& = number& 'protect value of number! -DO - remain% = {{Cl|ABS}}(num&) {{Cl|MOD}} basenum% ' remainder is used to create actual digit 0 to Z - num& = num& \ basenum% ' move up one exponent of base% with integer division - {{Cl|IF...THEN|IF}} remain% > 9 {{Cl|THEN}} - b$ = {{Cl|CHR$}}(65 + (remain% - 10)) 'limited to base 36 - {{Cl|ELSE}}: b$ = {{Cl|LTRIM$}}({{Cl|STR$}}(remain%)) ' make remainder a string number - {{Cl|END IF}} - BN$ = b$ + BN$ ' add remainder character to base number string -{{Cl|LOOP}} {{Cl|UNTIL}} num& = 0 -BASEN$ = BN$ -{{Cl|END FUNCTION}} -{{CodeEnd}} -: ''Note:'' Base numbering systems over base 10(0 - 9) use alphabetical letters to represent digits greater than 9 like [[&H|Hexadecimal]](0 - F). - - -{{PageSeeAlso}} -* [[/|/ (normal division operator)]] -* [[\|\ (integer division operator)]] -* [[INT]], [[CINT]], [[FIX]], [[_ROUND]], [[_CEIL]] -* [[Mathematical Operations]] - - -{{PageNavigation}} diff --git a/internal/help/Mathematical_Operations_100000000000_1000000000.txt b/internal/help/Mathematical_Operations_100000000000_1000000000.txt deleted file mode 100644 index d7b61bc11..000000000 --- a/internal/help/Mathematical_Operations_100000000000_1000000000.txt +++ /dev/null @@ -1,517 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:05}} -__NOEDITSECTION__ -{|align="right" -|__TOC__ -|} - -==Basic and QB64 Numerical Types== -
'''QBasic Number Types'''
- -* [[INTEGER]] ['''%''']: 2 Byte signed whole number values from -32768 to 32767. 0 to 65535 unsigned. (not checked in QB64) -* [[LONG]] ['''&''']: 4 byte signed whole number values from -2147483648 to 2147483647. 0 to 4294967295 unsigned. -* [[SINGLE]] ['''!''']: 4 byte signed floating decimal point values of up to 7 decimal place accuracy. '''Cannot be unsigned.''' -* [[DOUBLE]] [#]: 8 byte signed floating decimal point values of up to 15 decimal place accuracy. '''Cannot be unsigned.''' -* To get '''one byte''' values, can use an [[ASCII]] [[STRING]] character to represent values from 0 to 255 as in [[BINARY]] files. - - -
'''QB64 Number Types'''
- -* [[_BIT]] ['''`''']: 1 bit signed whole number values of 0 or -1 signed or 0 or 1 unsigned. [[_BIT]] * 8 can hold a signed or unsigned [[_BYTE|byte]] value. -* [[_BYTE]] ['''%%''']: 1 byte signed whole number values from -128 to 127. Unsigned values from 0 to 255. -* [[_INTEGER64]] ['''&&''']: 8 byte signed whole number values from -9223372036854775808 to 9223372036854775807 -* [[_FLOAT]] [##]: currently set as 10 byte signed floating decimal point values up to 1.1897E+4932. '''Cannot be unsigned.''' -* [[_OFFSET]] [%&]: undefined flexable length integer offset values used in [[DECLARE DYNAMIC LIBRARY]] declarations. - - -
'''Signed and Unsigned Integer Values'''
- -Negative (signed) numerical values can affect calculations when using any of the BASIC operators. SQR cannot use negative values! There may be times that a calculation error is made using those negative values. The SGN function returns the sign of a value as -1 for negative, 0 for zero and 1 for unsigned positive values. ABS always returns an unsigned value. - -::::* [[SGN]](n) returns the value's sign as -1 if negative, 0 if zero or 1 if positive. -::::* [[ABS]](n) changes negative values to the equivalent positive values. -::::* '''QB64:''' [[_UNSIGNED]] in a [[DIM]], [[AS]] or [[_DEFINE]] statement for only positive [[INTEGER]] values. - - -[[_UNSIGNED]] integer, byte and bit variable values can use the tilde ~ suffix before the type suffix to define the type. - - -
[[#toc|Return to Top]]
- -==Mathematical Operation Symbols== -Most of the BASIC math operators are ones that require no introduction. The addition, subtraction, multplication and division operators are ones commonly used as shown below: - -{| align="center" border=1 -! Symbol -! Procedure Type -! Example Usage -! Operation Order -|- -| align="center" |[[+]] || Addition || align="center" | c = a + b || align="center" | Last -|- -| align="center" |[[-]] || Subtraction || align="center" | c = a - b || align="center" | Last -|- -| align="center" |[[-]] || Negation || align="center" | c = - a || align="center" | Last -|- -| align="center" |[[*]] || Multiplication || align="center" | c = a * b || align="center" | Second -|- -| align="center" |[[/]] || Division || align="center" | c = a / b || align="center" | Second -|} - - -BASIC can also use two other operators for '''[[INTEGER]] division'''. Integer division returns only whole number values. [[MOD]] '''remainder division''' returns a value only if an integer division cannot divide a number exactly. Returns 0 if a value is exactly divisible. - - -{| align="center" border=1 -!Symbol -!Procedure Type -!Example Usage -!Operation Order -|- -| align="center" |[[\]] || Integer division || align="center" | c = a \ b || align="center" | Second -|- -| align="center" |[[MOD]] || Remainder division || align="center" | c = a MOD b || align="center" | Second -|} - - -
'''''It is an [[ERROR|error]] to divide by zero or to take the remainder modulo zero.'''''
- - -There is also an operator for '''exponential''' calculations. The exponential operator is used to raise a number's value to a designated exponent of itself. In QB the exponential return values are [[DOUBLE]] values. The [[SQR]] function can return a number's Square Root. For other '''exponential roots''' the operator can be used with fractions such as (1 / 3) designating the cube root of a number. - - -{| align="center" border=1 -!Symbol -!Procedure -!Example Usage -!Operation Order -|- -| align="center" |[[^]] || Exponent || align="center" | c = a [[^]] (1 / 2) || align="center" | First -|- -| align="center" | [[SQR]] || Square Root || align="center" | c = [[SQR]](a [[^]] 2 + b [[^]] 2) || align="center" | First -|} - - -===Notes=== -* Exponent fractions should be enclosed in () brackets in order to be treated as a root rather than as division. -* Negative exponential values must be enclosed in () brackets in QB64. - - -
[[#toc|Return to Top]]
- -==Basic's Order of Operations== - -When a normal calculation is made, BASIC works from left to right, but it does certain calculations in the following order: - - -:::# Exponential and exponential Root calculations including [[SQR]]. -:::# Negation (Note that this means that ''- 3 ^ 2'' is treated as ''-(3 ^ 2)'' and not as ''(-3) ^ 2.)'' -:::# Multiplication, normal Division, [[INTEGER]] Division and Remainder([[MOD]]) Division calculations -:::# Addition and Subtraction calculations - - -
'''Using Parenthesis to Define the Operation Order'''
- -Sometimes a calculation may need BASIC to do them in another order or the calculation will return bad results. BASIC allows the programmer to decide the order of operations by using [[parenthesis]] around parts of the equation. BASIC will do the calculations inside of the [[parenthesis]] brackets first and the others from left to right in the normal operation order. - -==Basic's Mathematical Functions== - -{| align=center border=1 - ! Function - ! Description - |- - | [[ABS]](n) || returns the absolute (positive) value of n: ABS(-5) = 5 - |- - | [[ATN]](angle*) || returns the arctangent of an angle in radians: π = 4 * ATN(1) - |- - | [[COS]](angle*) || returns the cosine of an angle in radians. (horizontal component) - |- - | [[EXP]](n) || returns ex, '''(n <= 88.02969)''': e = EXP(1) ' (e = 2.718281828459045) - |- - | [[LOG]](n) || returns the base e natural logarithm of n. '''(n > 0)''' - |- - | [[SGN]](n) || returns -1 if n < 0, 0 if n = 0, 1 if n > 0: SGN(-5) = -1 - |- - | [[SIN]](angle*) || returns the sine of an angle in radians. (vertical component) - |- - | [[SQR]](n) || returns the square root of a number. '''(n >= 0)''' - |- - | [[TAN]](angle*) || returns the tangent of an angle in radians - |} - -
'''* angles measured in radians'''
- - -{{TextStart}} '''Degree to Radian Conversion:''' -FUNCTION Radian (degrees) -Radian = degrees * (4 * {{Cb|ATN}}(1)) / 180 -END FUNCTION - -FUNCTION Degree (radians) -Degree = radians * 180 / (4 * {{Cb|ATN}}(1)) -END FUNCTION - - '''Logarithm to base n''' -FUNCTION LOGN (X, n) -IF n > 0 AND n <> 1 AND X > 0 THEN LOGN = {{Cb|LOG}}(X) / {{Cb|LOG}}(n) ELSE BEEP -END FUNCTION - -FUNCTION LOG10 (X) 'base 10 logarithm -IF X > 0 THEN LOG10 = {{Cb|LOG}}(X) / {{Cb|LOG}}(10) ELSE BEEP -END FUNCTION -{{TextEnd}} - - -
'''The numerical value of n in the [[LOG]](n) evaluation must be a positive value.'''
- -
'''The numerical value of n in the [[EXP]](n) evaluation must be less than or equal to 88.02969.'''
- -
'''The numerical value of n in the [[SQR]](n) evaluation ''cannot'' be a negative value.'''
- - -
[[#toc|Return to Top]]
- -==Derived Mathematical Functions== - - -The following Trigonometric functions can be derived from the '''BASIC Mathematical Functions''' listed above. Each function checks that certain values can be used without error or a [[BEEP]] will notify the user that a value could not be returned. An error handling routine can be substituted if desired. '''Note:''' Functions requiring '''Ï€''' use 4 * [[ATN]](1) for [[SINGLE]] accuracy. Use [[ATN]](1.#) for [[DOUBLE]] accuracy. - - -{{TextStart}} -FUNCTION SEC (x) 'Secant -IF COS(x) <> 0 THEN SEC = 1 / {{Cb|COS}}(x) ELSE BEEP -END FUNCTION - -FUNCTION CSC (x) 'CoSecant -IF SIN(x) <> 0 THEN CSC = 1 / {{Cb|SIN}}(x) ELSE BEEP -END FUNCTION - -FUNCTION COT (x) 'CoTangent -IF TAN(x) <> 0 THEN COT = 1 / {{Cb|TAN}}(x) ELSE BEEP -END FUNCTION - -FUNCTION ARCSIN (x) 'Inverse Sine -IF x < 1 THEN ARCSIN = {{Cb|ATN}}(x / {{Cb|SQR}}(1 - (x * x))) ELSE BEEP -END FUNCTION - -FUNCTION ARCCOS (x) ' Inverse Cosine -IF x < 1 THEN ARCCOS = (2 * ATN(1)) - {{Cb|ATN}}(x / {{Cb|SQR}}(1 - x * x)) ELSE BEEP -END FUNCTION - -FUNCTION ARCSEC (x) ' Inverse Secant -IF x < 1 THEN ARCSEC = {{Cb|ATN}}(x / {{Cb|SQR}}(1 - x * x)) + ({{Cb|SGN}}(x) - 1) * (2 * ATN(1)) ELSE BEEP -END FUNCTION - -FUNCTION ARCCSC (x) ' Inverse CoSecant -IF x < 1 THEN ARCCSC = ATN(1 / SQR(1 - x * x)) + (SGN(x)-1) * (2 * ATN(1)) ELSE BEEP -END FUNCTION - -FUNCTION ARCCOT (x) ' Inverse CoTangent -ARCCOT = (2 * {{Cb|ATN}}(1)) - {{Cb|ATN}}(x) -END FUNCTION - -FUNCTION SINH (x) ' Hyperbolic Sine -IF x <= 88.02969 THEN SINH = ({{Cb|EXP}}(x) - {{Cb|EXP}}(-x)) / 2 ELSE BEEP -END FUNCTION - -FUNCTION COSH (x) ' Hyperbolic CoSine -IF x <= 88.02969 THEN COSH = (EXP(x) + EXP(-x)) / 2 ELSE BEEP -END FUNCTION - -FUNCTION TANH (x) ' Hyperbolic Tangent or SINH(x) / COSH(x) -IF 2 * x <= 88.02969 AND EXP(2 * x) + 1 <> 0 THEN - TANH = ({{Cb|EXP}}(2 * x) - 1) / ({{Cb|EXP}}(2 * x) + 1) -ELSE BEEP -END IF -END FUNCTION - -FUNCTION SECH (x) ' Hyperbolic Secant or (COSH(x)) ^ -1 -IF x <= 88.02969 AND (EXP(x) + EXP(-x)) <> 0 THEN SECH = 2 / ({{Cb|EXP}}(x) + {{Cb|EXP}}(-x)) ELSE BEEP -END FUNCTION - -FUNCTION CSCH (x) ' Hyperbolic CoSecant or (SINH(x)) ^ -1 -IF x <= 88.02969 AND (EXP(x) - EXP(-x)) <> 0 THEN CSCH = 2 / ({{Cb|EXP}}(x) - {{Cb|EXP}}(-x)) ELSE BEEP -END FUNCTION - -FUNCTION COTH (x) ' Hyperbolic CoTangent or COSH(x) / SINH(x) -IF 2 * x <= 88.02969 AND EXP(2 * x) - 1 <> 0 THEN - COTH = ({{Cb|EXP}}(2 * x) + 1) / ({{Cb|EXP}}(2 * x) - 1) -ELSE BEEP -END IF -END FUNCTION - -FUNCTION ARCSINH (x) ' Inverse Hyperbolic Sine -IF (x * x) + 1 >= 0 AND x + SQR((x * x) + 1) > 0 THEN -ARCSINH = {{Cb|LOG}}(x + {{Cb|SQR}}(x * x + 1)) -ELSE BEEP -END IF -END FUNCTION - -FUNCTION ARCCOSH (x) ' Inverse Hyperbolic CoSine -IF x >= 1 AND x * x - 1 >= 0 AND x + SQR(x * x - 1) > 0 THEN -ARCCOSH = {{Cb|LOG}}(x + {{Cb|SQR}}(x * x - 1)) -ELSE BEEP -END IF -END FUNCTION - -FUNCTION ARCTANH (x) ' Inverse Hyperbolic Tangent -IF x < 1 THEN ARCTANH = {{Cb|LOG}}((1 + x) / (1 - x)) / 2 ELSE BEEP -END FUNCTION - -FUNCTION ARCSECH (x) ' Inverse Hyperbolic Secant -IF x > 0 AND x <= 1 THEN ARCSECH = {{Cb|LOG}}(({{Cb|SGN}}(x) * {{Cb|SQR}}(1 - x * x) + 1) / x) ELSE BEEP -END FUNCTION - -FUNCTION ARCCSCH (x) ' Inverse Hyperbolic CoSecant -IF x <> 0 AND x * x + 1 >= 0 AND (SGN(x) * SQR(x * x + 1) + 1) / x > 0 THEN - ARCCSCH = {{Cb|LOG}}(({{Cb|SGN}}(x) * {{Cb|SQR}}(x * x + 1) + 1) / x) -ELSE BEEP -END IF -END FUNCTION - -FUNCTION ARCCOTH (x) ' Inverse Hyperbolic CoTangent -IF x > 1 THEN ARCCOTH = {{Cb|LOG}}((x + 1) / (x - 1)) / 2 ELSE BEEP -END FUNCTION -{{TextEnd}} -{{WhiteStart}} - '''Hyperbolic Function Relationships:''' - - COSH(-x) = COSH(x) - SINH(-x) = -SINH(x) - - SECH(-x) = SECH(x) - CSCH(-x) = -CSCH(x) - TANH(-x) = -TANH(x) - COTH(-x) = -COTH(x) - - '''Inverse Hyperbolic Function Relatonships:''' - - ARSECH(x) = ARCOSH(x) ^ -1 - ARCSCH(x) = ARSINH(x) ^ -1 - ARCOTH(x) = ARTANH(x) ^ -1 - - '''Hyperbolic sine and cosine satisfy the Pythagorean trig. identity:''' - - (COSH(x) ^ 2) - (SINH(x) ^ 2) = 1 - -{{WhiteEnd}} - -
[http://support.microsoft.com/kb/28249 Microsoft's Derived BASIC Functions (KB 28249)]
- - -
[[#toc|Return to Top]]
- -==Mathematical Logical Operators== - -The following logical operators compare numerical values using bitwise operations. The two numbers are compared by the number's [[Binary]] bits on and the result of the operation determines the value returned in decimal form. [[NOT]] checks one value and returns the opposite. It returns 0 if a value is not 0 and -1 if it is 0. See [[Binary]] for more on bitwise operations. - - -
'''Truth table of the 6 BASIC Logical Operators'''
- - -{{LogicalTruthTable}} - -
BASIC can accept any + or - value that is not 0 to be True when used in an evaluation.
- - -
[[#toc|Return to Top]]
- -==Relational Operators== -Relational Operations are used to compare values in a Conditional [[IF...THEN]], [[SELECT CASE]], [[UNTIL]] or [[WHILE]] statement. - - -{{RelationalTable}} - - -
[[#toc|Return to Top]]
- -==Basic's Rounding Functions== - -: Rounding is used when the program needs a certain number value or type. There are 4 [[INTEGER]] or [[LONG]] Integer functions and one function each for closest [[SINGLE]] and closest [[DOUBLE]] numerical types. Closest functions use "bankers" rounding which rounds up if the decimal point value is over one half. Variable types should match the return value. - -{| align=center border=1 -! Name -! Description -|- - -|[[INT]](n) || rounds down to lower Integer value whether positive or negative -|- -|[[FIX]](n) || rounds positive values lower and negative to a less negative Integer value -|- -|[[CINT]](n) ||rounds to closest Integer. Rounds up for decimal point values over one half. -|- -| [[CLNG]](n) || rounds Integer or Long values to closest value like CINT.(values over 32767) -|- -| [[CSNG]](n) || rounds Single values to closest last decimal point value. -|- -| [[CDBL]](n) || rounds Double values to closest last decimal point value. -|- -| [[_ROUND]] || rounds to closest numerical integer value in '''QB64''' only. -|} - -===Note=== -* Each of the above functions define the value's type in addition to rounding the values. - -
[[#toc|Return to Top]]
- -==Base Number Systems== - - -{{TextStart}} - '''Comparing the [[INTEGER]] Base Number Systems''' - - '''Decimal (base 10) Binary (base 2) Hexadecimal (base 16) Octal (base 8)''' - - ''' [[&B]] [[&H]] [[HEX$]](n) [[&O]] [[OCT$]](n)''' - - 0 0000 0 0 - 1 0001 1 1 - 2 0010 2 2 - 3 0011 3 3 - 4 0100 4 4 - 5 0101 5 5 - 6 0110 6 6 - 7 0111 7 7 -- maxed - 8 1000 8 10 - maxed-- 9 1001 9 11 - 10 1010 A 12 - 11 1011 B 13 - 12 1100 C 14 - 13 1101 D 15 - 14 1110 E 16 - 15 ------------- 1111 <--- Match ---> F ---------------- 17 -- max 2 - 16 10000 10 20 - - When the Decimal value is 15, the other 2 base systems are all maxed out! - The Binary values can be compared to all of the HEX value digit values so - it is possible to convert between the two quite easily. To convert a HEX - value to Binary just add the 4 binary digits for each HEX digit place so: - - F A C E - &HFACE = 1111 + 1010 + 1100 + 1101 = &B1111101011001101 - - To convert a Binary value to HEX you just need to divide the number into - sections of four digits starting from the right(LSB) end. If one has less - than 4 digits on the left end you could add the leading zeros like below: - - &B101011100010001001 = 0010 1011 1000 1000 1001 - hexadecimal = 2 + B + 8 + 8 + 9 = &H2B889 - - See the Decimal to Binary conversion function that uses '''[[HEX$]]''' on the '''[[&H]]''' page. - -{{TextEnd}} - - -
'''[[VAL]] converts [[STRING|string]] numbers to Decimal values.'''
- -* VAL reads the string from left to right and converts numerical string values, - and . to decimal values until it finds a character other than those 3 characters. Commas are not read. -* HEXadecimal and OCTal base values can be read with [[&H]] or [[&O]]. - - -
'''The [[OCT$]] [[STRING|string]] function return can be converted to a decimal value using [[VAL]]("&O" + OCT$(n)).'''
- -
'''The [[HEX$]] [[STRING|string]] function return can be converted to a decimal value using [[VAL]]("&H" + HEX$(n)).'''
- - -:[[STR$]] converts numerical values to string characters for [[PRINT]] or variable strings. It also removes the right number PRINT space. - - - -
[[#toc|Return to Top]]
- -==Bits and Bytes== - -
'''[[_BIT|BITS]]'''
-* The '''MSB''' is the most significant(largest) bit value and '''LSB''' is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte: - -:* '''"Big-endian"''': MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time. -:* '''"Little-endian"''': LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time. -{{WhiteStart}} - '''Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000''' - ---------------------------------- -------- - '''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240 - '''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15 -{{WhiteEnd}} -::The big-endian method compares exponents of 27 down to 20 while the little-endian method does the opposite. - -
'''[[_BYTE|BYTES]]'''
-* [[INTEGER]] values consist of 2 bytes called the '''HI''' and '''LO''' bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative, even with [[SINGLE]] or [[DOUBLE]] values. -{{WhiteStart}} '''16 BIT INTEGER OR REGISTER''' - '''AH (High Byte Bits) AL (Low Byte Bits)''' - BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0 - ---------------------------------------|-------------------------------------- - HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1 - | - DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1 -{{WhiteEnd}} -::The HI byte's '''MSB''' is often called the '''sign''' bit! When the highest bit is on, the signed value returned will be negative. - - -''Example:'' Program displays the bits on for any integer value between -32768 and 32767 or &H80000 and &H7FFF. -{{CodeStart}} -{{Cl|DEFINT}} A-Z -{{Cl|SCREEN (statement)|SCREEN}} 12 -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 2 - {{Cl|PRINT}} " AH (High Register Byte Bits) AL (Low Register Byte Bits)" -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 11, 2 - {{Cl|PRINT}} " 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0" -{{Cl|COLOR}} 13: {{Cl|LOCATE}} 14, 2 - {{Cl|PRINT}} " {{Cl|&H}}8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 {{Cl|&H}}1" -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 15, 2 - {{Cl|PRINT}} "-32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1" -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 16 - {{Cl|CIRCLE}} (640 - (37 * i), 189), 8, 9 'place bit circles -{{Cl|NEXT}} -{{Cl|LINE}} (324, 160)-(326, 207), 11, BF 'line splits bytes -{{Cl|DO}} - {{Cl|IF}} Num {{Cl|THEN}} - {{Cl|FOR...NEXT|FOR}} i = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 - {{Cl|IF}} (Num {{Cl|AND}} 2 ^ i) {{Cl|THEN}} - {{Cl|PAINT}} (640 - (37 * (i + 1)), 189), 12, 9 - Bin$ = Bin$ + "1" - {{Cl|ELSE}} - {{Cl|PAINT}} (640 - (37 * (i + 1)), 189), 0, 9 - Bin$ = Bin$ + "0" - {{Cl|END IF}} - {{Cl|NEXT}} - {{Cl|COLOR}} 10: {{Cl|LOCATE}} 16, 50: {{Cl|PRINT}} "Binary ="; {{Cl|VAL}}(Bin$) - {{Cl|COLOR}} 9: {{Cl|LOCATE}} 16, 10: {{Cl|PRINT}} "Decimal ="; Num;: {{Cl|COLOR}} 13: {{Cl|PRINT}} " Hex = "; Hexa$ - Hexa$ = "": Bin$ = "" - {{Cl|END IF}} - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 17, 15: {{Cl|INPUT}} "Enter a decimal or HEX({{Cl|&H}}) value (0 Quits): ", frst$ - first = {{Cl|VAL}}(frst$) - {{Cl|IF}} first {{Cl|THEN}} - {{Cl|LOCATE}} 17, 15: {{Cl|PRINT}} {{Cl|SPACE$}}(55) - {{Cl|COLOR}} 13: {{Cl|LOCATE}} 17, 15: {{Cl|INPUT}} "Enter a second value: ", secnd$ - second = {{Cl|VAL}}(secnd$) - {{Cl|LOCATE}} 17, 10: {{Cl|PRINT}} {{Cl|SPACE$}}(69) - {{Cl|END IF}} - Num = first + second - Hexa$ = "{{Cl|&H}}" + {{Cl|HEX$}}(Num) -{{Cl|LOOP}} {{Cl|UNTIL}} first = 0 {{Cl|OR (boolean)|OR}} Num > 32767 {{Cl|OR (boolean)|OR}} Num < -32767 -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 28, 30: {{Cl|PRINT}} "Press any key to exit!"; -{{Cl|SLEEP}} -{{Cl|SYSTEM}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} - - -
[[#toc|Return to Top]]
- -==OFFSET== - -* [[_OFFSET (function)]] returns the memory offset position as a flexible sized value for a designated variable. See [[Using _OFFSET]]. - - -
'''Warning: [[_OFFSET]] values cannot be reassigned to other variable [[TYPE|types]].'''
- - -
'''[[_OFFSET]] values can only be used in conjunction with [[_MEM]]ory and [[DECLARE DYNAMIC LIBRARY]] procedures.'''
- -==References== -''See also:'' -* [[_OFFSET]], [[_MEM]] -* [[DIM]], [[_DEFINE]] -* [[TYPE]] - -{{PageNavigation}} diff --git a/internal/help/NAME_1111.txt b/internal/help/NAME_1111.txt deleted file mode 100644 index c8edbbd89..000000000 --- a/internal/help/NAME_1111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:33}} -The [[NAME]] statement changes the name of a file or directory to a new name. - - - -{{PageSyntax}} -: [[NAME]] {{Parameter|oldFileOrFolderName$}} '''AS''' {{Parameter|newFileOrFolderName$}} - - -{{PageDescription}} -* {{Parameter|oldFileOrFolderName$}} and {{Parameter|newFileOrFolderName$}} are variables or literal [[STRING]]s in quotes. Paths can be included. -* If the two paths are different, the statement moves the original file to the new path and renames it. -* If the path is the same or a path is not included, the original file is just renamed. -* [[SHELL]] can use ''"REN " + filename$ + " " + newname$'' for the same purpose (Windows). -* Path or filename [[ERROR Codes|errors]] are possible and should be handled in the program. -* '''Caution: There is no prompt to continue or execution verification.''' - - -{{PageExamples}} -{{CodeStart}} - {{Cl|NAME}} "BIGBAD.TXT" {{Cl|AS}} "BADWOLF.TXT" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[SHELL]], [[MKDIR]], [[FILES]] -* [[CHDIR]], [[KILL]], [[RMDIR]] -* [[Windows_Libraries#File_Dialog_Boxes|Windows Open and Save Dialog Boxes]] - - -{{PageNavigation}} diff --git a/internal/help/NEXT_1111.txt b/internal/help/NEXT_1111.txt deleted file mode 100644 index df3a376a3..000000000 --- a/internal/help/NEXT_1111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:34}} -[[NEXT]] is used in a [[FOR...NEXT|FOR]] counter loop to progress through the loop count. - - -{{PageSyntax}} -: [[FOR]] {{Parameter|counterVariable}} = {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} [{{KW|STEP}} {{Parameter|increment}}] -:: ''{code}'' -:: ⋮ -: [[NEXT]] [{{Parameter|counterVariable}}] - - -{{PageDescription}} -* [[NEXT]] is required in a FOR loop or a [[ERROR Codes|"FOR without NEXT" error]] will occur. -* The FOR variable name is not required after [[NEXT]]. -* [[NEXT]] can be grouped with other NEXTs in nested FOR loops using colons like [[NEXT]]: [[NEXT]] -* [[NEXT]] can also end more than one nested [[FOR...NEXT|FOR]] loop using comma separated variables like [[NEXT]] j, i -* [[NEXT]] increases the FOR loop count, so after the loop is over the counterVariable's value will be stopValue + 1 (or stopValue + increment). -* [[NEXT]] is also used with the [[RESUME]] statement. - - -{{PageExamples}} -''Example:'' Finding the FOR variable value AFTER a simple counter loop to 10. -{{CodeStart}} -FOR i = 1 TO 10 -PRINT i; -NEXT i - -PRINT "AFTER the LOOP, NEXT makes the value of i ="; i -{{CodeEnd}} -{{OutputStart}} -1 2 3 4 5 6 7 8 9 10 AFTER the LOOP, NEXT makes the value of i = 11 -{{OutputEnd}} -''Result:'' The last value of i = 11 although FOR only looped 10 times. '''Only use the count values while inside of the loop or compensate for this behavior in your code.''' - - -{{PageSeeAlso}} -* [[FOR...NEXT]] -* [[DO...LOOP]] -* [[RESUME|RESUME NEXT]] - - -{{PageNavigation}} diff --git a/internal/help/NOT_111.txt b/internal/help/NOT_111.txt deleted file mode 100644 index 3a3ca78e8..000000000 --- a/internal/help/NOT_111.txt +++ /dev/null @@ -1,84 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:35}} -[[NOT]] is a [[Boolean|boolean]] logical operator that will change a false statement to a true one and vice-versa. - - -{{PageSyntax}} -: ''True'' = -1: ''False'' = [[NOT]] True - - -{{PageDescription}} -* In QBasic, True = -1 and False = 0 in boolean logic and evaluation statements. -* [[NOT]] evaluates a value and returns the bitwise opposite, meaning that {{InlineCode}}NOT 0 = -1{{InlineCodeEnd}}. -* Often called a negative logic operator, it returns the opposite of a value as true or false. -* Values are changed by their bit values so that each bit is changed to the opposite of on or off. See example 3 below. - - -{{RelationalTable}} - - -{{LogicalTruthTable}} - - -{{PageExamples}} -''Example 1:'' Alternating between two conditions in a program loop. -{{CodeStart}}{{Cl|DO}} -switch = {{Cl|NOT}} switch '{{Cl|NOT}} changes value from -1 to 0 and vice-versa -{{Cl|LOCATE}} 10, 38 -{{Cl|IF}} switch {{Cl|THEN}} {{Cl|PRINT}} "True!" {{Cl|ELSE}} {{Cl|PRINT}} "False" -{{Cl|SLEEP}} -k$ = {{Cl|INKEY$}} -{{Cl|LOOP}} {{Cl|UNTIL}} k$ = {{Cl|CHR$}}(27) ' escape key quit -{{CodeEnd}} - - -''Example 2:'' Reading a file until it reaches the End Of File. -{{CodeStart}}DO WHILE NOT EOF(1) - INPUT #1, data1, data2, data3 -LOOP -{{CodeEnd}} -:''Explanation:'' [[EOF]] will return 0 until a file ends. NOT converts 0 to -1 so that the loop continues to run. When EOF becomes -1, NOT converts it to 0 to end the loop. - - -''Example 3:'' So why does '''NOT 5 = -6'''? Because NOT changes every bit of a value into the opposite: -{{CodeStart}}{{Cl|PRINT}} {{Cl|NOT}} 5 -{{Cl|PRINT}} -ReadBits 5 -ReadBits -6 - -{{Cl|SUB}} ReadBits (n {{Cl|AS}} {{Cl|INTEGER}}) 'change type value and i bit reads for other whole type values -{{Cl|FOR...NEXT|FOR}} i = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 'see the 16 bit values - {{Cl|IF...THEN|IF}} n {{Cl|AND (boolean)|AND}} 2 ^ i {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0"; -{{Cl|NEXT}} -{{Cl|PRINT}} -{{Cl|END SUB}} -{{CodeEnd}} -{{OutputStart}}-6 - -0000000000000101 -1111111111111010 -{{OutputEnd}} -:''Explanation:'' The bit values of an [[INTEGER]] are 2 [[_BYTE]]s and each bit is an exponent of 2 from 15 to 0 (16 bits). Thus comparing the numerical value with those exponents using [[AND]] reveals the bit values as "1" for bits on or "0" for bits off as text. - -: QB64 can use [[&B]] to convert the above [[_BIT]] values back to [[INTEGER]] or [[_BYTE]] values as shown below: -{{CodeStart}}'16 bit INTEGER values from -32768 to 32767 -a% = {{Cl|&B}}0000000000000101 -{{Cl|PRINT}} a% -b% = {{Cl|&B}}1111111111111010 -{{Cl|PRINT}} b% -'8 bit BYTE values from -128 to 127 -a%% = {{Cl|&B}}00000101 -{{Cl|PRINT}} a%% -b%% = {{Cl|&B}}11111010 -{{Cl|PRINT}} b%% -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_BIT]], [[&B]], [[_BYTE]] -* [[AND]], [[XOR]], [[OR]] -* [[Binary]], [[Boolean]] -* [[Mathematical Operations]] - - -{{PageNavigation}} diff --git a/internal/help/Not_Equal_100_10000.txt b/internal/help/Not_Equal_100_10000.txt deleted file mode 100644 index b2d3c4ae3..000000000 --- a/internal/help/Not_Equal_100_10000.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:12}} -The '''<>''' condition symbol denotes that a value must not equal another value for the condition to be True. - - -''Example usage:'' IF x [[Not_Equal|<>]] 320 THEN PRINT "Not in center of screen" - - -* Statements will evaluate as True or -1 when two values are not equal or False or 0 when equal. -* More than one <> symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical pairs. - - -''See also:'' - -* [[Equal|=]] -* [[Greater_Than|>]] -* [[Less_Than|<]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/OCT$_111$.txt b/internal/help/OCT$_111$.txt deleted file mode 100644 index 18b4cbdb9..000000000 --- a/internal/help/OCT$_111$.txt +++ /dev/null @@ -1,78 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:36}} -This function returns the octal (base 8) representation of any numeric value. - - -{{PageSyntax}} -: {{Parameter|octvalue$}} = [[OCT$]]({{Parameter|number}}) - - -{{PageParameters}} -* {{Parameter|number}} can be any [[INTEGER]], [[LONG]] or [[_INTEGER64]] value, positive or negative. -* {{Parameter|number}} can also be any [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] value, but only the integer part of the value is converted in that case. That is, from the value ''-123.45'' the function would convert the ''-123'' only. - - -{{PageDescription}} -* The function returns the base 8 (octal) representation of the given {{Parameter|number}} as [[STRING]]. -* Different from [[STR$]], this function does not return a leading sign placeholder space, so no [[LTRIM$]] to strip that space from positive numbers is necessary. -* [[VAL]] can convert the returned oct string value back to a decimal value by prefixing the string with "[[&O]]". -** Eg. {{InlineCode}}decimal = {{Cl|VAL}}("&O" + octvalue$){{InlineCodeEnd}}. - - -{{PageExamples}} -;Example 1:Comparing decimal, hexadecimal, octal and binary string values from 0 to 15. -{{CodeStart}} -tabletop$ = " Decimal | Hexadecimal | Octal | Binary " -tablesep$ = "---------+-------------+-------+--------" -tableout$ = " \ \ | \\ | \\ | \ \ " 'the PRINT USING template - -{{Cl|LOCATE}} 2, 10: {{Cl|PRINT}} tabletop$ -{{Cl|LOCATE}} 3, 10: {{Cl|PRINT}} tablesep$ -{{Cl|FOR...NEXT|FOR}} n% = 0 {{Cl|TO}} 15 - {{Cl|LOCATE}} 4 + n%, 10: {{Cl|PRINT USING}} tableout$; {{Cl|STR$}}(n%); {{Cl|HEX$}}(n%); {{Cl|OCT$}}(n%); {{Cl|_BIN$}}(n%) -{{Cl|NEXT}} n% -{{CodeEnd}} -;Note:Although the decimal numbers 0-15 have a maximum width of 2 digits only, an extra space in the ''tableout$'' template is needed when using the (fixed width string) slash output format, as [[STR$]] values contain a leading sign placeholder space. -{{OutputStart}} - Decimal | Hexadecimal | Octal | Binary - ---------+-------------+-------+-------- - 0 | 0 | 0 | 0 - 1 | 1 | 1 | 1 - 2 | 2 | 2 | 10 - 3 | 3 | 3 | 11 - 4 | 4 | 4 | 100 - 5 | 5 | 5 | 101 - 6 | 6 | 6 | 110 - 7 | 7 | 7 | 111 - 8 | 8 | 10 | 1000 - 9 | 9 | 11 | 1001 - 10 | A | 12 | 1010 - 11 | B | 13 | 1011 - 12 | C | 14 | 1100 - 13 | D | 15 | 1101 - 14 | E | 16 | 1110 - 15 | F | 17 | 1111 -{{OutputEnd}} - - -;Example 2:Converting a octal value to decimal. -{{CodeStart}} -octvalue$ = {{Cl|OCT$}}(255) -{{Cl|PRINT}} "Oct: "; octvalue$ -{{Cl|PRINT}} "Converting Oct value to Decimal:"; {{Cl|VAL}}("&O" + octvalue$) -{{CodeEnd}} -{{OutputStart}} -Oct: 377 -Converting Oct value to Decimal: 255 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_BIN$]], [[HEX$]], [[STR$]] -* [[&B]] (binary), [[&H]] (hexadecimal), [[&O]] (octal), [[VAL]] -* [[Base Comparisons]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/OFF_111.txt b/internal/help/OFF_111.txt deleted file mode 100644 index 7cdecfcce..000000000 --- a/internal/help/OFF_111.txt +++ /dev/null @@ -1,16 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:37}} -[[OFF]] is a flag that disables event-trappping for [[KEY(n)]], [[ON COM (n)|COM(n)]], [[PEN]], [[PLAY]], [[STRIG(n)]], [[TIMER]], [[UEVENT]]. - - -{{PageDescription}} -* [[OFF]] can be used to turn off the display of soft-key assignments at the bottom of the screen using [[KEY]]. -* [[OFF]] can also be used to disable an event-trapping in the following statements: [[KEY(n)]], [[ON COM (n)|COM(n)]], [[PEN]], [[PLAY]], [[STRIG(n)]], [[TIMER]], [[UEVENT]]. The trap can be turned back [[ON]], but all events triggered since [[OFF]] was used are lost. -* [[$CHECKING]]:'''OFF''' is used to disable C++ error trapping (used for verified sections of code that require speed). - - -{{PageSeeAlso}} -* [[ON]], [[STOP]], [[KEY]], [[KEY(n)]], [[$CHECKING]] - - -{{PageNavigation}} diff --git a/internal/help/ON...GOSUB_11...11111.txt b/internal/help/ON...GOSUB_11...11111.txt deleted file mode 100644 index 67e43cbfa..000000000 --- a/internal/help/ON...GOSUB_11...11111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:47}} -[[ON...GOSUB]] is a control-flow statement that branches to a line or label in a list depending on a numerical expression. - - -{{PageSyntax}} -: '''ON''' {{Parameter|numericalExpression}} [[GOSUB]] {{Parameter|labelOrNumber}}[,{{Parameter|labelOrNumber}}][,...] - - -{{PageDescription}} -* {{Parameter|numericalExpression}} represents the ''line'' or ''label'' that the program should branch to: 1 branches to the first line or label in the list, 2 branches to the second, etc. -* The procedure must be used after the number value is determined or in a loop to monitor current user events. -* [[RETURN]] returns to the next code statement after the [[ON...GOSUB]] statement. [[END]] or [[SYSTEM]] can be used to end program. -* '''Note:''' [[SELECT CASE]] provides a much more convenient way of doing this task. - - -==QBasic/QuickBASIC== -* In QuickBASIC 4.5 the list could contain a maximum of 60 line numbers or labels, while '''QB64''' has no limit. - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|CLS}} -a = 2 -''ON'' a '''GOSUB''' hello, hereweare, 143 -{{Cl|PRINT}} "Also notice the RETURN statement that can be used with GOSUB!" -{{Cl|END}} - -hello: -{{Cl|PRINT}} "Hello, with a = 1 you get to see this!" -{{Cl|END}} - -hereweare: -{{Cl|PRINT}} "with a = 2 here we are...return to line after ON." -{{Cl|RETURN}} - -143 -{{Cl|PRINT}} "Line 143, with a = 3 you get to see this!" -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} -with a = 2 here we are...return to line after ON. -Also notice the RETURN statement that can be used with GOSUB! -{{OutputEnd}} - -:''Explanation:'' Since ''a'' equals to 2 it goes to the second item in the list (''hereweare'') and branches the program to there. Try changing 'a' to 1 or 3. - - -{{PageSeeAlso}} -* [[ON...GOTO]] -* [[GOSUB]], [[GOTO]] -* [[SELECT CASE]], [[RETURN]] - - -{{PageNavigation}} diff --git a/internal/help/ON...GOTO_11...1111.txt b/internal/help/ON...GOTO_11...1111.txt deleted file mode 100644 index f2269a0aa..000000000 --- a/internal/help/ON...GOTO_11...1111.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:48}} -[[ON...GOTO]] is a control-flow statement that branches to a line or label in a list depending on a numerical expression. - - -{{PageSyntax}} -: '''ON''' {{Parameter|numericalExpression}} [[GOTO]] {{Parameter|labelOrNumber}}[,{{Parameter|labelOrNumber}}][,...] - - -{{PageDescription}} -* {{Parameter|numericalExpression}} represents the ''line'' or ''label'' that the program should branch to: 1 branches to the first line or label in the list, 2 branches to the second, etc. -* The procedure must be used after the number value is determined or in a loop to monitor current user events. -* '''Note:''' [[SELECT CASE]] provides a much more convenient way of doing this task. - - -==QBasic/QuickBASIC== -* In QuickBASIC 4.5 the list could contain a maximum of 60 line numbers or labels, while '''QB64''' has no limit. - - -{{PageExamples}} -''Example:'' Changing the program flow when a value is not 0. -{{CodeStart}} -{{Cl|CLS}} -a = 2 -{{Cl|ON...GOTO|ON a GOTO}} hello, hereweare, 143 -{{Cl|END}} -hello: -{{Cl|PRINT}} "you don't get to see this!" -{{Cl|END}} -hereweare: -PRINT "And here we are..." -END -143 -PRINT "you don't get to see this neither..." -END -{{CodeEnd}} -{{OutputStart}} -And here we are... -{{OutputEnd}} - -''Explanation:'' Since ''a'' equals 2 it goes to the second item in the list (hereweare) and branches to there. Try changing ''a' to 1 or 3. - - -{{PageSeeAlso}} -* [[ON...GOSUB]] -* [[GOTO]] -* [[GOSUB]] -* [[SELECT CASE]] - - -{{PageNavigation}} diff --git a/internal/help/ON_ERROR_11_11111.txt b/internal/help/ON_ERROR_11_11111.txt deleted file mode 100644 index d4cef0ddc..000000000 --- a/internal/help/ON_ERROR_11_11111.txt +++ /dev/null @@ -1,72 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:39}} -[[ON ERROR]] is used with [[GOTO]] to handle errors in a program. - - -{{PageSyntax}} -: [[ON ERROR]] [[GOTO]] {''lineNumber''|''lineLabel''} - - -{{PageDescription}} -* An ''untreated error'' in a program will cause execution to stop and an error message is displayed to the user, who can choose to continue (ignore the error - which could have unexpected results) or end the program. -* Use [[ON ERROR]] when your program performs operations that are likely to generate errors, like file access operations. -* [[ON ERROR]] statements can be in the main module code or in [[SUB]] or [[FUNCTION]] procedures. -* [[ON ERROR]] statements take precedence in the order they are encountered. It will also handle any subroutine errors. -* '''ON ERROR GOTO 0''' can be used to disable custom [[ON ERROR]] trapping and give default error messages. -* A subsequent ON ERROR statement will override the previous one. -* [[GOTO]] is required in the statement. Cannot use [[GOSUB]]. -* Comment out [[ON ERROR]] to find specific error locations. QB64 can return the file line position with [[_ERRORLINE]] -* Note: QB64 does not support the PDS (QuickBASIC 7) '''ON ERROR RESUME NEXT''' statement. - - -{{PageExamples}} -''Example 1:'' Using an error handler that ignores any error. - -{{CodeStart}} - {{Cl|ON ERROR}} {{Cl|GOTO}} Errhandler - ' Main module program error simulation code - {{Cl|ERROR}} 7 ' simulate an Out of Memory Error - PRINT "Error handled...ending program" - {{Cl|SLEEP}} 4 - {{Cl|SYSTEM}} ' end of program code - - Errhandler: 'error handler sub program line label - PRINT "Error"; {{Cl|ERR}}; "on program file line"; {{Cl|_ERRORLINE}} - {{Cl|BEEP}} ' warning beep - {{Cl|RESUME}} NEXT ' moves program to code following the error. -{{CodeEnd}} -{{OutputStart}} -Error 7 on program file line 3 -Error handled...ending program -{{OutputEnd}} -:''Explanation:'' The ON ERROR statement is normally placed at the beginning of the main module code. Errhandle is the line label sub referred to in the statement. The handler prints the error code and attempts to use the next line of code using [[RESUME]] NEXT which is only used in error handling procedures. [[_ERRORLINE]] returns the program file's actual text line count found in the IDE. - - -''Example 2:'' Using an error handler in a [[SUB]] procedure. -{{CodeStart}} -s -{{Cl|END}} - -hand: -{{Cl|PRINT}} "got error!" -{{Cl|RESUME}} {{Cl|NEXT}} - -{{Cl|SUB}} s -{{Cl|ON ERROR}} {{Cl|GOTO}} hand -{{Cl|ERROR}} 1 -{{Cl|ON ERROR}} {{Cl|GOTO}} 0 -{{Cl|PRINT}} "Done!" -{{Cl|END SUB}} -{{CodeEnd}} -: ''Explanation:'' The [[GOTO]] procedure must be in the main code area after [[END]] to avoid a [[RESUME]] error later. Use GOTO 0 to clear the ON ERROR set in the sub so that later errors are not handled by it. - - -{{PageSeeAlso}} -* [[ERR]], [[ERL]], [[RESUME]] -* [[ON...GOTO]] -* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]] -* [[ERROR]] {{text|(simulates an error)}} -* [[ERROR Codes]] - - -{{PageNavigation}} diff --git a/internal/help/ON_KEY(n)_11_111(0).txt b/internal/help/ON_KEY(n)_11_111(0).txt deleted file mode 100644 index 6b1e2b404..000000000 --- a/internal/help/ON_KEY(n)_11_111(0).txt +++ /dev/null @@ -1,64 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:41}} -The [[ON KEY(n)]] statement defines a line number or label to go to (or a [[SUB]] to run) when a specified key is pressed. - - -{{PageSyntax}} -: [[ON KEY(n)]] [[GOSUB]] {{Parameter|linelabel}}|{{Parameter|linenumber}} -: [[ON KEY(n)]] [[SUB]]procedure - - -{{PageDescription}} -* Predefined and user defined KEY event number assignments to use with ON KEY(n): -{{WhiteStart}} '''1 to 10'''.............Reserved '''F1 to F10''' function keys only. - '''11, 12, 13 and 14'''...Reserved '''Up, Left, Right and Down''' numeric keypad arrows only - '''15 to 29'''............'''user-defined keys''' using value: [[CHR$]](keyflag) + [[CHR$]]([[Keyboard scancodes|scancode]]) - '''30 and 31'''...........Reserved '''F11 and F12''' function keys only. -{{WhiteEnd}} -* See the [[KEY n]] page for user defined key or key combination presses and F function softkey assignments. -* [[GOSUB]] with a {{Parameter|linelabel}} or {{Parameter|linenumber}} or a [[SUB]] procedure (without the [[CALL]] keyword) can be triggered in '''QB64'''. - - -{{PageExamples}} -''Example 1:'' Using ON KEY with [[GOSUB]] to execute code. -{{CodeStart}} -{{Cl|KEY(n)|KEY(1) ON}} -{{Cl|ON KEY(n)|ON KEY}}(1) {{Cl|GOSUB}} trap -{{Cl|PRINT}} "Press F1 to quit!" -{{Cl|DO}}:{{Cl|LOOP}} 'never ending loop - -trap: -{{Cl|PRINT}} "You pressed F1 like I told you to :)" -{{Cl|END}} -{{Cl|RETURN}} -{{CodeEnd}} - - -''Example 2:'' Setting multiple ON KEY statements to send different values to a [[SUB]] procedure. -{{CodeStart}} - -{{Cl|FOR...NEXT|FOR}} n = 1 {{Cl|TO}} 10 - {{Cl|KEY n|KEY}} n, {{Cl|STR$}}(n) ' assigns soft key as a numerical string - {{Cl|ON KEY(n)|ON KEY}}(n) Funct n 'designate SUB procedure and parameter value passed - {{Cl|KEY(n)|KEY}}(n) ON ' turns each key event monitor on -{{Cl|NEXT}} -{{Cl|KEY n|KEY}} ON 'displays F1 to F10 soft key assignments at bottom of screen - -{{Cl|DO}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|END}} - -{{Cl|SUB}} Funct (num%) -{{Cl|CLS}}' clears the screen and refreshes bottom soft key list -{{Cl|PRINT}} "You pressed F"; {{Cl|LTRIM$}}({{Cl|STR$}}(num%)) -{{Cl|END SUB}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[KEY(n)]], [[KEY n]] {{text|(soft key)}} -* [[ON...GOSUB]], [[Scancodes]] -* [[_KEYHIT]], [[_KEYDOWN]] - - -{{PageNavigation}} diff --git a/internal/help/ON_STRIG(n)_11_11111(0).txt b/internal/help/ON_STRIG(n)_11_11111(0).txt deleted file mode 100644 index 8322de60b..000000000 --- a/internal/help/ON_STRIG(n)_11_11111(0).txt +++ /dev/null @@ -1,75 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:44}} -The [[ON STRIG(n)]] statement is an event procedure that directs program flow upon the press of a specified joystick button. - - -{{PageSyntax}} -: '''ON STRIG'''({{Parameter|buttonFunction}}) [[GOSUB]] {{{Parameter|lineNumber}}|{{Parameter|lineLabel}}} - -: '''ON STRIG'''({{Parameter|buttonFunction}}[, {{Parameter|joystickNumber}}]) {[[GOSUB]] {{{Parameter|lineNumber}}|{{Parameter|lineLabel}}} | [[SUB]]procedure} - - -* In '''QB64''' the value can be any button function number with any number of joysticks. See [[STRIG]] and [[STICK]] for parameters. -* There are two {{Parameter|buttonFunction}} for each button. The even numbered function is always the event of any press since last read. -* The statement sends the procedure to a line number, line label or [[SUB]] procedure when a button event occurs. - - -==QBasic/QuickBASIC== -* In QBasic, value of ''n'' could only be a number from 0 to 3 only as it could only monitor 2 joystick buttons and 2 joysticks. - - -{{PageExamples}} -''Example 1:'' Reading a STRIG event to do something in a [[GOSUB]] procedure. -{{CodeStart}} -{{Cl|ON STRIG(n)|ON STRIG}}(0) {{Cl|GOSUB}} 10 -{{Cl|STRIG(n)|STRIG}}(0)ON - -{{Cl|DO...LOOP|DO}} - {{Cl|PRINT}} "."; - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -10 -a$ = "[STRIG 0 EVENT]" -{{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} {{Cl|LEN}}(a$) - {{Cl|PRINT}} {{Cl|MID$}}(a$, x, 1); - {{Cl|_DELAY}} 0.02 -{{Cl|NEXT}} -{{Cl|RETURN}} -{{CodeEnd}} - - -''Example 2:'' Displays any number of game pad or joystick device button presses. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} 256 - {{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} 256 - {{Cl|ON STRIG(n)|ON STRIG}}((b - 1) * 4, j) JoyButton (j - 1) * 256 + b - 1 - {{Cl|NEXT}} -{{Cl|NEXT}} -{{Cl|STRIG(n)|STRIG}} ON - -{{Cl|DO...LOOP|DO}} - {{Cl|PRINT}} "."; - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -{{Cl|SUB}} JoyButton (js {{Cl|AS}} {{Cl|LONG}}) -{{Cl|PRINT}} "Joystick #"; js \ 256 + 1; "button #"; (js {{Cl|AND (boolean)|AND}} 255) + 1; "pressed!" -{{Cl|END SUB}} -{{CodeEnd}} -:''Explanation:'' Up to 256 controllers can be used in QB64 with many buttons to read. - - -{{PageSeeAlso}} -* [[STRIG ]], [[STICK]] {{text|(functions)}} -* [[STRIG(n)]] {{text|(statement)}} -* [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] - - -===External links=== -* [http://en.wikipedia.org/wiki/Analog_stick Single and Dual Stick Controllers] - - -{{PageNavigation}} diff --git a/internal/help/ON_TIMER(n)_11_11111(0).txt b/internal/help/ON_TIMER(n)_11_11111(0).txt deleted file mode 100644 index 821e45fe4..000000000 --- a/internal/help/ON_TIMER(n)_11_11111(0).txt +++ /dev/null @@ -1,81 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:45}} -The [[ON_TIMER(n)|ON TIMER]] statement sets up a timed event to be repeated at specified intervals throughout a program when enabled. - - -{{PageSyntax}} -: '''ON TIMER'''({{Parameter|seconds%}}) [[GOSUB]] {{{Parameter|lineLabel}}|{{Parameter|lineNumber}}} -: '''ON TIMER'''([{{Parameter|number%}},] {{Parameter|seconds!}}) { [[SUB]]procedure | [[GOSUB]] {{{Parameter|lineLabel}}|{{Parameter|lineNumber}}} } - - -{{PageDescription}} -===Legacy syntax=== -* In the first syntax, the [[INTEGER]] {{Parameter|seconds%}} parameter can be from 1 to 86400 seconds (one day). -* A [[TIMER (statement)|TIMER ON]] statement must follow an '''ON TIMER''' event setup to initiate it. -* [[TIMER (statement)|TIMER STOP]] disables timer events but remembers previous events when enabled again by a [[TIMER (statement)|TIMER ON]] statement, and the recorded events may be executed immediately if a timer event has occurred. -* [[TIMER (statement)|TIMER OFF]] disables timer event trapping. Events will not be remembered in a subsequent [[TIMER (statement)|TIMER ON]] statement. -* '''ON TIMER''' events will interrupt a [[SLEEP]] call and [[RETURN]] to running program procedures. -* Only one TIMER event can be set at a time using this legacy syntax and all TIMER code must be in the main code, as it uses [[GOSUB]]. - - -===QB64 syntax=== -* '''QB64''' can use multiple numbered timer events and [[SINGLE]] floating point second values down to one millisecond (.001). -* The '''TIMER''' {{Parameter|number%}} must be obtained from the [[_FREETIMER]] function. Store _FREETIMER numbers in a variable or an array to be able to reference them later. -* If the '''TIMER''' number is omitted or {{InlineCode}}'''ON TIMER'''(0, {{Parameter|seconds!}}){{InlineCodeEnd}} is used, then the TIMER used is the ''base TIMER'' (same as in the legacy syntax above). -* [[SUB]] procedures are allowed to be referenced, but [[CALL]] must not be used. -* '''[[SUB]] parameter values are passed by value and should be [[SHARED]] or literal values.''' -* Specific '''TIMER''' events can be turned on, suspended, turned off or freed using [[TIMER (statement)|TIMER(n)]] ON, STOP, OFF or FREE. -* Use '''TIMER(n) FREE''' to release a timer event after it has been turned off or is no longer used. -** The ''base TIMER'' cannot be freed. -* '''QB64''' allows TIMER statements to also be inside of SUB and FUNCTION procedures. -* '''ON TIMER''' events will interrupt a [[SLEEP]] call and [[RETURN]] to running program procedures. -* [[$CHECKING]]:OFF can disable all QB64 event checking. '''Setting $CHECKING:OFF is only designed for 100% stable, error-less sections of code, where every CPU cycle saved counts.''' - - -==QB64 Timing Alternatives== -* The [[TIMER]] function can be used to find timed intervals down to 1 millisecond(.001) accuracy. -* The [[_DELAY]] statement can be used to delay program execution for intervals down to milliseconds. -* [[_LIMIT]] can slow down loops to a specified number of frames per second. This can also alleviate a program's CPU usage. - - -{{PageExamples}} -''Example:'' Using a numbered TIMER to check the mouse button press status in '''QB64'''. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} Button {{Cl|AS}} {{Cl|LONG}} 'share variable value with Sub - -t1 = _{{Cl|TIMER (statement)|FREE}}{{Cl|TIMER}} 'get a timer number from _FREETIMER ONLY! -{{Cl|ON TIMER(n)|ON TIMER}}(t1, .05) MouseClick -{{Cl|TIMER}}(t1) ON - -DO - {{Cl|LOCATE}} 1, 1 - {{Cl|IF...THEN|IF}} Button {{Cl|THEN}} - {{Cl|PRINT}} "Mouse button"; Button; "is pressed."; - {{Cl|ELSE}} {{Cl|PRINT}} {{Cl|SPACE$}}(70) - {{Cl|END IF}} - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|TIMER}}(t1) {{Cl|OFF}} -{{Cl|TIMER}}(t1) {{Cl|TIMER (statement)|FREE}} 'release timer -{{Cl|END}} - -{{Cl|SUB}} MouseClick -{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - {{Cl|IF...THEN|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} - {{Cl|COLOR}} 10: Button = 1 - {{Cl|ELSEIF}} {{Cl|_MOUSEBUTTON}}(2) {{Cl|THEN}} - {{Cl|COLOR}} 12: Button = 2 - {{Cl|ELSE}} Button = 0 - {{Cl|END IF}} -{{Cl|LOOP}} -{{Cl|END SUB}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[TIMER]], [[_FREETIMER]] -* [[TIMER (statement)]], [[_DELAY]], [[_LIMIT]] -* [[$CHECKING]] {{text|(QB64 [[Metacommand]])}} - - -{{PageNavigation}} diff --git a/internal/help/OPEN_1111.txt b/internal/help/OPEN_1111.txt deleted file mode 100644 index 796d8ab96..000000000 --- a/internal/help/OPEN_1111.txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:50}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/OPEN_COM_1111_111.txt b/internal/help/OPEN_COM_1111_111.txt deleted file mode 100644 index de1cc0dcd..000000000 --- a/internal/help/OPEN_COM_1111_111.txt +++ /dev/null @@ -1,131 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:51}} -The [[OPEN COM]] statement is used to access a computer's serial port COM. - - -{{PageSyntax}} -: '''OPEN''' "COMn: ''Speed'', ''Parity'', ''Bits'', ''Stopbit'', [''Options'']" [FOR {[[RANDOM]]|[[BINARY]]|[[OUTPUT]]|[[INPUT (file mode)|INPUT]]}] AS #''P'' [LEN = {{Parameter|byteSize}}] - - -{{Parameters}} -* ''Speed'' (baud rate): 50, 150, 300, 600, 1200, 1800, 2400, '''9600''' (QBasic's maximum), 19200 or '''115200''' ('''QB64''''s maximum). -* ''Parity'': '''N''' (none), E (even), O (odd), S (space) or M (mark). Note: If 8 bits, use parity N for numerical data. -* ''Bits'' = number of bits/byte: Valid numbers: 5, 6, 7 or '''8''' -* ''Stopbit'' = number of stop bits: Valid numbers: '''1''', 1.5 or 2 -* Optional COM port ''Options'' (separated by commas): -::* ASC : [[ASCII]] byte mode. End of line = [[CHR$]](13). End of file = CHR$(26) -::* BIN : [[Binary]] byte mode. Default mode if ASC is not used(option not required). -:: ''Below ms is the timeout in milliseconds 1 to 65535. Zero ignores a timeout. Default without ms = 1000 :'' -::* CD[ms] : Time until timeout of DCD (Carrier Detect) line in. CD0 ignores timeouts. -::* CS[ms] : Time until timeout of CTS (Clear to Send) line in. CS0 ignores timeouts. -::* DS[ms] : Time until timeout of DSR (Data Set Ready) line in. DS0 ignores timeouts. -::* OP[ms] : Time until data lines become active. If timeout then OPEN fails, OP0 ignores timeouts. -::* RB[b] : Size of receive buffer in bytes when used. Default when not used = 512 bytes -::* TB[b] : Size of transmit buffer in bytes when used. Default when not used = 512 bytes -::* RS : Supress detection of Request to Send (RTS) line. - - -{{PageDescription}} -* '''If any optional CD, CS, DS or OP timeouts occur the OPEN will fail or port access will stop. Try 0 to ignore.''' -* '''QB64''' can open any COM''n'' port number from 1 to 9. -* See Windows System '''Device Manager''' for COM port numbers and port addresses &H3F8, &H2F8, &H3E8 and &H2E8. -* Four commas are required after the Speed, Parity, Bits, and Stopbit, even if none of the Options are used. -* Other [[OPEN]] ''options'' are optional and in any order separated by commas within the OPEN command [[STRING|string]].(See list below) -* The optional FOR access ''mode'' can be [[OUTPUT]], [[INPUT (file mode)|INPUT]] or [[RANDOM]] (default mode when no FOR statement is used). -* '''Currently, QB64 only supports [[OPEN]] FOR [[RANDOM]] access using the [[GET]]/[[PUT]] commands in [[BINARY|BIN]] mode.''' -* '''Use the BIN option listed below for [[BINARY]] byte mode port access.''' -* The [[LEN]] statement is also optional. The default record size is 512 bytes when not used. -* Use the [[LOC]](portnumber) function to determine that there is data in the receive buffer when the value is greater than 0. -* OPEN AS number can use a [[FREEFILE]] value. Numbers used by files already open '''cannot''' be used by OPEN COM. -* [[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 1:'' Checking to see if a COM port exists. If the port does not exist QBasic will cause a Windows access error. -{{CodeStart}} -{{Cl|ON ERROR}} {{Cl|GOTO}} Handler -FF = {{Cl|FREEFILE}} -comPort$ = "COM1:" 'try a COM port number that does not exist -{{Cl|CONST}} comMode$ = "9600,N,8,1,CS0,DS0" 'Use 0 to avoid timeouts -{{Cl|OPEN}} comPort$ + comMode$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} FF -{{Cl|IF...THEN|IF}} errnum = 0 {{Cl|THEN}} {{Cl|PRINT}} "COM exists! - -K$ = {{Cl|INPUT$}}(1) -{{Cl|END}} - -Handler: -errnum = {{Cl|ERR}} -{{Cl|PRINT}} "Error:"; errnum -{{Cl|RESUME}} {{Cl|NEXT}} -{{CodeEnd}} -: ''Explanation:'' QB64 may create error 68 if COM is not found. Use a zero CD, CS, DS or OP timeout value to avoid COM timeouts. - - -''Example 2:'' Opening a COM port with the BIN, CS0 and DS0 options in '''QB64'''. -{{CodeStart}} -{{Cl|DIM}} bytestr {{Cl|AS}} {{Cl|STRING}} * 1 'one byte transfers -{{Cl|INPUT}} "{{Cl|COM}} port number #", port$ 'any COM port number available - -{{Cl|OPEN}} "{{Cl|COM}}" + port$ + ":9600,N,8,1,BIN,CS0,DS0" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 -{{Cl|DO}} 'main loop - 'receive data in buffer when LOC > 0 - {{Cl|IF}} {{Cl|LOC}}(1) {{Cl|THEN}} - {{Cl|GET}} #1, , bytestr - {{Cl|PRINT}} "[" + bytestr + "]"; - {{Cl|END IF}} - 'transmit (send) - k$ = {{Cl|INKEY$}} - {{Cl|IF}} {{Cl|LEN}}(k$) = 1 {{Cl|THEN}} - k = {{Cl|ASC}}(k$) - {{Cl|IF}} k >= 32 {{Cl|THEN}} 'ignore control key codes - {{Cl|PRINT}} ">" + k$ + "<"; - bytestr = k$: {{Cl|PUT}} #1, , bytestr - {{Cl|END IF}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} k$ = {{Cl|CHR$}}(27) -{{Cl|CLOSE}} #1: {{Cl|PRINT}} "Finished!" -{{CodeEnd}} - - -''Example 3:'' Sending string data from one COM port to another requires predefined length strings: -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} ByteIn {{Cl|AS}} {{Cl|STRING}} * 1 'One byte transfers -{{Cl|DIM}} {{Cl|SHARED}} Byte4 {{Cl|AS}} {{Cl|STRING}} * 4 'Four byte transfers - -Byte4 = {{Cl|CHR$}}(254) + {{Cl|CHR$}}(175) + {{Cl|CHR$}}(0) + {{Cl|CHR$}}(3) 'Command code to query all 4 banks of switch input board. - -{{Cl|OPEN}} "COM1:115200,N,8,1,BIN,CS0,DS0" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 'Open port used to send commands. -{{Cl|OPEN}} "COM2:115200,N,8,1,BIN,CS0,DS0" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 'Open port used to receive commands. - -{{Cl|PUT}} #1, , Byte4 'Send the 4 byte command. - -Start# = {{Cl|TIMER}} -{{Cl|DO...LOOP|DO}} {{Cl|UNTIL}} {{Cl|LOC}}(2) <> 0 'Check if there is data received at com2 - {{Cl|IF...THEN|IF}} {{Cl|TIMER}} - Start# > .5 {{Cl|THEN}} {{Cl|EXIT DO}} 'Exit loop if no data arrives within .5 seconds. -{{Cl|LOOP}} - -{{Cl|IF...THEN|IF}} {{Cl|LOC}}(2) = 0 {{Cl|THEN}} 'If no data was received..... - {{Cl|PRINT}} "No data received from COM port." - {{Cl|END}} -{{Cl|END IF}} - -{{Cl|PRINT}} "Received from COM2:"; - -{{Cl|DO...LOOP|DO}} {{Cl|UNTIL}} {{Cl|LOC}}(2) = 0 'Read data from COM2 until there is no more data. - {{Cl|GET}} #2, , ByteIn - {{Cl|PRINT}} {{Cl|ASC}}(ByteIn); -{{Cl|LOOP}} -{{Cl|END}} -{{CodeEnd}}{{small|Code courtesy of forum member Hydrofoiler}} - - -{{PageSeeAlso}} -* [[BINARY]], [[RANDOM]] -* [[INPUT$]], [[PRINT (file statement)|PRINT #]] -* [[LOC]], [[INKEY$]], [[OPEN]] -* [[GET|GET #]], [[PUT|PUT #]] -* [[Port Access Libraries]] {{text|(Includes full LPT and COM port descriptions with downloadable DLL library)}} -* [[Windows_Libraries#Windows_Ports|Enumerating Windows Ports]] - - -{{PageNavigation}} diff --git a/internal/help/OPTION_BASE_111111_1111.txt b/internal/help/OPTION_BASE_111111_1111.txt deleted file mode 100644 index 34f616e02..000000000 --- a/internal/help/OPTION_BASE_111111_1111.txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:52}} -The [[OPTION BASE]] statement is used to set the default lower bound of arrays. - - -{{PageSyntax}} -: [[OPTION BASE]] {0|1} - - -{{PageDescription}} -* This statement affects array declarations where the lower bound of a dimension is not specified. -* When used, [[OPTION BASE]] must come before any array declarations ([[DIM]]) to be affected. -* By default, the lower bound for arrays is zero, and may be changed to one using the statement. -* Otherwise, arrays will be dimensioned from element 0 if you DIM just the upper bounds. -* You can also set other array boundaries by using [[TO]] in the DIM declaration such as {{InlineCode}}DIM array(5 TO 10){{InlineCodeEnd}} - - -{{PageExamples}} -''Example 1:'' Set the default lower bound for array declarations to one. -{{CodeStart}} -{{Cl|OPTION BASE}} 1 - -' Declare a 5-element one-dimensional array with element indexes of one through five. -{{Cl|DIM}} array(5) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|PRINT}} {{Cl|LBOUND}}(array) -{{CodeEnd}} -{{OutputStart}} 1{{OutputEnd}} - - -''Example 2:'' Set the default lower bound for array declarations to zero. -{{CodeStart}} -{{Cl|OPTION BASE}} 0 - -' Declare an 18-element two-dimensional array with element indexes of zero through two -' for the first dimension, and 10 through 15 for the second dimension. -{{Cl|DIM}} array(2, 10 to 15) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|PRINT}} {{Cl|LBOUND}}(array, 1) -{{Cl|PRINT}} {{Cl|LBOUND}}(array, 2) -{{CodeEnd}} -{{OutputStart}} 0 - 10 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[Arrays]], [[LBOUND]], [[UBOUND]] -* [[DIM]], [[REDIM]], [[STATIC]], [[COMMON]] - - -{{PageNavigation}} diff --git a/internal/help/OPTION__EXPLICITARRAY_111111__1111111111111.txt b/internal/help/OPTION__EXPLICITARRAY_111111__1111111111111.txt deleted file mode 100644 index 236ee3acd..000000000 --- a/internal/help/OPTION__EXPLICITARRAY_111111__1111111111111.txt +++ /dev/null @@ -1,41 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:11}} -{{DISPLAYTITLE:OPTION _EXPLICITARRAY}} -[[OPTION _EXPLICITARRAY]] instructs the compiler to require arrays be declared with [[DIM]], [[REDIM]] or equivalent. - -{{PageSyntax}} -: [[OPTION _EXPLICITARRAY]] - - -{{PageDescription}} -* Normally statements like {{InlineCode}}x(2) = 3{{InlineCodeEnd}} will implicitly create an array x(). [[OPTION _EXPLICITARRAY]] requires a preceding declaration for the array, helping to catch mistyped array and function names. -* Unlike [[OPTION _EXPLICIT]], simple variables can still be used without a declaration. Example: {{InlineCode}}i = 1{{InlineCodeEnd}} - -{{PageErrors}} -* If used, [[OPTION _EXPLICITARRAY]] must be the very first statement in your program. No other statements can precede it (except for [[$NOPREFIX]] or comment lines started with an [[Apostrophe|apostrophe]] or [[REM]]). -* Do not use [[OPTION _EXPLICITARRAY]] in [[$INCLUDE]]d modules. - - -{{PageExamples}} -''Example:'' Avoiding simple typos with [[OPTION _EXPLICITARRAY]] results shown in the QB64 IDE Status area. -{{CodeStart}}{{Cl|OPTION _EXPLICITARRAY}} -x = 1 'This is fine, it's not an array so not affected - -{{Cl|DIM}} z(5) -z(2) = 3 'All good here, we've explicitly DIMmed our array - -y(2) = 3 'This now generates an error -{{CodeEnd}} - -''QB64 IDE Status will show:'' -'''Array 'y' (SINGLE) not defined on line 7''' - - -{{PageSeeAlso}} -* [[OPTION _EXPLICIT]] -* [[DIM]], [[REDIM]] -* [[SHARED]] -* [[STATIC]] - - -{{PageNavigation}} diff --git a/internal/help/OPTION__EXPLICIT_111111__11111111.txt b/internal/help/OPTION__EXPLICIT_111111__11111111.txt deleted file mode 100644 index 506697bbf..000000000 --- a/internal/help/OPTION__EXPLICIT_111111__11111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:10}} -{{DISPLAYTITLE:OPTION _EXPLICIT}} -[[OPTION _EXPLICIT]] instructs the compiler to require variable declaration with [[DIM]], [[REDIM]] or an equivalent statement. - - -{{PageSyntax}} -: [[OPTION _EXPLICIT]] - - -{{PageDescription}} -* With [[OPTION _EXPLICIT]] you can avoid typos by having QB64 immediately warn in the '''Status area''' of new variables used without previous declaration. -* Enable [[OPTION _EXPLICIT]] temporarily even if a program source file doesn't contain the directive by specifying the '''-e''' switch when compiling via command line (''qb64 -c file.bas -e''). - - -{{PageErrors}} -* If used, [[OPTION _EXPLICIT]] must be the very first statement in your program. No other statements can precede it (except for [[$NOPREFIX]] or comment lines started with an [[Apostrophe|apostrophe]] or [[REM]]). -* Do not use [[OPTION _EXPLICIT]] in [[$INCLUDE]]d modules. - - -{{PageExamples}} -''Example:'' Avoiding simple typos with [[OPTION _EXPLICIT]] results shown in the QB64 IDE Status area. -{{CodeStart}}{{Cl|OPTION _EXPLICIT}} - -{{Cl|DIM}} myVariable {{Cl|AS}} {{Cl|INTEGER}} - -myVariable = 5 - -{{Cl|PRINT}} myVariabe -{{CodeEnd}} - -''QB64 IDE Status will show:'' -'''Variable 'myVariabe' (SINGLE) not defined on line 4''' - - -{{PageSeeAlso}} -* [[OPTION _EXPLICITARRAY]] -* [[DIM]], [[REDIM]] -* [[SHARED]] -* [[STATIC]] - - -{{PageNavigation}} diff --git a/internal/help/OR_(boolean)_11_(0000000).txt b/internal/help/OR_(boolean)_11_(0000000).txt deleted file mode 100644 index 7aba8c3a2..000000000 --- a/internal/help/OR_(boolean)_11_(0000000).txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:55}} -The '''OR''' conditional operator evaluates an expression to true (-1) if any of the arguments is also true. - - -{{PageSyntax}} -: [[IF]] {{Parameter|expression1}} '''OR''' {{Parameter|expression2}} THEN {code} - - -{{PageDescription}} -* OR adds an alternative to another conditional evaluation. If either element in the evaluation is true then the evaluation is true. -* Parenthesis may be used to clarify the order of comparisons in an evaluation. -* Not to be confused with the [[AND]] and [[OR]] numerical operations. - - -{{RelationalTable}} - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -a% = 100 -b% = 50 - -IF (a% > b% AND a% < 100) OR b% = 50 THEN PRINT "True" -{{CodeEnd}} -{{OutputStart}} -True -{{OutputEnd}} -: ''Explanation:'' The first evaluation was False, but the OR evaluation made the statement true and the code was executed. - - -{{PageSeeAlso}} -* [[AND]], [[OR]] {{text|(logical operators)}} -* [[AND (boolean)]], [[XOR (boolean)]] -* [[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/OR_11.txt b/internal/help/OR_11.txt deleted file mode 100644 index 526bd7c5a..000000000 --- a/internal/help/OR_11.txt +++ /dev/null @@ -1,49 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:53}} -The [[OR]] numerical operator returns a comparative bit value of 1 if either value's bit is on. - - -{{PageSyntax}} -: {{Parameter|result}} = firstValue [[OR]] secondValue - - - -{{PageDescription}} -* If both bits are off, it returns 0. -* If one or both bits are on then it returns 1. -* [[OR]] never turns off a bit and can be used only to turn a bit on. - - -{{LogicalTruthTable}} - - -{{PageExamples}} -''Example 1:'' OR always turns bits on! Never off. -{{CodeStart}} - a% = 5 ' 101 binary - b% = 4 ' 100 binary - results% = a% {{Cl|OR}} b% ' still 101 binary using OR - {{Cl|PRINT}} "Results% ="; results% -{{CodeEnd}} -{{OutputStart}} - Results% = 5 -{{OutputEnd}} - - -''Example 2:'' Turning a data register bit on. -{{CodeStart}} - address% = 888 'parallel port data register - bytevalue% = {{Cl|INP}}(address%) - {{Cl|OUT}} address%, bytevalue% {{Cl|OR}} 4 -{{CodeEnd}} - -:''Explanation:'' The third register bit is only turned on if it was off. This ensures that a bit is set. OR could set more bits on with a sum of bit values such as: OUT address%, 7 would turn the first, second and third bits on. 1 + 2 + 4 = 7 - - -{{PageSeeAlso}} -* [[AND]], [[XOR]] -* [[AND (boolean)]], [[OR (boolean)]] -* [[Binary]], [[Boolean]] - - -{{PageNavigation}} diff --git a/internal/help/OUTPUT_111111.txt b/internal/help/OUTPUT_111111.txt deleted file mode 100644 index 747c3385f..000000000 --- a/internal/help/OUTPUT_111111.txt +++ /dev/null @@ -1,163 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:57}} -The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output. - - -{{PageSyntax}} -: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}] - - -===Legacy ''GW-BASIC'' syntax=== -: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}] - - -{{Parameters}} -* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes. -* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write). -* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above. -* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function. -* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer. - - -{{PageDescription}} -* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time. -* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.''' -* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below) -* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.''' -* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic. -* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''. -* Once a file or port is opened, it can be used in any program procedure using the assigned file number. -* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3). -* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''. -: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system. -* [[OPEN COM]] can also be used for serial port access in '''QB64'''. - - -{{PageErrors}} -* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed. -* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found". -** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name. -* '''QB64''' does not have DOS file name limitations. - - -==Details== -===File ACCESS and LOCK Permissions=== -* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network. -* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network. -* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records. -* 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. - -===File Access Modes=== -* FOR mode can be: -** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]]. -** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.''' -** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.''' -** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode. -** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes) -** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number. - - -====GW-BASIC modes==== -* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following: -** "A" = '''APPEND'''. -** "B" = '''BINARY'''. -** "I" = '''INPUT'''. -** "O" = '''OUTPUT'''. -** "R" = '''RANDOM'''. - - -{{PageExamples}} -''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK. - -{{CodeStart}} - file$ = "Hello,~1.mp3" 'example call below - {{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors% - -{{Cl|FUNCTION}} CheckName% (Filename$) - '{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call! - {{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}} - L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension - {{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}} - CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} - {{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character" - code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes - {{Cl|SELECT CASE}} code% 'check for errors and highlight in red - '{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors''' - {{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors''' - {{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12 - {{Cl|END SELECT}} - {{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print - {{Cl|NEXT}} - CheckName% = E% -{{Cl|END FUNCTION}} -{{CodeEnd}} -''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64. - -{{OutputStart}} - {{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}} = {{text|1|yellow}} -{{OutputEnd}} -:''Note:'' The screen output displays filename characters in green except for red comma QBasic error. - - -''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file: -{{CodeStart}} -f% = {{Cl|FREEFILE}} 'should always be 1 at program start -{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f% -g% = {{Cl|FREEFILE}} 'should always be 2 after 1 -{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g% - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2 - {{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version" -NEXT -{{CodeEnd}}{{small|code by Steve McNeill}} -: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name. - - -''Example 3:'' Showcasing different file modes. -{{CodeStart}} -{{Cl|CLS}} - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted." -{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:" -{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted." -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) -{{Cl|INPUT (file statement)|INPUT}} #1, a$ -{{Cl|PRINT}} a$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 - -{{Cl|KILL}} "test.tst" - -{{Cl|END}} - -{{CodeEnd}} - -{{OutputStart}} -If test.tst didn't exist: -A new file was created named test.tst and then deleted. -If test.tst did exist: -It was overwritten with this and deleted. -{{OutputEnd}} -:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten. - - -{{PageSeeAlso}} -* [[PRINT (file statement)]], [[INPUT (file statement)]] -* [[GET]], [[PUT]], [[WRITE (file statement)]] -* [[INPUT$]], [[LINE INPUT (file statement)]] -* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]] -* [[SEEK (statement)]], [[SEEK]] -* [[OPEN COM]], [[LEN]], [[RESET]] -* [[FIELD]], [[TYPE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}} -* [[_SNDOPEN]], [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/OUT_111.txt b/internal/help/OUT_111.txt deleted file mode 100644 index 6901063ef..000000000 --- a/internal/help/OUT_111.txt +++ /dev/null @@ -1,103 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:56}} -[[OUT]] writes values to register and port hardware addresses. - - -{{PageSyntax}} -: [[OUT]] {{Parameter|registerAddress%}}, {{Parameter|value%}} - - -{{Parameters}} -* {{Parameter|registerAddress%}} is a value expressed as a decimal [[INTEGER]] or [[&H|hexadecimal]]. -* The [[INTEGER]] {{Parameter|value%}} sent is normally only 0 to 255 per byte register (8 bit) address. - - -{{PageDescription}} -* '''QB64 has limited access to registers. VGA memory and registers are emulated.''' -* OUT can be used to change color port and a limited number of other port settings in QB64. -* Some settings may be set in a specific order to gain access to settings and [[INP]] reads. -* [[SCREEN]] modes determine the number of available color palette attributes from 2 to 256 in SCREEN 13. -* Windows NT may block access to Parallel printer and Serial ports. See [[Port Access Libraries]] or other DLLs. -* [[_PALETTECOLOR]] can also be used to set RGB intensity values using [[_RGB32|32 bit color]] values. -* OUT can toggle the blinking attribute of SCREEN 0 color 16-31 for legacy code. [[_BLINK]] is the preferred method. (starting with build 20170816/61). - - -==Color Port Palette access using OUT== - -:::::{{InlineCode}}OUT &H3C7, attribute{{InlineCodeEnd}} : Set port to read RGB settings for start attribute -:::::{{InlineCode}}[[INP]] &H3C9, colorIntensity{{InlineCodeEnd}} : Reads RGB color intensity settings in order - -:::::{{InlineCode}}OUT &H3C8, attribute{{InlineCodeEnd}} : Set port to write RGB settings for start attribute -:::::{{InlineCode}}OUT &H3C9, colorIntensity{{InlineCodeEnd}} : Writes RGB color intensity settings in order - -::::* Every 3 reads or writes, changes to next color attribute without a set -::::* Color setting is Red, Green and Blue attribute intensities in order. -::::* Color attribute intensity values range from 0 to 63. -::::* Some [[DAC]] color attribute intensities cannot be changed using OUT. - - -==QBasic/QuickBASIC== -* In DOS, OUT accesses memory and hardware directly, unlike [[POKE]], and could cause PC damage. - - -{{PageExamples}} -''Example 1:'' Reading the default RGB color settings of color attribute 15. - -{{CodeStart}} -{{Cl|OUT}} &H3C7, 15 'set color port attribute 15 for a read -red% = {{Cl|INP}}(&H3C9) -green% = INP(&H3C9) -blue% = INP(&H3C9) -PRINT red%, green%, blue% -{{CodeEnd}} -{{OutputStart}} - 63 63 63 -{{OutputEnd}} - - -''Example 2:'' Changing the color intensity settings of the [[SCREEN]] background [[COLOR]] 0 to bright white. -{{CodeStart}} -{{Cl|OUT}} &H3C8, 0 'attribute number. 0 for black screen background -{{Cl|OUT}} &H3C9, 63 'red -{{Cl|OUT}} &H3C9, 63 'green -{{Cl|OUT}} &H3C9, 63 'blue -{{CodeEnd}} -:''Explanation:'' In [[SCREEN]] 0 this is one way to make high intensity background colors. {{InlineCode}}[[COLOR]] ,15{{InlineCodeEnd}} is actually grey (7). - - -''Example 3:'' Toggling blinking colors in SCREEN beginning with build 20170816/61 -{{CodeStart}} -{{Cl|OUT}} &H3C0, &H10 'disables blinking and enables high intensity backgrounds (colors 16-31) -{{Cl|OUT}} &H3C0, 2 ^ 3 'reenables blinking and disables high intensity backgrounds (colors 16-31) -{{CodeEnd}} -: Note: In QB64, the recommended practice is to use the [[_BLINK]] {ON|OFF} statement. - - -''Example 4:'' Restoring colors to a bitmap from the Red, Green and Blue [[BSAVE]]d indexed array of color values. -{{CodeStart}} - {{Cl|SCREEN (statement)|SCREEN}} 12 - {{Cl|OUT}} {{Cl|&H}}3C8, 0 ' set color port for output at attribute 0 - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 47 ' 48 RGB values is (3 * 16) -1 color attributes from 0 in screen 12 - {{Cl|OUT}} {{Cl|&H}}3C9, Image%(i) ' changes to next attribute after 3 RGB loops - {{Cl|NEXT}} - {{Cl|PUT (graphics statement)|PUT}}(clm, row), Image(48) PSET -{{CodeEnd}} -:''Explanation:'' The color RGB intensity settings were imported from a file to the Image array using [[BLOAD]]. The color attribute advances to the next one every 3 writes using OUT. The color information was indexed to the start of the array. The image is after the color settings at index 48. Index 48 is the [[GET (graphics statement)|GET]] image width and 49 is the height. - - -{{PageSeeAlso}} -* [[PALETTE]], [[_PALETTECOLOR]] -* [[INP]] {{text|(read register)}} -* [[PEEK]] {{text|(read memory)}} -* [[POKE]] {{text|(write to memory)}} -* [[COLOR]], [[SCREEN]] -* [[BSAVE]], [[BLOAD]] -* [[_BLINK]], [[_BLINK (function)]] -* [[Port Access Libraries]] {{text|(COM or LPT registers)}} - - -===External Links=== -* [http://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers PC I/O base address device assignments] - - -{{PageNavigation}} diff --git a/internal/help/PAINT_11111.txt b/internal/help/PAINT_11111.txt deleted file mode 100644 index 527269e53..000000000 --- a/internal/help/PAINT_11111.txt +++ /dev/null @@ -1,148 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:58}} -The [[PAINT]] statement is used to fill a delimited area in a graphic screen mode with color. - - -{{PageSyntax}} -: [[PAINT]] ['''STEP'''] ({{Parameter|column%}}, {{Parameter|row%}}), {{Parameter|fillColor}}[, {{Parameter|borderColor%}}] - - -{{Parameters}} -* Can use the [[STEP]] keyword for relative coordinate placements. See example 1 below. -* {{Parameter|fillColor}} is an [[INTEGER]] or [[LONG]] 32-bit value to paint the inside of an object. Colors are limited to the [[SCREEN]] mode used. -* Optional [[INTEGER]] or [[LONG]] 32-bit {{Parameter|borderColor%}} is the color of the border of the shape to be filled when this is different from the fill color. -* {{Parameter|fillColor}} can be a string made up of a sequence of [[CHR$]] values, each representing a tiling pattern to fill the shape. See Example 3 below. - - -{{PageDescription}} -* Graphic {{Parameter|column%}} and {{Parameter|row%}} [[INTEGER]] pixel coordinates should be inside of a fully closed "shape", whether it's a rectangle, circle or custom-drawn shape using [[DRAW]]. -* If the coordinates passed to the [[PAINT]] statement are on a pixel that matches the border colors, no filling will occur. -* If the shape's border isn't continuous, the "paint" will "leak". -* If the shape is not totally closed, every color except the border color may be painted over. -* [[DRAW]] shapes can be filled using the string "P {{Parameter|fillColor}}, {{Parameter|borderColor}}". Use a "B" blind move to offset from the shape's border. - - -{{PageExamples}} -''Example 1:'' Painting a [[CIRCLE]] immediately after it is drawn using [[STEP]](0, 0) to paint from the circle's center point. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -x = 200: y = 200 -{{Cl|CIRCLE}} (x, y), 100, 10 -{{Cl|PAINT}} {{Cl|STEP}}(0, 0), 2, 10 -{{CodeEnd}} -:''Results:'' A circle located at x and y with a bright green border filled in dark green. The last coordinate used was the circle's center point and PAINT used it also with the [[STEP]] relative coordinates being zero. - - -''Example 2:'' Routine to check a [[DRAW]] string to make sure that the drawn shape is fully closed so that a PAINT does not "leak". -{{CodeStart}} -{{Cl|SCREEN}} 12 -drw$ = "C15S20R9D4R6U3R3D3R7U5H3U2R9D3G2D6F1D3F5L10D1G1L4H2L7G2L3H2L3U8L2U5R1BF4" - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(drw$) - tmp$ = {{Cl|UCASE$}}({{Cl|MID$}}(drw$, i, 1)) - check = 1 - {{Cl|SELECT CASE}} tmp$ - {{Cl|CASE}} "U": ver = -1: hor = 0 - {{Cl|CASE}} "D": ver = 1: hor = 0 - {{Cl|CASE}} "E": ver = -1: hor = 1 - {{Cl|CASE}} "F": ver = 1: hor = 1 - {{Cl|CASE}} "G": ver = 1: hor = -1 - {{Cl|CASE}} "H": ver = -1: hor = -1 - {{Cl|CASE}} "L": ver = 0: hor = -1 - {{Cl|CASE}} "R": ver = 0: hor = 1 - {{Cl|CASE ELSE}}: check = 0 - {{Cl|END SELECT}} - {{Cl|IF...THEN|IF}} check {{Cl|THEN}} - snum$ = "" - {{Cl|FOR...NEXT|FOR}} j = i + 1 {{Cl|TO}} i + 4 'set for up to 4 digits and spaces - {{Cl|IF...THEN|IF}} j > {{Cl|LEN}}(drw$) {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} - n$ = {{Cl|MID$}}(drw$, j, 1) - num = {{Cl|ASC}}(n$) - {{Cl|IF...THEN|IF}} (num > 47 {{Cl|AND (boolean)|AND}} num < 58) {{Cl|OR (boolean)|OR}} num = 32 {{Cl|THEN}} - snum$ = snum$ + n$ - {{Cl|ELSE}}: {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} - {{Cl|END IF}} - {{Cl|NEXT}} - vertical = vertical + (ver * {{Cl|VAL}}(snum$)) - horizont = horizont + (hor * {{Cl|VAL}}(snum$)) - {{Cl|END IF}} - {{Cl|PRINT}} tmp$, horizont, vertical - '{{Cl|SLEEP}} -{{Cl|NEXT}} -{{Cl|PSET}} (300, 300): {{Cl|DRAW}} drw$ -{{CodeEnd}} -: ''Explanation:'' If the [[DRAW]] string is fully closed, the end values should each be 0. In the example, the proper result should be 4, 4 as there is a BF4 offset for PAINT which cannot be on a border. The result is 4, 5 because the shape is not completely closed. - - -''Example 3:'' Tiling using PAINT to create a red brick pattern inside a yellow border: -{{CodeStart}} -{{Cl|DIM}} Row$(1 {{Cl|TO}} 8) -{{Cl|SCREEN}} 12 - - 'make red-brick wall - Row$(1) = {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}FE) + {{Cl|CHR$}}({{Cl|&H}}FE) - Row$(2) = Row$(1) - Row$(3) = Row$(1) - Row$(4) = {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}0) - Row$(5) = {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}0) + {{Cl|CHR$}}({{Cl|&H}}EF) + {{Cl|CHR$}}({{Cl|&H}}EF) - Row$(6) = Row$(5) - Row$(7) = Row$(5) - Row$(8) = Row$(4) - Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8) - - {{Cl|LINE}} (59, 124)-(581, 336), 14, B 'yellow box border to paint inside - {{Cl|PAINT}} (320, 240), Tile$, 14 'paints brick tiles within yellow border -{{CodeEnd}} - - -''Example 4:'' Generating a tiling pattern for PAINT from [[DATA]] statements: -{{CodeStart}} -ptndata: -{{Cl|DATA}} "c4444444" -{{Cl|DATA}} "c4444444" -{{Cl|DATA}} "cccccccc" -{{Cl|DATA}} "444c4444" -{{Cl|DATA}} "444c4444" -{{Cl|DATA}} "444c4444" -{{Cl|DATA}} "cccccccc" -{{Cl|DATA}} "c4444444" -{{Cl|DATA}} --- - -{{Cl|RESTORE}} ptndata: ptn$ = loadpattern$ - -{{Cl|SCREEN}} 7 -{{Cl|DRAW}} "c15l15f10g10r30g10f10l50u80r100m160,100" -{{Cl|PAINT}} (160, 90), ptn$, 15 - -{{Cl|FUNCTION}} loadpattern$ - {{Cl|DIM}} quad(0 TO 3) {{Cl|AS}} {{Cl|INTEGER}} - res$ = "" - {{Cl|DO}} - {{Cl|READ}} row$ - {{Cl|IF}} {{Cl|LEFT$}}(row$, 3) = "---" {{Cl|THEN}} {{Cl|EXIT}} {{Cl|DO}} - {{Cl|FOR}} x = 0 {{Cl|TO}} 7 - pixel = {{Cl|VAL}}("&h" + {{Cl|MID$}}(row$, x + 1, 1)) - {{Cl|FOR}} bit = 0 {{Cl|TO}} 3 - {{Cl|IF}} pixel {{Cl|AND}} 2 ^ bit {{Cl|THEN}} - quad(bit) = quad(bit) {{Cl|OR}} (2 ^ (7 - x)) - {{Cl|END}} {{Cl|IF}} - {{Cl|NEXT}} - {{Cl|NEXT}} - {{Cl|FOR}} i = 0 {{Cl|TO}} 3 - res$ = res$ + {{Cl|CHR$}}(quad(i)) - quad(i) = 0 - {{Cl|NEXT}} - {{Cl|LOOP}} - loadpattern$ = res$ -{{Cl|END}} {{Cl|FUNCTION}} -{{CodeEnd}} -:: ''Code provided by collaborator https://github.com/NEONTEC75'' - - -{{PageSeeAlso}} -* [[PSET]], [[PRESET]] -* [[CIRCLE]], [[LINE]], [[DRAW]] -* [[SCREEN]], [[CHR$]] - - -{{PageNavigation}} diff --git a/internal/help/PALETTE_1111111.txt b/internal/help/PALETTE_1111111.txt deleted file mode 100644 index 5d4a2dfe9..000000000 --- a/internal/help/PALETTE_1111111.txt +++ /dev/null @@ -1,47 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:43:59}} -The [[PALETTE]] statement can swap color settings, set colors to default or set the red, green and blue color components of palette colors. - - -{{PageSyntax}} - -: [[PALETTE]] [{{Parameter|attribute%}}, ''red%'' + (''green%'' * 256) + (''blue%'' * 65536)] -: [[PALETTE]] [{{Parameter|existingAttribute%}}, {{Parameter|newAttribute%}}] - - -{{PageDescription}} -* {{Parameter|red%}}, {{Parameter|green%}} and {{Parameter|blue%}} values can range from 0 to 63. Many color shades are possible in non-[[DAC]] color attributes. -* If the {{Parameter|red%}}, {{Parameter|green%}} and {{Parameter|blue%}} color intensity settings are all the same value the resulting color is a shade of grey. -* A swap is often used with [[DAC]] color attributes that cannot change RGB settings. Only the RGB color settings are swapped from original {{Parameter|existingAttribute%}} to {{Parameter|newAttribute%}}. Screens 0 thru 9 support swaps. Screen 10 supports up to attribute 8 only. -* PALETTE without any value sets any changed RGB settings back to the default color settings, including [[DAC]] colors. -* [[PALETTE USING]] can be used when color intensity values are stored in an [[Arrays|array]]. -* QB64 implements the [[_PALETTECOLOR]] statement to provide extended palette functionality. - - -==QBasic/QuickBASIC== -* Screens 0, 7 and 9 ([[DAC]]) colors could not be changed using the first syntax, but the program could use [[OUT]] to change intensity settings of attributes 1 thru 5. - - -{{PageExamples}} -''Example:'' Displaying all 64 DAC color hues as backgrounds in SCREEN 9 using a PALETTE swap. - -{{CodeStart}} - {{Cl|SCREEN (statement)|SCREEN}} 9 ' background is default black - {{Cl|LOCATE}} 20, 33: {{Cl|PRINT}} "Press any Key!" - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 63 - a$ = {{Cl|INPUT$}}(1) ' wait for a keypress - {{Cl|PALETTE}} 0, i - {{Cl|NEXT}} -{{CodeEnd}} -:''Note:'' Other attributes (1 to 15) can also be swapped for DAC foreground colors. - - -{{PageSeeAlso}} -* [[_PALETTECOLOR]] -* [[PALETTE USING]] -* [[COLOR]] -* [[OUT]], [[INP]] -* [[SCREEN]] - - -{{PageNavigation}} diff --git a/internal/help/PALETTE_USING_1111111_11111.txt b/internal/help/PALETTE_USING_1111111_11111.txt deleted file mode 100644 index 2c88e52f1..000000000 --- a/internal/help/PALETTE_USING_1111111_11111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:00}} -The [[PALETTE USING]] statement sets all RGB screen color intensities using values from an [[Arrays|array]]. - - -{{PageSyntax}} -: [[PALETTE USING]] array%({{Parameter|startIndex%}}) - - -{{PageDescription}} -* The [[Arrays|array]] holds the RGB color value using the color value as {{InlineCode}}{{Parameter|red%}} + 256 * {{Parameter|green%}} + 65536 * {{Parameter|blue%}}{{InlineCodeEnd}}. -** Color intensities range from 0 to 63. -* {{Parameter|startIndex%}} indicates the index in the array from which the statement should start reading. The statement will read all color attributes available in that [[SCREEN (statement)|SCREEN]] mode. The '''number of values required''' in the array is listed below: -{{WhiteStart}}''' Screen mode Attributes Colors Values''' - 0 0 - 15 0 - 63 16 - 1 0 - 3 0 - 3 4 - 2 0 - 1 0 - 1 2 - 7 0 - 15 0 - 15 16 - 8 0 - 15 0 - 15 16 - 9 0 - 15 0 - 63 16 - 10 0 - 3 0 - 8 4 - 11 0 - 1 0 - 1 2 - 12 0 - 15 0 - 262,143 16 - 13 0 - 15 0 - 263,143 256 -{{WhiteEnd}} - -* A color argument of -1 in the array leaves the attribute unchanged. Other negative numbers are invalid. - - -{{PageSeeAlso}} -* [[PALETTE]], [[COLOR]] -* [[_PALETTECOLOR]] -* [[SCREEN (statement)]] - - -{{PageNavigation}} diff --git a/internal/help/PCOPY_11111.txt b/internal/help/PCOPY_11111.txt deleted file mode 100644 index 2d4d5c9c2..000000000 --- a/internal/help/PCOPY_11111.txt +++ /dev/null @@ -1,84 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:02}} -The [[PCOPY]] statement copies one source screen page to a destination page in memory. - - -{{PageSyntax}} -: [[PCOPY]] {{Parameter|sourcePage%}}, {{Parameter|destinationPage%}} - - -{{PageDescription}} -* {{Parameter|sourcePage%}} is an image page in video memory. -* {{Parameter|destinationPage%}} is the video memory location to copy the source image to. -* The working page is set as 0. All drawing occurs there. -* The visible page is set as any page number that the SCREEN mode allows. -* The [[_DISPLAY (function)]] return can be used a page number reference in '''QB64''' (See Example 1). -* The '''QB64''' [[_DISPLAY]] statement can also be used to stop screen flicker without page flipping or [[CLS]] and '''is the recommended practice'''. - - -==QBasic/QuickBASIC== -* {{Parameter|sourcePage%}} and {{Parameter|destinationPage%}} numbers are limited by the SCREEN mode used. In '''QB64''', the same limits don't apply. - - -{{PageExamples}} -''Example 1:'' Creating a mouse cursor using a page number that '''you create''' in memory without setting up page flipping. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) 'any graphics mode should work without setting up pages -{{Cl|_MOUSEHIDE}} -SetupCursor -{{Cl|PRINT}} "Hello World!" -{{Cl|DO}}: {{Cl|_LIMIT}} 30 - {{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}: {{Cl|LOOP}} 'main loop must contain _MOUSEINPUT -' other program code -{{Cl|LOOP}} - -{{Cl|SUB}} SetupCursor -{{Cl|ON TIMER(n)|ON TIMER}}(0.02) UpdateCursor -{{Cl|TIMER}} ON -{{Cl|END SUB}} - -{{Cl|SUB}} UpdateCursor -{{Cl|PCOPY}} {{Cl|_DISPLAY (function)|_DISPLAY}}, 100 'any page number as desination with the _DISPLAY function as source -{{Cl|PSET}} ({{Cl|_MOUSEX}}, {{Cl|_MOUSEY}}), {{Cl|_RGB}}(0, 255, 0) -{{Cl|DRAW}} "ND10F10L3F5L4H5L3" -{{Cl|_DISPLAY}} 'statement shows image -{{Cl|PCOPY}} 100, {{Cl|_DISPLAY (function)|_DISPLAY}} 'function return as destination page -{{Cl|END SUB}} -{{CodeEnd}} -:''Note:'' Works with [[_DISPLAY (function)]] as the other page. If mouse reads are not crucial, put the _MOUSEINPUT loop inside of the UpdateCursor Sub. - - -''Example 2:'' Bouncing balls -{{CodeStart}} - {{Cl|SCREEN (statement)|SCREEN}} 7, 0, 1, 0 - {{Cl|DIM}} x(10), y(10), dx(10), dy(10) - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} 10 - x(a) = {{Cl|INT}}({{Cl|RND}} * 320) + 1 - y(a) = {{Cl|INT}}({{Cl|RND}} * 200) + 1 - dx(a) = ({{Cl|RND}} * 2) - 1 - dy(a) = ({{Cl|RND}} * 2) - 1 - {{Cl|NEXT}} - {{Cl|DO...LOOP|DO}} - {{Cl|PCOPY}} 1, 0 'place image on the visible page 0 - {{Cl|CLS}} - {{Cl|_LIMIT}} 100 'regulates speed of balls in QB64 - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} 10 - {{Cl|CIRCLE}}(x(a), y(a)), 5, 15 'all erasing and drawing is done on page 1 - x(a) = x(a) + dx(a) - y(a) = y(a) + dy(a) - {{Cl|IF...THEN|IF}} x(a) > 320 {{Cl|THEN}} dx(a) = -dx(a): x(a) = x(a) - 1 - {{Cl|IF...THEN|IF}} x(a) < 0 {{Cl|THEN}} dx(a) = -dx(a): x(a) = x(a) + 1 - {{Cl|IF...THEN|IF}} y(a) > 200 {{Cl|THEN}} dy(a) = -dy(a): y(a) = y(a) - 1 - {{Cl|IF...THEN|IF}} y(a) < 0 {{Cl|THEN}} dy(a) = -dy(a): y(a) = y(a) + 1 - {{Cl|NEXT}} - {{Cl|DO...LOOP|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) ' escape exit -{{CodeEnd}} -:''Explanation:'' PCOPY reduces the flickering produced by clearing the screen. x(a) = x(a) - 1, etc. is just to be safe that the balls stay within the boundaries. dx(a) = -dx(a), etc. is to keep the actual speed while inverting it (so that the ball "bounces"). The rest should be self-explanatory, but if you are unsure about arrays you might want to look at QB64 Tutorials -> [[Arrays]]. - - -{{PageSeeAlso}} -* [[_DISPLAY]] -* [[SCREEN (statement)]] - - -{{PageNavigation}} diff --git a/internal/help/PEEK_1111.txt b/internal/help/PEEK_1111.txt deleted file mode 100644 index b3133a7c1..000000000 --- a/internal/help/PEEK_1111.txt +++ /dev/null @@ -1,68 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:03}} -The '''PEEK''' function returns the value that is contained at a certain memory address offset. '''QB64 currently has limited access!''' - - -{{PageSyntax}} -:: variable = PEEK(''segment_offset'') - - -* Reads the specified memory ''segment_offset'' value. -* Use [[DEF SEG]] before PEEK to specify which memory segment to work in. -* PEEK only reads the memory byte value. Not certain bits. (See [[AND]]) -* Important [[SCREEN (statement)|SCREEN]] segments using [[PEEK]] and [[POKE]] include &HB800 (text segment) and &HA000 (graphics segment). -* To return to Basic default segment use [[DEF SEG]] without any arguments. -* '''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.''' - - -''Example:'' Checking the 8 keyboard bit settings using a PEEK return value. -{{CodeStart}} - SCREEN 12 - {{Cl|DEF SEG}} = 0 ' BIOS area - oldvalue = PEEK(1047) ' IMPORTANT! save initial setting to reset later - DO: {{Cl|_LIMIT}} 100 - port = {{Cl|PEEK}}(1047) - IF port > 0 THEN LOCATE 26, 19: COLOR 11: - PRINT "Turn ALL Locks off to see each key's bit value!" - END IF - COLOR 14:LOCATE 2, 25 - PRINT "PEEK(1047) ="; port; "present keyboard port byte value" - LOCATE 5, 35 - IF (port {{Cl|AND}} 1) = 1 THEN COLOR 10: PRINT "R SHIFT PRESSED  " ELSE COLOR 12: PRINT "R SHIFT RELEASED" - LOCATE 7, 35 - IF (port AND 2) = 2 THEN COLOR 10: PRINT "L SHIFT PRESSED  " ELSE COLOR 12: PRINT "L SHIFT RELEASED" - LOCATE 9, 35 - IF (port AND 4) = 4 THEN COLOR 10: PRINT "CTRL KEY PRESSED " ELSE COLOR 12: PRINT "CTRL KEY RELEASED" - LOCATE 11, 35 - IF (port AND 8) = 8 THEN COLOR 10: PRINT "ALT KEY PRESSED " ELSE COLOR 12: PRINT "ALT KEY RELEASED" - LOCATE 13, 35 - IF (port AND 16) = 16 THEN COLOR 10: PRINT "SCROLL LOCK ON " ELSE COLOR 12: PRINT "SCROLL LOCK OFF" - LOCATE 15, 35 - IF (port AND 32) = 32 THEN COLOR 10: PRINT "NUMBER LOCK ON " ELSE COLOR 12: PRINT "NUMBER LOCK OFF" - LOCATE 17, 35 - IF (port AND 64) = 64 THEN COLOR 10: PRINT "CAPS LOCK ON " ELSE COLOR 12: PRINT "CAPS LOCK OFF" - LOCATE 19, 35 - IF (port AND 128) = 128 THEN COLOR 10: PRINT "INSERT MODE ON " ELSE COLOR 12: PRINT "INSERT MODE OFF" - COLOR 11: LOCATE 21, 20: PRINT "Press mode keys to change or [ESC] to quit!"; - LOOP UNTIL {{Cl|INP}}(&H60) = 1 ' escape key exit - {{Cl|POKE}} 1047, oldvalue ' IMPORTANT reset to original settings - {{Cl|DEF SEG}} -{{CodeEnd}} -: '''NOTE: Keyboard Port function key settings cannot be reset on NT machines!''' - - - -''See Example:'' [[SelectScreen]] (Screen 0 row highlighting) - - -''See also:'' -* [[POKE]] {{text|(write to memory)}}, [[INP]] {{text|(read register)}} -* [[DEF SEG]], [[VARSEG]], [[VARPTR]] -* [[_MEMGET (function)]], [[_MEMPUT]] -* [[DEF SEG = 0]], [[Scancodes]] {{text|(demo)}} -* [[PEEK and POKE Library]] -* [[Screen Memory]] - - -{{PageNavigation}} diff --git a/internal/help/PLAY_1111.txt b/internal/help/PLAY_1111.txt deleted file mode 100644 index 30a6dea66..000000000 --- a/internal/help/PLAY_1111.txt +++ /dev/null @@ -1,336 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:07}} -'''PLAY''' is a statement that plays notes of sound through the sound card in QB64 using a command [[STRING]]. - - -{{PageSyntax}} -::: '''PLAY ''commandstring$''''' - - -{{Parameters}} -* The ''commandstring'' can be any literal or variable [[STRING]] consisting of the following uppercase or lowercase commands: -:*'''O'''n - Sets the current octave (from 0 to 6). Example: '''{{text|PLAY "O3"|green}}''' -:*'''<''' - Down one octave (cannot be below zero). Example: '''{{text|PLAY "<<"|green}}''' 'goes down two octaves. -:*'''>''' - Up one octave (cannot be above 6). Example: '''{{text|PLAY ">>"|green}}''' ' goes up two octaves. -:*'''A''', '''B''', '''C''', '''D''', '''E''', '''F''' or '''G''' are the notes in the current octave. Can use the following suffixes: -::*'''+''' or '''#''' for a sharp note. Example: '''{{text|PLAY "C#"|green}}''' -::*'''-''' for a flat note. Example: '''{{text|PLAY "C-"|green}}''' -:*'''N'''n - Plays a note n by number(n can be between 0 to 84 in the 7 octaves, where 0 is a rest). Example: '''{{text|PLAY "N42"|green}}''' -:*'''L'''n - Sets length of a note (n can be 1 to 64 where 1 is a whole note and 4 is a quarter of a note etc.). Example: '''{{text|PLAY "L4"|green}}''' -::*'''MS''' - Each note plays 3/4 of length set by L (staccato) -::*'''MN''' - Each note plays 7/8 of length set by L (normal) -::*'''ML''' - Each note plays full length set by L (legato) -::*'''P'''n - Pause in the duration of n quarternotes (n can be 1 to 64) corresponding to L, Example: '''{{text|PLAY "P32"|green}}''' -::*'''T'''n - Tempo sets number of L4 quarter notes per minute (n can be 32 to 255 where 120 is the default). Example: '''{{text|PLAY "T180"|green}}''' -:::*''' . ''' - period after a note plays 1½ times the note length determined by L * T. -:::*'''.. ''' - two periods plays 1-3/4 times the note length determined by L * T. -:*''', ''' - '''commas in QB64''' stop play advancement to allow more than one note to be played simultaneously. Example: '''{{text|PLAY "C,E,G,"|green}}''' -:*'''V'''n - Volume in '''QB64 only''' can be any volume from 0(none) to 100(full). The default level is 50 when '''n''' is not specified. -:*'''MF''' - Play music in the foreground (each note must be completed before another can start). -:*'''MB''' - Play music in the background while program code execution continues (QB64 has no note buffer limits). -:*'''X''' '''+''' [[VARPTR$]](string-expression) - executes a command string variable. '''MUST be used with variables!'''. - - -''Usage:'' -* MB will allow music to play while program code progresses. MF will wait for code to continue playing notes. -* Command string values are not case sensitive and spacing is ignored. Use upper or lower case as desired. -*'''NOTE: In QB64, PLAY may NOT delay program progress! Use [[_DELAY]] and [[END]] to allow music completion.''' - - -''Example 1:'' Plays a sound with the volume and note varying from 0 to 50. Maximum note can only be 84. -{{CodeStart}} -{{Cl|PLAY}} "mll64" -{{Cl|DO}} - {{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} 50 - a$ = a$ + "v" + {{Cl|LTRIM$}}({{Cl|STR$}}(x)) + "n" + {{Cl|LTRIM$}}({{Cl|STR$}}(x)) - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} x = 50 {{Cl|TO}} 1 {{Cl|STEP}} -1 - a$ = a$ + "v" + {{Cl|LTRIM$}}({{Cl|STR$}}(x)) + "n" + {{Cl|LTRIM$}}({{Cl|STR$}}(x)) - {{Cl|NEXT}} - {{Cl|PLAY}} a$ - a$ = "" -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|PLAY}} "v10l1c,l4egl2o5c,o4l4eg" -{{CodeEnd}} -{{small|Code by Galleon}} - - -''Example 2:'' Plays "Frosty the snowman". The lyric printing is not delayed by PLAY in QB64. -{{CodeStart}} -CLS : PRINT "Frosty the Snow Man" -{{Cl|FOR...NEXT|FOR}} X = 1 {{Cl|TO}} 2 - PRINT - IF X = 1 THEN PRINT "Fros-ty the Snow man was a jolly happy soul," - IF X = 2 THEN PRINT "Fros-ty the Snow man knew the sun was hot that day" - {{Cl|PLAY}} "t140o2p4g2e4.f8g4o3c2o2b8o3c8d4c4o2b4a8g2." 'MB removed to print song one line at a time - IF X = 1 THEN PRINT "with a corn cob pipe and a button nose and two eyes made out of coal." - IF X = 2 THEN PRINT "so he said Let's run and we'll have some fun now before I melt away." - {{Cl|PLAY}} "o2b8o3c8d4c4o2b4a8a8g8o3c4o2e8e4g8a8g4f4e4f4g2." - IF X = 1 THEN PRINT "Fros-ty the Snow Man is a fair-y tale, they say," - IF X = 2 THEN PRINT "Down to the vil-lage, with a broom-stick in his hand," - {{Cl|PLAY}} "g2e4.f8g4o3c2o2b8o3c8d4c4o2b4a8g2." - IF X = 1 THEN PRINT "He was made of snow but the chil-dren knew how he come to life one day." - IF X = 2 THEN PRINT "run-ning here and there all a-round the square, say-in' catch me if you can." - {{Cl|PLAY}} "o2b8o3c8d4c4o2b4a8a8g8o3c4o2e8e4g8a8g4f4e4d4c2." - IF X = 1 THEN PRINT "There must have been some magic in that old silk hat they found." - IF X = 2 THEN PRINT "He led them down the streets of town right to the traffic cop." - {{Cl|PLAY}} "c4a4a4o3c4c4o2b4a4g4e4f4a4g4f4e2." - IF X = 1 THEN PRINT "For when they placed it on his head he be-gan to dance a round." - IF X = 2 THEN PRINT "And he on-ly paused a moment when he heard him hol-ler Stop!" - {{Cl|PLAY}} "e8e8d4d4g4g4b4b4o3d4d8o2b8o3d4c4o2b4a4g4p4" - IF X = 1 THEN PRINT "Oh, Fros-ty the Snow Man was a-live as he could be," - IF X = 2 THEN PRINT "For, Fros-ty the Snow Man had to hur-ry on his way" - {{Cl|PLAY}} "g2g2e4.f8g4o3c2o2b8o3c8d4c4o2b4a8g8g2." - IF X = 1 THEN PRINT "and the chil-dren say he could laugh and play just the same as you and me." - IF X = 2 THEN PRINT "but he waved good-bye say-in' Don't you cry, I'll be back a-gain some day." - {{Cl|PLAY}} "o2b8o3c8d4c4o2b4a8a8g8o3c4o2e8e4g8a8g4f4e4d4c2.p4" -NEXT X -PRINT : PRINT "Thump-et-y thump thump, thump-et-y thump thump, look at Fros-ty go." -{{Cl|PLAY}} "t180g8g8g4g4g4a8g8g4g4g4a4g4e4g4d1" -PRINT "Thump-et-y thump thump, thump-et-y thump thump, ov-er the hills of snow." -{{Cl|PLAY}} "t180g8g8g4g4g4a8g8g4g4g4g8g8g4a4b4o3c2c4p1" -{{Cl|END}} -{{CodeEnd}} -{{small|Greg Rismoen 12/09/84}} - - -''Example 3:'' Clicking on the grid enables various notes to be played simultaneously. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} grid(16, 16), grid2(16, 16), cur -{{Cl|CONST}} maxx = 512 -{{Cl|CONST}} maxy = 512 -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(maxx, maxy, 32) -{{Cl|_TITLE}} "MusicGrid" -cleargrid -{{Cl|DO}} - {{Cl|IF}} {{Cl|TIMER}} - t# > 1 / 8 {{Cl|THEN}} cur = (cur + 1) {{Cl|AND (boolean)|AND}} 15: t# = {{Cl|TIMER}} - {{Cl|IF}} cur <> oldcur {{Cl|THEN}} - figuregrid - drawgrid - playgrid - oldcur = cur - {{Cl|END IF}} - domousestuff - in$ = {{Cl|INKEY$}} - {{Cl|IF}} in$ = "C" {{Cl|OR (boolean)|OR}} in$ = "c" {{Cl|THEN}} cleargrid -{{Cl|LOOP}} {{Cl|UNTIL}} in$ = {{Cl|CHR$}}(27) - -{{Cl|SUB}} drawgrid -scale! = maxx / 16 -scale2 = maxx \ 16 - 2 -{{Cl|FOR...NEXT|FOR}} y = 0 {{Cl|TO}} 15 - y1 = y * scale! - {{Cl|FOR...NEXT|FOR}} x = 0 {{Cl|TO}} 15 - x1 = x * scale! - c& = {{Cl|_RGB32}}(grid2(x, y) * 64 + 64, 0, 0) - {{Cl|LINE}} (x1, y1)-(x1 + scale2, y1 + scale2), c&, BF - {{Cl|NEXT}} x -{{Cl|NEXT}} y -{{Cl|END SUB}} - -{{Cl|SUB}} figuregrid -{{Cl|FOR...NEXT|FOR}} y = 0 {{Cl|TO}} 15 - {{Cl|FOR...NEXT|FOR}} x = 0 {{Cl|TO}} 15 - grid2(x, y) = grid(x, y) - {{Cl|NEXT}} x -{{Cl|NEXT}} y -{{Cl|FOR...NEXT|FOR}} y = 1 {{Cl|TO}} 14 - {{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} 14 - {{Cl|IF}} grid(x, y) = 1 {{Cl|AND (boolean)|AND}} cur = x {{Cl|THEN}} - grid2(x, y) = 2 - {{Cl|IF}} grid(x - 1, y) = 0 {{Cl|THEN}} grid2(x - 1, y) = 1 - {{Cl|IF}} grid(x + 1, y) = 0 {{Cl|THEN}} grid2(x + 1, y) = 1 - {{Cl|IF}} grid(x, y - 1) = 0 {{Cl|THEN}} grid2(x, y - 1) = 1 - {{Cl|IF}} grid(x, y + 1) = 0 {{Cl|THEN}} grid2(x, y + 1) = 1 - {{Cl|END IF}} - {{Cl|NEXT}} x -{{Cl|NEXT}} y -{{Cl|END SUB}} - -{{Cl|SUB}} domousestuff -{{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - {{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} - x = {{Cl|_MOUSEX}} \ (maxx \ 16) - y = {{Cl|_MOUSEY}} \ (maxy \ 16) - grid(x, y) = 1 - grid(x, y) - {{Cl|END IF}} -{{Cl|LOOP}} -{{Cl|END SUB}} - -{{Cl|SUB}} playgrid -n$ = "L16 " -'scale$ = "O1CO1DO1EO1FO1GO1AO1BO2CO2DO2EO2FO2GO2AO2BO3CO3D" -scale$ = "o1fo1go1ao2co2do2fo2go2ao3co3do3fo3go3ao4co4do4fo" -{{Cl|FOR...NEXT|FOR}} y = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 - {{Cl|IF}} grid(cur, y) = 1 {{Cl|THEN}} - note$ = {{Cl|MID$}}(scale$, 1 + (15 - y) * 3, 3) - n$ = n$ + note$ + "," 'comma plays 2 or more column notes simultaneously - {{Cl|END IF}} -{{Cl|NEXT}} y -n$ = {{Cl|LEFT$}}(n$, {{Cl|LEN}}(n$) - 1) -{{Cl|PLAY}} n$ -{{Cl|END SUB}} - -{{Cl|SUB}} cleargrid -{{Cl|FOR...NEXT|FOR}} y = 0 {{Cl|TO}} 15 - {{Cl|FOR...NEXT|FOR}} x = 0 {{Cl|TO}} 15 - grid(x, y) = 0 - {{Cl|NEXT}} x -{{Cl|NEXT}} y -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by JP}} - - -''Example 4:'' Play strings starting with MB allow program code to run while music plays in background. -{{CodeStart}} -' 2012, 2013 mennonite -' license: creative commons cc0 1.0 universal -' (public domain) http://creativecommons.org/publicdomain/zero/1.0/ - -{{Cl|SCREEN}} 12 ' the following works in other screen modes, too -{{Cl|RANDOMIZE}} {{Cl|TIMER}} - -{{Cl|PLAY}} "mb l4cf.l8el4fag.l8fl4gl8agl4f.l8fl4a>cl2dl4dl4c.l4dc.dc.cl2dl4dc. 1 {{Cl|THEN}} - {{Cl|LINE}} ((gposxp - 1) * gscalep, (gposyp - 1) * gscalep)-{{Cl|STEP}}(gscalep - 1, gscalep - 1), pcolorp, BF - {{Cl|ELSE}}: - {{Cl|PSET}} (gposxp, gposyp), pcolorp - {{Cl|END IF}} - {{Cl|END IF}} - glocate gposyp, gposxp + 1 -{{Cl|NEXT}} p -gposxp = 1 -glocate gposyp + 1, 1 'gposyp = gposyp + 1 -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code by Mennonite}} - - -''Example 5:'' This example uses [[PRINT]] to good effect as string spacing is ignored by PLAY: -{{CodeStart}} -{{Cl|WIDTH}} 59, 28 -{{Cl|PRINT}} -x$ = x$ + " o3 l4 t 0120c mlc 1, mnf .e 8f am l< e1 ,g " -x$ = x$ + " 1, >c 1, mn g. f8 ga 8g 8m l< " -x$ = x$ + " f2.,a2., >c 2. ,m nf .f 8a mlc,mn >cd2.,d,f,mn>d ml >c .< " -x$ = x$ + " a8 af ml c1 ,< e1 ,g " -x$ = x$ + " " -x$ = x$ + " 1,m n> g.f8ga8g8m l< f1 " -x$ = x$ + " ,d1, " -x$ = x$ + " >f .d 8d c< f2 ., " -x$ = x$ + " a2 ., c2 .,>f2. ml < b- " -x$ = x$ + " ,> d, f, mn>dml > c. g .f8 gmld, f, mn " -x$ = x$ + " " -x$ = x$ + ">d ml < c2.,m n> c." -x$ = x$ + " c ,m n>" -x$ = x$ + " cm l< d 2. ,f 2." -x$ = x$ + " ,mn> d2.ml< d ,f ,m n>" -x$ = x$ + " dm l<c1,mn >c.g .f 8g a8 g8" -x$ = x$ + " ml << b- 1, >d 1, " -x$ = x$ + " f1 ,mn>f.d8dc l1 ml f, c, -{{Cl|PRINT}} x$; -{{Cl|PLAY}} x -{{CodeEnd}}{{small|Code by Luke}} - - -''See also:''' -* [[SOUND]], [[DRAW]] -* [[_SNDRAW]] (play frequency waves) -* [[_SNDOPEN]] (play sound files) - - -{{PageNavigation}} diff --git a/internal/help/PMAP_1111.txt b/internal/help/PMAP_1111.txt deleted file mode 100644 index 80a733295..000000000 --- a/internal/help/PMAP_1111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:09}} -The '''PMAP''' statement returns the physical or [[WINDOW]] view port coordinates. - - - -{{PageSyntax}} -:: PMAP (''coordinate'', ''function_number%'') - - -* The ''coordinate'' is the coordinate point to be mapped. -* The ''function'' can have one of four values: - -:: 0 = Maps view port coordinate to physical x screen coordinate -:: 1 = Maps view port coordinate to physical y screen coordinate -:: 2 = Maps physical screen coordinate to view port x coordinate -:: 3 = Maps physical screen coordinate to view port y coordinate - -* The four PMAP functions allow the user to find equal point locations between the view coordinates created with the [[WINDOW]] statement and the physical screen coordinates of the viewport as defined by the [[VIEW]] statement. -* Mouse co-ordinates returned by [[_MOUSEX]] and [[_MOUSEY]] are the physical screen co-ordinates. - - -''Example:'' Use PMAP to convert coordinate values from view to screen coordinates and from screen coordinates to view coordinates. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 - 'Coordinates of upper-left corner of the window is defined in following statement are (90,100) -{{Cl|WINDOW}} {{Cl|SCREEN (statement)|SCREEN}} (90, 100)-(200, 200) 'coordinates of lower-right 'corner are 200, 200. - -X = {{Cl|PMAP}}(90, 0) ' X = 0 -{{Cl|PRINT}} X -Y = {{Cl|PMAP}}(100, 1) ' Y = 0 -{{Cl|PRINT}} Y - -'These statements return the screen coordinates equal to the view coordinates 200, 200. -X = {{Cl|PMAP}}(200, 0) ' X = 639 -{{Cl|PRINT}} X -Y = {{Cl|PMAP}}(200, 1) ' Y = 479 -{{Cl|PRINT}} Y - -'These statements return the view coordinates equal to the screen coordinates 0, 0 -X = {{Cl|PMAP}}(0, 0) -{{Cl|PRINT}} X -Y = {{Cl|PMAP}}(0, 0) -{{Cl|PRINT}} Y - -'These statements return the view coordinates equal to the screen coordinates 639, 479. -X = {{Cl|PMAP}}(639, 2) ' X = 200 -{{Cl|PRINT}} X -Y = {{Cl|PMAP}}(479, 3) ' Y = 200 -{{Cl|PRINT}} Y - -{{Cl|SLEEP}} ' pause before clearing view port -{{Cl|CLS}} 1 ' clear grahic view port -{{Cl|WINDOW}} ' end graphic view port -{{Cl|END}} -{{CodeEnd}} -: ''Note:'' If physical screen coordinates are (0, 0) in the upper-left corner and (639, 479) in the lower-right corner, then the statements return the screen coordinate's equal to the view coordinates 90, 100. - - -''See also:'' -* [[WINDOW]], [[VIEW]] -* [[VIEW PRINT]] - - -{{PageNavigation}} diff --git a/internal/help/POINT_11111.txt b/internal/help/POINT_11111.txt deleted file mode 100644 index d0ac9a618..000000000 --- a/internal/help/POINT_11111.txt +++ /dev/null @@ -1,155 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:10}} -The '''POINT''' function returns the pixel [[COLOR]] attribute at a specified graphics coordinate or the current graphic cursor position. - - -''Color'' {{PageSyntax}} -::::color_attribute% = '''POINT ('''''column%, row%''''')''' - - -''Graphic cursor position'' {{PageSyntax}} -::::pointer_coordinate% = '''POINT('''{0|1|2|3}''')''' - - -{{Parameters}} - -Graphic Color syntax: -* The [[INTEGER]] ''column'' and ''row'' coordinates designate the pixel position color on the screen to read. -* The return value is an [[INTEGER]] palette attribute value or an [[_UNSIGNED]] [[LONG]] [[_RGBA]] 32 bit value in QB64. - - - -Graphic cursor position syntax: - -* The [[INTEGER]] position number can be 0 to 3 depending on the cursor position desired: -** POINT(0) returns the current graphic cursor [[SCREEN]] column pixel coordinate. -** POINT(1) returns the current graphic cursor [[SCREEN]] row pixel coordinate. -** POINT(2) returns the current graphic cursor [[WINDOW]] column position. -** POINT(3) returns the current graphic cursor [[WINDOW]] row position. -* If a [[WINDOW]] view port has not been established, the coordinate returned will be the [[SCREEN]] cursor pixel position. -* The return value is the current graphic cursor ''column'' or ''row'' pixel position on the [[SCREEN]] or [[WINDOW]]. -* Graphic cursor positions returned will be the last ones used in a graphic shape such as a [[CIRCLE]] center point. - - -''Usage:'' -* Use '''[[_SOURCE]]''' first to set the image handle that POINT should read or QB64 will assume the current source image. -:: '''{{text|_SOURCE 0|green}}''' 'sets POINT to read the current SCREEN image after reading a previous source image -* '''POINT cannot be used in SCREEN 0!''' Use the [[SCREEN (function)|SCREEN]] function to point text character codes and colors in SCREEN 0. - - -
'''POINT in QBasic Legacy Graphic SCREEN Modes:'''
-* The [[INTEGER]] color attributes returned are limited by the number of colors in the legacy SCREEN mode used. -* ''Column'' and ''row'' [[INTEGER]] parameters denote the graphic pixel coordinate to read. -* In '''QB64''' the offscreen or off image value returned is -1. Use IF POINT(x, y) <> -1 THEN... -* In QBasic the coordinates MUST be on the screen or an [[ERROR Codes|Illegal Function Call error]] will occur. - - -
'''POINT in QB64 32 Bit Graphic [[_NEWIMAGE]] or [[_LOADIMAGE]] Modes:'''
-* Returns [[_UNSIGNED]] [[LONG]] 32 bit color values. Use [[_UNSIGNED]] values when you don't want negative values. -* '''[[_UNSIGNED]] [[LONG]] variables should be used when comparing POINT returns with [[_RGB]] or [[_RGB32]] [[_ALPHA]] bit values''' -* Convert 32 bit color values to RGB intensities(0 to 255) using the [[_RED32]], [[_GREEN32]] and [[_BLUE32]] functions. -* To convert color intensities to OUT &H3C9 color port palette intensity values divide the values of 0 to 255 by 4. -* Use the [[_PALETTECOLOR (function)]] to convert color port palette intensities in 32 bit modes. - - -''Example 1:'' How [[_RGB]] 32 bit values return [[DOUBLE]] or [[_UNSIGNED]] [[LONG]] values in QB64. -{{CodeStart}} -{{Cl|DIM}} clr {{Cl|AS}} {{Cl|LONG}} 'DO NOT use LONG in older versions of QB64 (V .936 down) -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|CLS}} , {{Cl|_RGB}}(255, 255, 255) 'makes the background opaque white - -{{Cl|PRINT}} "POINT(100, 100) ="; {{Cl|POINT}}(100, 100) -clr = {{Cl|POINT}}(100, 100) -{{Cl|PRINT}} "Variable clr = "; clr -{{Cl|IF...THEN|IF}} clr = {{Cl|_RGB}}(255, 255, 255) {{Cl|THEN}} {{Cl|PRINT}} "Long OK" -{{Cl|IF...THEN|IF}} {{Cl|POINT}}(100, 100) = {{Cl|_RGB}}(255, 255, 255) {{Cl|THEN}} {{Cl|PRINT}} "_RGB OK" -{{Cl|IF...THEN|IF}} {{Cl|POINT}}(100, 100) = clr {{Cl|THEN}} {{Cl|PRINT}} "Type OK" 'will not print with a LONG variable type -{{CodeEnd}} -:'''Note:''' Change the [[DIM]] ''clr'' variable type to [[LONG]] to see how the last [[IF]] statement doesn't [[PRINT]] as shown in the output below: -{{OutputStart}}POINT(100, 100) = 4294967295 -Variable clr = -1 -Long OK -_RGB OK -{{OutputEnd}} - - - -''Example 2:'' Using a [[POINT]] mouse routine to get the 32 bit color values of the image. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|_TITLE}} "Mouse {{Cl|POINT}}er 32" - - -'{{Cl|LINE INPUT}} "Enter an image file: ", image$ 'use quotes around file names with spaces -image$ = "QB64bee.png" 'any 24/32 bit image up to 320 X 240 with current {{Cl|_PUTIMAGE}} settings -i& = {{Cl|_LOADIMAGE}}(image$, 32) -{{Cl|IF...THEN|IF}} i& >= -1 {{Cl|THEN}} {{Cl|BEEP}}: {{Cl|PRINT}} "Could {{Cl|NOT}} load image!": {{Cl|END}} -w& = {{Cl|_WIDTH (function)|_WIDTH}}(i&): h& = {{Cl|_HEIGHT}}(i&) - -{{Cl|PRINT}} "Make background transparent?(Y\N)"; -BG$ = {{Cl|UCASE$}}({{Cl|INPUT$}}(1)) -{{Cl|PRINT}} BG$ -{{Cl|_DELAY}} 1 - -'{{Cl|CLS}} 'commented to keep background alpha 0 - -{{Cl|IF...THEN|IF}} BG$ = "Y" {{Cl|THEN}} {{Cl|_CLEARCOLOR}} {{Cl|_RGB32}}(255, 255, 255), i& 'make white Background transparent -{{Cl|_PUTIMAGE}} (320 - w&, 240 - h&)-((2 * w&) + (320 - w&), (2 * h&) + (240 - h&)), i&, 0 -{{Cl|_FREEIMAGE}} i& - -{{Cl|_MOUSEMOVE}} 320, 240 'center mouse pointer on screen - -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 100 - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - mx = {{Cl|_MOUSEX}} - my = {{Cl|_MOUSEY}} - c& = {{Cl|POINT}}(mx, my) - r = {{Cl|_RED32}}(c&) - g = {{Cl|_GREEN32}}(c&) - b = {{Cl|_BLUE32}}(c&) - a = {{Cl|_ALPHA32}}(c&) - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} mx; my, "R:"; r, "G:"; g, "B:"; b, "A:"; a; " " - {{Cl|LOCATE}} 2, 2: {{Cl|PRINT}} "HTML Color: {{Cl|&H}}" + {{Cl|RIGHT$}}({{Cl|HEX$}}(c&), 6) - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' Use the mouse pointer to get the background RGB of the image to make it transparent with [[_CLEARCOLOR]]. - - -''Snippet:'' Creating an image mask to PUT an image over other colored backgrounds. See: [[GET and PUT Demo]] to run code. -{{TextStart}} - FOR c = 0 TO 59 '60 X 60 area from 0 pixel - FOR r = 0 TO 59 - IF {{Cb|POINT}}(c, r) = 0 THEN {{Cb|PSET}} (c, r), 15 ELSE PSET (c, r), 0 - NEXT r - NEXT c - {{Cb|GET (graphics statement)|GET}}(0, 0)-(60, 60), Image(1500) ' save mask in an array(indexed above original image). -{{CodeEnd}} - -:''Explanation:'' In the procedure all black areas(background) are changed to white for a PUT using AND over other colored objects. The other image colors are changed to black for a PUT of the original image using XOR. The array images can be {{KW|BSAVE}}d for later use. '''QB64 can also''' [[PUT]]''' a full screen 12 image from an array directly into a''' [[BINARY]] '''file.''' - - -''See Examples:'' - -* [[SAVEIMAGE]] (QB64 Image to Bitmap SUB by Galleon) - -* [[Program ScreenShots]] (Member program for legacy screen modes) - -* [[ThirtyTwoBit SUB]] (QB64 Image area to bitmap) - -* [[ThirtyTwoBit MEM SUB]] (Fast image area to Bitmap using [[_MEM]]) - - - -''See also:'' -* [[_NEWIMAGE]], [[_LOADIMAGE]] {{text|(see 32 bit modes)}} -* [[_MEMIMAGE]], [[_MEMGET]] -* [[PSET]], [[PRESET]] -* [[SCREEN]], [[SCREEN (function)]] {{text|(text pointer function)}} -* [[GET (graphics statement)]], [[PUT (graphics statement)]] -* [[Bitmaps]], [[Creating Sprite Masks]], [[Text Using Graphics]] (Demo) - - -{{PageNavigation}} diff --git a/internal/help/POKE_1111.txt b/internal/help/POKE_1111.txt deleted file mode 100644 index 36208a6e3..000000000 --- a/internal/help/POKE_1111.txt +++ /dev/null @@ -1,107 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:11}} -The '''POKE''' statement sets the value of a specified memory address offset. '''QB64 currently has limited access!''' - - -{{PageSyntax}} -:: POKE ''segment_offset'', ''offset_value'' - - -* Writes a value to the ''segment_offset'' address in memory. -* POKE can only be used to set a value from 0 to 255 (one byte). -* A segment should be defined using [[DEF SEG]], if you don't define a segment qbasics ordinary segment will be used. -* POKE sends byte values to memory areas. It does not directly access registers. -* Important [[SCREEN (statement)|SCREEN]] segments using [[PEEK]] and [[POKE]] include &HB800 (text segment) and &HA000 (graphics segment). -* [[DEF SEG]] should always be used to reset the default segment when access to other memory is no longer necessary. -* POKE is safer to use than [[OUT]] which could damage a PC register. -* '''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.''' - - -:''Example 1:'' Turning keyboard Lock and Insert modes on and off. -{{CodeStart}} - DEF SEG = 0 - oldsetting% = PEEK(1047) - POKE 1047,PEEK(1047) OR 16 ' ENABLES SCROLL LOCK - POKE 1047,PEEK(1047) OR 32 ' ENABLES NUMBER LOCK - POKE 1047,PEEK(1047) OR 64 ' ENABLES CAPS LOCK - POKE 1047,PEEK(1047) OR 128 ' ENABLES INSERT MODE - DEF SEG - -{{CodeEnd}} -:''Note: Use [[XOR]] instead of [[OR]] above to alternate between on and off modes.'' -{{CodeStart}} - {{Cl|DEF SEG}} = 0 - oldsetting% = {{Cl|PEEK}}(1047) - POKE 1047,PEEK(1047) AND 239 ' TURNS OFF SCROLL LOCK (239 = 255 - 16) - POKE 1047,PEEK(1047) AND 223 ' TURNS OFF NUMBER LOCK (223 = 255 - 32) - POKE 1047,PEEK(1047) AND 191 ' TURNS OFF CAPS LOCK (191 = 255 - 64) - POKE 1047,PEEK(1047) AND 127 ' TURNS OFF INSERT MODE (127 = 255 - 128) - {{Cl|DEF SEG}} -{{CodeEnd}} -:''Note: Using [[AND]] requires that the bit value is subtracted from 255 to turn off a bit.'' The above examples won't work in NT. - -:'''Warning: The keyboard lights may NOT change so it is a good idea to restore the original settings!''' - - -''Example 2:'' A small PEEK and POKE fractal program. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 13 -{{Cl|DEF SEG}} = {{Cl|&H}}A000 'set to read screen buffer -{{Cl|DO}} - {{Cl|FOR...NEXT|FOR}} a& = 0 {{Cl|TO}} 65535 - {{Cl|POKE}} a&, {{Cl|PEEK}}((a& * 2) {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&) + 1 - {{Cl|NEXT}} - {{Cl|_LIMIT}} 25 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|DEF SEG}} -{{CodeEnd}} - - -''Example 3:'' Highlighting a row of text in Screen 0 -{{CodeStart}} -minX = 20: maxX = 60: minY = 10: maxY = 24 -selection = 0 'the screen Y coordinate of the previously highlighted item -{{Cl|FOR}} i% = 1 {{Cl|TO}} 25: {{Cl|LOCATE}} i%, 40: {{Cl|PRINT}} i%;: {{Cl|NEXT}} -{{Cl|DO}}: {{Cl|_LIMIT}} 100 - {{Cl|IF}} {{Cl|_MOUSEINPUT}} {{Cl|THEN}} - 'Un-highlight any selected row - {{Cl|IF}} selection {{Cl|THEN}} selectRow selection, minX, maxX, 0 - x = {{Cl|CINT}}({{Cl|_MOUSEX}}) - y = {{Cl|CINT}}({{Cl|_MOUSEY}}) - {{Cl|IF}} x >= minX {{Cl|AND (boolean)|AND}} x <= maxX {{Cl|AND (boolean)|AND}} y >= minY {{Cl|AND (boolean)|AND}} y <= maxY {{Cl|THEN}} - selection = y - {{Cl|ELSE}} - selection = 0 - {{Cl|END IF}} - 'Highlight any selected row - {{Cl|IF}} selection {{Cl|THEN}} SelectRow selection, minX, maxX, 2 - {{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|LOCATE}} 1, 2: {{Cl|PRINT}} x, y, selection - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SUB}} SelectRow (y, x1, x2, col) -{{Cl|DEF SEG}} = {{Cl|&H}}B800 -addr& = (x1 - 1 + (y - 1) * {{Cl|_WIDTH (function)|_WIDTH}}) * 2 + 1 -{{Cl|FOR}} x = x1 {{Cl|TO}} x2 - oldCol = {{Cl|PEEK}}(addr&) {{Cl|AND (boolean)|AND}} {{Cl|&B}}10001111 ' Mask foreground color and blink bit - {{Cl|POKE}} addr&, oldCol {{Cl|OR}} ((col {{Cl|AND (boolean)|AND}} {{Cl|&B}}111) * {{Cl|&B}}10000) ' Apply background color - addr& = addr& + 2 -{{Cl|NEXT}} -{{Cl|END SUB}} -{{CodeEnd}} - - -''See Example:'' [[SelectScreen]] (Screen mode selection) - - -''See also:'' -* [[DEF SEG]], [[DEF SEG = 0]] {{text|(reference)}} -* [[PEEK]] {{text|(read memory)}}, [[OUT]] {{text|(write to register)}} -* [[VARSEG]], [[VARPTR]] -* [[_MEMGET (function)]], [[_MEMPUT]] -* [[Scancodes]] {{text|(demo)}}, [[Screen Memory]] -* [[PEEK and POKE Library]] - - -{{PageNavigation}} diff --git a/internal/help/POS_111.txt b/internal/help/POS_111.txt deleted file mode 100644 index cb6fab1f4..000000000 --- a/internal/help/POS_111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:12}} -The '''POS''' function returns the current print cursor text column position. - - -{{PageSyntax}} -:: column% = POS(0) - - -* The value in parenthesis is normally 0, but any numerical value or variable could be used for compatibility with Basic. -* When a semicolon ends the previous PRINT statement the cursor column position will be after the last character printed. -* If [[TAB]] or a comma is used the column position will be immediately after the tabbed position normally 9 spaces after text -* If a [[PRINT]] statement does not use a semicolon or comma at the end, the return value will be 1 on the next row. -* Column position returned can be saved to return to a previous print position later using [[LOCATE]]. - - -''Example:'' Column positions after prints. -{{CodeStart}} -{{Cl|PRINT}} {{Cl|POS}}(0) 'column position always starts on 1 at top of new or after {{Cl|CLS}} -{{Cl|PRINT}} "hello"; 'column position is 6 on same row immediately after text -{{Cl|PRINT}} {{Cl|POS}}(0) -{{Cl|PRINT}} 'start new row -{{Cl|PRINT}} "hello", 'column position is 15 on same row (normally tabs 9 spaces) -{{Cl|PRINT}} {{Cl|POS}}(0) -{{Cl|PRINT}} 'start new row -{{Cl|PRINT}} -{{Cl|PRINT}} {{Cl|POS}}(0) ' column position is 1 on next row -{{CodeEnd}} -''Note:'' Column tab prints may not always move 9 spaces past the center of the screen. Some may move text to next row. - - -''See also:'' -* [[CSRLIN]], [[LOCATE]], [[PRINT]] -* [[_PRINTSTRING]] {{text|(graphic position print)}} - - -{{PageNavigation}} diff --git a/internal/help/PRESET_111111.txt b/internal/help/PRESET_111111.txt deleted file mode 100644 index e6ea8bc40..000000000 --- a/internal/help/PRESET_111111.txt +++ /dev/null @@ -1,144 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:13}} -The '''PRESET''' graphic [[SCREEN]] statement turns a pixel at a coordinate to the background color or a designated color attribute. - - -{{PageSyntax}} -:: '''PRESET''' [STEP]'''('''''column%'', ''row%''''')'''[, colorAttribute] - - -''[[Parameters]]:'' -* Can use [[STEP]] when relative graphics coordinates are required. -* ''column'' and ''row'' coordinates can be literal ot variable [[INTEGER]] values which can be offscreen. -* If the ''colorAttribute'' is omitted, PRESET will use the current [[_DEST|destination]] page's [[_BACKGROUNDCOLOR]]. - - -''Usage:'' -* Color attributes are limited to those available in the [[SCREEN]] mode used. [[PSET]] can be used to adopt previously used colors. -* Any color value other than 0 will be white in monochrome [[SCREEN]] modes 2 and 11 where the [[COLOR]] statement cannot be used. -* PRESET can invisibly locate other graphics objects like [[CIRCLE]]s and add color to subsequent graphic objects and [[DRAW]] when used. -* The PRESET action can be used in a graphics [[PUT (graphics statement)|PUT]] to produce a color inverted image on any background. See Example 2. -* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates. -* '''PRESET can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!''' - - -''Example 1:'' Using PRESET to locate a [[DRAW]] statement that draws a box that is bright red. -{{CodeStart}} -SCREEN 12 -{{Cl|PRESET}}(100, 100) -{{Cl|DRAW}} "C12 U20 R20 D20 L20" -{{CodeEnd}} -:''Explanation:'' The [[DRAW]] string required a color designation as PRESET defaulted to the black background color. - - - -''Example 2:'' Displays the flags of countries that use simple horizontal or vertical color blocks with a highlighted arrow key menu. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} c$(21), x$(21), gg%(477) - -ARRAY -SETUP -SELECTION -TERMINATE - -{{Cl|END}} - -{{Cl|SUB}} ARRAY -c$(1) = "Armenia H040914" -c$(2) = "Austria H041504" -c$(3) = "Belgium V001404" -c$(4) = "Bulgaria H150204" -c$(5) = "Chad V011404" -c$(6) = "C“te D'Ivoire V061502" -c$(7) = "Estonia H090015" -c$(8) = "France V011504" -c$(9) = "Germany H000414" -c$(10) = "Hungary H041502" -c$(11) = "Ireland V021506" -c$(12) = "Italy V021504" -c$(13) = "Lithuania H140204" -c$(14) = "Luxembourg H041509" -c$(15) = "Mali V021404" -c$(16) = "Netherlands H041501" -c$(17) = "Nigeria V021502" -c$(18) = "Romania V091404" -c$(19) = "Russia H150104" -c$(20) = "Sierra Leone H021509" -c$(21) = "Yemen H041500" -{{Cl|END SUB}} - -{{Cl|SUB}} DISPLAY.FLAG (calc%) -f% = {{Cl|VAL}}({{Cl|MID$}}(x$(calc%), 2, 2)) -s% = {{Cl|VAL}}({{Cl|MID$}}(x$(calc%), 4, 2)) -t% = {{Cl|VAL}}({{Cl|MID$}}(x$(calc%), 6, 2)) - -{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(x$(calc%), 1) = "V" {{Cl|THEN}} - {{Cl|LINE}} (120, 225)-(253, 465), f%, BF - {{Cl|LINE}} (254, 225)-(385, 465), s%, BF - {{Cl|LINE}} (386, 225)-(519, 465), t%, BF -{{Cl|END IF}} - -{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(x$(calc%), 1) = "H" {{Cl|THEN}} - {{Cl|LINE}} (120, 225)-(519, 305), f%, BF - {{Cl|LINE}} (120, 306)-(519, 386), s%, BF - {{Cl|LINE}} (120, 387)-(519, 465), t%, BF -{{Cl|END IF}} -{{Cl|END SUB}} - -{{Cl|SUB}} SELECTION 'menu selection using arrow keys -x% = 2: y% = 4 - -DO - {{Cl|WHILE}} (x% <> prevx% {{Cl|OR (boolean)|OR}} y% <> prevy%) {{Cl|AND (boolean)|AND}} k$ <> {{Cl|CHR$}}(27) - k$ = {{Cl|INKEY$}} - x% = x% + (k$ = ({{Cl|CHR$}}(0) + "K") {{Cl|AND (boolean)|AND}} x% > 1) + {{Cl|ABS}}(k$ = ({{Cl|CHR$}}(0) + "M") {{Cl|AND (boolean)|AND}} x% < 3) - y% = y% + (k$ = ({{Cl|CHR$}}(0) + "H") {{Cl|AND (boolean)|AND}} y% > 1) + {{Cl|ABS}}(k$ = ({{Cl|CHR$}}(0) + "P") {{Cl|AND (boolean)|AND}} y% < 7) - calc% = (x% - 1) * 7 + y%: {{Cl|LOCATE}} 14, 18: {{Cl|PRINT}} c$(calc%); {{Cl|SPACE$}}(10) - x1% = 140 + (x% - 1) * 128 - x2% = x1% + {{Cl|LEN}}(c$(calc%)) * 8 + 7 - y1% = 48 + y% * 16 - {{Cl|IF...THEN|IF}} x1% <> prevx1% {{Cl|OR (boolean)|OR}} y1% <> prevy1% {{Cl|THEN}} - {{Cl|IF...THEN|IF}} g% {{Cl|THEN}} {{Cl|PUT (graphics statement)|PUT}}(prevx1%, prevy1%), gg%(), {{Cl|PSET}} - {{Cl|GET (graphics statement)|GET}}(x1%, y1%)-(x2%, y1% + 16), gg%(): g% = 1 - {{Cl|PUT (graphics statement)|PUT}}(x1%, y1%), gg%(), {{Cl|PRESET}} - prevx1% = x1%: prevx2% = x2%: prevy1% = y1% - DISPLAY.FLAG calc% - {{Cl|END IF}} - {{Cl|WEND}} -{{Cl|LOOP}} {{Cl|UNTIL}} k$ = {{Cl|CHR$}}(27) -{{Cl|END SUB}} - -{{Cl|SUB}} SETUP -{{Cl|SCREEN}} 12 -{{Cl|COLOR}} 6 -c% = 1 - -{{Cl|FOR...NEXT|FOR}} x% = 11 {{Cl|TO}} 50 {{Cl|STEP}} 16 - {{Cl|FOR...NEXT|FOR}} y% = 1 {{Cl|TO}} 7 - x$(c%) = {{Cl|RIGHT$}}(c$(c%), 7) - c$(c%) = {{Cl|RTRIM$}}({{Cl|LEFT$}}(c$(c%), {{Cl|LEN}}(c$(c%)) - 7)) - {{Cl|LOCATE}} y% + 4, x% + 8: {{Cl|PRINT}} c$(c%) - c% = c% + 1 -{{Cl|NEXT}} y%, x% - -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 3, 20: {{Cl|PRINT}} "Use the Cursor Keys to Select a Country:" -{{Cl|LINE}} (119, 224)-(520, 466), 7, B -{{Cl|END SUB}} - -{{Cl|SUB}} TERMINATE -{{Cl|FOR...NEXT|FOR}} c% = 1 {{Cl|TO}} 219 - {{Cl|LINE}} (116 + c%, 29 + c%)-(523 - c%, 469 - c%), 0, B -{{Cl|NEXT}} -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code by AlGoreIthm}} -: ''Explanation:'' Using the [[PUT (graphics statement)|PUT]] PRESET action highlights the menu selection in graphic screen modes by returning a negative image. - - -''See also:'' - -* [[PUT (graphics statement)]] -* [[GET (graphics statement)]] -* [[CIRCLE]], [[LINE]], [[PSET]] - - -{{PageNavigation}} diff --git a/internal/help/PRINT_(file_statement)_11111_(0000_000000000).txt b/internal/help/PRINT_(file_statement)_11111_(0000_000000000).txt deleted file mode 100644 index 0d1519fa0..000000000 --- a/internal/help/PRINT_(file_statement)_11111_(0000_000000000).txt +++ /dev/null @@ -1,78 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:16}} -The [[PRINT (file statement)|PRINT #]] statement prints numeric or string expressions to a sequential file, IO port or device. - - -{{PageSyntax}} -::: '''PRINT #''fileNumber&''''', [ [{{Parameter|expression}}] [{;|,] ... ] - - -{{Parameters}} -* {{Parameter|fileNumber&}} is the file number of a file or device opened for writing. See {{KW|OPEN}}. -* {{Parameter|expression}} is a numeric or string expression to be written to the file. Quotes will be removed from strings. -* The print statement can be followed by a [[semicolon]] to stop the print cursor or a [[comma]] to tab the next print. - - -''Usage:'' -* [[STRING]] values will be stripped of leading and trailing quotation marks when printed to the file. Use [[CHR$]](34) to add quotes to a file. -* {{Parameter|separator}} is used to separate multiple expressions and specifies how the file cursor is to be moved before writing the next expression. It can be one of the following: -** semi-colon (;) - specifies that the print cursor stop immediately after the print. A subsequent print will start there. -** comma (,) - specifies that the file cursor is to move to the next 14-column tab-stop. If the file cursor is at column 56 or greater, it is moved to the next file row at column 1. -* If {{Parameter|separator}} is not used at the end of the expression list, the file cursor moves to the next file row at column 1. -* PRINT # can use the '''+ concatenation''' operator or semicolons to combine strings. -* [[SPC]]({{Parameter|n%}}) - specifies that {{Parameter|n%}} space characters will be written in a print. -* [[TAB]]({{Parameter|column%}}) - specifies that the file cursor is to move to a column number {{Parameter|column%}}. If the file cursor is beyond that column, it is moved to that column on the next file row. -* When printing literal or variable numerical values the following rules apply: -** If the value is positive, the number is prefixed with a space character, otherwise, the number is prefixed with a negative sign (-). -** If the value is an [[INTEGER]] (whole number), no decimal point or fractional part will be written. -** If the value is not an integer (whole number) and has zero for a coefficient, no leading zero is written. For example, -0.123 is written as "-.123 " -** If a numeric literal is in scientific notation, the number is also written in scientific notation. [[PRINT USING (file statement)|PRINT #, USING]] can return actual rounded numerical values in string form. -** The numerical value is always followed by a space character unless [[STR$]] is used to convert it to a string value. -* Whenever [[PRINT (file statement)|PRINT #]] moves the file cursor to a new file row, a carriage return character ({{KW|CHR$|CHR$(13)}}) followed by a line feed character ({{KW|CHR$|CHR$(10)}}) is written. The combination are referred to as the "CRLF" character. -* '''Note: [[RANDOM]] and [[BINARY]] files are not affected by PRINT # statements to them and will create a syntax error in QB64!''' - - -''Example:'' Prints data to a text file sequentially and reads it back to the program screen as one line of text. -{{CodeStart}} -filename$ = "testfile.dat" -x = 1: y = 2: z$ = "Three" - -{{Cl|OPEN}} filename$ {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 'opens and clears an existing file or creates new empty file - -{{Cl|PRINT (file statement)|PRINT}} #1, x, y, z$ - -{{Cl|CLOSE}} #1 - -{{Cl|PRINT}} "File created with data. Press a key!" - -K$ = {{Cl|INPUT$}}(1) 'press a key - -{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #2 'opens a file to read it - -{{Cl|LINE INPUT (file statement)|LINE INPUT}} #2, text$ - -{{Cl|CLOSE}} #2 - -{{Cl|PRINT}} text$ -{{Cl|WRITE}} text$ - -{{Cl|END}} -{{CodeEnd}} -: ''File content:'' [[PRINT (file statement)|PRINT]] string file values will not include the enclosing quotation marks but can be read by [[LINE INPUT (file statement)|LINE INPUT]] as text. -{{TextStart}} 1 2 Three {{TextEnd}} -: ''Screen output:'' [[PRINT]] string values will not display enclosing quotation marks. [[WRITE]] screen displays will. -{{OutputStart}} 1 2 Three -" 1 2 Three" -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[SPC]], [[SPACE$]], [[TAB]] -* [[PRINT USING (file statement)|PRINT #, USING]] -* [[PRINT]] -* [[WRITE (file statement)|WRITE #]], [[INPUT (file statement)|INPUT #]] -* [[LINE INPUT (file statement)|LINE INPUT #]] -* [[OPEN]], [[LPRINT]], [[WRITE]] - - -{{PageNavigation}} diff --git a/internal/help/PRINT_11111.txt b/internal/help/PRINT_11111.txt deleted file mode 100644 index c0dd3022c..000000000 --- a/internal/help/PRINT_11111.txt +++ /dev/null @@ -1,89 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:15}} -The {{KW|PRINT}} statement prints numeric or string expressions to the program screen. Typing shortcut '''?''' will convert to PRINT. - - -{{PageSyntax}} -::: '''PRINT''' [{{Parameter|expression}}] [{;|,] [''expression''...] - - -{{Parameters}} -* {{Parameter|expression}} is a numeric or string expression or list of expressions to be written to the screen. End quotes will not be displayed in strings. -* The print statement can be followed by a [[semicolon]] to stop the print cursor or a [[comma]] to tab space the next print. - - -''Usage:'' -* [[STRING]] values will eliminate leading and trailing quotation marks when printed to the screen. Use [[CHR$]](34) to add quotes to the [[SCREEN]]. -* PRINT with no parameters moves the print cursor to the next print row at column 1. -* {{Parameter|expression}} is a numeric or string expression to be printed. -** [[SPACE$]]({{Parameter|n%}}) or [[SPC]]({{Parameter|n%}}) - specifies that {{Parameter|n%}} space characters will be printed. -** [[TAB]]({{Parameter|column%}}) - specifies that the print cursor is to move to column number {{Parameter|column%}}. If the print cursor is already beyond that column, it is moved to the designated column on the next row. -* A ''separator'' is used to separate multiple expressions and specifies how the print cursor is to be moved: -** [[Semicolon]](;) - specifies that the print cursor stops at the end of the printed ''expression'' and may append later ''expressions'' or prints. PRINT ; or PRINT ""; will stop cursor movement and append later prints. Ending [[semicolon]]s can also stop screen roll. -** [[Comma]](,) - specifies that the print cursor is to move to the next 14-column tab-stop. If the print cursor is at column 56 or greater, it is moved to the next row at column 1. When used after an ''expression'' it may Tab-stop append later prints. -** [[+|Plus]](+) uses [[concatenation]] to add [[STRING]] expressions ONLY with no spacing. '''Cannot combine numerical ''expression''s!''' -** If a {{Parameter|separator}} is not used at the end of the expression list, the print cursor moves to the next row at column 1. -* When '''printing numerical''' ''expressions'' values, the following rules are used: -** If the value is positive, the number is prefixed with a space character, otherwise, the number is prefixed with a negative sign (-). -** If the value is an integer (whole number), no decimal point or fractional part will be printed. -** If the value is not an [[INTEGER|integer]](whole number) and has zero for a coefficient, no leading zero is printed. EX: -0.123 prints "-.123 " -** If the expression is in [[scientific notation]], the number is also printed in scientific notation. -** The number is [[PRINT|printed]] with a space after it unless [[STR$]](number) is used to convert it to string text. -** Numerical values MUST be added to a PRINT statement string using [[comma]]s or [[semicolon]]s on each side of the value or by using [[STR$]] to convert the value to a string to use [[concatenation]] (+ string addition). -* [[VIEW PRINT]] can set up a viewport area for PRINTs. Text printed on the bottom view port row will scroll the text upward. -* Text to be printed can be a [[STRING]] variable or a literal value inside of quotation marks. -* Use [[semicolon]] ends on bottom 2 rows of the SCREEN mode used or the PRINT will roll the screen up. -* '''Quotes cannot be inside of a literal STRING! Use [[CHR$]](34) [[concatenation]] to insert [[quotation mark]]s into a literal string.''' -* To better format number and text data placement use {{KW|PRINT USING}}. -* Instead of typing PRINT you can just type a [[question mark]] (?). It will change to PRINT when enter is pressed in the IDE. -* Use the [[_PRINTMODE]] statement before a print to deal with the text background in '''QB64''': -:*'''1''' _KEEPBACKGROUND: Text background transparent. Only the text is displayed over anything behind it. -:*'''2''' _ONLYBACKGROUND: Text background is only displayed. Text is transparent to anything behind it. -:*'''3''' _FILLBACKGROUND: Text and background block anything behind them. Default setting. -:* Use the [[_PRINTMODE (function)]] to find the current _PRINTMODE setting number. -* [[WRITE]] can be used to print a list of comma separated data values to the screen with [[comma]]s between each value. -* Use [[_DEST]] [[_CONSOLE]] before PRINT statements to be used in a [[$CONSOLE|console]] window. -* Use [[_CONTROLCHR]] '''OFF''' to PRINT the unprintable lower [[ASCII]] control characters in QB64. - - -''Example 1:'' Using semicolons, comma tabs or concatenation to insert [[ASCII]] characters and numbers in a PRINT: -{{CodeStart}} -{{Cl|PRINT}} CHR$(34); "Hello world!"; CHR$(34) ' adding quotation marks -{{Cl|PRINT}} 123 'demonstrates the positive leading space -a$ = "Hello country!": a = 321: b = -321 -{{Cl|PRINT}} a$, a ' demonstrates comma in statement -{{Cl|PRINT}} a$; a ' demonstrates semicolon in statement -{{Cl|PRINT}} a$ + {{Cl|STR$}}(b) ' concatenation of string numerical values only -? "Hello city!" ' a ? changes to PRINT after moving cursor from the code line in IDE -{{CodeEnd}} -{{OutputStart}}"Hello world!" - 123 -Hello country! 321 -Hello country! 321 -Hello country!-321 -Hello city! -{{OutputEnd}} -:First PRINT prints the text between two quotation marks, then it prints the value 123, notice that there are no quotation marks when printing the value, quotation marks mean that it will be treated like a literal string of text. a$ is set to "Hello country" and 'a' is set to the value 321, the dollar sign is used when a variable holds the text string. The contents of a$ is then printed and the "," means that the value of 'a' is printed separated by a tab and ";" means that there is no separation from the other text except for the leading positive value space. - - -''Example 2:'' Changing colors in a line of text using semicolons with colon separators between PRINTs on the same code line. -{{CodeStart}} -{{Cl|COLOR}} 12: {{Cl|PRINT}} "Start red "; : {{Cl|COLOR}} 10: {{Cl|PRINT}} "and end green." -{{Cl|COLOR}} 11: {{Cl|PRINT}} "Start aqua "; -{{Cl|COLOR}} 14: {{Cl|PRINT}} "and end blue." -{{CodeEnd}} -{{OutputStart}}{{text|Start red|#FF1515}} {{text|and end green.|#15FF15}} -{{text|Start aqua|#15FFFF}} {{text|and end blue.|#0000FF}} {{OutputEnd}} - - -{{PageSeeAlso}} -* [[_PRINTMODE]], [[_PRINTSTRING]], [[PRINT USING]] -* [[SPC]], [[TAB]], [[SPACE$]], [[SCREEN]] -* [[CSRLIN]], [[POS]], [[SCREEN (function)]] -* [[COLOR]], [[LOCATE]], [[VIEW PRINT]] -* [[INPUT]], [[STR$]], [[CHR$]] -* [[ASCII]] (character codes), [[_CONTROLCHR]] -* [[Text Using Graphics]] (Demo) - - -{{PageNavigation}} diff --git a/internal/help/PRINT_USING_(file_statement)_11111_11111_(0000_000000000).txt b/internal/help/PRINT_USING_(file_statement)_11111_11111_(0000_000000000).txt deleted file mode 100644 index cb28a87d8..000000000 --- a/internal/help/PRINT_USING_(file_statement)_11111_11111_(0000_000000000).txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:18}} -The '''PRINT #, USING''' statement is used to [[PRINT]] formatted text data to a file. - - - -{{PageSyntax}} -:: '''PRINT ''filenumber%,''''' [''text$''{;|,}] '''USING ''template$''; ''variable'''''[; ...][{;|,}] - - -{{Parameters}} -* [[INTEGER]] ''filenumber'' refers to the file number [[OPEN]]ed previously followed by a [[comma]]. -* Literal or variable [[STRING]] ''text$'' can be placed between PRINT and USING or it can be included in the ''template''. -* A [[semicolon]] or [[comma]] may follow the ''text'' to stop or tab the print cursor before the ''template'' [[PRINT]]. -* The literal or variable [[STRING]] ''template'' should use the template symbols to display each variable [[type]] in the list following it. -* The list of data ''variables'' used in the ''template'' are '''separated by semicolons''' after the template string value. -* In '''QB64''' ONE [[semicolon]] or [[comma]] may follow the variable list to stop the print cursor for pending prints. QB only allowed a semicolon. - - -''Usage:'' -* '''If the ''template'' string is omitted or symbols don't match the ''variable(s)'' an "Illegal Function Call" [[ERROR Codes|ERROR]] will occur!''' -* The list of data variables used in the template are '''separated by semicolons''' after the template string value. -* The variables should be listed in the order that they are used in the template from left to right. -* Normal text is allowed in the template also (see example). -* '''NOTE:''' If the numerical value exceeds the template's integer digit range a % symbol will appear in the leftmost digit area. -* '''WARNING: The numbers displayed are rounded so the actual values are never changed and are actually more accurate.''' - - -{{PrintUsingTable}} - - -''See also:'' -* [[PRINT USING]], [[PRINT (file statement)|PRINT #]] -* [[LPRINT USING]] - - -{{PageNavigation}} diff --git a/internal/help/PRINT_USING_11111_11111.txt b/internal/help/PRINT_USING_11111_11111.txt deleted file mode 100644 index 6f56dec25..000000000 --- a/internal/help/PRINT_USING_11111_11111.txt +++ /dev/null @@ -1,87 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:17}} -The '''PRINT USING''' statement is used to [[PRINT]] formatted data to the Screen using a [[STRING]] template. - - -{{PageSyntax}} -:: '''PRINT''' [''text$''{;|,}] '''USING''' ''template$''; ''variable''[; ...][{;|,}] - - -{{Parameters}} -* Literal or variable [[STRING]] ''text$'' can be placed between PRINT and USING or it can be included in the ''template''. -* A [[semicolon]] or [[comma]] may follow the ''text'' to stop or tab the print cursor before the ''template'' [[PRINT]]. -* The literal or variable [[STRING]] ''template'' should use the template symbols to display each variable [[type]] in the list following it. -* The list of data ''variables'' used in the ''template'' are '''separated by semicolons''' after the template string value. -* In '''QB64''' ONE [[semicolon]] or [[comma]] may follow the variable list to stop the print cursor for pending prints. QB only allowed a semicolon. - - -''Usage:'' -* The ''variables'' should be listed in the order that they are used in the template from left to right. -* '''If the ''template'' string is omitted or symbols don't match the ''variable(s)'' an "Illegal Function Call" [[ERROR Codes|ERROR]] will occur!''' -* No more than 25 # digit places are allowed in a template number or an [[ERROR Codes|error]] will occur. -* Can convert numerical exponential or [[scientific notation]] values to normal decimal point values using less digits. -* '''NOTE:''' If the numerical value exceeds the template's digit range a % symbol will appear in the leftmost digit area. -* '''WARNING: The numbers displayed are rounded so the actual values are never changed and are actually more accurate.''' - - -{{PrintUsingTable}} - - -''Example 1:'' Printing formatted data using a predefined [[STRING|string]] template variable. -{{CodeStart}} -first$ = "Bobby": last$ = "Smith" -boxes% = 1510: sales! = 4530 -tmp$ = "Salesperson: & & #####,. $$#####,.##" - -{{Cl|PRINT USING}} tmp$; first$; last$; boxes%; sales! -{{CodeEnd}} -{{OutputStart}}Salesperson: Bobby Smith 1,510 $4,530.00 -{{OutputEnd}} -''Explanation:'' The ''Salesperson:'' text precedes the formatted data. The name lengths will change the length of the string template accordingly so columns will not all line up. If \ \ was used, the columns would stay the same, but parts of some names might be lost. If the box or sales values exceed 3 digits, a comma is used in the value every 3 digits. - - -''Example 2:'' How to display formatting symbols as normal text using underscores in a PRINT USING template. -{{CodeStart}} -errcode = 35 -{{Cl|PRINT USING}} "Error ## occurred!!"; errcode -'now there are the !! at the end of the printed string -{{Cl|PRINT USING}} "Error ## occurred_!_!"; errcode -{{Cl|END}} '' -{{CodeEnd}} -{{OutputStart}}Error 35 occurred -Error 35 occurred!! -{{OutputEnd}} -: ''Explanation:'' The first template will not print the exclamation points or error when the requested text parameters are omitted. - - -''Example 3:'' Exponential notation is designated after the leading digits are formatted. Digit places determine rounded value displayed. -{{CodeStart}} -{{Cl|PRINT USING}} "##.##^^^^"; 234.56 -{{Cl|PRINT USING}} ".####^^^^-"; -777777 -{{Cl|PRINT USING}} "+.##^^^^"; 123 -{{Cl|PRINT USING}} "+.##^^^^^"; 123 -{{CodeEnd}} -{{OutputStart}} 2.35E+02 -.7778E+06- -+.12E+03 -+.12E+003 -{{OutputEnd}} -: ''Explanation:'' Note how 5 carets in the bottom format expands the number of exponent digits to accommodate larger exponent values. - - -''Example 4:'' USING does not necessarily have to immediately follow PRINT, but it must follow it in the code line. -{{CodeStart}} -money = 12345.45 -tmp$ = "$$#######,.##" - -{{Cl|PRINT}} "I have this much money!"; {{Cl|PRINT USING|USING}} tmp$; money -{{CodeEnd}} -: ''Note:'' This can also be used to print the USING formatting characters outside of the template. - - -''See also:'' -* [[PRINT]], [[PRINT USING (file statement)|PRINT #, USING]] -* [[LPRINT]], [[LPRINT USING]] - - -{{PageNavigation}} diff --git a/internal/help/PSET_1111.txt b/internal/help/PSET_1111.txt deleted file mode 100644 index 2f15bb63c..000000000 --- a/internal/help/PSET_1111.txt +++ /dev/null @@ -1,161 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:19}} -The '''PSET''' grahics [[SCREEN (statement)|SCREEN]] statement sets a pixel to a coordinate with a default or designated color attribute. - - -{{PageSyntax}} -:: '''PSET''' [STEP]'''('''''column%'', ''row%''''')'''[, ''colorAttribute''] - - -''[[Parameters]]:'' -* Can use [[STEP]] relative graphics coordinates from a previous graphic object. -* ''Column'' and ''row'' can be literal or variable [[INTEGER]] coordinates values which can be offscreen. -* If the ''colorAttribute'' is omitted, PSET will use the current [[_DEST|destination]] page's _DEFAULTCOLOR. - - -''Usage:'' -* ''Color attributes'' are limited to the SCREEN mode used. Any color value other than 0 will be white in [[SCREEN (statement)|SCREEN]]s 2 or 11. -* PSET can locate other graphics objects and color [[DRAW]] statements. -* The PSET action can be used in a graphics [[PUT (graphics statement)|PUT]] to produce an identical image on any background. -* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates. -* '''PSET can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only! (Or in any _NEWIMAGE(x, y, 0) screens which are text only as well.)''' - - -''Example:'' Using PSET to locate and color a [[DRAW]] statement. -{{CodeStart}} -SCREEN 12 -{{Cl|PSET}}(100, 100), 12 -{{Cl|DRAW}} "U20 R20 D20 L20" -{{CodeEnd}} -:''Screen results:'' A drawn box that is bright red. - - -''Example 2:'' Magnifying a box portion of a Mandelbrot image with PSET -{{CodeStart}} -{{Cl|DEFSTR}} A-Z -{{Cl|DIM}} red(15) {{Cl|AS}} {{Cl|INTEGER}}, green(15) {{Cl|AS}} {{Cl|INTEGER}}, blue(15) {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} i {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|SCREEN}} 12 -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 15: {{Cl|READ}} red(i): {{Cl|NEXT}} -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 15: {{Cl|READ}} green(i): {{Cl|NEXT}} -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 15: {{Cl|READ}} blue(i): {{Cl|NEXT}} -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 15: {{Cl|PALETTE}} i, 65536 * blue(i) + 256& * green(i) + red(i): {{Cl|NEXT}} -{{Cl|DATA}} 0,63,63,63,63,63,31, 0, 0,31,31,31,47,63,63,63 -{{Cl|DATA}} 0, 0,15,31,47,63,63,63,63,31,15, 0, 0, 0, 0, 0 -{{Cl|DATA}} 0, 0, 0, 0, 0, 0, 0, 0,31,63,63,63,63,63,42,21 - -{{Cl|DIM}} dmag {{Cl|AS}} {{Cl|INTEGER}}, dlogmag {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} a {{Cl|AS}} {{Cl|DOUBLE}}, b {{Cl|AS}} {{Cl|DOUBLE}}, mag {{Cl|AS}} {{Cl|DOUBLE}} -{{Cl|DIM}} dx {{Cl|AS}} {{Cl|INTEGER}}, dy {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} mx {{Cl|AS}} {{Cl|INTEGER}}, my {{Cl|AS}} {{Cl|INTEGER}}, mz {{Cl|AS}} {{Cl|INTEGER}} - -dmag = 16 -mag = 1 - -a = -.75 -b = 0 -DO - {{Cl|DIM}} limitx {{Cl|AS}} {{Cl|DOUBLE}}, limit {{Cl|AS}} {{Cl|INTEGER}} - {{Cl|DIM}} inc {{Cl|AS}} {{Cl|DOUBLE}}, left {{Cl|AS}} {{Cl|DOUBLE}}, top {{Cl|AS}} {{Cl|DOUBLE}} - - limitx = 150 * ({{Cl|LOG}}(mag) + 1) - {{Cl|IF...THEN|IF}} limitx > 32767 {{Cl|THEN}} limitx = 32767 - limit = {{Cl|INT}}(limitx) - inc = .004 / mag - left = a - inc * 319 - top = b + inc * 239 - {{Cl|CLS}} - - {{Cl|DIM}} yy {{Cl|AS}} {{Cl|INTEGER}}, xx {{Cl|AS}} {{Cl|INTEGER}} - {{Cl|DIM}} x {{Cl|AS}} {{Cl|DOUBLE}}, y {{Cl|AS}} {{Cl|DOUBLE}}, z {{Cl|AS}} {{Cl|INTEGER}} - - {{Cl|FOR...NEXT|FOR}} yy = 0 {{Cl|TO}} 479 - y = top - inc * yy - {{Cl|FOR...NEXT|FOR}} xx = 0 {{Cl|TO}} 639 - x = left + inc * xx - z = mandel(x, y, limit) - {{Cl|IF...THEN|IF}} z < limit {{Cl|THEN}} {{Cl|PSET}} (xx, yy), 1 + z {{Cl|MOD}} 15 - {{Cl|IF...THEN|IF}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) {{Cl|THEN}} {{Cl|SYSTEM}} - {{Cl|NEXT}} - {{Cl|NEXT}} - mz = 0 - {{Cl|CALL}} readmouse(mx, my, mz) - DO - dx = 319 \ dmag - dy = 239 \ dmag - {{Cl|CALL}} readmouse(mx, my, mz) - {{Cl|IF...THEN|IF}} mz {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|CALL}} rectangle(mx - dx, my - dy, mx + dx, my + dy) - {{Cl|DIM}} t {{Cl|AS}} {{Cl|DOUBLE}} - t = {{Cl|TIMER}} - {{Cl|WHILE}} t = {{Cl|TIMER}} - key$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} key$ - {{Cl|CASE}} {{Cl|CHR$}}(27) - {{Cl|SYSTEM}} - {{Cl|CASE}} {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) - dmag = dmag \ 2 - {{Cl|IF...THEN|IF}} dmag < 2 {{Cl|THEN}} dmag = 2 - {{Cl|CASE}} {{Cl|CHR$}}(0) + {{Cl|CHR$}}(80) - dmag = dmag * 2 - {{Cl|IF...THEN|IF}} dmag > 128 {{Cl|THEN}} dmag = 128 - {{Cl|END SELECT}} - {{Cl|WEND}} - {{Cl|CALL}} rectangle(mx - dx, my - dy, mx + dx, my + dy) - {{Cl|LOOP}} - a = a + inc * (mx - 319): b = b - inc * (my - 239) - {{Cl|IF...THEN|IF}} (mz = 1) {{Cl|THEN}} mag = dmag * mag {{Cl|ELSE}} mag = mag / dmag - {{Cl|IF...THEN|IF}} (mag < 1) {{Cl|THEN}} mag = 1 -{{Cl|LOOP}} - -{{Cl|FUNCTION}} mandel% (x {{Cl|AS}} {{Cl|DOUBLE}}, y {{Cl|AS}} {{Cl|DOUBLE}}, limit {{Cl|AS}} {{Cl|INTEGER}}) - {{Cl|DIM}} a {{Cl|AS}} {{Cl|DOUBLE}}, b {{Cl|AS}} {{Cl|DOUBLE}}, t {{Cl|AS}} {{Cl|DOUBLE}} - {{Cl|DIM}} n {{Cl|AS}} {{Cl|INTEGER}} - n = 0: a = 0: b = 0 - DO - t = a * a - b * b + x - b = 2 * a * b + y: a = t - n = n + 1 - {{Cl|LOOP}} {{Cl|UNTIL}} a * a + b * b > 4 {{Cl|OR (boolean)|OR}} n > limit - mandel = n -{{Cl|END FUNCTION}} - -{{Cl|SUB}} readmouse (x {{Cl|AS}} {{Cl|INTEGER}}, y {{Cl|AS}} {{Cl|INTEGER}}, z {{Cl|AS}} {{Cl|INTEGER}}) -z=0 -DO -if {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} z = z {{Cl|OR (boolean)|OR}} 1 -if {{Cl|_MOUSEBUTTON}}(2) {{Cl|THEN}} z = z {{Cl|OR (boolean)|OR}} 2 -if {{Cl|_MOUSEBUTTON}}(3) {{Cl|THEN}} z = z {{Cl|OR (boolean)|OR}} 4 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_MOUSEINPUT}}=0 -x={{Cl|_MOUSEX}} -y={{Cl|_MOUSEY}} -{{Cl|END SUB}} - -{{Cl|SUB}} rectangle (x1 {{Cl|AS}} {{Cl|INTEGER}}, y1 {{Cl|AS}} {{Cl|INTEGER}}, x2 {{Cl|AS}} {{Cl|INTEGER}}, y2 {{Cl|AS}} {{Cl|INTEGER}}) - {{Cl|DIM}} i {{Cl|AS}} {{Cl|INTEGER}}, j {{Cl|AS}} {{Cl|INTEGER}} - {{Cl|FOR...NEXT|FOR}} i = x1 {{Cl|TO}} x2 - j = {{Cl|POINT}}(i, y1) - {{Cl|PSET}} (i, y1), j {{Cl|XOR (boolean)|XOR}} 15 - j = {{Cl|POINT}}(i, y2) - {{Cl|PSET}} (i, y2), j {{Cl|XOR (boolean)|XOR}} 15 - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} i = y1 {{Cl|TO}} y2 - j = {{Cl|POINT}}(x1, i) - {{Cl|PSET}} (x1, i), j {{Cl|XOR (boolean)|XOR}} 15 - j = {{Cl|POINT}}(x2, i) - {{Cl|PSET}} (x2, i), j {{Cl|XOR (boolean)|XOR}} 15 - {{Cl|NEXT}} -{{Cl|END SUB}} -{{CodeEnd}} {{small|Code by Codeguy}} -: ''Notes:'' Left click, to zoom in on the rectangle. Right click, to zoom out. Up arrow makes the rectangle bigger and down arrow makes the rectangle smaller. - - -''See also:'' -* [[PRESET]], [[CIRCLE]], [[LINE]] -* [[COLOR]], [[POINT]] -* [[PUT (graphics statement)]] -* [[GET (graphics statement)]] -* [[Text Using Graphics]] (Demo) - - -{{PageNavigation}} diff --git a/internal/help/PUT_(TCP%2FIP_statement)_111_(111%2111_000000000).txt b/internal/help/PUT_(TCP%2FIP_statement)_111_(111%2111_000000000).txt deleted file mode 100644 index 7d5598e50..000000000 --- a/internal/help/PUT_(TCP%2FIP_statement)_111_(111%2111_000000000).txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:22}} -The '''PUT #''' TCP/IP statement sends unformatted(raw) data to an open connection using a user's handle. - - -{{PageSyntax}} -:: '''PUT ''#handle'', , ''data'' ''' - - -{{Parameters}} -* The ''handle'' value is returned by the [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]] '''QB64''' functions. -* The ''data'' can be any variable type value. Literal values are not allowed. - - -
'''Communicating using unformatted/raw streamed data:'''
-* Benefit: Communicate with any TCP/IP compatible protocol (eg. FTP, HTTP, web-pages, etc) -* Disadvantage: Streamed data has no 'message length' as such, just a continuous bunch of bytes all in a row. Some messages get fragmented and parts of messages can (and often do) arrive at different times. -* The position parameter (between the commas) is not used in TCP/IP statements as all data is streamed consecutively. -
'''Your program MUST cater for these situations manually.'''
- -{{WhiteStart}}''Example: string variable b$'s length is adjusted to the number of bytes read.'' - - {{Cb|PUT (TCP/IP statement)|PUT #}}client, , a$ 'sends data (this could be a string, variable array, user defined type, etc) - {{Cb|GET (TCP/IP statement)|GET #}}openconn, , b$ 'reads any available data into variable length string b$ - {{Cb|GET (TCP/IP statement)|GET #}}openconn, , x% 'reads 2 bytes of data as an integer value. -{{WhiteEnd}} -: ''Explanation:'' Checking [[EOF]](o) is unnecessary. If 2 bytes are available, they are read into x%, if not then nothing is read and [[EOF]](o) will return -1 - - - - -''See the example in [[_OPENCLIENT]]'' - - -''See also:'' -* [[GET (TCP/IP statement)]], [[PUT|PUT #]] -* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] - - -{{PageNavigation}} diff --git a/internal/help/PUT_(graphics_statement)_111_(00000000_000000000).txt b/internal/help/PUT_(graphics_statement)_111_(00000000_000000000).txt deleted file mode 100644 index 2441ceba1..000000000 --- a/internal/help/PUT_(graphics_statement)_111_(00000000_000000000).txt +++ /dev/null @@ -1,92 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:23}} -The '''PUT''' graphics statement is used to place [[GET (graphics statement)|GET]] or [[BSAVE]] file images stored in the designated array. - - -{{PageSyntax}} - -:: '''PUT''' [{{KW|STEP}}]'''(''column'', ''row''), Array('''[''index'']''')'''[,] [{{KW|_CLIP}}] [{PSET|PRESET|AND|OR|XOR}]][, ''omitcolor''] - - -''[[Parameters]]:'' -* The [[STEP]] keyword can be used to for coordinates relative to the last graphic coordinates used. -* ''column'' and ''row'' [[INTEGER]] coordinate values designate the top left corner where the image is to be placed and cannot be off screen. -* The [[INTEGER]] ''array'' holds data of an image box area created by [[GET (graphics statement)|GET]]. The brackets can be empty or designate a starting ''index''. -* [[_CLIP]] can be used in QB64 when part of an image must be off screen. -* [[XOR]], [[PSET]], [[PRESET]], [[OR]] or [[AND]] actions will affect the coloring of the image on certain background colors. See below. -* ''omitcolor'' is the pixel color attribute to ignore in QB64 only. This may be used instead of using an [[AND]] mask. - - -''Usage:'' -* '''The entire box area of the image MUST be on the screen or an "Illegal function call" [[ERROR Codes|error]] will occur!''' -* In '''QB64''' [[_CLIP]] can be used when part of the image may be off of the screen. This will also prevent off screen errors! -::PUT (-10, 10), mypic(0), PSET ' this causes an illegal function call without [[_CLIP]] -::PUT (-10, 10), mypic(0), _CLIP PSET ' allows a graphic to be placed partially off-screen -::PUT (-10, 10), mypic(0), _CLIP ' uses the default PUT XOR operation -::PUT (-10, 10), mypic(0), _CLIP PSET, 4 ' doesn't place the red pixels of the image -* In '''QB64''' a background color attribute can be removed from the PUT image using the ''omit color'' option instead of creating a mask. -* The [[arrays|array]] must have image data at the array index given. [[GET (graphics statement)|GET]] or [[BLOAD]] should be used to place image data into the array. -* The [[INTEGER]] array size can be calculated as slightly larger than the box area width times the height. A closer estimate can be done by reading the array indices from [[UBOUND]] to [[LBOUND]] after a [[GET (graphics statement)|GET]] of a white box area. In QB64 a [[LONG]] array can be used for large or full screen images. -* If no [[arrays|array]] index (brackets optional in QB) is designated, the image will be assumed to be at the array's starting index. -* The first two indices of the [[arrays|array]] or array offset will hold the width and height of the stored image area. In [[SCREEN]] 13 divide the width by 8. -* More than one image can be stored in the [[INTEGER]] array by indexing the [[GET (graphics statement)|GET]] array offset. Be sure the index is not already used! -* A [[_DEST]] [[handle]] can be set to PUT images elsewhere other than on the current screen. Use [[_SOURCE]] to [[GET (graphics statement)|GET]] images there. -* If no color action is listed after the image array, the action will be assumed to be the default [[XOR]]. -::* [[XOR]] may blend with background colors, but can be used to erase an image when placed a second time. -::* [[PSET]] completely overwrites any background with the identical image. -::* [[PRESET]] creates a inverted coloring of the original image completely overwriting the background. -::* [[AND]] merges background colors with the black areas of the image where a white image mask is used. -::* [[OR]] blends the background and foreground colors together. -* In QB64 [[_PUTIMAGE]] is recommended over PUT as it can also do the [[GET (graphics statement)|GET]] directly from the image source without requiring an array. -* [[PUT]] and [[GET]] file statements can also write and read image array data using [[BINARY]] files instead of using [[BSAVE]] or [[BLOAD]]. - - -''Example 1:'' How [[GET]] and PUT can be used with images loaded with [[_LOADIMAGE]]. The background color is omitted or "masked". -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) -{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} -image& = {{Cl|_LOADIMAGE}}("QB64.png") - -wide& = {{Cl|_WIDTH (function)|_WIDTH}}(image&): deep& = {{Cl|_HEIGHT}}(image&) -{{Cl|DIM}} Array(wide& * deep&) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|_SOURCE}} image& 'REQUIRED to GET the proper image area! -{{Cl|GET (graphics statement)|GET}} (0, 0)-(wide& - 1, deep& - 1), Array(0) - -{{Cl|_DEST}} 0 -{{Cl|_COPYPALETTE}} image&, 0 'necessary for custom image colors other than screen defaults -{{Cl|PUT (graphics statement)|PUT}}(10, 10), Array(0), {{Cl|PSET}} , {{Cl|_RGB}}(255, 255, 255) 'mask white background color -{{Cl|END}} -{{CodeEnd}} -: ''Explanation:'' '''QB64''' allows one PUT color to be "masked" to allow odd shaped sprite image backgrounds to be transparent. - - -''Example 2:'' Using a [[STRING]] instead of an [[arrays|array]] to store [[GET]] image data that can be PUT later. For images up to 256 colors only. -{{CodeStart}} -a$ = {{Cl|SPACE$}}(4 + 100) '4 byte header + 100 pixels for a 10 X 10 image -{{Cl|SCREEN}} 13 -{{Cl|LINE}} (0, 0)-(319, 199), 4, BF 'color 4 = CHR$(4) = ♦ -{{Cl|LINE}} (40, 40)-(49, 49), 14, B 'color 14 = CHR$(14) = ♫ -{{Cl|GET (graphics statement)|GET}} (40, 40)-(49, 49), a$ - -K$ = {{Cl|INPUT$}}(1) - -{{Cl|CLS}} -{{Cl|PRINT}} a$ 'display string data. Width = {{Cl|CHR$}}(10 * 8) = "P" -{{Cl|PUT (graphics statement)|PUT}}(100, 100), a$, {{Cl|PSET}} -{{CodeEnd}} -{{small|Code by Galleon}} -: ''Explanation:'' The header holds the [[INTEGER]] width and depth of the image area as 2 bytes each. Screen 13 width is multiplied by 8. - - -''See also:'' -* [[_PUTIMAGE]], [[_LOADIMAGE]] -* [[_MAPTRIANGLE]] -* [[GET (graphics statement)|GET]], [[BSAVE]], [[BLOAD]] -* [[SCREEN (statement)|SCREEN]], [[Scancodes]]{{text|(Example 3)}} -* [[Creating Sprite Masks]] {{text|(for non-box shaped sprites)}} -* [[GET and PUT Demo]] -* [[Bitmaps]] - - -{{PageNavigation}} diff --git a/internal/help/PUT_111.txt b/internal/help/PUT_111.txt deleted file mode 100644 index ca71e9e85..000000000 --- a/internal/help/PUT_111.txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:21}} -The '''PUT #''' file or port statement writes data to a specific byte or record location. - - - -{{PageSyntax}} -:: '''PUT #''filenumber&'',''' [''position''][, {''holdingvariable''|''holdingarray()''}] - - - -* File/port number is the number used in the [[OPEN]] statement. -* The [[INTEGER]] or [[LONG]] file byte ''position'' in a [[BINARY]] file or the record ''position'' in a [[RANDOM]] file '''must be greater than zero'''. -* The file byte or record ''position'' can be omitted if the [[PUT]] or [[GET]] is consecutive or when creating new file data sequentially. -* The ''holding variable'' [[TYPE|type]] determines byte size and the next byte position in the file when the ''position'' is ommitted. -* The first byte or record position is 1. This may require adding one to an offset value when documentation uses that position as 0. -* Both the file ''position'' and ''holding variable''(and comma) can be omitted when using a [[FIELD]] definition. -* If a [[LEN]] = record length statement is omitted in an [[OPEN]] FOR [[RANDOM]] statement the record size defaults to 128 bytes! -* '''Warning: Not designating a PUT position can overwrite previous file data based on the current file ''position''!''' -* When using a numeric ''holding variable'', values do NOT require conversion using [[MKI$]], [[MKL$]], [[MKS$]] or [[MKD$]]. -* '''QB64''' can load [[Arrays|array]] data directly(brackets required) to a [[BINARY]] file using '''one''' PUT to a [[BINARY]] file: '''{{text|PUT #1, , array()|green}}''' - - -''Example 1:'' Using a [[TYPE]] record variable(Contact) to enter a new [[RANDOM]] record to a file. -{{CodeStart}} -{{Cl|TYPE}} ContactType - first {{Cl|AS}} {{Cl|STRING}} * 10 - last {{Cl|AS}} {{Cl|STRING}} * 20 - age {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|END}} {{Cl|TYPE}} -{{Cl|DIM}} Contact {{Cl|AS}} ContactType - -{{Cl|INPUT}} "Enter a first name: ", Contact.first -{{Cl|INPUT}} "Enter a last name: ", Contact.last -{{Cl|INPUT}} "Enter an age: ", Contact.age - -{{Cl|OPEN}} "Record.lst" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = {{Cl|LEN}}(Contact) -NumRecords% = {{Cl|LOF}}(1) \ {{Cl|LEN}}(Contact) -{{Cl|PRINT}} NumRecords%; "previous records" - -{{Cl|PUT}} #1, NumRecords% + 1, Contact ' add a new record {{Cl|TYPE}} record value -{{Cl|CLOSE}} #1 -{{CodeEnd}} -: ''Note:'' The DOT record variable values were created or changed before the PUT. The record length is 32 bytes. - - -''Example 2:'' Placing the contents of a numerical array into a [[BINARY]] file. You may want to put the array size at the beginning too. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} array(100) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 100 - array(i) = i -{{Cl|NEXT}} -showme 'display array contents - -{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 - -{{Cl|PUT}} #1, , array() - -{{Cl|ERASE}} array 'clear element values from array and display empty -showme -{{Cl|CLOSE}} #1 - -{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 -{{Cl|GET}} #2, , array() -{{Cl|CLOSE}} #2 -showme 'display array after transfer from file - -{{Cl|END}} - -{{Cl|SUB}} showme -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 100 - {{Cl|PRINT}} array(i); -{{Cl|NEXT}} -{{Cl|PRINT}} "done" -{{Cl|END SUB}} -{{CodeEnd}} -: ''Note:'' Use empty brackets in QB64 when using [[GET]] to create an array or [[PUT]] to create a [[BINARY]] data file. - - -''See Example:'' [[Program ScreenShots]] - - -''See also:'' -* [[GET|GET #]] -* [[SEEK]], [[SEEK (statement)]] -* [[PRINT (file statement)|PRINT #]] -* [[FIELD]] -* [[PUT (graphics statement)]] -* [[PUT (TCP/IP statement)]] - - -{{PageNavigation}} diff --git a/internal/help/Parenthesis_10000000000.txt b/internal/help/Parenthesis_10000000000.txt deleted file mode 100644 index fba0384f1..000000000 --- a/internal/help/Parenthesis_10000000000.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:59}} -'''Parenthesis''' are used to enclose [[SUB]] and [[FUNCTION]] parameters or to set the operation order in [[Mathematical Operations]]. - - -''Usage:'' COLOR 14: PRINT [[TAB]](30); "Hello World" - -{{OutputStart}} - {{text|Hello World|yellow}} -{{OutputEnd}} - - -* [[SUB]] parameters MUST be enclosed in parenthesis when the [[CALL]] statement is used. Do '''not''' use parenthesis without CALL. -* Parenthesis can be used in calculations to determine the order in which math operations are performed when the normal order would not work correctly. Normal operation order is: '''1)''' exponential, '''2)''' multiplication or division '''3)''' addition or subtraction. -* Parenthesis can also denote the array index or the dimension size(s) in a [[DIM]] statement. -* Instead of [[BYVAL]], use extra parenthesis around sub-procedure call parameters to pass them by value instead of by reference. -* Extra pairs of brackets have no effect on the code! If one is missing the IDE should tell you. - - -''Example:'' Using too many brackets does not harm the code execution as long as they are paired up. -{{CodeStart}} -nmb$ = {{Cl|STR$}}(100) -nmb$ = {{Cl|LTRIM$}}((({{Cl|RTRIM$}}(nmb$)))) 'extra bracket pairs do not affect the code - -{{Cl|PRINT}} nmb$ -{{CodeEnd}} - - -''See also:'' - -* [[DIM]], DECLARE -* [[SUB]], [[FUNCTION]] -* [[Arrays]] - - -{{PageNavigation}} diff --git a/internal/help/QB64_FAQ_1164_111.txt b/internal/help/QB64_FAQ_1164_111.txt deleted file mode 100644 index 884c71105..000000000 --- a/internal/help/QB64_FAQ_1164_111.txt +++ /dev/null @@ -1,302 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:54}} -__NOEDITSECTION__ -{| align="center" - |__TOC__ - |} - - -As with everything else, this list will be updated to correspond to new progress of QB64 so make sure that you are using the latest version of '''QB64'''. Please note that it may take a short time to update this list. - - -
'''{{text|It's recommended to exclude (whitelist) "qb64.exe" (also the ''internal'' folder) from any real-time anti-virus scanning to prevent IDE Module Errors.|red}}'''
- - -==Q: What is QB64?== - -A: '''QB64''' is a BASIC compatible Editor and C++ emitter that creates working Executable files from QBasic BAS files that can be run on 32 or 64 bit PC's using '''Windows''' (XP to 10), '''Linux''' or '''macOS'''. The goal is to be 100% compatible with QuickBASIC 4.5 plus add hundreds of new abilities such as program icons and custom sized windows and a great retro Editor with builtin help. - - -The '''new keywords''' add some '''new features''' such as playing '''music or sound''' files and instant access to '''32 bit graphics''' file images. Also '''TCP/IP''' internet communication is available to '''download''' files, '''email''' messages over the web or play '''internet games'''. '''DLL Libraries''' can add more programming options and QB64 can access all of the new USB gaming '''controllers''' and '''printers'''. - - -QB is an abbreviation for '''QBasic''' or '''QuickBASIC''' which is an easy to learn language that grew very popular in the 90's. It uses simple syntax but holds great potential as there are methods to achieve nearly anything. '''QBasic is more alive than ever with QB64!''' - - -

[[Keywords currently not supported by QB64]]

- - -==Q: Does it have modern features? Do they HAVE to be used?== - -A: QB64 has plenty of modern features, but they do not have to be used. You may just want to run some of your old favorites. -
'''QB64 was created to run your old QBasic 4.5 (or less) programs on newer Operating Systems without any changes.'''
-You could code using the original QuickBASIC syntax all the way through and it should work as you expect it to or even better. QB64 is often faster and has none of the memory limitations that plagued QBasic in the past. - -QB64 is not meant to run PDS (7.1) QBX code. Most GW Basic code will run with minor changes. - -The modern statements are designed to go along with the BASIC philosophy and expand QBasic into the future! - - -
'''QB64 FEATURES INCLUDE:'''
-{{TextStart}} - - 1) Full graphic functions for [[_NEWIMAGE|images]] up to 32 bit color. [[_ALPHA|Alpha]] transparency supported. - - 2) Instant [[_LOADIMAGE|loading]] of image files including BMP, PNG, JPEG, GIF and more... - - 3) Supports [[_SNDOPEN|stereo sound]] files like WAV, OGG, MP3, speaker and volume control and more... - - 4) Animation is easy to do using [[_DISPLAY]] instead of page flipping, to achieve flicker-free graphics. - - 5) [[_CLIPBOARD$|Clipboard]] reading and writing support. - - 6) Networking over TCP/IP and Email. - - 7) True type [[_FONT|font]] and [[Unicode]] support for many Languages. - - 8) Integrated [[_MOUSEINPUT|mouse]] and [[_DEVICES|game controller]] input including [[_MOUSEWHEEL|scroll wheel]] support. - - 9) Support for C++, OpenGL, Windows API and other custom Dynamic Link [[Libraries]]. -{{TextEnd}} - -

([[#toc|Return to FAQ topics]])

- -==Q: How do I install QB64 on Windows, Linux, macOS?== - -A: QB64 supports the following Operating Systems: - -
'''Windows NT (XP), Windows Vista, Windows 7, 8 or 10:'''
- -:'''1)''' Download the appropriate package according to your system from [http://github.com/QB64Team/qb64/releases GitHub] -:'''2)''' Unpack the contents to any location on your computer. Avoid unpacking to Program Files or other system folders that may require administrative privileges. QB64 needs to have full write permissions to its own folder. - -:*Executable programs are portable between like systems by copying the stand-alone executable file. - - ----- -
'''Most distributions of Linux, both 32 and 64 bit'''
- -:'''1)''' Download the appropriate package according to your system from [http://github.com/QB64Team/qb64/releases GitHub] -:'''2)''' After extracting the downloaded package, run the installation batch/script called ''./setup_lnx.sh'' in the main ''qb64'' folder to setup QB64. -:'''3)''' Most dependencies should be automatically downloaded by the setup script, but these are the ones you should look for if compilation fails: OpenGL developement libraries, ALSA development libraries, GNU C++ Compiler (g++) - - -
Executable programs are portable between like systems by copying the executable file.
-
'''Note: Some QB64 keywords and procedures are not available for Linux.'''
- - -

([[#toc|Return to FAQ topics]])

- ----- -
'''macOS'''
- -:'''1)''' You must install Apple's '''Xcode command line tools''' for C++ compilation from their website. The simplest way to do so is opening a terminal window and typing the following command: '''xcode-select --install''' (more info here: [http://developer.apple.com/technologies/tools/xcode.html Xcode download]) -:    (you won't be using the Xcode interface, QB64 just needs to have access to the C++ compiler and libraries it installs) -:'''3)''' Download the appropriate package according to your system from [http://github.com/QB64Team/qb64/releases GitHub] -:    Extract the downloaded package and run ''./setup_osx.command'', found within the QB64 folder to install the QB64 compiler. - -
'''After installation you should run '''./qb64''' or '''./qb64_start_osx.command''' to run qb64.'''
- -:*Executable programs are portable between macOS systems by copying the executable file. -:*To help launch executables without a console, a file called ''programname_start.command'' is created along with the program. -
'''Note: Some QB64 keywords and procedures are not available for macOS.'''
- - -
[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keywords Not Supported in Linux or MAC OSX versions]]
- - ----- -

([[#toc|Return to FAQ topics]])

- - -==Q: Why won't QB64 work on my computer?== -QB64 currently supports Windows versions from XP to the latest version. Most Linux and macOS versions are also supported. - -:'''Don't move QB64 executable out of the QB64 folder. The various sub-folders hold the C++ compiler files and libraries.''' - -:'''QB64 does not change any settings on your machine. All required files are in the QB64 folder.''' - - -

([[#toc|Return to FAQ topics]])

- -==Q: Are there any known incompatibilities?== - -A: There are some things that QB64 cannot do, like direct hardware access, which makes older more advanced programs that make use of [[CALL ABSOLUTE|ABSOLUTE]], [[INTERRUPT]], [[PEEK]], [[POKE]] and [[OUT]] not work properly. Although some older functionality is emulated, if your program doesn't use such statements you probably won't notice any difference between QB 4.5 and QB64 (and if you do, report it as a bug in the forums). You can expect the most common addresses for interrupts, etc. to be functioning. - - -See: [[Keywords currently not supported by QB64]] - - -You should be careful with '''CPU usage'''. QB64 is a lot faster than QBasic was and it does not have many of the size limitations that confined QBasic programming abilities. Having said that, '''care must be taken to assure that programs do not hog resources.''' To do that, use speed limits when possible to keep the resources used to a minimum. Also, '''Monitor Task Manager''' when your programs are running, as it can tell you how much or system resources are being used in different parts of a program. The following keywords can lower the impact of your programs on those resources by releasing them to other programs: - -:::::*[[_LIMIT]]: Limits the loops per second in any loop and thus lowers the overall CPU usage. - -:::::*[[_DELAY]]: Pauses a procedure and releases unused resources for other programs. - -:::::*[[SLEEP]]: Stops or delays program procedures and shares resources. - -:::::*[[INPUT]] and [[INPUT$]] stop program procedures until an entry or key press is given. - - -QB64 can be fast when you need it to be, but take the time to consider the impact of your program on other programs as people seldom have only one program running and the OS has tasks it must do too. - -

([[#toc|Return to FAQ topics]])

- - -==Q: How do I update the information in QB64's help system?== - -A: The help provided in the QB64 IDE Help System fetches the pages from this wiki. Use the '''Update current page''' in the IDE Help menu selection to update a page. Use the '''Update all pages''' choice to update them all, but this may take longer. - - -==Q: Can I use the same libraries with QB64 that I used with QB 4.5?== - -A: If the libraries are pure QB 4.5 code then yes, otherwise no. QLB files are not supported but you can easily copy your favorite SUBs or FUNCTIONs to a text BI file and [[$INCLUDE]] them at the end of any program. Include them after all SUB and FUNCTION code in the BAS file. - -[[DECLARE LIBRARY]] allows users to reference C, Windows, OpenGL and other DLL libraries. If you find some functions that you like please share them with us at the forum! The following pages list working functions our members have found and tested: - -
[[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
- - -

([[#toc|Return to FAQ topics]])

- -==Q: I can't get my QB 4.5 source code to work in QB64! Why?== - -A: QB64 is 99% compatible with QB4.5 programs. The commands that haven't been implemented are either obsolete or are too obscure and have been replaced by modern functionality. - -See: [[Keywords currently not supported by QB64]] - -

([[#toc|Return to FAQ topics]])

- -==Q: What files are required to run my QB64 compiled program in my Operating System?== -A: Programs compiled by QB64 (version 1.000 and up) are stand-alone so no external files are required to be with your program's EXE file. - - -

([[#toc|Return to FAQ topics]])

- - -==Q: Is there a way to use QB64 from the command line?== - -A: Yes! Just type QB64 -? at the command prompt to see a list of available options. - -;Note:The '''-c''' and '''-x''' option do just compile a program without running it. -:The '''-z''' option does not even create an executable file, it performs the first compile pass only (syntax checking and generate C code). - -{{FixedStart}} -Usage: qb64 [switches] - -Options: - Source file to load - -c Compile instead of edit - -o Write output executable to - -x Compile instead of edit and output the result to the - console - -w Show warnings - -q Quiet mode (does not inhibit warnings or errors) - -m Do not colorize compiler output (monochrome mode) - -e Enable OPTION _EXPLICIT, making variable declaration - mandatory (per-compilation; doesn't affect the - source file or global settings) - -s[:switch=true/false] View/edit compiler settings - -l: Start the IDE at the specified line number - -p Purge all pre-compiled content first - -z Generate C code without compiling to executable -{{FixedEnd}} - -

([[#toc|Return to FAQ topics]])

- - -==Q: How do I link modules or include SUB procedures in QB64?== - -A: QB64 allows you to [[$INCLUDE]] code or BAS modules into one module when it is compiled. Text .BI files containing SUB or FUNCTION code or entire BAS modules can be included in one module that will be compiled. - -After the EXE is compiled, you do not have to even use the added code anymore. The EXE will contain ALL of the program code as ONE stand-alone program. This also allows you to add SUB code to any program that you desire. - - -See: [[$INCLUDE]] - -

([[#toc|Return to FAQ topics]])

- - -==Q: Some screens look small. Can I enlarge them or make them fullscreen?== - -*You can use the [[_FULLSCREEN]] statement to make your programs run fullscreen. -*[[$RESIZE]] can be added to a program so you can track window resize events. -*You can also create custom sized screens with page flipping and up to 32 bit colors using [[_NEWIMAGE]]. -*Page flipping is available in most screens and the new [[_DISPLAY]] feature allows the images to be displayed when YOU desire. -*Picture or image files such as BMP, PNG, JPEG and GIF are EASY to load using [[_LOADIMAGE]]. -*Once images are loaded, all you have to do is use the image handle with any of the new statements and functions. -*[[_PUTIMAGE]] GETs and PUTs images fast in ONE call. It can even stretch or compress the image sizes. - - -

([[#toc|Return to FAQ topics]])

- - -==Q: Can I have background music as well as [[SOUND]], [[PLAY]] and [[BEEP]]?== - -A: Yes, they are emulated to use the soundcard. - -'''There also are a bunch of new sound capabilities that allow the use of WAV, OGG, MP3 files and more.''' - -Capabilities include: - -#Multiple sound tracks -#Volume and speaker control -#Background music - - -'''Get started with [[_SNDOPEN|music]]:''' - -:[[_SNDCLOSE]] (statement), [[_SNDCOPY]] (function), [[_SNDGETPOS]] (function), [[_SNDLEN]] (function), [[_SNDLIMIT]] (statement) - -:[[_SNDLOOP]] (statement), [[_SNDOPEN]] (function), [[_SNDPAUSE]] (statement), [[_SNDPAUSED]] (function), [[_SNDPLAY]] (statement) - -:[[_SNDPLAYCOPY]] (statement), [[_SNDPLAYFILE]] (statement), [[_SNDPLAYING]] (function), [[_SNDSETPOS]] (statement) - -:[[_SNDRAW]] (statement), [[_SNDSTOP]] (statement), [[_SNDVOL]] (statement) - - -

([[#toc|Return to FAQ topics]])

- - -==Q: If QB64 creates Basic programs why is there no Immediate Window?== - - -A: Because there is no '''QB64''' interpreter. All C code has to be compiled before it can be run. - -'''QB64''' uses the Immediate window area to suggest syntax for keyword entries and give the compiler status when compiling. - -

([[#toc|Return to FAQ topics]])

- - -==Q: Does it work on Windows 98 or any OS older than Windows 2000?== - -A: No, it doesn't. QB64 is made to run on new systems (Windows XP and up, Linux and macOS). - - -==Q: Does QB64 support CURRENCY values from PDS or VB programs?== - -A: Not directly, but [[_FLOAT]] currency values up to 4 decimal places can be multiplied by 10000(10 ^ 4) and converted to MKC$ string values using [[_MK$]] with an [[_INTEGER64]] value. [[_CV]] with an [[_INTEGER64]] value divided by 10000 converts it back to [[_FLOAT]] values. - - -[[PUT]] can write a PDS or VB, 8 byte currency string by multiplying the currency amount by 10000 and using an [[_INTEGER64]] variable. - -[[GET]] can read a [[_FLOAT]] CURRENCY value as an [[INTEGER64]] variable value divided by 10000. - - -

([[#toc|Return to FAQ topics]])

- - -==Q: Do you provide changelogs?== - -We do. - -*For all recent changelogs, check at [http://github.com/QB64Team/qb64/blob/development/CHANGELOG.md GitHub] - -

([[#toc|Return to FAQ topics]])

- - -==Q: Where I can view the C++ code before it gets compiled?== -Look in the QB64 '''internal\temp''' folder for '''main.txt''' to get the C code used to compile the latest program. - - -{{PageNavigation}} diff --git a/internal/help/QB64_Help_Menu_1164_1000_1000.txt b/internal/help/QB64_Help_Menu_1164_1000_1000.txt deleted file mode 100644 index cbfa08169..000000000 --- a/internal/help/QB64_Help_Menu_1164_1000_1000.txt +++ /dev/null @@ -1,16 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:55}} -This is QB64's built-in help system. It's data is based on the QB64 Wiki. In fact, the pages shown here are cached copies of the online Wiki pages and are displayed here in a '''simplified''' form. Obviously we can't reproduce the detailed output of a full fledged web browser here, especially tables are too complex to handle it here. However, you can click the cyan colored '''View on Wiki''' button at any time to open the original online Wiki page in your standard browser. - - -== Help Topics == -* [[Keyword Reference - Alphabetical]] -* [[Keyword Reference - By usage]] -* [[QB64 FAQ|Frequently asked questions about QB64]] -;Note:As the QB64 Wiki is a vital resource maintained by our community, it might be a good idea to periodically use the '''Update All Pages...''' command from the '''Help''' menu to fetch the latest changes done in the online Wiki. - - -== Community Links == -* [https://qb64phoenix.com/forum/index.php QB64 Phoenix Edition Forum] -* [https://qb64phoenix.com/qb64wiki/index.php QB64 Phoenix Edition Wiki] '''(the source of this help)''' -* [https://discord.gg/D2M7hepTSx QB64 Phoenix Edition Discord] diff --git a/internal/help/Question_mark_10000000_0000.txt b/internal/help/Question_mark_10000000_0000.txt deleted file mode 100644 index 12474d7f4..000000000 --- a/internal/help/Question_mark_10000000_0000.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:54}} -A '''question mark''' can be used as a substitute shortcut to typing PRINT when creating code. - - -''Usage:'' ?"Hello world" - - -''Result:'' PRINT "Hello world" - - -* When the IDE cursor moves to the next code line, the question mark is changed to PRINT and the prompt text and variable are spaced appropriately. -* When an [[INPUT]] statement has no text, a question mark will appear before the input. -* A [[semicolon]] after the [[INPUT]] prompt text will add a question mark after the statement. - - -''See also:'' - -* [[PRINT]] -* [[Semicolon]], [[Comma]] -* [[Quotation mark]] - - -{{PageNavigation}} diff --git a/internal/help/Quotation_mark_100000000_0000.txt b/internal/help/Quotation_mark_100000000_0000.txt deleted file mode 100644 index bb7a893dd..000000000 --- a/internal/help/Quotation_mark_100000000_0000.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:53}} -A '''quotation mark''' delimits the start and end of a literal [[STRING]] value. - - -''Usage:'' string_value$ = "This is a text STRING." - - -* The quotation mark must delimit the ends of a string or text prompt in a [[PRINT]], [[WRITE]], [[INPUT]] or [[LINE INPUT]] statement. -* The IDE may add a missing quotation mark at the end of a [[SUB|statement]] or [[FUNCTION|function]]. -* [[LINE INPUT]] allows quotation marks to be entered as user input. The [[LINE INPUT (file statement)]] can transfer quotation marks. -* Quotation marks should be used when [[comma]]s are used in a literal [[WRITE]] or [[INPUT (file statement)]] text string. -* To insert quotation marks in a [[PRINT]] statement insert [[CHR$]](34) using string [[concatenation]] or [[semicolon]]s. -* String values can be [[concatenation|concatenated]] or added using the plus ([[+]]) operator. Cannot be used to combine numerical values! -* Concatenation MUST be used when combining literal [[STRING|string]] values in a variable definition. -* String values can be combined with other string or numerical values using [[semicolon]]s or [[comma]] tabs in a PRINT statement. -* Literal [[DATA]] strings do not require quotation marks unless the value is a keyword, uses commas or has end spaces. - - -''See also:'' - -* [[STRING]], [[PRINT]], [[WRITE]] -* [[CHR$]], [[LINE INPUT]] - - -{{PageNavigation}} diff --git a/internal/help/RANDOMIZE_111111111.txt b/internal/help/RANDOMIZE_111111111.txt deleted file mode 100644 index d2844238a..000000000 --- a/internal/help/RANDOMIZE_111111111.txt +++ /dev/null @@ -1,106 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:25}} -'''RANDOMIZE''' is used with a seed value to generate different random number sequences using the [[RND]] function. - - -{{PageSyntax}} -:: '''RANDOMIZE''' [USING] '''{''seednumber''|TIMER}''' - - -* The ''seed number'' can be ANY positive or negative numerical type value. The [[TIMER]] value is often used to change [[RND]] output each run. -* If the ''seed number'' is omitted, the program will display: '''Random-number seed (-32768 to 32767)?''' request on screen. -* '''USING''' resets a ''seed number'' sequence to the start of the sequence as if the program just started using that seed in '''QB64 only'''. -* '''Note:''' The RANDOMIZE USING ''seed number'' MUST be designated or a {{text|Name already in use|blue}} status error will occur! -* If the same initial seed number is used, the sequence of random numbers returned will be identical every program run. -* The fact that random numbers would always be the same has been used for simple data encryption and decryption. -* Using a [[TIMER]] starting value ensures that the initial return sequence values are different almost every time the program is run! -* [[RUN]] should reset the [[RANDOMIZE]] sequence to the starting [[RND]] function value.(Not yet in QB64) - - -''Example 1:'' Using RANDOMIZE '''TIMER''' to set a different starting sequence of [[RND|random]] numbers every run. -{{CodeStart}}{{Cl|RANDOMIZE}} {{Cl|TIMER}} -{{Cl|DO...LOOP|DO}} -randnum% = INT({{Cl|RND}} * 11) + 2 'add one to multiplier as INT rounds down and never equals 10 -PRINT randnum% -K$ = {{Cl|INPUT$}}(1) -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|UCASE$}}(K$) = "Q" 'q = quit -{{Cl|END}} -{{CodeEnd}} -:''Explanation:'' Procedure generates random integer values from 2 to 12 like a pair of dice. - - -''Example 2:'' Repeating a random number sequence with RANDOMIZE '''USING''' and a specific seed value in '''QB64''' only. -{{CodeStart}}seed = 10 -{{Cl|RANDOMIZE}} seed -Print7 -{{Cl|RANDOMIZE}} seed -Print7 -{{Cl|PRINT}} "Press a key to start sequence over!" -K$ = {{Cl|INPUT$}}(1) -{{Cl|RANDOMIZE}} '''USING''' seed -Print7 - -{{Cl|SUB}} Print7 -{{Cl|FOR...NEXT|FOR}} r = 1 TO 7 - {{Cl|PRINT}} {{Cl|RND}}; -{{Cl|NEXT}} -{{Cl|PRINT}}: {{Cl|PRINT}} -{{Cl|END SUB}} -{{CodeEnd}} -: ''Explanation:'' The second RANDOMIZE statement just continues the sequence where USING in the third restarts the sequence. - - -''Example 3:'' Random fireworks explosions: -{{CodeStart}}{{Cl|RANDOMIZE}} {{Cl|TIMER}} -{{Cl|DEFINT}} A-Z - -{{Cl|TYPE}} ftype - vx {{Cl|AS}} {{Cl|SINGLE}} - vy {{Cl|AS}} {{Cl|SINGLE}} -{{Cl|END}} {{Cl|TYPE}} -{{Cl|DIM}} frag(500) {{Cl|AS}} ftype 'fragments - -{{Cl|DIM}} pi {{Cl|AS}} {{Cl|SINGLE}} -pi = 3.141593 - -{{Cl|DIM}} x {{Cl|AS}} {{Cl|SINGLE}}, y {{Cl|AS}} {{Cl|SINGLE}} -{{Cl|DIM}} t {{Cl|AS}} {{Cl|SINGLE}}, g {{Cl|AS}} {{Cl|SINGLE}}, p {{Cl|AS}} {{Cl|SINGLE}} -t = 0 -g = 0.4 'gravity -p = 15 'explosion power - -sw = 800 -sh = 600 - -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(sw, sh, 32) - -DO - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} {{Cl|UBOUND}}(frag) - frag(i).vx = {{Cl|RND}} * {{Cl|COS}}(2 * pi * {{Cl|RND}}) - frag(i).vy = {{Cl|RND}} * {{Cl|SIN}}(2 * pi * {{Cl|RND}}) - {{Cl|NEXT}} - - x = sw * {{Cl|RND}} - y = sh * {{Cl|RND}} - - {{Cl|FOR...NEXT|FOR}} t = 0 {{Cl|TO}} 25 {{Cl|STEP}} 0.1 - {{Cl|LINE}} (0, 0)-(sw, sh), {{Cl|_RGB}}(0, 0, 0), BF - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} {{Cl|UBOUND}}(frag) - {{Cl|PSET}} (x + t * p * frag(i).vx, y + t * p * frag(i).vy + g * t * t), {{Cl|_RGB}}(255, 255, 0) - {{Cl|NEXT}} - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 150 - - {{Cl|IF...THEN|IF}} {{Cl|_KEYHIT}} = -27 {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|NEXT}} -{{Cl|LOOP}} -{{Cl|SYSTEM}} -{{CodeEnd}}{{small|Code by Ben}} - - -''See also:'' -* [[RND]], [[INT]], [[CINT]] -* [[TIMER]] - - -{{PageNavigation}} diff --git a/internal/help/RANDOM_111111.txt b/internal/help/RANDOM_111111.txt deleted file mode 100644 index d72af1001..000000000 --- a/internal/help/RANDOM_111111.txt +++ /dev/null @@ -1,107 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:24}} -'''RANDOM''' is used in an [[OPEN]] statement to read([[GET]]) from or write([[PUT]]) to a file. - - - -{{PageSyntax}} -:: OPEN Filename$ FOR RANDOM AS #1 [LEN = ''recordlength%''] - - -* RANDOM is the Default mode if no mode is given in the [[OPEN]] statement. -* It creates the file if the legal file name given does NOT exist. -* As a RANDOM file, it can read or write any record using [[GET]] and/or [[PUT]] statements. -* ''Recordlength%'' is determined by getting the LEN of a [[TYPE]] variable or a [[FIELD]] statement. -:: [[STRING]] = 1 byte/character, [[INTEGER]] = 2 bytes, [[LONG]] = 4 bytes, [[SINGLE]] = 4 bytes [[DOUBLE]] = 8 bytes -:: [[_BYTE]] = 1 byte, [[_INTEGER64]] = 8 bytes, [[_FLOAT]] = 10 bytes (so far) - -* If no record length is used in the [[OPEN]] statement, the default record size is 128 bytes except for the last record. -* A record length cannot exceed 32767 or an [[ERROR Codes|error]] will occur! -* To determine the number of records in a file the records% = [[LOF]] \ recordlength%. -* When '''variable length strings''' are PUT into RANDOM files the record length must exceed the maximum string entry by: -:: 2 bytes are reserved for recording variable string lengths up to 32767 bytes (LEN = longest + 2) -:: 8 bytes are reserved for recording variable string lengths exceeding 32767 bytes (LEN = longest + 8) -* A serial communication port can also be opened for RANDOM in an [[OPEN COM]] statement. - - -''Example 1:'' Function that finds a RANDOM file's record number for a string value such as a phone number. -{{CodeStart}} -{{Cl|TYPE}} customer - age {{Cl|AS}} {{Cl|INTEGER}} - phone {{Cl|AS}} {{Cl|STRING}} * 10 -{{Cl|END}} {{Cl|TYPE}} - -{{Cl|DIM}} {{Cl|SHARED}} cust {{Cl|AS}} customer, recLEN -recLEN = {{Cl|LEN}}(cust) 'get the length of the record type -{{Cl|PRINT}} "Rec{{Cl|LEN}}:"; recLEN - -{{Cl|OPEN}} "randfile.rec" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = recLEN -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 4 - {{Cl|READ}} cust.age, cust.phone - {{Cl|PUT}} #1, , cust -{{Cl|NEXT}} -{{Cl|CLOSE}} #1 - -RP = RecordPos("randfile.rec", "2223456789") 'returns 0 if record not found! - -{{Cl|PRINT}} RP - -{{Cl|IF...THEN|IF}} RP {{Cl|THEN}} - {{Cl|OPEN}} "randfile.rec" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 {{Cl|LEN}} = recLEN - {{Cl|GET}} #2, RP, cust - {{Cl|CLOSE}} #2 -{{Cl|PRINT}} cust.age, cust.phone -{{Cl|END IF}} - -{{Cl|END}} - -{{Cl|DATA}} 59,2223456789,62,4122776477,32,3335551212,49,1234567890 - -{{Cl|FUNCTION}} RecordPos (file$, search$) -f = {{Cl|FREEFILE}} -{{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f -FL = {{Cl|LOF}}(f) -dat$ = {{Cl|INPUT$}}(FL, f) -{{Cl|CLOSE}} f -recpos = {{Cl|INSTR}}(dat$, search$) -{{Cl|IF...THEN|IF}} recpos {{Cl|THEN}} RecordPos = recpos \ recLEN + 1 {{Cl|ELSE}} RecordPos = 0 -{{Cl|END FUNCTION}} -{{CodeEnd}} -:''Note:'' Random files can store records holding various variable types using a [[TYPE]] definition or a [[FIELD]] statement. - - -''Example 2:'' When not using a [[TYPE]] or fixed length strings, QB4.5 allows RANDOM files to hold variable length strings up to 2 bytes less than the LEN = record length statement: -{{CodeStart}} -{{Cl|_CONTROLCHR}} OFF -{{Cl|OPEN}} "myfile.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1: {{Cl|CLOSE}} #1: ' clears former file of all entries. -{{Cl|OPEN}} "myfile.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = 13 'strings can be up to 11 bytes with 2 byte padder - -a$ = {{Cl|CHR$}}(1) + {{Cl|CHR$}}(0) + "ABCDEFGHI" -b$ = "ABCDEFGHI" -c$ = "1234" - -{{Cl|PUT}} #1, 1, a$ -{{Cl|PUT}} #1, 2, b$ -{{Cl|PUT}} #1, 3, c$ - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 3 - {{Cl|GET}} #1, i, a$ - {{Cl|PRINT}} a$, {{Cl|LEN}}(a$) -{{Cl|NEXT}} - -{{Cl|CLOSE}} -{{CodeEnd}} -{{OutputStart}}☺ ABCDEFGHI 11 -ABCDEFGHI 9 -1234 4 -{{OutputEnd}} -: ''Note:'' The 2 byte file padders before each string PUT will show the length of a string for GET as [[ASCII]] characters. Padders will always be 2 bytes and strings up to the last one will be 13 bytes each no matter the length up to 11, so the file size can be determined as (2 + 11) + (2 + 9 + 2) + (2 + 4) or 13 + 13 + 2 + 4 = 32 bytes. - - -''See also:'' -* [[GET]], [[PUT]], [[FIELD]] -* [[BINARY]] -* [[SEEK]], [[SEEK (statement)]] - - -{{PageNavigation}} diff --git a/internal/help/READ_1111.txt b/internal/help/READ_1111.txt deleted file mode 100644 index 5ed8af288..000000000 --- a/internal/help/READ_1111.txt +++ /dev/null @@ -1,69 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:27}} -The '''READ''' statement reads values from a [[DATA]] field and assigns them to one or a comma separated list of variables. - - -{{PageSyntax}} -::: [[READ]] value1$[, value2!, value3%, ...] - - -* READ statements assign variables to [[DATA]] statement values on a one-to-one basis sequentially. -* A single READ statement may access one or more [[DATA]] values. They are accessed in the order set. -* Several READ statements may access the same [[DATA]] statement block at the following sequential position. -* [[DATA]] can be READ using [[STRING]] or numerical [[TYPE]] variables singularly or in a comma separated list: -:: [[STRING]] READ variables can read quoted or unquoted text or numerical DATA values! -:: Numerical type READ variables can only read '''unquoted''' numerical DATA values! -::'''If they do not agree, a [[ERROR Codes|"Syntax error"]] may result when run reading string data as numerical values!''' -* If the number of variables specified is fewer than the number of elements in the DATA statement(s), subsequent READ statements begin reading data at the next unread element. If there are no subsequent READ statements, the extra data is ignored. -* If variable reads exceed the number of elements in the DATA field(s), an [[ERROR Codes|"Out of data" error]] will occur! -* Use the [[RESTORE]] statement to reread DATA statements from the start, with or without a line label as required. -* [[ACCESS]] READ can be used in an [[OPEN]] statement to limit file access to read only, preserving file data. -* '''WARNING! Do not place DATA fields after [[SUB]] or [[FUNCTION]] procedures! QB64 will FAIL to compile properly!''' -: QBasic allowed programmers to add DATA fields anywhere because the IDE separated the main code from other procedures. - - -''Example 1:'' Placing data into an array. -{{CodeStart}} -{{Cl|DIM}} A(10) AS {{Cl|SINGLE}} -{{Cl|FOR...NEXT|FOR}} I = 1 {{Cl|TO}} 10 - {{Cl|READ}} A(I) -{{Cl|NEXT}} I -{{Cl|FOR...NEXT|FOR}} J = 1 {{Cl|TO}} 10 - {{Cl|PRINT}} A(J); -{{Cl|NEXT}} -{{Cl|END}} - -{{Cl|DATA}} 3.08, 5.19, 3.12, 3.98, 4.24 -{{Cl|DATA}} 5.08, 5.55, 4.00, 3.16, 3.37 -{{CodeEnd}} -{{OutputStart}} - 3.08 5.19 3.12 3.98 4.24 5.08 5.55 4 3.16 3.37 -{{OutputEnd}} -:''Explanation:'' This program reads the values from the DATA statements into array A. After execution, the value of A(1) is 3.08, and so on. The DATA statements may be placed anywhere in the program; they may even be placed ahead of the READ statement. - - -''Example 2:'' Reading three pieces of data at once. -{{CodeStart}} - PRINT " CITY ", " STATE ", " ZIP" - PRINT {{Cl|STRING$}}(30, "-") 'divider - {{Cl|READ}} C$, S$, Z& - PRINT C$, S$, Z& - - {{Cl|DATA}} "DENVER,", COLORADO, 80211 -{{CodeEnd}} -{{OutputStart}} - CITY STATE ZIP - ------------------------------ - DENVER, COLORADO 80211 -{{OutputEnd}} -:''Note:'' String DATA values do not require quotes unless they contain commas, end spaces or QBasic keywords. - - - -''See also:'' -* [[DATA]], [[RESTORE]] -* [[PRINT USING]] -* [[OPEN]] FOR [[INPUT (file mode)|INPUT]] {{text|(file statement)}} - - -{{PageNavigation}} diff --git a/internal/help/REDIM_11111.txt b/internal/help/REDIM_11111.txt deleted file mode 100644 index a5d934f2a..000000000 --- a/internal/help/REDIM_11111.txt +++ /dev/null @@ -1,68 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:29}} -A {{KW|REDIM}} statement can re-dimension one [[$DYNAMIC|dynamic]](flexible) [[Arrays|array]] or a [[comma]] separated list of arrays. - - -{{PageSyntax}} -:[[REDIM]] [{{KW|_PRESERVE}}] [{{KW|SHARED}}] ArrayName[''typesuffix''] ({''max_element''|low_element[{{KW|TO}} ''upper_element'', ...]}) [{{KW|AS}} {{KW|TYPE|Type}}] - - -{{PageDescription}} -* Can change the number of elements in an array (the present array data is lost unless [[_PRESERVE]] is used). -* Dynamic array elements can also be sized or resized by a program user's entry. -* The [[_PRESERVE]] option also allows the ''element'' range values to be moved upward or downward in '''QB64 only!''' -* {{Parameter|Array}} is the name of the array to be dimensioned or re-dimensioned. -* {{Parameter|elements}} is the number of elements the array should hold. Use the optional [[TO]] {{Parameter|elements2}} to set a range. -* '''Always use the same array [[TYPE]] suffix ([[AS]] type) or a new array type with the same name may be created.''' -* REDIM cannot change [[$STATIC]] arrays created with a [[DIM]] statement unless the [[$DYNAMIC]] [[Metacommand]] is used! -* To create a dynamic array use the [[$DYNAMIC]] metacommand or use [[REDIM]] rather than [[DIM]] when first creating the array. -* Use REDIM [[_PRESERVE]] to change the range or number of array elements without losing the remaining elements. Data may move up or down to accommodate those boundary changes. -* '''REDIM [[_PRESERVE]] cannot change the number of array dimensions or type!''' -* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used to clear the arrays as they no longer exist. -* When [[AS]] is used to declare the type, use [[AS]] to retain that type or it will change to [[SINGLE]]! -* '''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!''' - - -''Example 1:'' The [[$DYNAMIC]] Metacommand allows an array to be re-sized using [[DIM]] and REDIM. -{{CodeStart}} -'{{Cl|$DYNAMIC}} - -{{Cl|INPUT}} "Enter array size: ", size -{{Cl|DIM}} Array(size) - -{{Cl|REDIM}} Array(2 * size) - -{{Cl|PRINT}} {{Cl|UBOUND}}(Array) -{{CodeEnd}} - - -''Example 2:'' Shows the difference between REDIM and REDIM [[_PRESERVE]]. -{{CodeStart}} -{{Cl|REDIM}} array(20) -array(10) = 24 - -{{Cl|PRINT}} array(10) - -{{Cl|REDIM}} {{Cl|_PRESERVE}} array(30) -{{Cl|PRINT}} array(10) - -{{Cl|REDIM}} array(15) -{{Cl|PRINT}} array(10) -{{CodeEnd}} -{{OutputStart}} - 24 - 24 - 0 -{{OutputEnd}} -: ''Explanation:'' REDIM without _PRESERVE erases the array data and cannot change the number of dimensions. - - -{{PageSeeAlso}} -* [[Arrays]] -* [[DIM]], [[SHARED]] -* [[_PRESERVE]], [[ERASE]] -* [[$DYNAMIC]], [[$STATIC]] - - -{{PageNavigation}} diff --git a/internal/help/REM_111.txt b/internal/help/REM_111.txt deleted file mode 100644 index 5bd150615..000000000 --- a/internal/help/REM_111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:30}} -'''REM''' or an apostrophe is used for programmer remarks, comments or to stop the execution of program code. - - -{{PageSyntax}} -:: REM program comment or ignore code - - -{{PageDescription}} -* Comments cannot be read by QBasic correctly and may cause syntax and other errors without REM! -* Instead of REM you can use the {{KW|REM|'}} symbol which can be put anywhere. -* Code can also be commented out for program testing purposes. -* QBasic Metacommands such as {{KW|$DYNAMIC}} and {{KW|$INCLUDE}} require the use of REM or the apostrophe. - - -''Example:'' Avoiding an END IF error. -{{CodeStart}} -{{Cl|REM}} This is a remark... -' This is also a remark... -{{Cl|IF...THEN|IF}} a = 0 {{Cl|THEN}} {{Cl|REM}} (REM follows syntax rules) -{{Cl|IF...THEN|IF}} a = 0 {{Cl|THEN}} '(apostrophe doesn't follow syntax rules, so use END IF after this) -{{Cl|END IF}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[Apostrophe]] -* {{KW|$DYNAMIC}}, {{KW|$STATIC}}, {{KW|$INCLUDE|$INCLUDE:}} - - -{{PageNavigation}} diff --git a/internal/help/RESET_11111.txt b/internal/help/RESET_11111.txt deleted file mode 100644 index 4bebc10b7..000000000 --- a/internal/help/RESET_11111.txt +++ /dev/null @@ -1,19 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:32}} -The '''RESET''' statement closes all files and writes the directory information to a diskette before it is removed from a disk drive. - - -{{PageSyntax}} -:: RESET - - -* Always execute a RESET command before removing a diskette from a disk drive. Otherwise, when the diskette is used again, it will not have the current directory information written on the directory track. -* RESET closes all open files on all drives and writes the directory track to every diskette with open files. - - -''See also:'' -* [[OPEN]] -* [[CLOSE]] - - -{{PageNavigation}} diff --git a/internal/help/RESTORE_1111111.txt b/internal/help/RESTORE_1111111.txt deleted file mode 100644 index c2d4f2384..000000000 --- a/internal/help/RESTORE_1111111.txt +++ /dev/null @@ -1,91 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:33}} -The '''RESTORE''' statement is used to reset the DATA pointer to the beginning of the data. - - -{{PageSyntax}} -:: RESTORE [datafield] - - -* The datafield line label or number enables a labeled data field to be [[READ]] more than once as required. -* Datafield label names are not required when working with ONE or a progression of data fields in the main body of code. -* Label multiple data fields to restore them to use them again when necessary. -* If RESTORE is used with unlabeled data fields or no datafield is designated then the first data field is read. -* Use RESTORE to avoid an [[ERROR Codes|"Out of Data" error]] when reading a data field! -* See the [[DATA]] statement for [[STRING]] data value specifications. -* '''Do not place [[DATA]] fields after [[SUB]] or [[FUNCTION]] procedures! QB64 will FAIL to [[RESTORE]] properly!''' -: QBasic allowed programmers to add DATA fields anywhere because the IDE separated the main code from other procedures. - - -''Example:'' Restoring a labeled DATA field to avoid going past the end of DATA. -{{CodeStart}} -DO - {{Cl|INPUT}} "Enter a month number(1 to 12): ", monthnum% - - {{Cl|RESTORE}} Months - FOR i = 1 TO monthnum% - {{Cl|READ}} month$, days% 'variables must match data field types - NEXT - {{Cl|PRINT}} "The month "; month$; " has"; days%; "days." -LOOP UNTIL monthnum% < 1 OR monthnum% > 12 - - Months: - {{Cl|DATA}} January, 31, February, 28, March, 31, April, 30, May, 31, June, 30 - {{Cl|DATA}} July, 31, August, 31, September, 30, October, 31, November, 30, December, 31 -{{CodeEnd}} -{{OutputStart}} -Enter a month number(1 to 12): 6 -The month June has 30 days. -{{OutputEnd}} -:''Note:'' String DATA values do not require quotes unless they have commas, end spaces or QBasic keywords in them. - - - -''Example:'' Using RESTORE to know the number of elements in the DATA in order to dimension and store the items in a array. -{{CodeStart}} -{{Cl|DO}} -{{Cl|READ}} dummy$ 'we won't actually use this string for anything else than to know when there is no more DATA. -count = count + 1 -{{Cl|LOOP}} {{Cl|UNTIL}} dummy$ = "stop" 'when dummy$ = "stop" then we know that it is the last entry so it only does the above loop until then. - -count = count - 1 'since the last string is "stop" and we don't want to store it in the array. - -{{Cl|PRINT}} "The number of relevant entries are:"; count - -{{Cl|DIM}} entry$(count) 'Now we know how many elements we need to make space for (DIM) - -{{Cl|RESTORE}} 'We restore it so that it begins reading from the first DATA again. - - -{{Cl|FOR}} c = 1 {{Cl|TO}} count -{{Cl|READ}} entry$(c) 'read the DATA and store it into the array. -{{Cl|NEXT}} - -'we can now print the contents of the array: - -{{Cl|FOR}} c = 1 {{Cl|TO}} count -{{Cl|PRINT}} entry$(c) -{{Cl|NEXT}} - -{{Cl|END}} - -{{Cl|DATA}} "entry1", "entry2", "entry3", "stop" -{{CodeEnd}} -{{small|Code By: Cyperium}} - -{{OutputStart}} -The number of relevant entries are: 3 -entry1 -entry2 -entry3 -{{OutputEnd}} -''Note:'' Now we can add any number of entries without further compensation to the code. - - - -''See also'' -* [[DATA]], [[READ]] -* [[line numbers]] / line labels - - -{{PageNavigation}} diff --git a/internal/help/RESUME_111111.txt b/internal/help/RESUME_111111.txt deleted file mode 100644 index fbcb961c5..000000000 --- a/internal/help/RESUME_111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:34}} -The '''RESUME''' statement is used with '''NEXT''' or a line number or label in an error handling routine. - - -{{PageSyntax}} -: [[RESUME]] {'''NEXT'''|{{Parameter|lineLabel}}|{{Parameter|lineNumber}}} - - -{{PageDescription}} -* '''NEXT''' returns execution to the code immediately following the error. -* A {{Parameter|lineLabel}} or {{Parameter|lineNumber}} is the code line to return to after an error. -* If the line label or number is omitted or the line number = 0, the code execution resumes at the code that created the original error. -* [[RESUME]]can only be used in ERROR handling routines. Use [[RETURN]] in normal [[GOSUB]] procedures. - - -{{PageSeeAlso}} -* [[ON ERROR]], [[ERROR]] -* [[RETURN]], [[ERROR Codes]] -* [[FOR...NEXT]] (counter loop) - - -{{PageNavigation}} diff --git a/internal/help/RETURN_111111.txt b/internal/help/RETURN_111111.txt deleted file mode 100644 index 7e932ee25..000000000 --- a/internal/help/RETURN_111111.txt +++ /dev/null @@ -1,75 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:35}} -'''RETURN''' is used in [[GOSUB]] procedures to return to the original call code line or a specified line label. - - -{{PageSyntax}} -:: '''RETURN''' [{''linelabel''|''linenumber''}] - - -{{Parameters}} -* RETURN without parameters returns to the code immediately following the original [[GOSUB]] call. -* ''line number'' or ''linelabel'' after the RETURN statement returns code execution to that label. - - -''Usage:'' -* Normally required at the end of a [[GOSUB]] procedure unless the procedure returns using a loop. -* RETURN is not used in error handling procedures. Error procedures use [[RESUME]] ''line number'' or [[RESUME|RESUME NEXT]]. -* GOSUB procedures use line numbers or line labels designated with a colon after the number or label. -* If RETURN is encountered without a previous [[GOSUB]] call a [[ERROR Codes|"RETURN without GOSUB" error]] is produced. -* To avoid errors, place [[GOSUB]] procedures AFTER the main program code [[END]] or after an [[EXIT SUB]] or [[EXIT FUNCTION]] call. - - - -''Example 1:'' Returns after a Gosub. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} 10 -{{Cl|PRINT}} a -{{Cl|IF...THEN|IF}} a = 5 {{Cl|THEN}} {{Cl|GOSUB}} five -{{Cl|NEXT}} -{{Cl|END}} 'END or SYSTEM stop the program before the execution of a sub procedure - -five: -{{Cl|PRINT}} "Aha! Five!" -{{Cl|RETURN}} -{{CodeEnd}} -{{OutputStart}} - 1 - 2 - 3 - 4 - 5 -Aha! Five! - 6 - 7 - 8 - 9 - 10 -{{OutputEnd}} - - -''Example 2:'' Returns to a specific line label. -{{CodeStart}} -{{Cl|GOSUB}} hey -{{Cl|PRINT}} "it didn't go here." -hoho: -{{Cl|PRINT}} "it went here." -{{Cl|END}} - -hey: -{{Cl|RETURN}} hoho -{{CodeEnd}} -{{small|Code by Cyperium}} -{{OutputStart}} -it went here. -{{OutputEnd}} - - - - -''See also:'' -* [[GOSUB]], [[GOTO]] -* [[RESUME]] - - -{{PageNavigation}} diff --git a/internal/help/RIGHT$_11111$.txt b/internal/help/RIGHT$_11111$.txt deleted file mode 100644 index c16d0e8de..000000000 --- a/internal/help/RIGHT$_11111$.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:36}} -The '''RIGHT$''' function returns a set number of characters in a [[STRING]] variable starting from the end and counting backwards. - - - -{{PageSyntax}} -:: '''RIGHT$('''''stringvalue$, numberofcharacters%''''')''' - - -{{Parameters}} -* The ''stringvalue$'' can be any string of [[ASCII]] characters as a [[STRING]] variable. -* The ''numberofcharacters'' [[INTEGER]] value determines the number of characters to return from the right end of the string. - - -{{PageDescription}} -* If the number of characters exceeds the string length([[LEN]]) the entire string is returned. -* RIGHT$ returns always start at the last character of the string, even if a space. [[RTRIM$]] can remove ending spaces. -* '''Number of characters cannot be a negative value.''' - - -''Example 1:'' Getting the right portion of a string value such as a person's last name. -{{CodeStart}} -name$ = "Tom Williams" - -Last$ = {{Cl|RIGHT$}}(name$, {{Cl|LEN}}(name$) - {{Cl|INSTR}}(name$, " ")) 'subtract space position from string length - -{{Cl|PRINT}} Last$ -{{CodeEnd}} -{{OutputStart}}Williams {{OutputEnd}} - - -''Example 2:'' Adding the leading zero in single digit [[HEX$]] values using RIGHT to take the right two hexadecimal string digits. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) '32 bit screen modes ONLY! -red = 255 -green = 0 -blue = 128 - -Color32 red, green, blue -{{Cl|PRINT}} "Colored text" - -{{Cl|SUB}} Color32 (R, G, B) -R = R {{Cl|AND (boolean)|AND}} {{Cl|&H}}FF: G = G {{Cl|AND (boolean)|AND}} {{Cl|&H}}FF: B = B {{Cl|AND (boolean)|AND}} {{Cl|&H}}FF ' limit values to 0 to 255 -hexadecimal$ = "{{Cl|&H}}FF" + {{Cl|RIGHT$}}("0" + {{Cl|HEX$}}(R), 2) + {{Cl|RIGHT$}}("0" + {{Cl|HEX$}}(G), 2) + {{Cl|RIGHT$}}("0" + {{Cl|HEX$}}(B), 2) -{{Cl|PRINT}} hexadecimal$ -{{Cl|COLOR}} {{Cl|VAL}}(hexadecimal$) -{{Cl|END SUB}} -{{CodeEnd}} -{{OutputStart}}'''{{text|&HFFFF0080|white}}''' -'''{{text|Colored text|#FF0080}}'''{{OutputEnd}} -: ''Note:'' When a single hexadecimal digit is returned the resulting value will need the leading zero added. Otherwise the hexa- decimal value created will have a byte missing from the value. EX: Color &HFF000000 is valid while &HFF000 is not. - - -''See also:'' -* [[LEFT$]], [[MID$]] -* [[LTRIM$]], [[RTRIM$]] -* [[INSTR]], [[HEX$]] - - -{{PageNavigation}} diff --git a/internal/help/RMDIR_11111.txt b/internal/help/RMDIR_11111.txt deleted file mode 100644 index 42ff66181..000000000 --- a/internal/help/RMDIR_11111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:37}} -The {{KW|RMDIR}} statement deletes an empty directory using a designated path relative to the present path location. - - -{{PageSyntax}} -:{{KW|RMDIR}} {{Parameter|directory$}} - - -{{PageDescription}} -* {{Parameter|directory$}} is a relative path to the directory to delete. -* Directory path must be a literal or variable [[STRING]] value designating the folder to be deleted. -* If the directory contains files or folders, a [[ERROR Codes|file/path access error]] will occur. -* If the directory path cannot be found, a [[ERROR Codes|path not found]] error occurs. - - -{{PageExamples}} -{{CodeStart}} - -{{Cl|ON ERROR|ON ERROR GOTO}} ErrorHandler - DO - ERRcode = 0 - {{Cl|INPUT}} "Enter path and name of directory to delete: "; directory$ - IF {{Cl|LEN}}(directory$) THEN 'valid user entry or quits - {{Cl|RMDIR}} directory$ 'removes empty folder without a prompt - IF ERRcode = 0 THEN PRINT "Folder "; directory$; " removed." - END IF - LOOP UNTIL ERRcode = 0 OR LEN(directory$) = 0 -{{Cl|SYSTEM}} - - -ErrorHandler: -ERRcode = {{Cl|ERR}} 'get error code returned -{{Cl|SELECT CASE}} ERRcode -{{Cl|CASE}} 75 - {{Cl|PRINT}} directory$ + " is not empty!" -{{Cl|CASE}} 76 - {{Cl|PRINT}} directory$ + " does not exist!" -{{Cl|CASE ELSE}} - {{Cl|PRINT}} "Error"; ERRcode; "attempting to delete " + directory$ -{{Cl|END SELECT}} -{{Cl|PRINT}} -{{Cl|RESUME|RESUME NEXT}} - -{{CodeEnd}} - -: This Windows-specific output from two runs of the above program is typical, though your output may vary. User-entered text is in italics. - -{{OutputStart}} - -Enter path and name of directory to delete: ''Some\Folder\That\Doesnt\Exist'' -Some\folder\That\Doesnt\Exist does not exist! - -Enter path and name of directory to delete: ''C:\temp'' -C:\temp is not empty! - -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[MKDIR]], [[CHDIR]] -* [[KILL]], [[FILES]] - - -{{PageNavigation}} diff --git a/internal/help/RND_111.txt b/internal/help/RND_111.txt deleted file mode 100644 index 1595b8f94..000000000 --- a/internal/help/RND_111.txt +++ /dev/null @@ -1,110 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:38}} -The '''RND''' function returns a random number with a value between 0 (inclusive) and 1 (exclusive). - - -{{PageSyntax}} -:: result! = [[RND]] [(''n'')] - - -{{Parameters}} -* ''n'' is a [[SINGLE]] numeric value that defines the behavior of the RND function but is '''NOT normally required''': -::n parameter omitted: Returns next random number in the sequence. -::n = 0: Return the last value returned. -::n < 0: Always returns the same value for any given n -::n > 0: the sequence of numbers generated will not change unless [[RANDOMIZE]] is initiated. - - -{{PageDescription}} -* The random numbers generated range from 0 minimum to .9999999 maximum [[SINGLE]] values that never equal 1. -* To get values in a range larger than 1, multiply RND with a number to get returns up to but not including that numerical value. -* To get values starting at a certain number, add that number to the RND result as RND minimums can be 0. -* If you need an integer range of numbers, like a dice roll, round it down to an [[INT]]. Add 1 to the maximum number with [[INT]]. -* The random sequence is 2 ^ 24 or 16,777,216 entries long, which can allow repeated patterns in some procedures. -* Formulas for the [[INT|Integer]] or [[CINT|Closest Integer]] of ANY number range from ''min%''(lowest value) to ''max%''(greatest value): -::* Using [[INT]]: randNum% = INT(RND * (max% - min% + 1)) + min% -::* Using [[CINT]]: randNum% = CINT(RND * (max% - min%)) + min% -* Use [[RANDOMIZE]] [[TIMER]] for different random number results each time a program is run. -* [[RUN]] should reset the [[RANDOMIZE]] sequence to the starting [[RND]] function value.(Not yet in QB64) - - -''Example 1:'' Generating a random integer value between 1 and 6 (inclusive) using INT. -{{CodeStart}} -dice% = {{Cl|INT}}({{Cl|RND}} * 6) + 1 'add one as INT value never reaches 6 -{{CodeEnd}} - - -''Example 2:'' Using uniform random numbers to create random numbers with a gaussian distribution ([http://en.wikipedia.org/wiki/Marsaglia_polar_method| Marsaglia's polar method]). -{{CodeStart}} -{{Cl|DO}} - u! = {{Cl|RND}} * 2 - 1 - v! = {{Cl|RND}} * 2 - 1 - s! = u! * u! + v! * v! -{{Cl|LOOP}} {{Cl|WHILE}} s! >= 1 {{Cl|OR}} s! = 0 -s! = SQR(-2 * {{Cl|LOG}}(s!) / s!) * 0.5 -u! = u! * s! -v! = v! * s! -{{CodeEnd}} -:''Explanation:'' Values ''u!'' and ''v!'' are now two independent random numbers with gaussian distribution, centered at 0. - - -''Example 3:'' Random flashes from an explosion -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|RANDOMIZE}} {{Cl|TIMER}} -BC = 120 ' BALL COUNT -{{Cl|DIM}} ballx(1 {{Cl|TO}} BC) -{{Cl|DIM}} bally(1 {{Cl|TO}} BC) -{{Cl|DIM}} velx(1 {{Cl|TO}} BC) -{{Cl|DIM}} vely(1 {{Cl|TO}} BC) -{{Cl|DIM}} bsize(1 {{Cl|TO}} BC) -Y = {{Cl|INT}}({{Cl|RND}} * (400 - 100 + 1)) + 100 -X0 = 325 -Y0 = 300 -Tmax = 150 -DO - {{Cl|FOR...NEXT|FOR}} p = 1 {{Cl|TO}} BC - T = {{Cl|INT}}({{Cl|RND}} * (Tmax - 50 + 1)) + 50 - X = {{Cl|INT}}({{Cl|RND}} * (1000 + 500 + 1)) - 500 - velx(p) = (X - X0) / T ' calculate velocity based on flight time - vely(p) = -1 * (Y - .05 * (T ^ 2 + 20 * Y0)) / (T) ' verticle velocity - {{Cl|NEXT}} p - - {{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} BC - bsize(w) = {{Cl|INT}}({{Cl|RND}} * (10 - 0 + 1)) + 0 'size - {{Cl|NEXT}} w - - {{Cl|FOR...NEXT|FOR}} J = 1 {{Cl|TO}} Tmax - {{Cl|_LIMIT}} 60 - {{Cl|CLS}} - '{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 255 {{Cl|STEP}} .5 - '{{Cl|CIRCLE}} (X0, Y0), i, {{Cl|_RGB}}(255 - i, 0, 0), 0, 3.147 - ' {{Cl|NEXT}} i - - R = {{Cl|INT}}({{Cl|RND}} * (25 - 20 + 1)) + 20 'random glimmer - {{Cl|FOR...NEXT|FOR}} z = 1 {{Cl|TO}} BC - ballx(z) = X0 + velx(z) * J - bally(z) = Y0 - vely(z) * J + .5 * .1 * J ^ 2 - {{Cl|NEXT}} z - - {{Cl|FOR...NEXT|FOR}} d = 1 {{Cl|TO}} BC - RCOL = {{Cl|INT}}({{Cl|RND}} * (255 - 0 + 1)) 'color - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} bsize(d) + 1 {{Cl|STEP}} .4 'draw balls - {{Cl|CIRCLE}} (ballx(d), bally(d)), i, {{Cl|_RGBA}}(255, RCOL - (R * i), RCOL - R * i, 255) - {{Cl|NEXT}} i - {{Cl|NEXT}} d - - {{Cl|_DISPLAY}} - - {{Cl|NEXT}} J - -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{CodeEnd}} {{small|Code by Falcon}} - - -{{PageSeeAlso}} -* [[RANDOMIZE]], [[TIMER]] -* [[INT]], [[CINT]], [[FIX]] - - -{{PageNavigation}} diff --git a/internal/help/RSET_1111.txt b/internal/help/RSET_1111.txt deleted file mode 100644 index 9622ee282..000000000 --- a/internal/help/RSET_1111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:40}} -The '''RSET''' statement right-justifies a string according to length of the string expression. - - -{{PageSyntax}} -:: RSET string_variable = string_expression - - - -* If the ''string_expression'' is longer than a fixed length string variable the value is truncated from the right side in [[LSET]] or RSET. -* If the ''string_expression'' is smaller than the fixed length, spaces will occupy the extra positions in the string. -* RSET can be used with a [[FIELD]] or [[TYPE]] string definition to set the buffer position before a [[PUT]]. - - -''Example:'' -{{CodeStart}} -{{Cl|CLS}} -{{Cl|DIM}} thestring {{Cl|AS}} {{Cl|STRING}} * 10 -{{Cl|PRINT}} "12345678901234567890" -{{Cl|RSET}} thestring = "Hello!" -{{Cl|PRINT}} thestring -anystring$ = {{Cl|SPACE$}}(20) -{{Cl|RSET}} anystring$ = "Hello again!" -{{Cl|PRINT}} anystring$ -{{Cl|RSET}} thestring = "Over ten characters long" -{{Cl|PRINT}} thestring -{{CodeEnd}} -{{OutputStart}} -12345678901234567890 - Hello! - Hello Again! -Over ten c -{{OutputEnd}} - -:''Explanation:'' Notice how "Hello!" ends at the tenth position because the length of ''thestring'' is 10. When we used SPACE$(20) the length of ''anystring$'' became 20 so "Hello Again!" ended at the 20th position. That is right-justified. The last line "Over ten c" is truncated as it didn't fit into ''thestring'''s length of only 10 characters. - - -''See also:'' -* [[RTRIM$]], [[FIELD]] -* [[LSET]], [[LTRIM$]] -* [[PUT]], [[GET]] - - -{{PageNavigation}} diff --git a/internal/help/RTRIM$_11111$.txt b/internal/help/RTRIM$_11111$.txt deleted file mode 100644 index 029901836..000000000 --- a/internal/help/RTRIM$_11111$.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:41}} -The {{KW|RTRIM$}} function removes trailing space characters from a {{KW|STRING}} value. - - -{{PageSyntax}} -:{{parameter|return$}} = {{KW|RTRIM$}}({{Parameter|value$}}) - - -{{PageDescription}} -* {{Parameter|value$}} is the {{KW|STRING}} value to trim. -* If {{Parameter|value$}} contains no trailing space characters, {{Parameter|value$}} is returned unchanged. -* Convert fixed length {{KW|STRING}} values by using a different {{parameter|return$}} variable. - - - -{{PageExamples}} -Trimming a fixed length string value for use by another string variable: -{{CodeStart}} -name$ = {{Cl|RTRIM$}}(contact.name) ' trims spaces from end of fixed length {{Cl|TYPE}} value. -{{CodeEnd}} - -Trimming text string ends: -{{CodeStart}}{{Cl|PRINT}} {{Cl|RTRIM$}}("some text") + "." -{{Cl|PRINT}} {{Cl|RTRIM$}}("some text ") + "." -{{Cl|PRINT}} {{Cl|RTRIM$}}("Tommy ") -{{CodeEnd}} -{{OutputStart}}some text. -some text. -Tommy -{{OutputEnd}} - - -{{PageSeeAlso}} -* {{KW|LTRIM$}}, {{KW|STR$}} - -* {{KW|LSET}}, {{KW|RSET}} - - -{{PageNavigation}} diff --git a/internal/help/RUN_111.txt b/internal/help/RUN_111.txt deleted file mode 100644 index c26e140a2..000000000 --- a/internal/help/RUN_111.txt +++ /dev/null @@ -1,64 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:42}} -'''RUN''' is a control flow statement that clears and restarts the program currently in memory or executes another specified program. - -The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 it 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}} -:: '''RUN''' [{''line_number'' | ''filespec$''}] [''command_parameter(s)''] - - -{{Parameters}} -* ''line number'' specifies a line number in the main module code. -* An optional ''filespec'' specifies a program to load into memory and run. -: * BAS or EXE extensions are assumed to be the same as the calling module's extension, EXE or BAS (QBasic only). -: * ''file names specs'' with other extensions must use the full filename. No extension requires a dot. -* In '''QB64''' ''command line parameters'' can follow the program file name and be read using the [[COMMAND$]] function later. - - -''Usage:'' -* The starting [[line number]] MUST be one used in the main module code, even if RUN is called from within a SUB or FUNCTION. -* If no line number is given the currently loaded program runs from the first executable line. -* In '''QB64''' RUN can open any kind of executable program and provide case sensitive program specific parameters. -** Recommended practice to run external programs is to use [[SHELL]]. -* RUN closes all open files and closes the invoking program module before the called program starts. -* RUN resets the [[RANDOMIZE]] sequence to the starting [[RND]] function value. -* '''Note: Calling RUN repeatedly may cause a stack leak in QB64 if it is called from within a [[SUB]] or [[FUNCTION]]. Avoid when possible.''' - - -''Example 1:'' Shows how RUN can reference multiple line numbers in the main module code. No line number executes first code line. -{{CodeStart}} -PRINT " A", " B", " C", " D" -10 A = 1 -20 B = 2 -30 C = 3 -40 D = 4 -50 {{Cl|PRINT}} A, B, C, D -60 {{Cl|IF...THEN|IF}} A = 0 {{Cl|THEN}} 70 {{Cl|ELSE}} {{Cl|RUN}} 20 'RUN clears all values -70 {{Cl|IF...THEN|IF}} B = 0 {{Cl|THEN}} 80 {{Cl|ELSE}} {{Cl|RUN}} 30 -80 {{Cl|IF...THEN|IF}} C = 0 {{Cl|THEN}} 90 {{Cl|ELSE}} {{Cl|RUN}} 40 -90 {{Cl|IF...THEN|IF}} D = 0 {{Cl|THEN}} 100 {{Cl|ELSE}} {{Cl|RUN}} 50 -100 {{Cl|PRINT}} -{{Cl|INPUT}} "Do you want to quit?(Y/N)", quit$ -{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(quit$) = "Y" {{Cl|THEN}} {{Cl|END}} {{Cl|ELSE}} {{Cl|RUN}} 'RUN without line number executes at first code line - -{{CodeEnd}} -{{OutputStart}}A B C D -1 2 3 4 -0 2 3 4 -0 0 3 4 -0 0 0 4 -0 0 0 0 - -Do you want to quit?(Y/N)_ -{{OutputEnd}} - - -''See also:'' -* [[CHAIN]], [[SHELL]] -* [[COMMAND$]] - - -{{PageNavigation}} diff --git a/internal/help/SADD_1111.txt b/internal/help/SADD_1111.txt deleted file mode 100644 index 212f6ee42..000000000 --- a/internal/help/SADD_1111.txt +++ /dev/null @@ -1,19 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:43}} -The '''SADD''' function returns the address of a [[STRING]] variable as an offset from the current data segment. - - -{{PageSyntax}} -:: SADD(stringvariable) - - -* The argument may be a simple string variable or a single element of a string array. You may not use fixed-length strings. -* Use this function carefully because strings can move in the BASIC string space storage area at any time. -* Adding characters may produce a run-time error. Don't add characters to the ends of parameters. - - -''See also:'' -* [[VARSEG]], [[VARPTR]], [[DEF SEG]] - - -{{PageNavigation}} diff --git a/internal/help/SCREEN_(function)_111111_(00000000).txt b/internal/help/SCREEN_(function)_111111_(00000000).txt deleted file mode 100644 index 534041720..000000000 --- a/internal/help/SCREEN_(function)_111111_(00000000).txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:44}} -The '''SCREEN''' function returns the [[ASCII]] code of a text character or the color attribute at a set text location on the screen. - - -{{PageSyntax}} -:: codeorcolor% = '''SCREEN (''row%'', ''column%''''' [, colorflag%]''')''' - - -{{Parameters}} -* ''row'' and ''column'' are the [[INTEGER]] text coordinates of the [[SCREEN]] mode used. -* Optional ''colorflag'' [[INTEGER]] value can be omitted or 0 for [[ASCII]] code values or 1 for color attributes. - - - -''Usage:'' -* The ''code'' value returned is the [[ASCII]] code from 0 to 255. Returns 32([[SPACE$|space]]) when no character is found at a coordinate. -* If the ''colorflag'' value is omitted or it is 0, the function returns the [[ASCII]] code of the text character at the position designated. -* When the ''flag'' value is greater than 0 in '''SCREEN 0''', the function returns the foreground and background color attribute of text position. -:: * The foreground color(0 to 15) is the returned SCREEN color value AND 15: '''{{text|FG = SCREEN(1, 1, 1) AND 15|green}}''' -:: * The background color(0 to 7) is the returned SCREEN color value \ 16: '''{{text|BG = SCREEN(1, 1, 1) \ 16|green}}''' -* '''QB64''' can return color values in screen modes other than [[SCREEN]] 0. QBasic returned the wrong color values in graphic screen modes! - - -''Example 1:'' Finding the text foreground and background colors in SCREEN 0 only: -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|COLOR}} 0, 15 -{{Cl|CLS}} - -{{Cl|PRINT}} "{{Cl|SCREEN}} ="; {{Cl|SCREEN (function)|SCREEN}}(1, 1, 1) -{{Cl|PRINT}} "FG color:"; {{Cl|SCREEN (function)|SCREEN}}(1, 1, 1) {{Cl|AND (boolean)|AND}} 15 'low nibble -{{Cl|PRINT}} "BG color:"; {{Cl|SCREEN (function)|SCREEN}}(1, 1, 1) \ 16 'high nibble -{{CodeEnd}} -{{TextStart}}'''SCREEN = 112''' -'''FG color: 0''' -'''BG color: 7''' -{{TextEnd}} -: ''Note:'' How the SCREEN 0 background color can only be changed to colors 0 through 7! 7 * 16 = 112. - - -''Example 2:'' Reading the [[ASCII]] code and color of a text character using the SCREEN function. Graphic colors were not reliable in QBasic! -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -row = 10: column = 10 - -{{Cl|COLOR}} 9: {{Cl|LOCATE}} row, column: {{Cl|PRINT}} "Hello" -code% = {{Cl|SCREEN (function)|SCREEN}}(row, column, 0) ' character code return parameter 0 -attrib% = {{Cl|SCREEN (function)|SCREEN}}(row, column, 1) ' character color return parameter 1 -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 15, 10: {{Cl|PRINT}} "ASCII:"; code%, "COLOR:"; attrib% -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} -{{Text| Hello|blue}} - - - -{{Text| ASCII: 72 COLOR: 9|yellow}} -{{OutputEnd}} -:''Explanation:'' The SCREEN function returns the [[ASCII]] code for "H" and the color 9. - - -''Example 3:'' Finding the current program path placed on the screen using [[FILES]] and the SCREEN function in SCREEN 0. -{{CodeStart}} -{{Cl|SCREEN}} 0, 0, 0, 0 -{{Cl|CLS}} -{{Cl|PRINT}} "This is a directory test..." -{{Cl|SCREEN}} 0, 0, 1, 0 -{{Cl|COLOR}} 0 'blank out the screen text -{{Cl|FILES}} "qb64.exe" 'the current program's filename can also be used -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 80 - a$ = a$ + {{Cl|CHR$}}({{Cl|SCREEN (function)|SCREEN}}(1, i)) 'scan the black text on the screen -{{Cl|NEXT}} -{{Cl|CLS}} -{{Cl|COLOR}} 7 -a$ = {{Cl|RTRIM$}}(a$) -{{Cl|SLEEP}} -{{Cl|SCREEN (statement)|SCREEN}} 0, 0, 0, 0 -{{Cl|LOCATE}} 3, 1: {{Cl|PRINT}} "The current directory is: "; a$ -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Pete from the N54 QB site}} -:''Explanation:'' The SCREEN page one is used to hide the [[FILES]] display using COLOR 0. The [[SCREEN (function)|SCREEN]] function reads the top of the screen page text and creates the current path string. It is then printed on the visual page. - - -''See also:'' -* [[PRINT]], [[SCREEN]] -* [[COLOR]], [[CHR$]], [[POINT]] -* [[CSRLIN]], [[POS]], [[ASCII]] -* [[Screen Memory]] - - -{{PageNavigation}} diff --git a/internal/help/SCREEN_111111.txt b/internal/help/SCREEN_111111.txt deleted file mode 100644 index 4b826ea18..000000000 --- a/internal/help/SCREEN_111111.txt +++ /dev/null @@ -1,194 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:45}} -{| align="Right" - | __TOC__ - |} -The [[SCREEN]] statement sets the video display mode and size of the program window's workspace. - - -{{PageSyntax}} - -: [[SCREEN]] {''mode%''|''imagehandle&''} [, , active_page, visual_page] - - -{{Parameters}} -* The SCREEN ''mode'' [[INTEGER]] values available today are 0 to 2 and 7 to 13 listed below. -* '''QB64''' can use a [[LONG]] [[_NEWIMAGE]] page or [[_LOADIMAGE]] file ''image handle'' value instead. -* The empty comma disables color when any value is used. '''DO NOT USE!''' Include the comma ONLY when using page flipping. -* If the SCREEN mode supports pages, the ''active page'' is the page to be worked on while ''visual page'' is the one displayed. - - -''Usage:'' -* No SCREEN statement in a program defaults to [[SCREEN]] 0 text ONLY mode. -* A SCREEN statement that changes screen modes also clears the screen like [[CLS]]. Nothing on the screen is retained. -* Some screen mode text sizes are adjustable with [[WIDTH]] and all '''QB64''' screens support [[PCOPY]] and page flipping. - -{{WhiteStart}} '''LEGACY SCREEN MODES AT A GLANCE''' - - '''Screen Text Graphics Colors Video Text Default''' - '''Mode Rows Columns Width Height Attrib. BPP Pages Block QB64 Font''' - - 0 25/43/50 80/40 No graphics 16/16 DAC 4 0-7 ----- _FONT 16 - 1 25 40 320 200 16/4 BG 4 none 8 X 8 _FONT 8 - 2 25 80 640 200 2/mono 1 none 8 X 8 _FONT 8 - ................................................................................. - 7 25 40 320 200 16/16 DAC 4 0-7 8 X 8 _FONT 8 - 8 25 80 640 200 16/16 4 0-3 8 X 8 _FONT 8 - 9 25 80 640 350 16/64 DAC 4 0-1 8 X 14 _FONT 14 - 10 25 80 640 350 4/2 GScale 2 none 8 X 14 _FONT 14 - 11 30/60 80 640 480 2/mono 1 none 8 X 16 _FONT 16 - 12 30/60 80 640 480 16/262K 4 none 8 X 16 _FONT 16 - 13 25 40 320 200 256/65K 8 none 8 X 8 _FONT 8 - - '''QB64 allows video paging and [[PCOPY]] in ALL screen modes!''' -{{WhiteEnd}} - -==QB64 Custom Screen Modes== - -: [[SCREEN]] ''imagehandle&'' [, , ''active_page'', ''visual_page''] - -: [[SCREEN]] [[_NEWIMAGE]](''wide&'', ''high&''[, {''mode''|''256''|''32''}]) [, , ''active_page'', ''visual_page''] - -: [[SCREEN]] [[_LOADIMAGE]](''file$''[, {''mode''|''256''|''32''}]) [, , ''active_page'', ''visual_page''] - - -* Custom screen modes can be created using a [[_NEWIMAGE]] or [[_LOADIMAGE]] function ''imagehandle'' return value. -* '''QB64''' screen modes 0 to 2 and 7 to 13 can be emulated with the same color depth and text block size and different dimensions. -* [[_NEWIMAGE]] screens can be any set size. A screen mode can be emulated or 256 or 32 bit colors can be designated. -* The [[_LOADIMAGE]] screen size will be the size of the image loaded. Can designate a ''mode'' or 256 or 32 bit colors. -* '''QB64''' allows page flipping or a [[PCOPY]] in ANY SCREEN mode. [[_DISPLAY]] can also be used to reduce flickering in animations. -* All SCREEN modes are Windows in QB64. Use [[_FULLSCREEN]] to set the window area to full screen. -* [[_SCREENMOVE]] can position a window or the _MIDDLE option can center it on the desktop. - -

([[#toc|Return to Table of Contents]])

- -==Legacy Screen Modes== - -* '''[[SCREEN]] 0''' (default mode) is a '''text only''' screen mode. 64 (VGA) colors with hi-intensity(blinking) colors 16 to 31. ([[DAC]] attrib 6, 8 to 15). 8 Background colors intensities only(0 - 7). No graphics are possible! Normally runs in a window. ALT-Enter switches from a window to fullscreen. To automatically run in '''QBasic''' fullscreen, use another Screen mode before using {{KW|SCREEN (statement)|SCREEN}} 0. Can use {{KW|PCOPY}} with video pages 0 to 7. Text is 25, 43 or 50 rows by 40 or 80 columns. Default is 25 by 80. See {{KW|WIDTH}}. - -: '''Note:''' Use [[OUT]] or [[_PALETTECOLOR]] to create higher intensity color backgrounds than [[COLOR]] , 7. - -:::'''All other available [[SCREEN]] modes can use text and graphics and are fullscreen in QBasic ONLY.''' - -* '''[[SCREEN]] 1''' has 4 background color attributes. 0 = black, 1 = blue, 2 = green, 3 = grey. White foreground only. Text is 25 by 40. White graphics is 320 by 200. - -* '''[[SCREEN]] 2''' is '''monochrome''' with black background and white foreground. Text is 25 by 80. White graphics 640 by 200.          NO [[COLOR]] keyword allowed. - -* '''[[SCREEN]] 3 to 6 are no longer supported''' on most computers! Using them will cause a video [[ERROR Codes|error]]! - -* '''[[SCREEN]] 7''' has 16 color attributes ([[DAC]] attrib. 8 to 15) with background colors. Text 25 rows by 40 columns. Graphics 320 columns by 200 rows. Video pages 0 to 7 for flipping or {{KW|PCOPY}}. - -* '''[[SCREEN]] 8''' has 16 color attributes with background. Text is 25 by 80. Graphics is 640 by 200. Video pages 0 to 3. - -* '''[[SCREEN]] 9''' has 64 DAC color hues for ([[DAC]] attrib. 6, 8 to 15) with background colors. Text is 25 by 80. Graphics is 640 by 350. Video pages 0 and 1 for flipping or {{KW|PCOPY}}. - -* '''[[SCREEN]] 10''' has 4 gray scale color attributes with black background. 1 = normal white, 2 = blinking white and 3 = bright white. Text is 25 by 80. Graphics is 640 by 350. - -* '''[[SCREEN]] 11''' is '''monochrome''' with black background and white foreground. Text is 30 or 60 by 80 columns(see {{KW|WIDTH}}). White graphics is 640 by 480. NO [[COLOR]] keyword allowed. - -* '''[[SCREEN]] 12''' has 16 color attributes, black background. 256K possible color hues. Text is 30 or 60 by 80 columns(see {{KW|WIDTH}}). Graphics 640 by 480. - -* '''[[SCREEN]] 13''' has 256 color attributes, black background. 256K possible color hues. Text is 25 by 40. Graphics is 320 by 200. - -* '''[[SCREEN]] [[_NEWIMAGE]]'''(wide&, deep&, mode%) can imitate any size screen mode or use 32 bit or 256 color modes in '''QB64'''. - -* '''[[SCREEN]] [[_LOADIMAGE]]'''(imagehandle&, colors) can load a program screen of an image file handle in '''QB64''' using 256 or 32 bit. - -
'''QB64 can use page flipping with any number of pages in any screen mode!'''
- -

([[#toc|Return to Table of Contents]])

- -==Text and Graphics== - - -:::::::::'''Text Coordinates:''' - -* Are a minimum of 1 and the values given above are the maximums. [[LOCATE]] 1, 1 is the top left [[SCREEN]] text position. -* Text characters occupy a certain sized pixel box adjusted by [[WIDTH]] in some screen modes. -* Text [[PRINT]] cursor positions can be read by {{KW|CSRLIN}} and {{KW|POS|POS(0)}} to [[LOCATE]] text [[PRINT]]s. -* [[VIEW PRINT]] can be used to designate a text view port area. -* In '''QB64''' the [[_WIDTH (function)|_WIDTH]] and [[_HEIGHT]] functions will return the text dimensions in SCREEN 0 only. - - -:::::::::'''Graphic Coordinates:''' - -* The minimum on screen graphics pixel coordinates are 0 for columns and rows in the top left corner. -* Maximum pixel coordinates are one less than the maximum dimensions above because the pixel count starts at 0. -* Graphic objects such as [[PSET]], [[PRESET]], [[LINE]], [[CIRCLE]] and [[DRAW]] can be placed partially off of the screen. -* [[GET (graphics statement)|GET]] and [[PUT (graphics statement)|PUT]] screen image operations MUST be located completely on the screen in QBasic! -* [[VIEW]] can be used to designate a graphic view port area of the screen. -* [[WINDOW]] can be used to set the graphics SCREEN coordinates to almost any size needed. Use the SCREEN option for normal row coordinate values. Row coordinates are Cartesian(decrease in value going down the screen) otherwise. -* In '''QB64''' the [[_WIDTH (function)|_WIDTH]] and [[_HEIGHT]] functions will return the graphic pixel dimensions in SCREENs other than 0. - - -:::::::'''QB64 Screen Statements and Functions:''' - -* For file image screens that adopt the image dimensions and image color settings use: [[_LOADIMAGE]] -* To create custom sized screen modes or pages and 256 or 32 bit colors use: [[_NEWIMAGE]] -* [[_PUTIMAGE]] can stretch or reduce the size of images to fit the SCREEN size. -* [[PUT (graphics statement)|PUT]] can use [[_CLIP]] to set objects partially off screen. [[GET (graphics statement)|GET]] can read objects off screen as a color in QB64 ONLY. -* A [[_DISPLAY]] statement can be used to only display an image after changes instead of using page flipping or [[PCOPY]]. -* The current desktop screen resolution can be found using the [[_SCREENIMAGE]] handle value with [[_WIDTH (function)|_WIDTH]] and [[_HEIGHT]]. -* '''NOTE: Default 32 bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0)! Use [[CLS]] to make the black opaque!''' - -

([[#toc|Return to Table of Contents]])

- -==Examples== - -:''Example 1:'' Shows an example of each legacy screen mode available to QBasic and QB64. -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|PRINT}} "This is {{Cl|SCREEN}} 0 - only text is allowed!" -{{Cl|FOR}} S = 1 {{Cl|TO}} 13 - {{Cl|IF}} S < 3 {{Cl|OR}} S > 6 {{Cl|THEN}} - {{Cl|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - {{Cl|SCREEN}} S - {{Cl|PRINT}} "This is {{Cl|SCREEN}}"; S; " - can use text and graphics!" - {{Cl|IF}} S = 2 {{Cl|OR}} S = 11 {{Cl|THEN}} {{Cl|PRINT}} "Monochrome - no {{Cl|COLOR}} statements!" - {{Cl|IF}} S = 10 {{Cl|THEN}} - {{Cl|COLOR}} 2: {{Cl|PRINT}} "This {{Cl|SCREEN}} has only 4 colors. Black and 3 white: 2 blinks. - {{Cl|CIRCLE}} (100,100), 50, 2 - {{Cl|ELSE}} : {{Cl|CIRCLE}} (100,100), 100, S - {{Cl|END IF}} - {{Cl|END IF}} -{{Cl|NEXT}} -{{Cl|SLEEP}} -{{Cl|SYSTEM}} -{{CodeEnd}} -{{OutputStart}} -This is SCREEN 0 - only text is allowed! -{{OutputEnd}} -:Displays each {{KW|SCREEN (statement)|SCREEN}} mode one at a time with a {{KW|CIRCLE}} (except for {{KW|SCREEN (statement)|SCREEN}} 0) - -

([[#toc|Return to Table of Contents]])

- -==References== - -''See Examples:'' - -* [[SAVEIMAGE]] {{text|(QB64 Image to Bitmap SUB by Galleon)}} - -* [[Program ScreenShots]] {{text|(Member program for legacy screen modes)}} - -* [[ThirtyTwoBit SUB]] {{text|(QB64 Image area to bitmap)}} - -* [[SelectScreen]] {{text|(Member Screen mode selection function)}} - -* [[ScreenMode]] {{text|(Member function to find current Screen mode)}} - - -{{PageSeeAlso}} -* [[COLOR]], [[CLS]], [[WIDTH]] -* [[_NEWIMAGE]], [[_LOADIMAGE]], [[_SCREENIMAGE]] -* [[_LOADFONT]], [[_FONT]] -* [[_DISPLAY]], [[_COPYIMAGE]], [[_SCREENMOVE]] -* [[_SCREENHIDE]], [[_SCREENSHOW]], [[_SCREENICON]] -* [[PALETTE]], [[OUT]], [[PCOPY]], -* [[GET (graphics statement)|GET]], [[PUT (graphics statement)|PUT]] {{text|(graphics)}} -* [[VIEW]], [[WINDOW]] {{text|(graphic viewport)}}, [[VIEW PRINT]] {{text|(text view port)}} -* [[SCREEN (function)]] {{text|(text only)}}, [[POINT]] {{text|(graphic pixel colors)}} -* [[Screen Memory]], [[Screen Saver Programs]] -* [[_CONSOLE]] - - -{{PageNavigation}} diff --git a/internal/help/SEEK_(statement)_1111_(000000000).txt b/internal/help/SEEK_(statement)_1111_(000000000).txt deleted file mode 100644 index e1c805a5f..000000000 --- a/internal/help/SEEK_(statement)_1111_(000000000).txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:48}} -The '''SEEK''' statement sets the next byte or record position of a file for a read or write. - - - -{{PageSyntax}} -:: SEEK ''filenumber&'', ''position'' - - - -* ''filenumber'' must be the file number that is [[OPEN]] and being read or written to. -* ''position'' is a byte in [[BINARY]] or sequencial files created in [[OUTPUT]], [[APPEND]] or [[INPUT (file mode)]]s. The first byte = 1. -* ''position'' is the record in [[RANDOM]] files to read or write. Records can hold more than one variable defined in a [[TYPE]]. -* Since the first SEEK file position is 1 it may require adding one to an offset value when documentation uses that position as 0. -* After a SEEK statement, the next file operation starts at that SEEK byte position. -* The SEEK statement can work with the [[SEEK]] function to move around in a file. - - -''Example:'' A SEEK statement using the [[SEEK]] function to move to the next random record in a file. - -{{CodeStart}} - SEEK 1, {{Cl|SEEK}}(1) + 1 -{{CodeEnd}} - - - -''See also:'' -* [[SEEK]] {{text|(function)}} -* [[GET]], [[PUT]] - - -{{PageNavigation}} diff --git a/internal/help/SEEK_1111.txt b/internal/help/SEEK_1111.txt deleted file mode 100644 index dabf3ecbc..000000000 --- a/internal/help/SEEK_1111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:47}} -The '''SEEK''' function returns the current byte or record position in a file. - - - -{{PageSyntax}} -:: byte = SEEK(filenumber&) - - -* Filenumber is the number of an [[OPEN]] file in any mode. -* In [[RANDOM]] files SEEK returns the current record position. -* In [[BINARY]] or sequencial files SEEK returns the current byte position(first byte = 1). -* Since the first file position is 1 it may require adding one to an offset value when documentation uses that position as 0. -* Devices that do not support SEEK (SCRN, CONS, KBRD, COMn and LPTn) return 0. - - -''See also:'' -*[[SEEK (statement)]] -*[[LOC]] - - -{{PageNavigation}} diff --git a/internal/help/SELECT_CASE_111111_1111.txt b/internal/help/SELECT_CASE_111111_1111.txt deleted file mode 100644 index 454995cd4..000000000 --- a/internal/help/SELECT_CASE_111111_1111.txt +++ /dev/null @@ -1,171 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:49}} -[[SELECT CASE]] is used to determine the program flow by comparing the value of a variable to specific CASE values. - - -{{PageSyntax}} -:'''SELECT''' [EVERY]'''CASE''' {{Parameter|testExpression}} -::'''CASE''' {{Parameter|expressionList1}} -:::[statement-block1] -::['''CASE''' {{Parameter|expressionList2}} -:::[statement-block2]]... -::['''CASE ELSE''' -:::[statementblock-n]] -:'''END SELECT''' - - - -* '''SELECT CASE''' evaluates {{Parameter|testExpression}} and executes the first matching [[CASE]] or [[CASE ELSE]] block and exits. -* '''SELECT EVERYCASE''' allows the execution of all matching [[CASE]] blocks from top to bottom or the [[CASE ELSE]] block. -* The literal, variable or expression {{Parameter|testExpression}} comparison can result in any string or numerical type. -* '''Note:''' A {{Parameter|testExpression}} variable value can be changed inside of true CASE evaluations in SELECT EVERYCASE. -* A {{Parameter|testExpression}} derived from an expression or [[FUNCTION]] will only be determined once at the start of the block execution. -* Supports individual CASE values and ranges or lists of literal values as below: -** '''CASE''' casevalue: code {{text|''''case compares one numerical or text value'''}} -** '''CASE''' casevalue1 [[TO]] casevalue2: code {{text|''''case compares a range of values '''}} -** '''CASE''' casevalue1, casevalue2, casevalue3: code {{text|''''case compares a list of values separated by commas'''}} -** '''CASE IS''' > casevalue: code {{text|''''case compares a value as =, <>, < or > '''}} -** '''CASE ELSE''': code {{text|''''bottom case statement executes only when no other CASE is executed.}}''' -* The CASE values should cover the normal ranges of the comparison {{Parameter|testExpression}} values. -* Use '''CASE ELSE''' before '''END SELECT''' if an alternative is necessary when no other case matches. -* CASEs should be listed in an ascending or descending values for best and fastest results. -* [[STRING]] comparisons will be based on their respective [[ASCII]] code values where capital letters are valued less than lower case. -* Use '''SELECT CASE''' when [[IF...THEN]] statements get too long or complicated. -* '''SELECT CASE''' and '''EVERYCASE''' statement blocks must '''always''' be ended with [[END SELECT]]. -* Use '''[[colon]]s''' to execute multiple statements in one line. -* An '''[[underscore]]''' can be used anywhere after the code on one line to continue it to the next line in '''QB64'''. - - -{{PageExamples}} -''Example 1:'' SELECT CASE can use literal or variable [[STRING]] or numerical values in CASE comparisons: -{{CodeStart}} -{{Cl|INPUT}} "Enter a whole number value from 1 to 40: ", value -value1 = 10 -value2 = 20 -value3 = 30 - -{{Cl|SELECT CASE}} value - {{Cl|CASE}} value1: {{Cl|PRINT}} "Ten only" - {{Cl|CASE}} value1 {{Cl|TO}} value2: {{Cl|PRINT}} "11 to 20 only" '10 is already evaluated - {{Cl|CASE}} value1, value2, value3: {{Cl|PRINT}} "30 only" '10 and 20 are already evaluated - {{Cl|CASE IS}} > value2: {{Cl|PRINT}} "greater than 20 but not 30" '30 is already evaluated - {{Cl|CASE ELSE}}: {{Cl|PRINT}} "Other value" 'values less than 10 -{{Cl|END SELECT}} -{{CodeEnd}} -: ''Explanation:'' The first true CASE is executed and SELECT CASE is exited. "Other value" is printed for values less than 10. - - -''Example 2:'' SELECT CASE will execute the first CASE statement that is true and ignore all CASE evaluations after that: -{{CodeStart}} -a = 100 -{{Cl|SELECT CASE}} a 'designate the value to compare - {{Cl|CASE}} 1, 3, 5, 7, 9 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 10 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 50 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 100 - {{Cl|PRINT}} "This will be displayed when a equals 100" - {{Cl|PRINT}} "(and no other case will be checked)" - {{Cl|CASE}} 150 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE IS}} < 150 - {{Cl|PRINT}} "This will not be shown as a previous case was true" - {{Cl|CASE}} 50 {{Cl|TO}} 150 - {{Cl|PRINT}} "This will not be shown as a previous case was true" - {{Cl|CASE ELSE}} - {{Cl|PRINT}} "This will only print if it gets this far!" -{{Cl|END SELECT}} -{{CodeEnd}} -{{OutputStart}}This will be displayed when a equals 100 -(and no other case will be checked) -{{OutputEnd}} -:''Explanation:'' The first case where a value is true is shown, the remainder are skipped. Try changing the value of ''a''. - - -''Example 3:'' Same as Example 2 but, SELECT EVERYCASE will execute every CASE statement that is true. -{{CodeStart}} -a = 100 -{{Cl|SELECT CASE|SELECT EVERYCASE}} a 'designate the value to compare - {{Cl|CASE}} 1, 3, 5, 7, 9 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 10 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 50 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE}} 100 - {{Cl|PRINT}} "This will be displayed when a equals 100" - {{Cl|PRINT}} "(and other cases will be checked)" - {{Cl|CASE}} 150 - {{Cl|PRINT}} "This will not be shown." - {{Cl|CASE IS}} < 150 - {{Cl|PRINT}} "This will be shown as 100 is less than 150" - {{Cl|CASE}} 50 {{Cl|TO}} 150 - {{Cl|PRINT}} "This will be shown as 100 is between 50 and 150" - {{Cl|CASE ELSE}} - {{Cl|PRINT}} "This will only print if no other CASE is true!" -{{Cl|END SELECT}} -{{CodeEnd}} -{{OutputStart}}This will be displayed when a equals 100 -(and other cases will be checked) -This will be shown as 100 is less than 150 -This will be shown as 100 is between 50 and 150 -{{OutputEnd}} -:''Explanation:'' [[CASE ELSE]] will only execute if no other CASE was true. See Example 5 for more usages. - - -''Example 4:'' SELECT CASE evaluates string values by the [[ASC]] code value according to [[ASCII]]. -{{CodeStart}} -{{Cl|PRINT}} "Enter a letter, number or punctuation mark from the keyboard: "; -valu$ = {{Cl|INPUT$}}(1) -{{Cl|PRINT}} value$ -value1$ = "A" -value2$ = "m" -value3$ = "z" - -{{Cl|SELECT CASE}} value$ - {{Cl|CASE}} value1$: {{Cl|PRINT}} "A only" - {{Cl|CASE}} value1$ {{Cl|TO}} value2$: {{Cl|PRINT}} "B to m" 'A is already evaluated - {{Cl|CASE}} value1$, value2$, value3$: {{Cl|PRINT}} "z only" 'A and m are already evaluated - {{Cl|CASE IS}} > value2$: {{Cl|PRINT}} "greater than m but not z" 'z is already evaluated - {{Cl|CASE ELSE}}: {{Cl|PRINT}} "other value" 'key entry below A including all numbers -{{Cl|END SELECT}} -{{CodeEnd}} -: ''Notes:'' [[STRING]] values using multiple characters will be compared by the [[ASCII]] code values sequentially from left to right. Once the equivalent code value of one string is larger than the other the evaluation stops. This allows string values to be compared and sorted alphabetically using [[Greater Than|>]] or [[Less Than|<]] and to [[SWAP]] values in [[arrays]] regardless of the string lengths. - - -''Example 5:'' EVERYCASE is used to draw sections of digital numbers in a simulated LED readout using numbers from 0 to 9: -{{CodeStart}} -{{Cl|SCREEN}} 12 -DO - {{Cl|LOCATE}} 1, 1: {{Cl|INPUT}} "Enter a number 0 to 9: ", num - {{Cl|CLS}} - {{Cl|SELECT CASE|SELECT EVERYCASE}} num - {{Cl|CASE}} 0, 2, 3, 5 {{Cl|TO}} 9: {{Cl|PSET}} (20, 20), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'top horiz - {{Cl|CASE}} 0, 4 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 20), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'left top vert - {{Cl|CASE}} 0, 2, 6, 8: {{Cl|PSET}} (20, 54), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12, 12" 'left bot vert - {{Cl|CASE}} 2 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 54), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12, 12" 'middle horiz - {{Cl|CASE}} 0 {{Cl|TO}} 4, 7 {{Cl|TO}} 9: {{Cl|PSET}} (54, 20), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'top right vert - {{Cl|CASE}} 0, 1, 3 {{Cl|TO}} 9: {{Cl|PSET}} (54, 54), 12 - {{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'bottom right vert - {{Cl|CASE}} 0, 2, 3, 5, 6, 8: {{Cl|PSET}} (20, 88), 12 - {{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'bottom horiz - {{Cl|CASE ELSE}} - {{Cl|LOCATE}} 20, 20: {{Cl|PRINT}} "Goodbye!"; num - {{Cl|END SELECT}} -{{Cl|LOOP}} {{Cl|UNTIL}} num > 9 -{{CodeEnd}} -: '''Note:''' [[CASE ELSE]] will only execute if no other CASE is true! Changing the comparison value in a CASE may affect later CASE evaluations. '''Beware of duplicate variables inside of cases affecting the comparison values and remaining cases.''' - - -{{PageSeeAlso}} -* [[IF...THEN]], [[Boolean]] - - -{{PageNavigation}} diff --git a/internal/help/SGN_111.txt b/internal/help/SGN_111.txt deleted file mode 100644 index f7955fedd..000000000 --- a/internal/help/SGN_111.txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:50}} -The '''SGN''' function returns the sign of a number value. - - - -{{PageSyntax}} -:: sign% = SGN(value) - - - -* Returns -1 when a sign is negative, 0 when a value is zero, or 1 when a value is positive. -* Function is used to store the original sign of a number. -* '''QB64''' allows programs to return only [[_UNSIGNED]] variable values using a [[_DEFINE]] statement. - - - -''Example:'' Checking and changing negative values to positive ones. -{{CodeStart}} -n = -100 -{{Cl|IF...THEN|IF}} {{Cl|SGN}}(n) = -1 THEN n = {{Cl|ABS}}(n) -PRINT n -{{CodeEnd}} -{{OutputStart}} 100 -{{OutputEnd}} - - -''See also:'' -* [[ABS]] -* [[_DEFINE]], [[_UNSIGNED]] -* [[Mathematical Operations]] - - -{{PageNavigation}} diff --git a/internal/help/SHARED_111111.txt b/internal/help/SHARED_111111.txt deleted file mode 100644 index 193938a92..000000000 --- a/internal/help/SHARED_111111.txt +++ /dev/null @@ -1,72 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:51}} -The '''SHARED''' statement allows variables to be passed automatically to any [[SUB]] or [[FUNCTION]] procedure. - - - -{{PageSyntax}} -:: DIM SHARED Qt AS STRING * 1 - - -* [[DIM]]ensioned variables are shared with all procedures in the program module. -* When used with [[DIM]] in the main module, it eliminates the need to pass a parameter variable to a [[SUB]] or [[FUNCTION]]. -* Use [[COMMON SHARED]] to share a list of variable values with sub-procedures or other modules. See also: [[COMMON]] -* SHARED ('''without [[DIM]]''') can share a list of variables inside of [[SUB]] or [[FUNCTION]] procedures with the main module only. -:'''Note: SHARED variables in sub-procedures will not be passed to other sub-procedures, only the main module.''' - - -''Example 1:'' Defining variable types with [[AS]] or type suffixes. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} Qt AS {{Cl|STRING}} * 1, price AS {{Cl|DOUBLE}}, ID AS {{Cl|INTEGER}} -{{Cl|DIM}} {{Cl|SHARED}} Q$, prices#, IDs% -{{CodeEnd}} - - -''Example 2:'' The DIR$ function 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|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 SHARED variable - {{Cl|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|NEXT}} -{{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}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} DirList$(ListMax%): Ready% = -1 'DIM array first use -{{Cl|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 (file statement)|FOR}} {{Cl|APPEND}} {{Cl|AS}} #ff% - size& = {{Cl|LOF}}(ff%) - {{Cl|CLOSE}} #ff% - {{Cl|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}} {{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% 'SHARED variable can return the file count - {{Cl|CLOSE}} #ff% - {{Cl|KILL}} TmpFile$ -{{Cl|ELSE}} {{Cl|IF}} Index% > 0 {{Cl|THEN}} Index% = Index% - 1 'no spec sends next file name -{{Cl|END IF}} -DIR$ = DirList$(Index%) -{{Cl|END FUNCTION}} -{{CodeEnd}}{{small|Code by Ted Weissgerber}} -: ''Explanation:'' The SHARED variable value ''DIRcount%'' can tell the main program how many files were found using a wildcard spec. - - -''See also:'' -* [[DIM]], [[REDIM]] -* [[COMMON]], [[COMMON SHARED]] - - -{{PageNavigation}} diff --git a/internal/help/SHELL_(function)_11111_(00000000).txt b/internal/help/SHELL_(function)_11111_(00000000).txt deleted file mode 100644 index 7c1eb7760..000000000 --- a/internal/help/SHELL_(function)_11111_(00000000).txt +++ /dev/null @@ -1,62 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:54}} -The '''SHELL''' function displays the console and returns the [[INTEGER]] code value sent when the external program exits. - - -{{PageSyntax}} -::: return_code = '''SHELL(''DOScommand$'')''' - - -{{Parameters}} -* The literal or variable [[STRING]] ''command'' parameter can be any valid external command or call to another program. - - -''Usage:'' -* A SHELL to a QB64 EXE program with an exit return code parameter after [[END]] or [[SYSTEM]] will return that code value. -* The return_code is usually 0 when the external program ends with no errors. -* The console window may appear when using the SHELL function. The [[_SHELLHIDE]] function will hide the console from view. - - -''Example:'' Shelling to another QB64 program will return the exit code when one is set in the program that is run. -{{TextStart}}''''DesktopSize.BAS ''' Compile in Windows with QB64 first - -{{Cb|CONST}} SM_CXSCREEN = 0 -{{Cb|CONST}} SM_CYSCREEN = 1 - -{{Cb|DECLARE LIBRARY}} - {{Cb|FUNCTION}} GetSystemMetrics& ({{Cb|BYVAL}} n {{Cb|AS}} {{Cb|LONG}}) -{{Cb|DECLARE LIBRARY|END DECLARE}} - -{{Cb|PRINT}} trimstr$(GetSystemMetrics(SM_CXSCREEN)); "X"; trimstr$(GetSystemMetrics(SM_CYSCREEN)) - -s& = {{Cb|_SCREENIMAGE}} -{{Cb|PRINT}} {{Cb|_WIDTH (function)|_WIDTH}}(s&); "X"; {{Cb|_HEIGHT}}(s&) - -{{Cb|END}} 3 '<<<<<< add a code to return after END or SYSTEM in any program - -{{Cb|FUNCTION}} trimstr$ (whatever) -trimstr = {{Cb|LTRIM$}}({{Cb|RTRIM$}}({{Cb|STR$}}(whatever))) -{{Cb|END FUNCTION}} -{{TextEnd}} -: ''Explanation:'' To set a program exit code use an [[INTEGER]] parameter value after [[END]] or [[SYSTEM]] in the called program. - -: After compiling ''DesktopSize.EXE'' run the following code in the QB64 IDE. After 1st program is done 3 will appear on screen: -{{CodeStart}} -returncode% = {{Cl|SHELL (function)|SHELL}}("DesktopSize") 'replace call with name of any QB64 program EXE - -{{Cl|PRINT}} returncode% 'prints code sent by called program after it is closed - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}}3 {{OutputEnd}} - - - -''See also:'' -* [[_SHELLHIDE]] {{text|(function)}} -* [[SHELL]], [[_HIDE]] -* [[_CONSOLE]], [[$CONSOLE]] -* [[SYSTEM]], [[END]] - - -{{PageNavigation}} diff --git a/internal/help/SHELL_11111.txt b/internal/help/SHELL_11111.txt deleted file mode 100644 index a8c3b1aae..000000000 --- a/internal/help/SHELL_11111.txt +++ /dev/null @@ -1,156 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:52}} -The [[SHELL]] statement allows a program to run external programs or command line statements in Windows, macOS and Linux. - - -{{PageSyntax}} -: [[SHELL]] [{{Parameter|DOSCommand$}}] -: [[SHELL]] ['''_DONTWAIT'''] ['''_HIDE'''] [{{Parameter|DOSCommand$}}] - - -{{PageDescription}} -* If the ''DOSCommand$'' [[STRING]] parameter isn't used, the "command console" is opened and execution is halted until the user closes it manually. -* If [[_DONTWAIT]] is used, the '''QB64''' program doesn't wait for the SHELLed program/command to end. -* When the [[_HIDE]] action is used, the [[CONSOLE|console]] window is hidden and screen info can be "redirected" (using redirection characters like >) to a file (recommended). -* Commands are external commands, according to the user's operating system, passed as [[STRING|strings]] enclosed in quotes or string variables. -* Commands can be a mixture of [[STRING|strings]] and string variables added together using the + [[concatenation]] operator. -* Command text can be in upper or lower case. Use single spacing between items and options. -* '''QB64''' automatically uses CMD /C when using [[SHELL]], but it is allowed in a command string. {{text|Note: CMD alone may lock up program.|red}} -** '''Note: Some commands may not work without adding CMD /C to the start of the command line.''' -* '''QB64''' program screens will not get distorted, minimized or freeze the program like QBasic fullscreen modes would. -* '''QB64''' can use long path folder names and file names and [[SHELL]] command lines can be longer than 124 characters. -* In Windows, use additional [[CHR$]](34) quotation marks around folder or file names that contain spaces. -* For other operating systems, both the quotation mark character and the apostrophe can be used to enclose a file name that contains spaces. -*'''NOTE: Use [[CHDIR]] instead of CD as SHELL commands cannot affect the current program path.''' - - -==QBasic/QuickBASIC== -* '''QBasic BAS files could be run like compiled programs without returning to the IDE when [[SYSTEM]] was used to [[END|end]] them.''' -* A user would invoke it with {{InlineCode}}SHELL "QB.EXE /L /RUN program.BAS"{{InlineCodeEnd}} - - -{{PageExamples}} -''Example 1:'' When working with file or folder names with spaces, add quotation marks around the path and/or file name with [[CHR$]](34). -{{CodeStart}} -{{Cl|SHELL}} {{Cl|_HIDE}} "dir " + {{Cl|CHR$}}(34) + "free cell.ico" + {{Cl|CHR$}}(34) + " /b > temp.dir" -{{Cl|SHELL}} "start Notepad temp.dir" ' display temp file contents in Notepad window -{{CodeEnd}} -:{{small|Contents of ''temp.dir'' text file:}} -{{TextStart}}Free Cell.ico -{{TextEnd}} - - -''Example 2:'' Opening a Windows program (Notepad) to read or print a Basic created text file. -{{CodeStart}} -{{Cl|INPUT}} "Enter a file name to read in Notepad: ", filename$ -{{Cl|SHELL}} "CMD /C start /max notepad " + filename$ ' display in Notepad full screen in XP or NT - -'{{Cl|SHELL}} "start /min notepad /p " + filename$ ' taskbar print using QB64 CMD /C not necessary -{{CodeEnd}} - -:''Explanation:'' Notepad is an easy program to open in Windows as no path is needed. Windows NT computers, including XP, use CMD /C where older versions of DOS don't require any command reference. The top command opens Notepad in a normal window for a user to view the file. They can use Notepad to print it. The second command places Notepad file in the taskbar and prints it automatically. The filename variable is added by the program using proper spacing. - -::*'''Start''' is used to allow a Basic program to run without waiting for Notepad to be closed. -::* '''/min''' places the window into the taskbar. '''/max''' is fullscreen and no option is a normal window. -::* Notepad's '''/p''' option prints the file contents, even with USB printers. - - - -''Example 3:'' Function that returns the program's current working path. -{{CodeStart}} - currentpath$ = Path$ ' function call saves a path for later program use - PRINT currentpath$ - - {{Cl|FUNCTION}} Path$ - {{Cl|SHELL}} {{Cl|_HIDE}} "CD > D0S-DATA.INF" 'code to hide window in '''QB64''' - {{Cl|OPEN}} "D0S-DATA.INF" FOR {{Cl|APPEND}} AS #1 'this may create the file - L% = {{Cl|LOF}}(1) 'verify that file and data exist - {{Cl|CLOSE}} #1 - {{Cl|IF}} L% {{Cl|THEN}} 'read file if it has data - {{Cl|OPEN}} "D0S-DATA.INF" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 - {{Cl|LINE INPUT (file statement)|LINE INPUT}} #1, line$ 'read only line in file - Path$ = line$ + "\" 'add slash to path so only a filename needs added later - {{Cl|CLOSE}} #1 - {{Cl|ELSE}} : Path = "" 'returns zero length string if path not found - END IF - {{Cl|KILL}} "D0S-DATA.INF" 'deleting the file is optional - {{Cl|END FUNCTION}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' The '''SHELL "CD"''' statement requests the current working path. This info is normally printed to the screen, but the '''>''' pipe character sends the information to the DOS-DATA.INF file instead('''QB64''' can use [[_HIDE]] to not display the DOS window). The function uses the [[OPEN]] FOR [[APPEND]] mode to check for the file and the data([[INPUT (file mode)|INPUT]] would create an error if file does not exist). The current path is listed on one line of the file. The file is opened and [[LINE INPUT (file statement)|LINE INPUT]] returns one line of the file text. The function adds a "\" so that the Path$ returned can be used in another file statement by just adding a file name. Save the Path$ to another variable for later use when the program has moved to another directory. -: In '''QB64''' you can simply use the [[_CWD$]] statement for the same purpose of the example above. - - -''Example 4:'' Determining if a drive or path exists. Cannot use with a file name specification. -{{CodeStart}} -{{Cl|LINE INPUT}} "Enter a drive or path (no file name): ", DirPath$ -{{Cl|IF}} PathExist%(DirPath$) {{Cl|THEN}} PRINT "Drive Path exists!" {{Cl|ELSE}} PRINT "Drive Path does not exist!" -{{Cl|END}} - -{{Cl|FUNCTION}} PathExist% (Path$) -PathExist% = 0 -{{Cl|IF}} {{Cl|LEN}}(Path$) = 0 {{Cl|THEN}} {{Cl|EXIT FUNCTION}} 'no entry -{{Cl|IF}} {{Cl|LEN}}({{Cl|ENVIRON$}}("OS")) {{Cl|THEN}} CMD$ = "CMD /C " {{Cl|ELSE}} CMD$ = "COMMAND /C " -{{Cl|SHELL}} {{Cl|_HIDE}} CMD$ + "If Exist " + Path$ + "\nul echo yes > D0S-DATA.INF" -{{Cl|OPEN}} "D0S-DATA.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|APPEND}} {{Cl|AS}} #1 -{{Cl|IF}} {{Cl|LOF}}(1) {{Cl|THEN}} PathExist% = -1 'yes will be in file if path exists -{{Cl|CLOSE}} #1 -{{Cl|KILL}} "D0S-DATA.INF" 'delete data file optional -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation: IF Exist'' checks for the drive path. ''\Nul'' allows an emply folder at end of path. ''Echo'' prints '''yes''' in the file if it exists. -: In '''QB64''' you can simply use the [[_FILEEXISTS]] statement for the same purpose of the example above. - - -''Snippet 1:'' When looking for '''printers''' this command gives you a file list with the default printer marked as '''TRUE''': -{{TextStart}}{{Cb|SHELL}} {{Cb|_HIDE}} "CMD /C" + "wmic printer get name,default > default.txt" -{{TextEnd}} -'''Created file's text:''' -{{TextStart}}Default Name - FALSE Microsoft XPS Document Writer - TRUE HP Photosmart C7200 series - FALSE HP Officejet Pro 8600 - FALSE Fax -{{TextEnd}} -: ''Explanation:'' [[LINE INPUT]] could be used to find the printer names as [[STRING]] variables. - - -''Snippet 2:'' Here is the code to set the default printer to the "HP Officejet Pro 8600": -{{TextStart}}SHELL _HIDE "CMD /C" + "wmic printer where name='HP Officejet Pro 8600' call setdefaultprinter" -{{TextEnd}} -: After executing this program, and then running the first snippet again, we see the following '''contents of the text file:''' -{{TextStart}}Default Name - FALSE Microsoft XPS Document Writer - FALSE HP Photosmart C7200 series - TRUE HP Officejet Pro 8600 - FALSE Fax -{{TextEnd}} - - -===More examples=== -''See examples in:'' -* [[FILELIST$ (function)]] (member-contributed file search routine) -* ''File Exist'' C++ Function that does not create a temp file: [[Windows_Libraries#File_Exist|FileExist Library Function]] - - -{{PageSeeAlso}} -* [[SHELL (function)]], [[_SHELLHIDE]] -* [[FILES]], [[CHDIR]], [[MKDIR]] -* [[_CWD$]], [[_STARTDIR$]] -* [[_FILEEXISTS]], [[_DIREXISTS]] -* [[RMDIR]], [[NAME]], [[KILL]], [[RUN]] -* [[_HIDE]], [[_DONTWAIT]] -* [[_CONSOLE]], [[$CONSOLE]] -* [[$SCREENHIDE]], [[$SCREENSHOW]] {{text|(QB64 [[Metacommand]]s)}} -* [[_SCREENHIDE]], [[_SCREENSHOW]] -* [[FILELIST$]], [[PDS_(7.1)_Procedures#DIR.24|DIR$]] {{text|(member-contributed file list array function)}} - - -===Extra reference=== -* [[Windows_Libraries#File_Dialog_Boxes|Windows Open and Save Dialog Boxes]] -* [[C_Libraries#Console_Window|C Console Library]] -* [[Windows Printer Settings]] - - -{{PageNavigation}} diff --git a/internal/help/SINGLE_111111.txt b/internal/help/SINGLE_111111.txt deleted file mode 100644 index 15157327e..000000000 --- a/internal/help/SINGLE_111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:56}} -'''SINGLE''' variables are 4 byte floating decimal point numerical values up to seven digits in length. - - -{{PageSyntax}} -:: [[DIM]] ''variable'' AS SINGLE - - -{{PageDescription}} -* Values can range up to 7 digits. Decimal point accuracy depends on whole value places taken. -* Single is the '''default variable type''' assigned to undefined variables without a type suffix. -* Variable suffix type designation is '''!'''. Suffix can also be placed after a literal numerical value by user or automatically by the IDE. -* 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]]! -* Values can be converted to 4 byte [[ASCII]] string values using [[_MKS$]] and back with [[_CVS]]. -* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix!''' - - -{{PageSeeAlso}} -* [[DIM]], [[DEFSNG]] -* [[MKS$]], [[CVS]] -* [[DOUBLE]], [[_FLOAT]] -* [[LEN]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/SIN_111.txt b/internal/help/SIN_111.txt deleted file mode 100644 index 6534084f2..000000000 --- a/internal/help/SIN_111.txt +++ /dev/null @@ -1,121 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:55}} -The {{KW|SIN}} function returns the vertical component or sine of an angle measured in radians. - - -{{PageSyntax}} -::: value! = '''SIN('''''radian_angle!''''')''' - - -{{Parameters}} -* The ''radian_angle'' must be measured in radians from 0 to 2 * Pi. - - -{{PageDescription}} -* To convert from degrees to radians, multiply degrees * Ï€/180. -* [[SIN]]E is the vertical component of a unit vector in the direction theta (é). -* Accuracy can be determined as [[SINGLE]] by default or [[DOUBLE]] by following the parameter value with a # suffix. - - -''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) -{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI -{{Cl|PRINT}} "COS(PI) = "; {{Cl|COS}}(PI) -{{Cl|PRINT}} "SIN(PI) = "; {{Cl|SIN}}(PI) -DO - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter the degree angle (0 quits): ", DEGREES% - RADIANS = DEGREES% * PI / 180 - {{Cl|PRINT}} "RADIANS = DEGREES% * PI / 180 = "; RADIANS - {{Cl|PRINT}} "X = COS(RADIANS) = "; {{Cl|COS}}(RADIANS) - {{Cl|PRINT}} "Y = SIN(RADIANS) = "; {{Cl|SIN}}(RADIANS) - {{Cl|CIRCLE}} (400, 240), 2, 12 - {{Cl|LINE}} (400, 240)-(400 + (50 * {{Cl|SIN}}(RADIANS)), 240 + (50 * {{Cl|COS}}(RADIANS))), 11 - DEGREES% = RADIANS * 180 / PI - {{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES% -{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0 -{{CodeEnd}} -{{OutputStart}} -PI = 4 * ATN(1) = 3.141593 -COS(PI) = -1 -SIN(PI) = -8.742278E-08 - -Enter the degree angle (0 quits): 45 -RADIANS = DEGREES% * PI / 180 = .7853982 -X = COS(RADIANS) = .7071068 -Y = SIN(RADIANS) = .7071068 -DEGREES% = RADIANS * 180 / PI = 45 -{{OutputEnd}} -: ''Explanation:'' When 8.742278E-08(.00000008742278) is returned by SIN or [[COS]] the value is essentially zero. - - -''Example 2:'' Displays rotating gears made using SIN and [[COS]] to place the teeth lines. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 9 -{{Cl|DIM}} {{Cl|SHARED}} Pi {{Cl|AS}} {{Cl|SINGLE}} -Pi = 4 * {{Cl|ATN}}(1) -{{Cl|DO}} - {{Cl|FOR...NEXT|FOR}} G = 0 {{Cl|TO}} Pi * 2 {{Cl|STEP}} Pi / 100 - {{Cl|CLS}} 'erase previous - {{Cl|CALL}} GEARZ(160, 60, 40, 20, 4, G, 10) - {{Cl|CALL}} GEARZ(240, 60, 40, 20, 4, -G, 11) - {{Cl|CALL}} GEARZ(240, 140, 40, 20, 4, G, 12) - {{Cl|CALL}} GEARZ(320, 140, 40, 20, 4, -G, 13) - {{Cl|CALL}} GEARZ(320 + 57, 140 + 57, 40, 20, 4, G, 14) - {{Cl|CALL}} GEARZ(320 + 100, 140 + 100, 20, 10, 4, -G * 2 - 15, 15) - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 20 'regulates gear speed and CPU usage - {{Cl|NEXT}} G -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -{{Cl|SUB}} GEARZ (XP, YP, RAD, Teeth, TH, G, CLR) -t = 0 -x = XP + (RAD + TH * {{Cl|SIN}}(0)) * {{Cl|COS}}(0) -y = YP + (RAD + TH * {{Cl|SIN}}(0)) * {{Cl|SIN}}(0) -{{Cl|PRESET}} (x, y) -m = Teeth * G -{{Cl|FOR...NEXT|FOR}} t = -Pi / 70 {{Cl|TO}} 2 * Pi {{Cl|STEP}} Pi / 70 - x = XP + (RAD + TH * {{Cl|SIN}}((Teeth * t + m)) ^ 3) * {{Cl|COS}}(t) - y = YP + (RAD + TH * {{Cl|SIN}}((Teeth * t + m)) ^ 3) * {{Cl|SIN}}(t) - {{Cl|LINE}} -(x, y), CLR - IF {{Cl|INKEY$}} <> "" THEN {{Cl|END}} -{{Cl|NEXT}} t -{{Cl|PAINT}} (XP, YP), CLR 'gear colors optional -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Adapted from code by: DarthWho}} - - -''Example 3:'' Displaying the current seconds for an analog clock. See [[COS]] for the clock face hour markers. -{{CodeStart}} -{{Cl|SCREEN}} 12 -Pi2! = 8 * {{Cl|ATN}}(1): sec! = Pi2! / 60 ' (2 * pi) / 60 movements per rotation -{{Cl|CIRCLE}} (320, 240), 80, 1 -{{Cl|DO}} - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} {{Cl|TIME$}} - Seconds% = {{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2)) - 15 ' update seconds - S! = Seconds% * sec! ' radian from the TIME$ value - Sx% = {{Cl|CINT}}({{Cl|COS}}(S!) * 60) ' pixel columns (60 = circular radius) - Sy% = {{Cl|CINT}}({{Cl|SIN}}(S!) * 60) ' pixel rows - {{Cl|LINE}} (320, 240)-(Sx% + 320, Sy% + 240), 12 - {{Cl|DO}}: Check% = {{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2)) - 15: {{Cl|LOOP}} UNTIL Check% <> Seconds% ' wait loop - {{Cl|LINE}} (320, 240)-(Sx% + 320, Sy% + 240), 0 ' erase previous line -{{Cl|LOOP}} UNTIL {{Cl|INKEY$}} = {{Cl|CHR$}}(27) ' escape keypress exits -{{CodeEnd}} -{{small|Code by: Ted Weissgerber}} -The value of 2 ã is used to determine the sec! multiplier that determines the radian value as S! The value is divided by 60 second movements. To calculate the seconds the [[TIME$]] function is used and that value is subtracted 15 seconds because the 0 value of pi is actually the 3 hour of the clock (15 seconds fast). SIN and COS will work with negative values the same as positive ones! Then the column and row coordinates for one end of the line are determined using SIN and [[COS]] multiplied by the radius of the circular line movements. The minute and hour hands could use similar procedures to read different parts of TIME$. - - -{{PageSeeAlso}} -* [[_PI]] {{text|(QB64 function)}} -*[[COS]] {{text|(cosine)}} -*[[ATN]] {{text|(arctangent)}} -*[[TAN]] {{text|(tangent)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/SLEEP_11111.txt b/internal/help/SLEEP_11111.txt deleted file mode 100644 index f7b2264cb..000000000 --- a/internal/help/SLEEP_11111.txt +++ /dev/null @@ -1,41 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:57}} -SLEEP pauses the program indefinitely or for a specified number of seconds, program is unpaused when the user presses a key or when the specified number of seconds has passed. - - -{{PageSyntax}} -:: SLEEP [seconds] - - -* Seconds are an optional [[INTEGER]] value. If there is no parameter, then it waits for a keypress. -* Any user keypress will abort the SLEEP time. -* SLEEP does NOT clear the keyboard buffer so it can affect [[INKEY$]], [[INPUT]], [[INPUT$]] and [[LINE INPUT]] reads. -* Use an [[INKEY$]] keyboard buffer clearing loop when an empty keyboard buffer is necessary. -* SLEEP allows other programs to share the processor time during the interval. - - -''Example:'' -{{CodeStart}} -{{Cl|CLS}} -{{Cl|PRINT}} "Press a key..." -{{Cl|SLEEP}} -{{Cl|PRINT}} "You pressed a key, now wait for 2 seconds." -{{Cl|SLEEP}} 2 -{{Cl|PRINT}} "You've waited for 2 seconds." -{{Cl|PRINT}} "(or you pressed a key)" -{{CodeEnd}} -{{OutputStart}} -Press a key... -You pressed a key, now wait for 2 seconds. -You've waited for 2 seconds. -(or you pressed a key) -{{OutputEnd}} -:''Explanation:'' SLEEP without any arguments waits until a key is pressed, next SLEEP statement uses the argument 2 which means that it will wait for 2 seconds, any number of seconds can be specified. - - -''See also:'' -* [[TIMER]], [[INKEY$]] -* [[_DELAY]], [[_LIMIT]] - - -{{PageNavigation}} diff --git a/internal/help/SOUND_11111.txt b/internal/help/SOUND_11111.txt deleted file mode 100644 index d5221dd11..000000000 --- a/internal/help/SOUND_11111.txt +++ /dev/null @@ -1,139 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:44:58}} -'''SOUND''' sets frequency and duration of sounds from the internal PC speaker if the computer has one or the sound card in QB64. - - -{{PageSyntax}} -:: SOUND ''frequency'', ''duration'' - - -{{PageDescription}} -* ''Frequency'' is any literal or variable value from 37 to 32767, but 0 is allowed for delays. -* ''Duration'' is any literal or variable number of [[TIMER]] ticks with a duration of 1/18th second. 18 = one second. -* In '''QB64''' the sound comes from the soundcard and the volume can be adjusted through the OS. - - -{{PageErrors}} -* Low ''frequency'' values between 0 and 37 will create an [[ERROR Codes|Illegal Function call error]]. -* '''Warning:''' SOUND may not work when the program is not in focus. Use SOUND 0, 0 at sound procedure start to set focus. -* '''Note:''' SOUND 0, 0 will not stop previous '''QB64''' sounds like it did in QBasic! -* SOUND may have clicks or pauses between the sounds generated. [[PLAY]] can be used for musical sounds. -{{WhiteStart}} - ''' The Seven Music Octaves ''' - - ''' Note Frequency Note Frequency Note Frequency''' - '''1'''* D#1 ...... 39 G3 ....... 196 A#5 ...... 932 - E1 ....... 41 G#3 ...... 208 B5 ....... 988 - F1 ....... 44 A3 ....... 220 '''6'''* C6 ....... 1047 - F#1 ...... 46 A#3 ...... 233 C#6 ...... 1109 - G1 ....... 49 B3 ....... 247 D6 ....... 1175 - G#1 ...... 51 '''4'''* C4 ....... 262 D#6 ...... 1245 - A1 ....... 55 C#4 ...... 277 E6 ....... 1318 - A#1 ...... 58 D4 ....... 294 F6 ....... 1397 - B1 ....... 62 D#4 ...... 311 F#6 ...... 1480 - '''2'''* C2 ....... 65 E4 ....... 330 G6 ....... 1568 - C#2 ...... 69 F4 ....... 349 G# ....... 1661 - D2 ....... 73 F#4 ...... 370 A6 ....... 1760 - D#2 ...... 78 G4 ....... 392 A#6 ...... 1865 - E2 ....... 82 G#4 ...... 415 B6 ....... 1976 - F2 ....... 87 A4 ....... 440 '''7'''* C7 ....... 2093 - F#2 ...... 92 A# ....... 466 C#7 ...... 2217 - G2 ....... 98 B4 ....... 494 D7 ....... 2349 - G#2 ...... 104 '''5'''* C5 ....... 523 D#7 ...... 2489 - A2 ....... 110 C#5 ...... 554 E7 ....... 2637 - A#2 ...... 117 D5 ....... 587 F7 ....... 2794 - B2 ....... 123 D#5 ...... 622 F#7 ...... 2960 - '''3'''* C3 ....... 131 E5 ....... 659 G7 ....... 3136 - C#3 ...... 139 F5 ....... 698 G#7 ...... 3322 - D3 ....... 147 F#5 ...... 740 A7 ....... 3520 - D#3 ...... 156 G5 ....... 784 A#7 ...... 3729 - E3 ....... 165 G#5 ...... 831 B7 ....... 3951 - F3 ....... 175 A5 ....... 880 '''8'''* C8 ....... 4186 - F#3 ...... 185 - '''# denotes sharp''' -{{WhiteEnd}} - - -''Example 1:'' Playing the seven octaves based on the base note DATA * 2 ^ (octave - 1). -{{CodeStart}} -notes$ = "C C#D D#E F F#G G#A A#B " -{{Cl|COLOR}} 9:{{Cl|LOCATE}} 5, 20: PRINT "Select an octave (1 - 7) to play (8 quits):" -{{Cl|DO}} - {{Cl|DO}}: octa$ = {{Cl|INKEY$}} - {{Cl|IF...THEN|IF}} octa$ <> "" {{Cl|THEN}} - {{Cl|IF...THEN|IF}} {{Cl|ASC}}(octa$) > 48 {{Cl|AND (boolean)|AND}} {{Cl|ASC}}(octa$) < 58 {{Cl|THEN}} octave% = {{Cl|VAL}}(octa$): {{Cl|EXIT DO}} - {{Cl|END IF}} - {{Cl|LOOP}} {{Cl|UNTIL}} octave% > 7 - {{Cl|IF...THEN|IF}} octave% > 0 {{Cl|AND (boolean)|AND}} octave% < 8 {{Cl|THEN}} - {{Cl|LOCATE}} 15, 6: {{Cl|PRINT}} {{Cl|SPACE$}}(70) - {{Cl|LOCATE}} 16, 6: {{Cl|PRINT}} {{Cl|SPACE$}}(70) - {{Cl|COLOR}} 14: {{Cl|LOCATE}} 15, 6: {{Cl|PRINT}} "Octave"; octave%; ":"; - {{Cl|RESTORE}} Octaves - {{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 12 - {{Cl|READ}} note! - snd% = {{Cl|CINT}}(note! * (2 ^ (octave% - 1))) 'calculate note frequency - {{Cl|COLOR}} 14: {{Cl|PRINT}} {{Cl|STR$}}(snd%); - c0l = {{Cl|POS}}(0) - {{Cl|COLOR}} 11: {{Cl|LOCATE}} 16, c0l - 2: {{Cl|PRINT}} {{Cl|MID$}}(notes$, 1 + (2 * (i - 1)), 2) - {{Cl|LOCATE}} 15, c0l - {{Cl|IF...THEN|IF}} snd% > 36 {{Cl|THEN}} {{Cl|SOUND}} snd%, 12 'error if sound value is < 36 - {{Cl|_DELAY}} .8 - {{Cl|NEXT}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} octave% > 7 -{{Cl|END}} - -Octaves: -{{Cl|DATA}} 32.7,34.65,36.71,38.9,41.2,43.65,46.25,49,51.91,55,58.27,61.74 -{{CodeEnd}} -{{small|Code adapted by Ted Weissgerber from code in [http://www.amazon.com/Running-MS-DOS-QBASIC-Michael-Halvorson/dp/1556153406 "Running MS-DOS QBasic"] by Microsoft Press}} - - -''Example 2:'' Playing a song called "Bonnie" with [[SOUND]] frequencies. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 13 -{{Cl|_FULLSCREEN}} -{{Cl|OUT}} {{Cl|&H}}3C8, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 20 -{{Cl|COLOR}} 1 -{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} 21 - {{Cl|LOCATE}} 2 + i%, 2: {{Cl|PRINT}} {{Cl|CHR$}}(178) - {{Cl|LOCATE}} 2 + i%, 39: {{Cl|PRINT}} {{Cl|CHR$}}(178) -{{Cl|NEXT}} i% -{{Cl|FOR...NEXT|FOR}} i% = 2 {{Cl|TO}} 39 - {{Cl|LOCATE}} 2, i%: {{Cl|PRINT}} {{Cl|CHR$}}(223) - {{Cl|LOCATE}} 23, i%: {{Cl|PRINT}} {{Cl|CHR$}}(220) -{{Cl|NEXT}} i% -{{Cl|COLOR}} 9 -{{Cl|LOCATE}} 3, 16: {{Cl|PRINT}} {{Cl|CHR$}}(34); "MY BONNIE"; {{Cl|CHR$}}(34) -{{Cl|SLEEP}} 3 -{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} 34 - {{Cl|SELECT CASE}} i% - {{Cl|CASE}} 1: {{Cl|LOCATE}} 5, 5 - {{Cl|CASE}} 10: {{Cl|LOCATE}} 10, 5 - {{Cl|CASE}} 18: {{Cl|LOCATE}} 15, 5 - {{Cl|CASE}} 27: {{Cl|LOCATE}} 20, 5 - {{Cl|END SELECT}} - {{Cl|READ}} note%, duration%, word$ - {{Cl|SOUND}} note%, duration%: {{Cl|PRINT}} word$; -{{Cl|NEXT}} i% -{{Cl|SLEEP}} 2 -{{Cl|LOCATE}} 23, 16: {{Cl|PRINT}} "Thank You!" -{{Cl|SLEEP}} 4 -{{Cl|SYSTEM}} - -{{Cl|DATA}} 392,8,"My ",659,8,"Bon-",587,8,"nie ",523,8,"lies ",587,8,"O-",523,8,"Ver ",440,8,"the " -{{Cl|DATA}} 392,8,"O-",330,32,"cean ",392,8,"My ",659,8,"Bon-",587,8,"nie ",523,8,"lies " -{{Cl|DATA}} 523,8,"O-",494,8,"ver ",523,8,"the ",587,40,"sea ",392,8,"My ",659,8,"Bon-",587,8,"nie" -{{Cl|DATA}} 523,8," lies ",587,8,"O-",523,8,"ver ",440,8,"the ",392,8,"O-",330,32,"cean ",392,8,"Oh " -{{Cl|DATA}} 440,8,"bring ",587,8,"back ",523,8,"my ",494,8,"Bon-",440,8,"nie ",494,8,"to ",523,32,"me..!" -{{CodeEnd}} -{{small|Code adapted by Ted Weissgerber from code [http://www.amazon.com/Running-MS-DOS-QBASIC-Michael-Halvorson/dp/1556153406 "Running MS-DOS QBasic"] by Microsoft Press}} - - -''See also:'' -* [[PLAY]], [[BEEP]] -* [[_SNDOPEN]] (play sound files) -* [[_SNDRAW]] (play frequency waves) - - -{{PageNavigation}} diff --git a/internal/help/SPACE$_11111$.txt b/internal/help/SPACE$_11111$.txt deleted file mode 100644 index f789ed2a4..000000000 --- a/internal/help/SPACE$_11111$.txt +++ /dev/null @@ -1,105 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:00}} -The {{KW|SPACE$}} function returns a {{KW|STRING}} consisting of a number of space characters. - - -{{PageSyntax}} -:''result$'' = '''SPACE$({{Parameter|count&}})''' - - -{{Parameters}} -* {{Parameter|count&}} is the number of space characters to repeat. Cannot use negative values! - - -''Usage:'' -* Semicolons can be used to combine spaces with text [[STRING]] or numerical values. -* [[Concatenation]] using + can be used to combine [[STRING]] text values only. -* Spaces are often used to erase previous text PRINTs from the screen. -* The function result can also be used to [[GET]] and [[PUT]] a number of bytes as zero characters: bytes$ = SPACE$(numbytes) -* Spaces can also be made using [[SPC]], [[CHR$]](32) or [[STRING$]](n%, 32). - - -''Differences between QB64 and QB 4.5:'' -* '''QB64''' can use [[LONG]] values for count up to 2,147,483,647 while '''QB 4.5''' could only use [[INTEGER]] values up to 32,767. - - -''Example 1:'' How to space text in a [[PRINT]] statement using SPACE$ with string [[concatenation]]. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} count% = 0 {{Cl|FOR...NEXT|TO}} 3 - {{Cl|PRINT}} "abc" + {{Cl|SPACE$}}( count% ) + "def" -{{Cl|FOR...NEXT|NEXT}} count% -{{CodeEnd}} -{{OutputStart}}abcdef -abc def -abc def -abc def -{{OutputEnd}} - - -''Example 2:'' In [[SCREEN]] 0 SPACE$ can be used to change the background color to make an American flag. -{{CodeStart}} - USA flag centered on screen with thin horizontal red & white stripes -' blue corner field with randomly twinkling stars -{{Cl|CLS}} -{{Cl|LOCATE}} 25, 1 -{{Cl|PRINT}} "Press any key to stop twinkling"; -{{Cl|COLOR}} , 4 -z = 15 -{{Cl|FOR...NEXT|FOR}} x = 5 {{Cl|TO}} 19 '13 red & white stripes (x =5 to 21 for 15 stripes) - {{Cl|IF...THEN|IF}} z = 15 {{Cl|THEN}} z = 4 {{Cl|ELSE}} z = 15 - {{Cl|COLOR}} , z - {{Cl|LOCATE}} x, 15 - {{Cl|PRINT}} {{Cl|SPACE$}}(55) -{{Cl|NEXT}} x -{{Cl|FOR...NEXT|FOR}} x = 5 {{Cl|TO}} 11 'blue field in upper left quadrant (x = 5 to 13 to hold all 50 stars) - {{Cl|COLOR}} 15, 1 'sits above 4th white stripe - {{Cl|LOCATE}} x, 15 - {{Cl|PRINT}} {{Cl|SPACE$}}(23) -{{Cl|NEXT}} x -DO - stop$ = {{Cl|INKEY$}} - {{Cl|FOR...NEXT|FOR}} x = 5 {{Cl|TO}} 10 {{Cl|STEP}} 2 '39 stars staggered across blue field (50 stars if x = 5 to 12) - w = 16 - {{Cl|FOR...NEXT|FOR}} y = 1 {{Cl|TO}} 6 '5 rows of 6 stars - r = {{Cl|INT}}({{Cl|RND}} * 6) - {{Cl|IF...THEN|IF}} r = 0 {{Cl|THEN}} z = 31 {{Cl|ELSE}} z = 15 - {{Cl|IF...THEN|IF}} stop$ = "" {{Cl|THEN}} {{Cl|COLOR}} z {{Cl|ELSE}} {{Cl|COLOR}} 15 - {{Cl|LOCATE}} x, w - w = w + 4 - {{Cl|PRINT}} "*"; - {{Cl|NEXT}} y - w = 18 - {{Cl|FOR...NEXT|FOR}} y = 1 {{Cl|TO}} 5 '5 rows of 5 stars - r = {{Cl|INT}}({{Cl|RND}} * 6) - {{Cl|IF...THEN|IF}} r = 0 {{Cl|THEN}} z = 31 {{Cl|ELSE}} z = 15 - {{Cl|IF...THEN|IF}} stop$ = "" {{Cl|THEN}} {{Cl|COLOR}} z {{Cl|ELSE}} {{Cl|COLOR}} 15 - {{Cl|LOCATE}} x + 1, w - w = w + 4 - {{Cl|PRINT}} "*"; - {{Cl|NEXT}} y - {{Cl|NEXT}} x - w = 16 - {{Cl|FOR...NEXT|FOR}} y = 1 {{Cl|TO}} 6 '1 row of 6 stars - r = {{Cl|INT}}({{Cl|RND}} * 6) - {{Cl|IF...THEN|IF}} r = 0 {{Cl|THEN}} z = 31 {{Cl|ELSE}} z = 15 - {{Cl|IF...THEN|IF}} stop$ = "" {{Cl|THEN}} {{Cl|COLOR}} z {{Cl|ELSE}} {{Cl|COLOR}} 15 - {{Cl|LOCATE}} x, w - w = w + 4 - {{Cl|PRINT}} "*"; - {{Cl|NEXT}} y - t = {{Cl|TIMER}} - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} t + .2 >= {{Cl|TIMER}}: {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|WHILE}} stop$ = "" -{{Cl|COLOR}} 7, 0 -{{Cl|END}} -{{CodeEnd}}{{small|Code by Solitaire}} -:''Explanation:'' In [[SCREEN]] 0, the background color is only placed with the the printed text and spaces. [[CLS]] can color the entire screen. - - -{{PageSeeAlso}} -* [[PRINT]], [[PRINT USING]] -* [[STRING$]], [[CLS]] -* [[SPC]], [[TAB]] - - -{{PageNavigation}} diff --git a/internal/help/SPC_111.txt b/internal/help/SPC_111.txt deleted file mode 100644 index 9bf6c5342..000000000 --- a/internal/help/SPC_111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:01}} -The {{KW|SPC}} function is used in [[PRINT]] and [[LPRINT]] statements to print or output a number of space characters. - - -{{PageSyntax}} -::: '''SPC({{Parameter|count%}})''' - - -{{Parameters}} -* ''count'' designates the number of column spaces to move the cursor in a [[PRINT]] statement. - - -''Usage:'' -* When used in a [[PRINT]] statement, -** {{Parameter|count%}} is the number of space characters to print, overwriting existing characters. -** If {{Parameter|count%}} is greater than the number of columns left in the current row, remaining space characters are printed on the next row. -* When used in a [[PRINT (file statement)|PRINT #]] statement, -** {{Parameter|count%}} is the number of space characters to output. -** If {{Parameter|count%}} is less than or equal to zero, the function has no effect. - - -''Example:'' Using SPC to space a text print. -{{CodeStart}}{{Cl|PRINT}} "123456789" -{{Cl|PRINT}} "abc" ; {{Cl|SPC}}(3) ; "123"{{CodeEnd}} -{{OutputStart}}123456789 -abc 123 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[PRINT]], [[PRINT (file statement)|PRINT #]] -* [[LPRINT]], [[STRING$]] -* [[TAB]], [[SPACE$]] - - -{{PageNavigation}} diff --git a/internal/help/SQR_111.txt b/internal/help/SQR_111.txt deleted file mode 100644 index 6741c1ff7..000000000 --- a/internal/help/SQR_111.txt +++ /dev/null @@ -1,80 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:02}} -The '''SQR''' function returns the square root of a numerical value. - - -{{PageSyntax}} -:: square_root = '''SQR('''value''')''' - - -* The ''square root'' returned is normally a [[SINGLE]] or [[DOUBLE]] numerical value. -* The ''value'' parameter can be any '''positive''' numerical type. '''Negative parameter values will not work!''' -* Other exponential root functions can use fractional exponents([[^]]) enclosed in '''parenthesis only'''. EX: {{text|root = c ^ (a / b)|green}} - - -''Example 1:'' Finding the hypotenuse of a right triangle: -{{CodeStart}} - A% = 3: B% = 4 - PRINT "hypotenuse! ="; SQR((A% ^ 2) + (B% ^ 2)) -{{CodeEnd}} -{{OutputStart}} - hypotenuse = 5 -{{OutputEnd}} - - -''Example 2:'' Finding the Cube root of a number. -{{CodeStart}} - number = 8 - cuberoot = number {{Cl|^}} (1/3) - PRINT cuberoot -{{CodeEnd}} -{{OutputStart}} - 2 -{{OutputEnd}} - - -''Example 3:'' Negative roots return fractional values of one. -{{CodeStart}} - number = 8 - negroot = number {{Cl|^}} -2 - PRINT negroot -{{CodeEnd}} -{{OutputStart}} - .015625 -{{OutputEnd}} -:''Explanation:'' A negative root means that the exponent value is actually inverted to a fraction of 1. So x ^ -2 actually means the result will be: 1 / (x ^ 2). - - -''Example 4:'' Fast Prime number checker limits the numbers checked to the square root (half way). -{{CodeStart}} -DEFLNG P -DO -PRIME = -1 'set PRIME as True -INPUT "Enter any number to check up to 2 million (Enter quits): ", guess$ -PR = {{Cl|VAL}}(guess$) -IF PR {{Cl|MOD}} 2 THEN 'check for even number - FOR P = 3 TO {{Cl|SQR}}(PR) STEP 2 'largest number that could be a multiple is the SQR - IF PR {{Cl|MOD}} P = 0 THEN PRIME = 0: EXIT FOR 'MOD = 0 when evenly divisible by another - NEXT -ELSE : PRIME = 0 'number to be checked is even so it cannot be a prime -END IF -IF PR = 2 THEN PRIME = -1 '2 is the ONLY even prime -IF PR = 1 THEN PRIME = 0 'MOD returns true but 1 is not a prime by definition -IF PRIME THEN PRINT "PRIME! How'd you find me? " ELSE PRINT "Not a prime, you lose!" -LOOP UNTIL PR = 0 -{{CodeEnd}} -{{OutputStart}} -Enter any number to check up to 2 million (Enter quits): 12379 -PRIME! How'd you find me? -{{OutputEnd}} -
''Note:'' Prime numbers cannot be evenly divided by any other number except one.
- - -''See also:'' -*[[MOD]] {{text|(integer remainder division)}} -*[[^]] {{text|(exponential operator)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Trigonometric Functions]] - - -{{PageNavigation}} diff --git a/internal/help/STATIC_111111.txt b/internal/help/STATIC_111111.txt deleted file mode 100644 index 0c9cd4e4f..000000000 --- a/internal/help/STATIC_111111.txt +++ /dev/null @@ -1,100 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:03}} -The {{KW|STATIC}} keyword is used in declaration statements to control where variables are stored. - - -{{PageSyntax}} -:{{KW|STATIC}} {{Parameter|variableName}}[()] [{{KW|AS}} {{Parameter|dataType}}][, ...] - -{{PageSyntax}} -:{[[SUB]]|[[FUNCTION]]} {{Parameter|procedureName}} [({{Parameter|parameterList}})] STATIC - - -{{PageDescription}} -* A STATIC list can be used in [[SUB]] and [[FUNCTION]] procedures to designate one or more variables to retain their values. -* Variables and arrays with static storage will retain their values in between procedure calls. The values may also be used recursively. -:* {{Parameter|variableName}} may include a type suffix or use [[AS]] to specify a type other than the default [[SINGLE]] type. -:* Arrays with static storage are declared by specifying empty parenthesis following the array name. See [[Arrays]] -* STATIC can be used after the name of a [[SUB]] or [[FUNCTION]] in the procedure to force all variables to retain their values. -* '''Recursive procedures may be required to be STATIC to avoid a Stack Overflow! QB64 programs may just close!''' -* [[$STATIC]] defined program [[arrays]] cannot be [[REDIM|re-sized]] or use [[_PRESERVE]]. - - -''Example 1: Finding the binary bit settings from a 32 bit [[LONG]] register return using recursion. -{{CodeStart}} -{{Cl|INPUT}} "Enter a numerical value to see binary value: ", num& -{{Cl|PRINT}} Bin$(num&) - -{{Cl|END}} - -{{Cl|FUNCTION}} Bin$ (n&) {{Cl|STATIC}} 'comment out STATIC to see what happens! -{{Cl|DIM}} p%, s$ -{{Cl|IF...THEN|IF}} 2 ^ p% > n& {{Cl|THEN}} - p% = 0 -{{Cl|ELSE}} - {{Cl|IF...THEN|IF}} n& {{Cl|AND (boolean)|AND}} 2 ^ p% {{Cl|THEN}} s$ = "1" + s$ {{Cl|ELSE}} s$ = "0" + s$ - {{Cl|IF...THEN|IF}} n& > 2 ^ p% {{Cl|THEN}} - p% = p% + 1 - s$ = Bin$(n&) 'recursive call to itself - {{Cl|ELSE}}: p% = 0 - {{Cl|END IF}} -{{Cl|END IF}} -{{Cl|IF...THEN|IF}} s$ = "" {{Cl|THEN}} Bin$ = "0" {{Cl|ELSE}} Bin$ = s$ -{{Cl|END FUNCTION}} -{{CodeEnd}} -: ''Explanation:'' The [[FUNCTION]] above returns a [[STRING]] value representing the bits ON in an [[INTEGER]] value. The string can be printed to the screen to see what is happening in a port register. '''STATIC''' keeps the function from overloading the memory "Stack" and is normally REQUIRED when recursive calls are used in QBasic! '''QB64 procedures will close without warning or error!''' - - -''Example 2:'' Using a static array to cache factorials, speeding up repeated calculations: -{{CodeStart}} - -{{Cl|PRINT}} Factorial(0) -{{Cl|PRINT}} Factorial(5) -{{Cl|PRINT}} Factorial(50 - -{{Cl|FUNCTION}} Factorial# ( n {{Cl|AS}} {{Cl|DOUBLE}} ) - {{Cl|CONST}} maxNToCache = 50 - {{Cl|STATIC}} resultCache() {{Cl|AS}} {{Cl|DOUBLE}} - {{Cl|STATIC}} firstCall {{Cl|AS}} {{Cl|INTEGER}} - - ' The lookup table is initially empty, so re-size it.. - {{Cl|IF...THEN|IF}} firstCall = 0 {{Cl|IF...THEN|THEN}} - firstCall = -1 - {{Cl|REDIM}} resultCache(maxNToCache) {{Cl|AS}} {{Cl|DOUBLE}} - - ' ..and pre-calculate some factorials. - resultCache(0) = 1 - resultCache(1) = 1 - resultCache(2) = 2 - {{Cl|IF...THEN|END IF}} - - ' See if we have the result cached. If so, we're done. - {{Cl|IF...THEN|IF}} n <= maxNToCache {{Cl|IF...THEN|THEN}} - {{Cl|IF...THEN|IF}} resultCache(n) <> 0 {{Cl|IF...THEN|THEN}} - Factorial = resultCache(n) - {{Cl|EXIT FUNCTION}} - {{Cl|IF...THEN|END IF}} - {{Cl|IF...THEN|END IF}} - - ' If not, we use recursion to calculate the result, then cache it for later use: - resultCache(n) = {{Cl|INT}}(n) * Factorial({{Cl|INT}}(n) - 1) - Factorial = resultCache(n) -{{Cl|END FUNCTION}} - -{{CodeEnd}} -{{OutputStart}} - 1 - 120 - 3.041409320171338D+64 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[DIM]], [[REDIM]], [[COMMON]] -* [[SUB]], [[FUNCTION]] -* [[TYPE]], [[Arrays]] -* [[$STATIC]], [[$DYNAMIC]] {{text|([[Metacommand]]s)}} -* [[Data types]] - - -{{PageNavigation}} diff --git a/internal/help/STEP_1111.txt b/internal/help/STEP_1111.txt deleted file mode 100644 index adef70187..000000000 --- a/internal/help/STEP_1111.txt +++ /dev/null @@ -1,58 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:06}} -The '''STEP''' keyword is used in [[FOR...NEXT]] loops to skip through the count or to count down instead of up. Used in graphics to designate a relative coordinate position of a graphics object function. - - -{{PageSyntax}} -:: FOR counter_variable = start_point TO stop_point ['''STEP ''interval'''''] - -:: CIRCLE '''STEP(0, 0)''', 10, 12 - - -* The FOR counter variable is used to designate and pass the current FOR incremented value. -* FOR loops without the optional STEP value increment by + 1 every loop. -* The STEP increment value can be any literal or variable numerical type. It cannot be changed inside of the loop! -* Start and stop point values can be any literal or variable type and they cannot be changed inside of the loop. -* STEP interval designates the portion to add or subtract from the FOR variable value. -:* When the STEP interval is positive, the start value should be less than the stop value ot the loop will be ignored. -:* When the STEP interval is negative, the start value should be greater than the stop value or the loop will be ignored. -* In graphics statements, STEP can be used before a pair of coordinate brackets to indicate that the coordinates are relative to the last graphics statement position. IE the position will be that number of pixels away from the last graphical object. - - -''Example:'' Stepping down 2 in a FOR counter loop. -{{CodeStart}} -{{Cl|FOR...NEXT}} i = 10 {{Cl|TO}} 0 {{Cl|STEP}} -2 - {{Cl|PRINT}} i; -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}} -10 8 6 4 2 0 -{{OutputEnd}} -:''Note:'' The value of i = -2 after the loop is done. - - - -::''Graphics Syntax:'' LINE STEP(column1%, row1%)-(column2%, row2%), color_attribute% - - -* STEP coordinate positions are relative positive or negative pixel moves from the previous graphics object's last coordinate. After a CIRCLE statement, the relative coordinates would be from its center. -* STEP can be used before the [[LINE]], [[CIRCLE]], [[PSET]], [[PRESET]], [[PAINT]] or [[DRAW]] graphics object coordinates. - - - -''Graphics Example:'' Using STEP coordinates to PAINT a circle's interior. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|CIRCLE}} (100, 100), 50, 12 -{{Cl|PAINT}} {{Cl|STEP}}(0, 0), 13, 12 -{{CodeEnd}} -:''Explanation:'' PAINT uses the CIRCLE's center coordinate position to paint the interior. - - -''See also:'' -* [[FOR...NEXT]] -* [[DRAW]] (see the M relative move function) -* [[LINE]], [[CIRCLE]], [[PSET]], [[PAINT]] - - -{{PageNavigation}} diff --git a/internal/help/STICK_11111.txt b/internal/help/STICK_11111.txt deleted file mode 100644 index c5359cd64..000000000 --- a/internal/help/STICK_11111.txt +++ /dev/null @@ -1,101 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:07}} -The '''STICK''' function returns the directional axis coordinate move of game port (&H201) joystick or USB controller devices. - - -{{PageSyntax}} -: coordinate_move% = [[STICK]]{{Parameter|(direction%)}} - - -QB64 {{PageSyntax}} -: coordinate_move% = [[STICK]]{{Parameter|(direction%[, axis_number%])}} - - -''Description:'' -* '''QB64''' allows any number of coordinate pairs for more than two game device controllers. STICK will not read a mouse axis. -* ''axis_number'' can be used as the next axis parameter for controllers with multiple axis using the SAME ''directional'' parameters. -* The ''axis_number'' 1 can be omitted for the main stick column and row parameter reads. -* Point of view "hats" also have 2 axis. Slide, turn or twist controls have one. The device determines the order of the axis. -* Returns coordinate values from 1 to 254. QBasic only returned values from 1 to 200. -* STICK(0) is required to get values from the other STICK functions. Always read it first! -{{WhiteStart}}'''STICK(0) returns the column coordinate of device 1. Enables reads of the other STICK values.''' -'''STICK(1) returns row coordinate of device 1.''' -STICK(2) returns column coordinate of device 2. (second joystick if used) -STICK(3) returns row coordinate of device 2 if used. (QBasic maximum was 2 controllers) -'''STICK(4) returns column coordinate of device 3. (other joysticks if used in QB64 only!)''' -'''STICK(5) returns row coordinate of device 3 if used.''' -{{WhiteEnd}} -* '''QB64''' allows more joysticks by extending the numbers in pairs like device 3 above. EX: STICK(6): STICK(7) 'device 4 -* '''QB64''' allows a dual stick to be read using the same first parameters and 2 as the second parameter. EX: STICK(0, 2) -* '''There will not be an error if you try to read too many device axis or buttons!''' - - -''Example 1:'' Displays the input from 3 joysticks, all with dual sticks and 3 buttons. -{{CodeStart}} -{{Cl|DO}}: {{Cl|_LIMIT}} 10 - - {{Cl|LOCATE}} 1, 1 - {{Cl|PRINT}} "JOY1: {{Cl|STICK}}"; {{Cl|STICK}}(0); {{Cl|STICK}}(1); {{Cl|STICK}}(0, 2); {{Cl|STICK}}(1, 2);_ - "STRIG"; {{Cl|STRIG}}(0); {{Cl|STRIG}}(1); {{Cl|STRIG}}(4); {{Cl|STRIG}}(5); {{Cl|STRIG}}(8); {{Cl|STRIG}}(9) - - {{Cl|PRINT}} "JOY2: {{Cl|STICK}}"; {{Cl|STICK}}(2); {{Cl|STICK}}(3); {{Cl|STICK}}(2, 2); {{Cl|STICK}}(3, 2);_ - "STRIG"; {{Cl|STRIG}}(2); {{Cl|STRIG}}(3); {{Cl|STRIG}}(6); {{Cl|STRIG}}(7); {{Cl|STRIG}}(10); {{Cl|STRIG}}(11) - - {{Cl|PRINT}} "JOY3: {{Cl|STICK}}"; {{Cl|STICK}}(4); {{Cl|STICK}}(5); {{Cl|STICK}}(4, 2); {{Cl|STICK}}(5, 2);_ - "STRIG"; {{Cl|STRIG}}(0, 3); {{Cl|STRIG}}(1, 3); {{Cl|STRIG}}(4, 3); {{Cl|STRIG}}(5, 3); {{Cl|STRIG}}(8, 3); {{Cl|STRIG}}(9, 3) - -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" -{{CodeEnd}} -:''Explanation:'' Notice the extra '''QB64 only''' parameters used to cater for the 2nd stick and the buttons of the 3rd joystick. - - -''Example 2:'' Displays the Sidewinder Precision Pro Stick, Slider, Z Axis, and Hat Point of View. -{{CodeStart}} -{{Cl|SCREEN}} 12 -d = {{Cl|_DEVICES}} -{{Cl|PRINT}} "Number of input devices found ="; d -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} d - {{Cl|PRINT}} {{Cl|_DEVICE$}}(i) - buttons = {{Cl|_LASTBUTTON}}(i) - {{Cl|PRINT}} "Buttons:"; buttons -{{Cl|NEXT}} - -DO: {{Cl|_LIMIT}} 50 - {{Cl|LOCATE}} 10, 1 - {{Cl|PRINT}} " X Main Y Slider Z-axis POV" - {{Cl|PRINT}} {{Cl|STICK}}(0, 1), {{Cl|STICK}}(1, 1), {{Cl|STICK}}(0, 2), {{Cl|STICK}}(1, 2), {{Cl|STICK}}(0, 3); {{Cl|STICK}}(1, 3); " " - {{Cl|PRINT}} " Buttons" - {{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 4 * buttons - 1 {{Cl|STEP}} 4 - {{Cl|PRINT}} {{Cl|STRIG}}(i); {{Cl|STRIG}}(i + 1); {{Cl|CHR$}}(219); - {{Cl|NEXT}} - {{Cl|PRINT}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{CodeEnd}} -: ''Explanation:'' Each axis on the first controller found is either STICK(0, n) or STICK(1, n) with n increasing when necessary. -{{OutputStart}} -Number of input devices found = 3 -[KEYBOARD][BUTTON]] -Buttons: 512 -[MOUSE][BUTTON][AXIS][WHEEL] -Buttons: 3 -[CONTROLLER][[NAME][Microsoft Sidewinder Precision Pro (USB)]][BUTTON][AXIS] -Buttons: 9 - - - X Main Y Slider Z-axis POV - 127 127 254 127 127 127 - Buttons --0 -1 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ 0 0 â–ˆ -{{OutputEnd}} -: ''Note:'' A Sidewinder Precision Pro requires that pins 2 and 7(blue and purple) be connected together for digital USB recognition. -
[http://www.amazon.com/Belkin-F3U200-08INCH-Joystick-Adapter-SideWinder/dp/B000067RIV Sidewinder Precision Pro game port to USB adapter]
- - -''See also:'' -* [[STRIG]] {{text|(function)}} -* [[ON STRIG(n)]] -* [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] -* [http://en.wikipedia.org/wiki/Analog_stick Single and Dual Stick Controllers] - - -{{PageNavigation}} diff --git a/internal/help/STOP_1111.txt b/internal/help/STOP_1111.txt deleted file mode 100644 index 53e4efd84..000000000 --- a/internal/help/STOP_1111.txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:08}} -The '''STOP''' statement is used to stop program execution when troubleshooting a program or to suspend event trapping. - - -{{PageSyntax}} -:: STOP - - -* STOP used in the QBasic IDE does not close any files or go to the operating system. It returns to the IDE. -* In the QB64 compiler, STOP closes the program window and returns to the IDE when the code is compiled from there. -* STOP is ONLY used for debugging purposes and should not be used to exit programs! -* STOP can also be used to suspend an event trap in the following statements: [[KEY(n)]], [[ON COM (n)|COM(n)]], [[PEN]], [[PLAY]], [[STRIG(n)]], [[TIMER]], [[UEVENT]]. The trap can be turned back on with [[ON]] and returns any trap events since '''STOP''' was used. - - -''Example:'' When run in the QBasic IDE, the program will return to the IDE at STOP. Press F5 to finish the program. -{{CodeStart}} -{{Cl|PRINT}} "start" - -{{Cl|SLEEP}} 3 - -{{Cl|STOP}} - -{{Cl|PRINT}} "resumed" -{{CodeEnd}} -: ''Explanation:'' QB64 will STOP the program and close the window as it does not have an interpreter to run the rest of the code. - - -''See also:'' -* [[END]], [[SYSTEM]] -* [[ON]], [[OFF]] - - -{{PageNavigation}} diff --git a/internal/help/STR$_111$.txt b/internal/help/STR$_111$.txt deleted file mode 100644 index 65c8dc500..000000000 --- a/internal/help/STR$_111$.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:09}} -The '''STR$''' function returns the [[STRING]] representation of a numerical value. - - -{{PageSyntax}} -:: result$ = '''STR$('''{{Parameter|number}}''')''' - - -{{Parameters}} -* {{Parameter|number}} is any numerical type value to convert. - - -{{PageDescription}} -* Returns any type number value with leading sign(space/minus) or decimal point when one exists in the numerical value. -* If {{Parameter|number}} is positive, the [[STRING]] value returned will have a leading space character which can be removed using [[LTRIM$]]. -* If {{Parameter|number}} is negative, the minus sign will precede the number instead of a space which [[LTRIM$]] will not remove. -* Trimming a STR$ string number using [[RTRIM$]] is not required as [[PRINT]] creates the undocumented trailing number space. - - -{{PageExamples}} -{{CodeStart}}{{Cl|PRINT}} {{Cl|STR$}}( 1.0 ) -{{Cl|PRINT}} {{Cl|STR$}}( 2.3 ) -{{Cl|PRINT}} {{Cl|STR$}}( -4.5 ) -{{CodeEnd}} -{{OutputStart}} - 1 - 2.3 --4.5 -{{OutputEnd}} - - -{{CodeStart}} -a = 33 -{{Cl|PRINT}} {{Cl|STR$}}(a) + "10" + "1" + "who" + {{Cl|STR$}}(a) + {{Cl|STR$}}(a) + {{Cl|LTRIM$}}({{Cl|STR$}}(a)) -{{CodeEnd}} -{{OutputStart}} 33101who 33 3333 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[VAL]], [[STRING]] -* [[LTRIM$]], [[MID$]] -* [[RIGHT$]], [[LEFT$]] -* [[HEX$]], [[OCT$]] - - -{{PageNavigation}} diff --git a/internal/help/STRIG(n)_11111(0).txt b/internal/help/STRIG(n)_11111(0).txt deleted file mode 100644 index 8f76e088e..000000000 --- a/internal/help/STRIG(n)_11111(0).txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:12}} -The {{KW|STRIG(n)}} statement controls event trapping for a particular joystick or game pad device button. - - -{{PageSyntax}} -::STRIG({{Parameter|button%}}) {ON|OFF|STOP} - - -QB64 {{PageSyntax}} -::STRIG[(''button_function%''[, ''device_number%''])] {ON|OFF|STOP} - - -{{PageDescription}} -* {{Parameter|button function}} specifies the device's button function. Even functions record events while odd ones read the actual presses. -* '''QB64''' can designate a button function and controller device number from 0 to 256. -* When no parameters are used '''QB64''' enables, disables or suspends the reading of ALL button events. -* [[STRIG(n)|ON]] specifies that event trapping is turned on for the specified button. -* [[STRIG(n)|OFF]] specifies that event trapping is turned off for the specified button. -* If {{KW|STRIG(n)|STOP}} is specified, event trapping is suspended for the specified button. Further joystick button events are remembered and trapped, in order, after the next {{KW|STRIG(n)|STRIG(n) ON}} statement is used. - - -''Example:'' -{{CodeStart}} -{{Cl|ON STRIG(n)|ON STRIG}}(0) {{Cl|GOSUB}} 10 -{{Cl|STRIG(n)|STRIG}}(0)ON - -DO - {{Cl|PRINT}} "."; - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -10 -a$ = "[STRIG 0 EVENT]" -{{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} {{Cl|LEN}}(a$) - {{Cl|PRINT}} {{Cl|MID$}}(a$, x, 1); - {{Cl|_DELAY}} 0.02 -{{Cl|NEXT}} -{{Cl|RETURN}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[ON STRIG(n)]] {{text|(event statement)}} -* [[STRIG]], [[STICK]] {{text|(functions)}} -* [http://en.wikipedia.org/wiki/Analog_stick Single and Dual Stick Controllers] - - -{{PageNavigation}} diff --git a/internal/help/STRIG_11111.txt b/internal/help/STRIG_11111.txt deleted file mode 100644 index 863394f49..000000000 --- a/internal/help/STRIG_11111.txt +++ /dev/null @@ -1,68 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:10}} -The '''STRIG''' function returns button press True or False status of game port (&H201) or USB joystick control device(s). - - -{{PageSyntax}} -:: IF STRIG(button_function%) THEN ... - - -QB64 {{PageSyntax}} -:: IF STRIG(''button_function%''[, ''device_number%'']) THEN ... - - -''Description:'' -* Function returns -1 when a button event(even functions) has occurred or a button is pressed(odd functions). -* STRIG will not read keyboard or mouse buttons detected by [[_DEVICES]]. -* The ''device number'' must be used with more than 2 devices. Use device 1 function numbers for just one joystick. -* '''QB64''' can read many buttons from many devices and allows the use of devices with more than 2 buttons. -* Returns True(-1) or False(0) button press values for 2 devices. Each leading STRIG checks for missed button press events: -{{WhiteStart}} '''STRIG(0) = -1 'lower button 1 on device 1 pressed since last STRIG(0) read''' - '''STRIG(1) = -1 'lower button 1 on device 1 currently pressed''' - STRIG(2) = -1 'lower button 1 on device 2 pressed since last STRIG(2) read - STRIG(3) = -1 'lower button 1 on device 2 currently pressed - '''STRIG(4) = -1 'upper button 2 on device 1 pressed since last STRIG(4) read''' - '''STRIG(5) = -1 'upper button 2 on device 1 currently pressed''' - STRIG(6) = -1 'upper button 2 on device 2 pressed since last STRIG(6) read - STRIG(7) = -1 'upper button 2 on device 2 currently pressed (maximum in QBasic) - '''STRIG(8) = -1 'button 3 on device 1 pressed since last STRIG(8) read''' 'QB64 only - '''STRIG(9) = -1 'button 3 on device 1 currently pressed''' - STRIG(10) = -1 'button 3 on device 2 pressed since last STRIG(10) read 'QB64 only - STRIG(11) = -1 'button 3 on device 2 currently pressed -{{WhiteEnd}} -* STRIG(0), STRIG(2), STRIG(4), STRIG(6), STRIG(8), STRIG(10) are used to monitor any presses that might have been missed. -* '''QB64''' allows more than two controllers by using the second parameter as the stick number and the odd or even STRIG values: -{{WhiteStart}}'''STRIG(0, 3): STRIG(1, 3): STRIG(4, 3): STRIG(5, 3): STRIG(8, 3): STRIG(9, 3) 'device 3 {odd)''' -STRIG(2, 4): STRIG(3, 4): STRIG(6, 4): STRIG(7, 4): STRIG(10, 4): STRIG(11, 4) 'device 4 (even) -{{WhiteEnd}} -:Odd devices use 0, 1, 4, 5, 8 and 9 and Even devices use 2, 3, 6, 7, 10 and 11 as first parameters with device number following. -* '''There will not be an error if you try to read too many device axis or buttons!''' - - -''Example:'' Displays the input from 3 joysticks, all with dual sticks and 3 buttons. -{{CodeStart}} -{{Cl|DO}}: {{Cl|_LIMIT}} 10 - - {{Cl|LOCATE}} 1, 1 - {{Cl|PRINT}} "JOY1: {{Cl|STICK}}"; {{Cl|STICK}}(0); {{Cl|STICK}}(1); {{Cl|STICK}}(0, 2); {{Cl|STICK}}(1, 2);_ - "STRIG"; {{Cl|STRIG}}(0); {{Cl|STRIG}}(1); {{Cl|STRIG}}(4); {{Cl|STRIG}}(5); {{Cl|STRIG}}(8); {{Cl|STRIG}}(9) - - {{Cl|PRINT}} "JOY2: {{Cl|STICK}}"; {{Cl|STICK}}(2); {{Cl|STICK}}(3); {{Cl|STICK}}(2, 2); {{Cl|STICK}}(3, 2);_ - "STRIG"; {{Cl|STRIG}}(2); {{Cl|STRIG}}(3); {{Cl|STRIG}}(6); {{Cl|STRIG}}(7); {{Cl|STRIG}}(10); {{Cl|STRIG}}(11) - - {{Cl|PRINT}} "JOY3: {{Cl|STICK}}"; {{Cl|STICK}}(4); {{Cl|STICK}}(5); {{Cl|STICK}}(4, 2); {{Cl|STICK}}(5, 2);_ - "STRIG"; {{Cl|STRIG}}(0, 3); {{Cl|STRIG}}(1, 3); {{Cl|STRIG}}(4, 3); {{Cl|STRIG}}(5, 3); {{Cl|STRIG}}(8, 3); {{Cl|STRIG}}(9, 3) - -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" -{{CodeEnd}} -:''Explanation:'' Notice the extra '''QB64 only''' parameters used to cater for the 2nd stick and the buttons of the 3rd joystick. - - -''See also:'' -* [[STRIG(n)]] {{text|(statement)}} -* [[ON STRIG(n)]], [[STICK]] -* [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] -* [http://en.wikipedia.org/wiki/Analog_stick Single and Dual Stick Controllers] - - -{{PageNavigation}} diff --git a/internal/help/STRING$_111111$.txt b/internal/help/STRING$_111111$.txt deleted file mode 100644 index 89f1b2aab..000000000 --- a/internal/help/STRING$_111111$.txt +++ /dev/null @@ -1,52 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:14}} -The {{KW|STRING$}} function returns a {{KW|STRING}} consisting of a single character repeated a number of times. - - -{{PageSyntax}} -: result$ = STRING$(''count&'', {''character$'' | ''ASCIIcode%''} ) - - -{{PageDescription}} - -* {{Parameter|count&}} is the number of times the character specified by {{Parameter|character}} is repeated. -* Character is a literal string character, a string variable or an [[ASCII]] code number. -* If {{Parameter|count&}} is negative, an [[ERROR Codes|illegal function call]] error will occur. The count can be zero. -* If {{Parameter|character}} is a [[STRING]] value and its length is zero, an [[ERROR Codes|illegal function call]] error will occur. -* If more than one string character value is used, the first character will be repeated. -* A [[STRING]] statement can be added to a string value with the + [[concatenation]] operator. -* The function result can also be used to [[GET]] and [[PUT]] a number of bytes as zero characters: bytes$ = STRING(numbytes, 0) - - -''Differences between QB64 and QB 4.5:'' -* '''QB64''' can use [[LONG]] values for a count up to 2,147,483,647 while '''QB 4.5''' could only use [[INTEGER]] values up to 32,767. - - -{{PageExamples}} -:Printing 40 asterisks across the screen using an ASCII character code instead of [[CHR$]](42). -{{CodeStart}}{{Cl|PRINT}} {{Cl|STRING$}}(40, 42) -{{CodeEnd}} -{{OutputStart}}**************************************** -{{OutputEnd}} - - -:Using a [[STRING]] to specify the repeated character. -{{CodeStart}}text$ = "B" + {{Cl|STRING$}}(40, "A") + "D" -{{Cl|PRINT}} text$ -{{CodeEnd}} -{{OutputStart}}BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD -{{OutputEnd}} - - -''See examples:'' -* [[SAVEIMAGE]] -* [[SaveIcon32]] - - -{{PageSeeAlso}} -* [[SPACE$]] -* [[ASC]], [[CHR$]] -* [[ASCII]] - - -{{PageNavigation}} diff --git a/internal/help/STRING_111111.txt b/internal/help/STRING_111111.txt deleted file mode 100644 index ac905e618..000000000 --- a/internal/help/STRING_111111.txt +++ /dev/null @@ -1,112 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:13}} -'''STRING''' variables or literal values are one byte per character length text or [[ASCII]] characters. - - -{{PageSyntax}} -:: DIM variable AS STRING [* byte_length] - - -* ''Byte length'' is optional in [[DIM]] statements, but is required in [[TYPE]] definitions as a literal or [[CONST|constant]] [[INTEGER]] value. -* Literal strings are defined by quotation marks on each end. The quotes will not [[PRINT]] to the screen. -* Quotation marks cannot be placed inside of literal string values! Use [[CHR$]](34) to display " quotes. -* Semicolons and commas outside of the string can be used to combine strings in a [[PRINT]] statement only. -* [[LEN]] determines the number of bytes and number of string characters that are in a particular string. -* Literal string ends are designated by quotation marks such as: "text". Use [[CHR$]](34) to add quotes to string values. -* Variable suffix type definition is $ such as: text$. -* STRING values are compared according to the [[ASCII]] code values from left to right until one string code value exceeds the other. -* '''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!''' - - -:::::'''Creating a fixed length STRING variable in QBasic:''' - -:* Variable$ = " " ' 1 space creates a one [[_BYTE|byte]] string length in a procedure(not fixed) -:* Variable$ = SPACE$(n%) ' defined as a n% length string in a procedure(not fixed) -:* [[DIM]] variable AS STRING * n% ' fixed string length cannot be changed later -:* Variable AS STRING * n% ' fixed string length in a [[SUB]] parameter or [[TYPE]] definition. -:* [[CONST]] variables can also be used after the constant value is defined. - - -:::::'''QB64 fixed length string type suffixes''' - -* A number after the string variable name $ suffix denotes the fixed string length: '''X$2''' denotes a 2 byte string. - - -::::::'''String [[Concatenation]] (addition)''' -::::''Must be used when defining a string variable's literal value!'' - -* Concatenation uses the + addition symbol to add literal or variable parts to a string variable value. -* Quotation marks cannot be added. Use [[CHR$]](34) as quotes are used to define the ends of strings. -* Numerical values added must be converted to strings in string variable definitions. See the [[STR$]] function. -* Concatenation can be used in PRINT statements along with semicolons and commas used by {{KW|PRINT}} ONLY. -* Semicolons or commas outside of quotes cannot be used to make a string variable's literal string value! - - -''Example 1:'' Using a string type suffix with a fixed length byte size in QB64 only. The number designates the fixed string length. -{{CodeStart}} -var$5 = "1234567" - -PRINT var$5 -{{CodeEnd}} -{{OutputStart}}12345{{OutputEnd}} -:''Note:'' The suffix must keep the same byte length or it is considered a different string variable with a different value! - - -''Example 2:'' Creating a string variable value by adding variable and literal string values. This procedure is called string [[concatenation]]. -{{CodeStart}} -age% = 10 -a$ = "I am " + {{Cl|CHR$}}(34) + {{Cl|LTRIM$}}({{Cl|STR$}}(age%)) + {{Cl|CHR$}}(34) + " years old." -b$ = "How old are you?" -question$ = a$ + {{Cl|SPACE$}}(1) + b$ -{{Cl|PRINT}} question$ -{{CodeEnd}} -{{OutputStart}} -I am "10" years old. How old are you? -{{OutputEnd}} -:''Note:'' Since quotation marks are used to denote the ends of literal strings, [[CHR$]](34) must be used to place quotes inside them. - - -''Example 3:'' How QB64 string type suffixes can fix the length by adding a number of bytes after it. -{{CodeStart}} -strings$5 = "Hello world" - -PRINT strings$5 -{{CodeEnd}}{{OutputStart}}Hello{{OutputEnd}} - - -''Example 4:'' STRING values can be compared by the [[ASC]] code value according to [[ASCII]]. -{{CodeStart}} -{{Cl|PRINT}} "Enter a letter, number or punctuation mark from the keyboard: "; -valu$ = {{Cl|INPUT$}}(1) -{{Cl|PRINT}} value$ -value1$ = "A" -value2$ = "m" -value3$ = "z" - -{{Cl|SELECT CASE}} value$ - {{Cl|CASE}} value1$: {{Cl|PRINT}} "A only" - {{Cl|CASE}} value1$ {{Cl|TO}} value2$: {{Cl|PRINT}} "B to m" 'A is already evaluated - {{Cl|CASE}} value1$, value2$, value3$: {{Cl|PRINT}} "z only" 'A and m are already evaluated - {{Cl|CASE IS}} > value2$: {{Cl|PRINT}} "greater than m but not z" 'z is already evaluated - {{Cl|CASE ELSE}}: {{Cl|PRINT}} "other value" 'key entry below A including all numbers -{{Cl|END SELECT}} -{{CodeEnd}} -: ''Notes:'' [[STRING]] values using multiple characters will be compared by the [[ASCII]] code values sequentially from left to right. Once the equivalent code value of one string is larger than the other the evaluation stops. This allows string values to be compared and sorted alphabetically using [[Greater Than|>]] or [[Less Than|<]] and to [[SWAP]] values in [[arrays]] irregardless of the string lengths. - - -''See also:'' -* [[DIM]], [[DEFSTR]] -* [[CHR$]], [[ASC]] -* [[LEFT$]], [[RIGHT$]], [[MID$]] -* [[LTRIM$]], [[RTRIM$]] -* [[LCASE$]], [[UCASE$]] -* [[STR$]] {{text|(decimal to string value)}} -* [[HEX$]] {{text|(decimal to [[&H|hexadecimal]] string value)}} -* [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]], [[_MK$]] {{text|(numerical to [[ASCII]] string)}} -* [[CVI]], [[CVL]], [[CVS]], [[CVD]], [[_CV]] {{text|([[ASCII]] string to numerical value)}} -* [[LEN]], [[VAL]] {{text|(function converts string to numerical value)}} -* [[ASCII]], [[DRAW]] -* [[PRINT]], [[PRINT USING]], [[WRITE]] - - -{{PageNavigation}} diff --git a/internal/help/SUB_111.txt b/internal/help/SUB_111.txt deleted file mode 100644 index dd37d9a63..000000000 --- a/internal/help/SUB_111.txt +++ /dev/null @@ -1,86 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:15}} -A '''SUB''' procedure is a procedure within a program that can calculate and return multiple parameter values just like a full program. - - -{{PageSyntax}} -:: '''SUB Procedure_name''' [(''parameter''[, ''list''...])] -:: ... -:: ... 'procedure variable definitions and statements -:: ... -:: '''END SUB''' - - -{{Parameters}} -* Parameters passed after the procedure call must match the variable types in the SUB parameters in order. -* If there are no ''parameter''s passed or they are [[SHARED]] the parameters and parenthesis are not required in the procedure. -* Parameter [[Variable]] names in the procedure do not have to match the names used in the [[CALL]], just the value types. -* To pass parameter variables [[BYVAL|by value]] to protect the value in a call, parenthesis can be placed around each variable name also. -* To pass [[arrays]] to a sub-procedure use empty brackets after the name or indicate the index in the call. - - -{{PageDescription}} -* All [[$DYNAMIC|dynamic]] [[variable]] values return to 0 or null strings when the procedure is exited except for [[STATIC]] variable values. -* SUB procedures can return multiple values through the parameters unlike functions. -* SUB procedures return to the next code statement after the call in the main or other procedures. -* [[EXIT]] SUB can be used to exit early or to exit before [[GOSUB]] procedures using [[RETURN]]. -* [[TYPE]] and [[DECLARE LIBRARY]] declarations can be made inside of SUB procedures in QB64 only. -* SUB procedures can save program memory as all memory used in a SUB is released on procedure exit except for [[STATIC]] values. -* [[_DEFINE]] can be used to define all new or old QB64 variable [[TYPE]] definitions instead of DEF***. -* [[$INCLUDE]] text library files with needed SUB and [[FUNCTION]] procedures can be included in programs after all sub-procedures. -* '''QB64 ignores all procedural DECLARE statements!''' Define all ''parameter'' [[TYPE]]s in the SUB procedure. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' - - -''Example 1:'' Text [[PRINT]] screen centering using [[PEEK]] to find the SCREEN mode width. Call and SUB procedure code: -{{CodeStart}} -{{Cl|DEFINT}} A-Z -{{Cl|SCREEN}} 13 -Center 10, 15, "This text is centered." ' example module sub call -{{Cl|END}} - -{{Cl|DEFINT}} A-Z ' only code allowed before SUB line is a DEF statement or a comment -{{Cl|SUB}} Center (Tclr, Trow, Text$) -Columns = {{Cl|_WIDTH}} / {{Cl|_FONTWIDTH}} 'Convert _WIDTH (in pixels) to width in characters -Middle = (Columns \ 2) + 1 ' reads any screen mode width -Tcol = Middle - ({{Cl|LEN}}(Text$) \ 2) -{{Cl|COLOR}} Tclr: {{Cl|LOCATE}} Trow, Tcol: {{Cl|PRINT}} Text$; ' end semicolon prevents screen roll -{{Cl|END SUB}} -{{CodeEnd}} - -:''Explanation:'' The procedure centers text printed to the screen. The parameters are the text color, row and the text itself as a string or string variable. The maximum width of the screen mode in characters is found and divided in half to find the center point. The text string's length is also divided in half and subtracted from the screen's center position. The procedure will also work when the [[WIDTH]] statement has been used. When adding variables to Text$ use the + concatenation operator. Not semicolons! - - -''Example 2:'' SUB and [[FUNCTION]] procedures always return to the place they were called in the main or other sub-procedures: -{{CodeStart}} -a = 10 -Add1 a -{{Cl|PRINT}} a 'Add1 returns final 'a' value here - -{{Cl|END}} - -{{Cl|SUB}} Add1 (n) -n = n + 1 -Add2 n -{{Cl|PRINT}} "exit 1" -{{Cl|END SUB}} - -{{Cl|SUB}} Add2 (m) -m = m + 2 -{{Cl|PRINT}} "exit 2" -{{Cl|END SUB}} -{{CodeEnd}} -{{OutputStart}}exit 2 -exit 1 - 13 -{{OutputEnd}} -: ''Note:'' Parameter '''a''' is used to call the sub-procedures even though parameters '''n''' and '''m''' are used internally. - - -''See also:'' -* [[FUNCTION]], [[CALL]] -* [[BYVAL]], [[SCREEN (statement)]] -* [[EXIT]], [[END]] - - -{{PageNavigation}} diff --git a/internal/help/SWAP_1111.txt b/internal/help/SWAP_1111.txt deleted file mode 100644 index 7c15329f2..000000000 --- a/internal/help/SWAP_1111.txt +++ /dev/null @@ -1,129 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:16}} -The {{KW|SWAP}} statement is used to exchange two variable or array element values. - - -{{PageSyntax}} -:{{KW|SWAP}} {{Parameter|variable1}}, {{Parameter|variable2}} - - -{{PageDescription}} - -* {{Parameter|variable1}} and {{Parameter|variable2}} are any type variables whose values will be exchanged. -* If either {{Parameter|variable1}} or {{Parameter|variable2}} is an array, then an element in the array must be designated. -* {{KW|SWAP}} can be used with string or number variable values. Both must be of the same type. -* SWAP is often used to sort array elements into greater or lesser numerical or cumulative [[ASCII]] [[STRING]] values. -* SWAP can be used in page flipping to change between source and destination pages. - - -''Example 1:'' A simple SWAP of [[STRING|string]] values. -{{CodeStart}} -a$ = "one" -b$ = "two" - -{{Cl|SWAP}} a$, b$ - -{{Cl|PRINT}} a$ -{{Cl|PRINT}} b$ -{{CodeEnd}} -{{OutputStart}}two -one -{{OutputEnd}} - - -''Example 2:'' Creating Cryptograms by scrambling EVERY capital letter in the alphabet. -{{CodeStart}} -{{Cl|DIM}} Letter$(65 {{Cl|TO}} 90) -{{Cl|RANDOMIZE}} {{Cl|TIMER}} -{{Cl|CLS}} -{{Cl|FOR...NEXT|FOR}} a = 65 {{Cl|TO}} 90 'set ASCII codes and letters in order - Letter$(a) = {{Cl|CHR$}}(a) 'create capitalized characters -{{Cl|NEXT}} a - -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 10 -{{Cl|FOR...NEXT|FOR}} i = 65 {{Cl|TO}} 90 - {{Cl|IF...THEN|IF}} Letter$(i) = {{Cl|CHR$}}(i) {{Cl|THEN}} 'find characters the same as the {{Cl|ASCII}} code index - {{Cl|DO...LOOP|DO}}: j = {{Cl|INT}}({{Cl|RND}} * 26) + 65: {{Cl|LOOP}} {{Cl|WHILE}} j = i 'loop until j <> i - {{Cl|SWAP}} Letter$(i), Letter$(j) 'swap corresponding letter characters - {{Cl|END IF}} - {{Cl|PRINT}} {{Cl|CHR$}}(i); " "; 'print normal alphabetical order -{{Cl|NEXT}} - -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 12, 10 -{{Cl|FOR...NEXT|FOR}} a = 65 {{Cl|TO}} 90 'display new alphabetical order - {{Cl|PRINT}} Letter$(a); " "; -{{Cl|NEXT}} - -text$ = "This is how a normal sentence would look before being encrypted." -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 20, 5: {{Cl|PRINT}} text$ -L = {{Cl|LEN}}(text$) -{{Cl|DIM}} Code(L) 'place ASCII code solution into an array -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 22, 5 -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} L - Code(i) = {{Cl|ASC}}({{Cl|UCASE$}}(text$), i) 'in QB64, ASC can read by character position - {{Cl|IF...THEN|IF}} Code(i) >= 65 {{Cl|AND (boolean)|AND}} Code(i) <= 90 {{Cl|THEN}} {{Cl|PRINT}} Letter$(Code(i)); {{Cl|ELSE}} {{Cl|PRINT}} {{Cl|CHR$}}(Code(i)); -{{Cl|NEXT}} -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:'' Explanation:'' The Letter$ [[STRING]] [[Arrays|array]] is first created with the letters matching the [[ASCII]] code index value. Every index is '''swap'''ped when the letter matches it's index code until every letter is different. The Code array holds the text code solution. - - -''Example 3:'' A very quick array sorting SUB procedure using recursion sorts 10 thousand numbers in milliseconds. -{{CodeStart}} -{{Cl|DEFINT}} A-Z -{{Cl|DIM}} {{Cl|SHARED}} swap2 {{Cl|AS}} {{Cl|LONG}} 'Demo only -{{Cl|DIM}} array(10000) {{Cl|AS}} {{Cl|SINGLE}} 'array can hold any type of value -{{Cl|RANDOMIZE}} {{Cl|TIMER}} -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 10000 - array(i) = {{Cl|RND}} * 1000 'populate array with random values to sort -{{Cl|NEXT}} -start = {{Cl|LBOUND}}(array) 'lowest element -finish = {{Cl|UBOUND}}(array) 'highest element -swap2 = 0 'count swaps for demo only -start! = {{Cl|TIMER}}(.001) -{{Cl|CALL}} QuickSort(start, finish, array()) -ending! = {{Cl|TIMER}}(.001) -tmp$ = " array(0)= ##.##### array(5000)= ###.#### array(10000)= ###.####" -{{Cl|PRINT USING}} tmp$; array(0); array(5000); array(10000) -{{Cl|PRINT USING}} " Elapsed time: #.###### seconds with #######, swaps"; ending! - start!; swap2& -{{Cl|FOR...NEXT|FOR}} n = 0 {{Cl|TO}} 10000 'check array sort order - {{Cl|IF}} array(n) >= max! {{Cl|THEN}} 'max should match the array type - max! = array(n) - {{Cl|ELSE}} {{Cl|BEEP}} - {{Cl|PRINT}} "Bad sort order!" - {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} - {{Cl|END IF}} -{{Cl|NEXT}} -{{Cl|END}} - -{{Cl|SUB}} QuickSort (start {{Cl|AS}} {{Cl|INTEGER}}, finish {{Cl|AS}} {{Cl|INTEGER}}, array() {{Cl|AS}} {{Cl|SINGLE}}) -{{Cl|DIM}} Hi {{Cl|AS}} {{Cl|INTEGER}}, Lo {{Cl|AS}} {{Cl|INTEGER}}, Middle {{Cl|AS}} {{Cl|SINGLE}} -Hi = finish: Lo = start -Middle = array((Lo + Hi) / 2) 'find middle of array -{{Cl|DO}} - {{Cl|DO}} {{Cl|WHILE}} array(Lo) < Middle: Lo = Lo + 1: {{Cl|LOOP}} - {{Cl|DO}} {{Cl|WHILE}} array(Hi) > Middle: Hi = Hi - 1: {{Cl|LOOP}} - {{Cl|IF}} Lo <= Hi {{Cl|THEN}} - {{Cl|SWAP}} array(Lo), array(Hi) - swap2 = swap2 + 1 'count swaps for demo only - Lo = Lo + 1: Hi = Hi - 1 - {{Cl|END IF}} 'If homework, you will fail -{{Cl|LOOP}} {{Cl|UNTIL}} Lo > Hi -{{Cl|IF}} Hi > start {{Cl|THEN}} {{Cl|CALL}} QuickSort(start, Hi, array()) -{{Cl|IF}} Lo < finish {{Cl|THEN}} {{Cl|CALL}} QuickSort(Lo, finish, array()) -{{Cl|END SUB}} -{{CodeEnd}} -{{OutputStart}} array(0)= 0.20200 array(5000)= 525.8505 array(10000)= 999.6196 - Elapsed time: 0.023438 seconds with 33,759 swaps -{{OutputEnd}} -:'''NOTE:''' The ''swap2'' shared value is used to count the swaps for the demo and can be removed from the SUB procedure for speed. - - -''See also:'' -* [[RND]], [[RANDOMIZE]] -* [[CHR$]], [[ASC]] -* [[ASCII]], [[Arrays]] - - -{{PageNavigation}} diff --git a/internal/help/SYSTEM_111111.txt b/internal/help/SYSTEM_111111.txt deleted file mode 100644 index 5e6c82923..000000000 --- a/internal/help/SYSTEM_111111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:17}} -The {{KW|SYSTEM}} statement immediately closes a program and returns control to the operating system. - - -{{PageSyntax}} -:'''SYSTEM''' [return_code%] - - -{{Parameters}} -* QB64 allows a ''code'' number to be used after SYSTEM to be read in another program module by the [[SHELL]] or [[_SHELLHIDE]] functions. - - -''Usage:'' -* This command should be used to close a program quickly instead of pausing with [[END]] or nothing at all. -* A code can be added after the statement to send a value to the [[SHELL (function)]] or [[_SHELLHIDE]] function in another module. -* SYSTEM ends the program and closes the window immediately. The last screen image may not be displayed. - - - -''QBasic or QuickBASIC:'' -* '''QBasic BAS files can be run like compiled programs without returning to the IDE when [[SYSTEM]] is used to [[END|end]] them!''' -* If a program BAS module is run from the IDE, stopped by Ctrl-Break or an error occurs the QB program will exit to the IDE. -* To run a QuickBASIC program without the IDE use the following DOS command line: {{text|QB.EXE /L /RUN filename.BAS|green}} - - -{{PageSeeAlso}} -* [[SHELL (function)]] -* [[_SHELLHIDE]] {{text|(function)}} -* [[_EXIT (function)]], [[END]] - - -{{PageNavigation}} diff --git a/internal/help/Semicolon_100000000.txt b/internal/help/Semicolon_100000000.txt deleted file mode 100644 index 5be258503..000000000 --- a/internal/help/Semicolon_100000000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:52}} -The '''semicolon''' is used in a [[PRINT]] statement to stop the screen print cursor immediately after the printed value. - - -''Usage:'' COLOR 13: PRINT "Value ="; value1; value2; value3 - -{{OutputStart}}{{text|1234 5678 9012|magenta}}{{OutputEnd}} - - -* Positive numerical values [[PRINT|printed]] will include a space before and after each value printed. Strings will not have spacing. -* Use the [[WRITE]] statement to print values with only commas between the values and no spacing. -* A semicolon can append the next print when used at the end of a [[PRINT]] statement. -* Use a semicolon after text that will be [[PRINT|printed]] on the last two text rows of a [[SCREEN (statement)|screen mode]] to prevent screen rolling. -* [[INPUT]] statements can use the semicolon '''before''' the text to prevent screen rolling. '''INPUT ; "text or question"; variable'''. -* A semicolon '''after''' the text will create a question mark and space after the [[INPUT]] text question. Use a comma for statements. -* '''NOTE: Semicolons can NOT be used to combine string variables in a string variable definition!''' -* Use the '''+''' [[concatenation]] operator to combine [[STRING|string]] variable definition values only! -* [[Semicolon]]s cannot be used in or following a [[WRITE]] statement! - - -''See also:'' - -* [[Comma]] -* [[PRINT]], [[PRINT USING]] -* [[WRITE]] -* [[INPUT]], [[LINE INPUT]] -* [[STR$]] {{text|(convert number to string)}} -* [[VAL]] {{text|(convert string to number)}} - - -{{PageNavigation}} diff --git a/internal/help/TAB_111.txt b/internal/help/TAB_111.txt deleted file mode 100644 index 154eca74c..000000000 --- a/internal/help/TAB_111.txt +++ /dev/null @@ -1,47 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:19}} -The {{KW|TAB}} function is used in [[PRINT]] and [[LPRINT]] statements to move to a specified column position. - - -{{PageSyntax}} -:{{KW|TAB}}({{Parameter|column%}}) - - -{{PageDescription}} -* Space characters are printed until the print cursor reaches the designated {{Parameter|column%}}, overwriting existing characters. -* If a subsequent TAB ''column%'' is less than the current position, TAB moves the next print to that column on the next row. -* [[ASCII]] [[CHR$]](9) can be substituted for sequencial 9 space column moves. -* [[Comma]] PRINT spacing is up to 15 column places (IE: TAB(15)) to a maximum column of 57. -* When printing to a file, a carriage return([[CHR$]](13)) and linefeed([[CHR$]](10)) character are output when it moves to the next row. -* '''Note:''' QBasic did not allow a TAB to be [[concatenation|added]] to a string value. In [[PRINT]] statements the [[+|plus]] would be changed to a [[semicolon]]. -: In QB64, TAB [[concatenation]] is allowed instead of [[semicolon]]s. Example: {{text|PRINT "text" + TAB(9) + "here"|green}} - - -''Example:'' Comparing TAB to [[comma]] print spacing which moves the next text print 15 columns. -{{CodeStart}} -{{Cl|PRINT}} {{Cl|TAB}}(15); "T" 'TAB spacing - -{{Cl|PRINT}} , "T" 'comma spacing - -{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{text|;|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'semicolons add nothing to position - -{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{text|,|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'comma moves column position beyond 20 -{{CodeEnd}} -{{OutputStart}} T - T - T A - B - T - A - B{{OutputEnd}} -: ''Explanation:'' TAB moves the PRINT down to the next row when the current column position is more than the TAB position. - - -{{PageSeeAlso}} -* [[PRINT]], [[LPRINT]] -* [[SPC]], [[SPACE$]] -* [[STRING$]] -* [[CHR$]], [[ASCII]] - - -{{PageNavigation}} diff --git a/internal/help/TAN_111.txt b/internal/help/TAN_111.txt deleted file mode 100644 index c9624837c..000000000 --- a/internal/help/TAN_111.txt +++ /dev/null @@ -1,92 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:20}} -The [[TAN]] function returns the ratio of [[SIN]]e to [[COS]]ine or tangent value of an angle measured in radians. - - -{{PageSyntax}} -::: tangent! = '''TAN('''''radian_angle!''''')''' - - -{{Parameters}} -* The ''radian_angle'' must be measured in radians. - - -{{PageDescription}} -* To convert from degrees to radians, multiply degrees * Ï€/180. -* TANGENT is the gradient or slope of the circle or arc at [[SIN]](é) / [[COS]](é). Do not use division when the [[COS]] = 0 to avoid [[ERROR Codes|errors]]. - - -''Example:'' Spiraling text using the [[SIN]] and [[TAN]] functions. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} text {{Cl|AS}} {{Cl|STRING}} -text$ = "S P I R A L" -{{Cl|DIM}} {{Cl|SHARED}} word(1 {{Cl|TO}} {{Cl|LEN}}(text$) * 8, 1 {{Cl|TO}} 16) - -{{Cl|CALL}} analyse -{{Cl|CLS}} -{{Cl|CALL}} redraw - -{{Cl|SUB}} analyse -{{Cl|CLS}} -{{Cl|SCREEN}} 12 -{{Cl|COLOR}} 2: {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} text$ -{{Cl|DIM}} px {{Cl|AS}} {{Cl|INTEGER}}, py {{Cl|AS}} {{Cl|INTEGER}}, cnt {{Cl|AS}} {{Cl|INTEGER}}, ltrcnt {{Cl|AS}} {{Cl|INTEGER}} -px = 1: py = 1 -DO - word(px, py) = {{Cl|POINT}}(px, py) - {{Cl|PSET}} (px, py), 1 - px = px + 1 - {{Cl|IF...THEN|IF}} px = {{Cl|LEN}}(text$) * 8 {{Cl|THEN}} - px = 1 - py = py + 1 - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} py = 16 -{{Cl|END SUB}} - -{{Cl|SUB}} redraw -{{Cl|CLS}} -{{Cl|DIM}} row {{Cl|AS}} {{Cl|INTEGER}}, cnt {{Cl|AS}} {{Cl|INTEGER}}, cstart {{Cl|AS}} {{Cl|SINGLE}}, cend {{Cl|AS}} {{Cl|SINGLE}} -{{Cl|DIM}} xrot {{Cl|AS}} {{Cl|INTEGER}}, yrot {{Cl|AS}} {{Cl|INTEGER}}, SCALE {{Cl|AS}} {{Cl|INTEGER}}, pan {{Cl|AS}} {{Cl|INTEGER}} -cstart = 0: cend = 6.2 -xrot = 6: yrot = 6: SCALE = 3: pan = 30 -{{Cl|OUT}} {{Cl|&H}}3C8, 1: {{Cl|OUT}} {{Cl|&H}}3C9, 10: {{Cl|OUT}} {{Cl|&H}}3C9, 10: {{Cl|OUT}} {{Cl|&H}}3C9, 60 -DO - row = 2 - DO - DO - {{Cl|FOR...NEXT|FOR}} i = cend {{Cl|TO}} cstart {{Cl|STEP}} -.03 - x = (SCALE * 60 - (row * xrot / 4)) * {{Cl|TAN}}({{Cl|COS}}(i)) - y = {{Cl|SIN}}(SCALE * 60 - (row * yrot)) * {{Cl|TAN}}({{Cl|SIN}}(i)) * pan - cnt = cnt + 1 - {{Cl|IF...THEN|IF}} word(cnt, row) > 0 {{Cl|THEN}} - {{Cl|CIRCLE}} (x + 320, y + 220), SCALE + 1, 1 'circled letters - '{{Cl|LINE}} (x + 320, y + 220)-{{Cl|STEP}}(12, 12), 1, BF 'boxed letters - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} cnt = {{Cl|LEN}}(text$) * 8 {{Cl|THEN}} cnt = 0: {{Cl|EXIT DO}} - {{Cl|NEXT}} - {{Cl|LOOP}} - row = row + 1 - {{Cl|LOOP}} {{Cl|UNTIL}} row = 16 - cend = cend + .1 - cstart = cstart + .1 - now! = {{Cl|TIMER}} - DO - newnow! = {{Cl|TIMER}} - {{Cl|LOOP}} {{Cl|UNTIL}} newnow! - now! >= .15 - {{Cl|LINE}} (1, 100)-(639, 280), 0, BF -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Unseen Machine}} - - -{{PageSeeAlso}} -* [[_PI]] {{text|(QB64 function)}} -* [[SIN]], [[COS]] -* [[ATN]] {{text|(arctangent)}} -* [[Mathematical Operations]] -* [[Text Using Graphics]] -* [[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/THEN_1111.txt b/internal/help/THEN_1111.txt deleted file mode 100644 index ec6c83707..000000000 --- a/internal/help/THEN_1111.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:21}} -'''THEN''' is required in [[IF...THEN]] conditional evaluation statements. - - - -{{PageSyntax}} -:: IF condition THEN execute_code - - -* THEN is required on the same code line as the IF statement. -* The condition value must be true(-1) or <> 0 for the statement code to be executed. - - -''See also:'' -* [[IF...THEN]] -* [[ELSE]], [[ELSEIF]] -* [[END IF]] - - -{{PageNavigation}} diff --git a/internal/help/TIME$_1111$.txt b/internal/help/TIME$_1111$.txt deleted file mode 100644 index 978b94c53..000000000 --- a/internal/help/TIME$_1111$.txt +++ /dev/null @@ -1,68 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:22}} -The '''TIME$''' Function returns a [[STRING]] representation of the current computer time in a 24 hour format. - - -{{PageSyntax}} -:: PRINT "Present time = "; '''TIME$''' - - -* Returns the present computer time in hh:mm:ss 24 hour format: "19:20:33" -* Uses 2 colon (:) separators between hours, minutes and seconds -* Hour values range from "00" to "23" starting from midnite. -* Minutes and seconds range from "00" to "59" -* Continuous TIME$ calls may lag if a QBasic program is minimized to the taskbar! - - -''Example 1:'' A simple clock using [[DRAW]] with Turn Angle. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DO}} - {{Cl|CLS}} - t$ = {{Cl|TIME$}}: h = {{Cl|VAL}}(t$): m = {{Cl|VAL}}({{Cl|MID$}}(t$, 4, 2)): s = {{Cl|VAL}}({{Cl|MID$}}(t$, 7, 2)) - {{Cl|PRINT}} t$ - {{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 200, 8 - {{Cl|DRAW}} "c12ta" + {{Cl|STR$}}((h {{Cl|MOD}} 12) * -30) + "nu133" - {{Cl|DRAW}} "c14ta" + {{Cl|STR$}}(m * -6) + "nu200" - {{Cl|DRAW}} "c9ta" + {{Cl|STR$}}(s * -6) + "nu200" - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 1 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} -{{small|Code by Galleon}} -: Explanation: Note that [[VAL]](TIME$) can just return the hour number 0 to 23 as the read stops at the first colon. - - -''Example 2:'' The following Function converts TIME$ to normal 12 hour AM-PM digital clock format. -{{CodeStart}} -PRINT TIME$ -PRINT Clock$ - -{{Cl|FUNCTION}} Clock$ -hour$ = {{Cl|LEFT$}}(TIME$, 2): H% = {{Cl|VAL}}(hour$) -min$ = {{Cl|MID$}}(TIME$, 3, 3) -IF H% >= 12 THEN ampm$ = " PM" ELSE ampm$ = " AM" -IF H% > 12 THEN - IF H% - 12 < 10 THEN hour$ = {{Cl|STR$}}(H% - 12) ELSE hour$ = {{Cl|LTRIM$}}({{Cl|STR$}}(H% - 12)) -ELSEIF H% = 0 THEN hour$ = "12" ' midnight hour -ELSE : IF H% < 10 THEN hour$ = {{Cl|STR$}}(H%) ' eliminate leading zeros -END IF -Clock$ = hour$ + min$ + ampm$ -END FUNCTION -{{CodeEnd}} -{{OutputStart}} -14:13:36 - 2:13 PM -{{OutputEnd}} -:''Explanation:'' When hours are less than 10 (but not 0), {{KW|STR$}}(H%) alone keeps a space ahead of the hour. For 2 digit hours, {{KW|LTRIM$}} is used to remove that leading space. For the hours of 10 AM to 12 PM, the hour {{KW|STRING}} value is passed from {{KW|LEFT$}}(TIME$, 2) at the beginning of the function. - - -''See also:'' -* [[TIME$ (statement)]], [[TIMER]] -* [[DATE$]], [[DATE$ (statement)]] -* [[VAL]], [[STR$]], [[HEX$]] -* [[LTRIM$]], [[MID$]], [[LEFT$]] -* [[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/TIMER_(statement)_11111_(000000000).txt b/internal/help/TIMER_(statement)_11111_(000000000).txt deleted file mode 100644 index cb78aa153..000000000 --- a/internal/help/TIMER_(statement)_11111_(000000000).txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:42:25}} -A '''TIMER''' statement enables, turns off or stops timer event trapping. QBasic only uses the base timer, but '''QB64''' can run many. - - -QB {{PageSyntax}} - -:::TIMER {ON|STOP|OFF} - -QB64 {{PageSyntax}} - -:::TIMER(''number%'') {ON|STOP|OFF|FREE} - - -{{Parameters}} -* ''number'' denotes a specific numbered timer event in '''QB64 only'''. QB64 can run many timer events at once including the base timer. -* TIMER ON enables event trapping of an [[ON TIMER (n)]] statement. While enabled, a check is made after every code statement to see if the specified time has elapsed and the ON TIMER [[GOSUB]] (or [[SUB]] in QB64) procedure is executed. -* TIMER STOP disables timer event trapping. When an event occurs while stopped, it is remembered. If timer events are turned back on later, any remembered events are immediately executed. -* TIMER OFF turns timer event trapping completely off and no subsequent events are remembered. - -
'''QB64 only'''
-* Get a TIMER number from [[_FREETIMER]] ONLY except when the base timer(no number or 0) is used. Use specific variables or an array to hold each event number value for later reference. -* If the TIMER number is omitted or 0, the TIMER used is the base timer. -* Specific TIMER events can be enabled, suspended, turned off or freed using [[TIMER (statement)|TIMER(n)]] ON, STOP, OFF or FREE. -* TIMER(n) '''FREE''' clears a specific timer event when it is no longer needed. '''The base TIMER or TIMER(0) cannot be freed!''' - - -
'''QB64 Timing Alternatives'''
-* The [[TIMER]] function can be used to find timed intervals down to 1 millisecond(.001) accuracy. -* The [[_DELAY]] statement can be used to delay program execution for intervals down to milliseconds. -* [[_LIMIT]] can slow down loops to a specified number of frames per second. This can also alleviate a program's CPU usage. - - -''Example:'' How to update the time while [[PRINT|printing]] at the same time in a program. -{{CodeStart}} - TIMER ON ' enable timer event trapping - LOCATE 4, 2 ' set the starting PRINT position - {{Cl|ON TIMER(n)|ON TIMER}}(10) GOSUB Clock ' set procedure execution repeat time - DO WHILE INKEY$ = "": PRINT "A"; : SLEEP 6: LOOP - TIMER OFF - {{Cl|SYSTEM}} - - Clock: - row = {{Cl|CSRLIN}} ' Save current print cursor row. - col = {{Cl|POS|POS(0)}} ' Save current print cursor column. - LOCATE 2, 37: PRINT {{Cl|TIME$}}; ' print current time at top of screen. - LOCATE row, col ' return to last print cursor position - {{Cl|RETURN}} -{{CodeEnd}} -: NOTE: SLEEP will be interrupted in QBasic. - - -''See also:'' - -* [[ON TIMER(n)]], [[TIMER]](function) - -* [[_DELAY]], [[_LIMIT]] - - - -{{PageNavigation}} diff --git a/internal/help/TIMER_11111.txt b/internal/help/TIMER_11111.txt deleted file mode 100644 index 2c44e0471..000000000 --- a/internal/help/TIMER_11111.txt +++ /dev/null @@ -1,88 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:23}} -The '''TIMER''' function returns the number of seconds past the previous midnite down to an accuracy of 1/18th of a second. - - -== QB Syntax == -::: seconds! = TIMER - -== QB64 Syntax == -::: seconds# = TIMER[(''accuracy!'')] - - -* TIMER return values range from 0 at midnight to 86399! A comparison value must stay within that range! -* [[INTEGER]] or [[LONG]] second values range from 0 at midnight to 86399 seconds each day. -* QBasic can return [[SINGLE]] values down to about .04 or 1/18th (one tick) of a second accurately. -* '''QB64''' can read [[DOUBLE]] ''accuracy'' down to 1 millisecond. Example: {{text|start# = TIMER(.001)|green}} -* Use [[DOUBLE]] variables for millisecond accuracy as [[SINGLE]] values are only accurate to 100ths of a second later in the day! -* TIMER loops should use a midnight adjustment to avoid non-ending loops in QBasic. -* TIMER can also be used for timing program Events. See [[ON TIMER(n)]] or the [[TIMER (statement)]] -* '''QB64''' can use a [[_DELAY]] down to .001(one millisecond) or [[_LIMIT]] loops per second. Both help limit program CPU usage. - - -''Example 1:'' Delay SUB with a midnight correction for when TIMER returns to 0. '''QB64''' can use [[_DELAY]] for delays down to .001. -{{CodeStart}} -{{Cl|DO...LOOP|DO}} - {{Cl|PRINT}} "Hello"; - Delay .5 'accuracy down to .05 seconds or 1/18th of a second in Qbasic - {{Cl|PRINT}} "World!"; -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} - -{{Cl|SUB}} Delay (dlay!) -start! = {{Cl|TIMER}} -{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} start! + dlay! >= {{Cl|TIMER}} - {{Cl|IF...THEN|IF}} start! > {{Cl|TIMER}} {{Cl|THEN}} start! = start! - 86400 -{{Cl|LOOP}} -{{Cl|END SUB}} -{{CodeEnd}} -:''Explanation:'' When the delay time is added to the present TIMER value, it could be over the maximum number of 86399 seconds. So when TIMER becomes less than start it has reached midnight. The delay value then must be corrected by subtracting 86400. - - -''Example 2:'' Looping one TIMER tick of 1/18th of a second (ticks per second can be changed) -{{CodeStart}} -{{Cl|DEF SEG}} = 0 ' set to {{Cl|PEEK}} and {{Cl|POKE}} {{Cl|TIMER}} Ticks -{{Cl|DO...LOOP|DO}} ' main program loop - ' program code - {{Cl|POKE}} 1132, 0 ' zero Timer ticks - {{Cl|DO...LOOP|DO}} ' delay loop - x% = {{Cl|PEEK}}(1132) - {{Cl|IF...THEN|IF}} x% <> px% {{Cl|THEN}} {{Cl|PRINT}} x%; - px% = x% - {{Cl|LOOP}} {{Cl|UNTIL}} x% >= 18 '18 ticks in one second - {{Cl|PRINT}} "code " ' program code -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|DEF SEG}} ' reset segment to default - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 code - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 code - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 code -{{OutputEnd}} -:''Explanation:'' The [[POKE]] before the delay loop sets the tick count to 0. The [[PEEK]] count increases until the tick count returns 18 ticks and ends the loop. The same thing could be approximated by using a delay loop with: {{text|second! = '''TIMER''' + 1|green}} - - -''Example 3:'' Using a [[DOUBLE]] variable for [[TIMER]](.001) millisecond accuracy in '''QB64''' throughout the day. -{{CodeStart}} - ts! = TIMER(.001) 'single variable - td# = TIMER(.001) 'double variable - - PRINT "Single ="; ts! - PRINT "Double ="; td# -{{CodeEnd}} -{{OutputStart}} - Single = 77073.09 - Double = 77073.094 -{{OutputEnd}} -:''Explanation:'' [[SINGLE]] variables will cut off the millisecond accuracy returned so [[DOUBLE]] variables should be used. TIMER values will also exceed [[INTEGER]] limits. When displaying TIMER values, use [[LONG]] for seconds and [[DOUBLE]] for milliseconds. - - -''See also:'' -* [[_DELAY]], [[_LIMIT]], [[SLEEP]] -* [[RANDOMIZE]], [[Scancodes]](example) -* [[ON TIMER(n)]], [[TIMER (statement)]] - - -{{PageNavigation}} diff --git a/internal/help/TO_11.txt b/internal/help/TO_11.txt deleted file mode 100644 index ee14cd960..000000000 --- a/internal/help/TO_11.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:24}} -[[TO]] {{text|indicates a range of numerical values or an assignment of one value to another.}} - - -{{PageSyntax}} - -::: DIM array(1 TO 100) -::: FOR i = 1 TO 10 -::: _MAPUNICODE unicode TO asciicode -::: _SETALPHA alpha%, c1& TO c2& - - -* To specify a range in the [[CASE]] clause of a [[SELECT CASE]] statement. -* To specify the range for the loop counter in a [[FOR...NEXT]] loop. -* Array dimensions can be set to have a range of element numbers with TO. -* Specifies an [[ASCII]] character code to set with [[_MAPUNICODE]]. -* Specifies a range of color values to set the transparencies with [[_SETALPHA]]. -* To specify a range of records to lock or unlock in a networked environment, in the [[LOCK|LOCK...UNLOCK]] statement. -* To separate the lower and upper bounds of an array specification in a [[DIM]] or [[REDIM]] statement. - - -''See also:'' -* [[DIM]], [[FOR...NEXT]] -* [[_MAPUNICODE]] -* [[_SETALPHA]] - - -{{PageNavigation}} diff --git a/internal/help/TYPE_1111.txt b/internal/help/TYPE_1111.txt deleted file mode 100644 index d8fb54573..000000000 --- a/internal/help/TYPE_1111.txt +++ /dev/null @@ -1,167 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:26}} -'''TYPE''' definitions are used to create variables that can hold more than one variable type of a fixed byte length. - - -{{PageSyntax}} -::'''TYPE''' typename - -::. - -::. variable(s) AS type - -::. - -::'''END TYPE''' - - -* Typename is an undefined type name holder as it can hold any variable types. -* TYPE definitions should be placed in the main module before the start of the program code execution. -* TYPE definitions CAN be placed in [[SUB]] or [[FUNCTION]] procedures using QB64 only! -* TYPE definitions cannot contain Array variables! Arrays can be [[DIM]]ensioned as a TYPE definition. -* TYPE definitions cannot be inside of another TYPE definition, but variables can be defined AS another type.(See Example 3) -* TYPE definitions must be ended with [[END TYPE]]. -* A TYPE variable MUST be assigned to the type after it is defined. Array variables are allowed. -* Type variables must be defined in every SUB or FUNCTION unless the type variable is [[DIM]]ensioned as [[SHARED]]. -* Type variables use DOT variable names to read or write specific values. They do not use type suffixes as they can hold ANY variable type values! The name before the dot is the one you defined after the type definition and the name after is the variable name used inside of the TYPE. The name of the dimensioned type variable alone can be used to [[PUT]] # or [[GET]] # all of the data at once! -* Once the TYPE variable is created you can find the record or byte size by using [[LEN]](typevariable). -* TYPE definitions can also be placed in [[$INCLUDE]] .BI text files such as [[QB.BI]] is used by [[INTERRUPT]] and [[INTERRUPTX]]. -* '''[[_BIT]] is not currently supported in User Defined [[TYPE]]s'''. -* '''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!''' - - -{{DataTypeTable}} - - -''Example 1:'' Creating a mouse [[INTERRUPT]] TYPE definition. Each [[INTEGER]] value is 2 bytes. -{{CodeStart}} - {{Cl|TYPE}} RegType - AX {{Cl|AS}} {{Cl|INTEGER}} ' mouse function to use - BX {{Cl|AS}} {{Cl|INTEGER}} ' mouse button - CX {{Cl|AS}} {{Cl|INTEGER}} ' mouse graphic column position - DX {{Cl|AS}} {{Cl|INTEGER}} ' mouse graphic row position - BP {{Cl|AS}} {{Cl|INTEGER}} ' not used by mouse, but required * - SI {{Cl|AS}} {{Cl|INTEGER}} ' not used by mouse, but required * - DI {{Cl|AS}} {{Cl|INTEGER}} ' not used by mouse, but required * - Flags {{Cl|AS}} {{Cl|INTEGER}} ' not used by mouse but required * - DS {{Cl|AS}} {{Cl|INTEGER}} ' used by {{Cl|INTERRUPTX}} only - ES {{Cl|AS}} {{Cl|INTEGER}} ' used by {{Cl|INTERRUPTX}} only - {{Cl|TYPE|END TYPE}} - - {{Cl|DIM}} {{Cl|SHARED}} InRegs {{Cl|AS}} RegType, OutRegs {{Cl|AS}} RegType ' create dot variables - - InRegs.AX = 3 ' sets the mouse function to read the mouse buttons and position. - - {{Cl|CALL}} {{Cl|INTERRUPT}}(&H33, InRegs, OutRegs) - - column% = OutRegs.CX ' returns the current mouse column position -{{CodeEnd}} -:''Explanation:'' InRegs and OutRegs become the DOT variable prefix name for the TYPE definition's variables. - -::::Each TYPE variable is designated as the DOT variable's suffix. - -'''* Note: Omitting variables in the RegType definition can change other program variable values!''' - - - -''Example 2:'' Creating an addressbook database for a [[RANDOM]] file. -{{CodeStart}} - TYPE ContactInfo - First AS STRING * 10 - Last AS STRING * 15 - Address1 AS STRING * 30 - Address2 AS STRING * 30 - City AS STRING * 15 - State AS STRING * 2 - Zip AS LONG ' (4 bytes) - Phone AS STRING * 12 - END TYPE - - DIM Contact AS ContactInfo 'create contact record variable for {{Cl|RANDOM}} file - RecordLEN% = {{Cl|LEN}}(Contact) ' 118 bytes - 'define values - Contact.First = "Ted" ' the fixed string length value will contain 7 extra spaces - Contact.Zip = 15236 ' {{Cl|LONG}} value that can be used to search certain zip code numbers. - - {{Cl|PUT|PUT #}}1, 5,Contact 'place contact info into fifth record position -{{CodeEnd}} - -:''Explanation:'' Use the assigned type variable to find the RANDOM record length which is 118 bytes. -::::The DOT variable names consist of Contact as the prefix: - - -''Example 3:'' Defining a TYPE variable as another variable type from a previous TYPE definition in QB64. -{{CodeStart}} -{{Cl|TYPE}} bar - b {{Cl|AS}} {{Cl|STRING}} * 10 -END TYPE - -TYPE foo - a {{Cl|AS}} {{Cl|SINGLE}} - c {{Cl|AS}} bar 'define variable as a bar type -END TYPE - -{{Cl|DIM}} foobar {{Cl|AS}} foo 'create a variable to use the foo type -foobar.a = 15.5 -foobar.c.b = "this is me" - -PRINT foobar.a, foobar.c.b -{{Cl|END}} -{{CodeEnd}} - - -''Example 4:'' A bitmap header information TYPE [[$INCLUDE]] File. -{{TextStart}} -' ******** -'Bitmap.BI can be included at start of program - - TYPE BMPHeaderType ' Description Bytes '''QB64''' - ID AS STRING * 2 ' File ID is "BM" 2 - Size AS LONG ' Size of the data file 4 - Res1 AS INTEGER ' Reserved 1 should be 0 2 - Res2 AS INTEGER ' Reserved 2 should be 0 2 - Offset AS LONG ' Start position of pixel data 4 - Hsize AS LONG ' Information header size 4 - PWidth AS LONG ' Image width 4 {{Cb|_WIDTH (function)}} - PDepth AS LONG ' Image height 4 {{Cb|_HEIGHT}} - Planes AS INTEGER ' Number of planes 2 - BPP AS INTEGER ' Bits per pixel(palette) 2 {{Cb|_PIXELSIZE}} - Compress AS LONG ' Compression 4 - ImageBytes AS LONG ' Width * Height = ImageSIZE 4 - Xres AS LONG ' Width in PELS per metre 4 - Yres AS LONG ' Depth in PELS per metre 4 - NumColors AS LONG ' Number of Colors 4 - SigColors AS LONG ' Significant Colors 4 - END TYPE ' Total Header bytes = 54 -{{TextEnd}} -{{CodeStart}} -'{{Cl|$INCLUDE}}: 'Bitmap.BI' 'use only when including a BI file - -{{Cl|DIM}} {{Cl|SHARED}} BMPHead AS BMPHeaderType - -{{Cl|GET|GET #}}1, , BMPHead 'get the entire bitmap header information -{{CodeEnd}} -:''Explanation:'' Use one [[GET]] to read all of the header information from the start of the bitmap file opened AS [[BINARY]]. It reads all 54 bytes as [[STRING]], [[INTEGER]] and [[LONG]] type DOT variable values. - -:NOTE: BPP returns 4(16 colors), 8(256 colors) or 24(16 million colors) bits per pixel in QBasic. 24 bit can only be in greyscale. - -:Then use the DOT variable name values like this [[GET (graphics statement)]] after you load the bitmap image to the screen: - -{{CodeStart}} -{{Cl|GET (graphics statement)|GET}} (0, 0)-(BMPHead.PWidth - 1, BMPHead.PDepth - 1), Image(48) 'indexed for 4 BPP colors -{{CodeEnd}} - -:The bitmap image is now stored in an {{KW|Arrays|array}} to {{KW|BSAVE}} to a file. The RGB color information follows the file header as [[ASCII]] character values read using {{KW|ASC}}. The color values could be indexed at the start of the Array with the image being offset to: index = NumberOfColors * 3. As determined by the {{KW|SCREEN (statement)|SCREEN}} mode used. In SCREEN 13(256 colors) the index would be 768. - - -''See also:'' -* [[INTEGER]], [[SINGLE]], [[DOUBLE]] -* [[LONG]], [[_INTEGER64]], [[_FLOAT]] -* [[STRING]], [[_BYTE]], [[_BIT]], [[_OFFSET]] -* [[GET|GET #]], [[PUT|PUT #]], [[BINARY]] -* [[GET (graphics statement)]], [[PUT (graphics statement)]] -* [[LEN]], [[LOF]], [[EOF]] -* [[Bitmaps]], [[Creating_Icon_Bitmaps#Icon_to_Bitmap_Conversion_Function|Icon to Bitmap Conversion Function]] - - -{{PageNavigation}} diff --git a/internal/help/Template%3ALogicalTruthPlugin_10000000%31100000010000100000.txt b/internal/help/Template%3ALogicalTruthPlugin_10000000%31100000010000100000.txt deleted file mode 100644 index 3458803a4..000000000 --- a/internal/help/Template%3ALogicalTruthPlugin_10000000%31100000010000100000.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:08-02-2022}} -{{QBDLTIME:22:58:34}} -{{FixedStart}} - The results of the bitwise logical operations, where '''A''' and '''B''' are operands, - and '''1''' or '''0''' indicate whether a bit is set or not set: - ┌───────────┬────────────────────────────────────────────────────────┠- │ '''Operands''' │ '''Logical operations''' │ - ├─────┬─────┼───────┬─────────┬────────┬─────────┬─────────┬─────────┤ - │ '''A''' │ '''B''' │ [[NOT]] '''B''' │ '''A''' [[AND]] '''B''' │ '''A''' [[OR]] '''B''' │ '''A''' [[XOR]] '''B''' │ '''A''' [[EQV]] '''B''' │ '''A''' [[IMP]] '''B''' │ - ├─────┼─────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ - │ '''1''' │ '''1''' │ 0 │ 1 │ 1 │ 0 │ 1 │ 1 │ - ├─────┼─────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ - │ '''1''' │ '''0''' │ 1 │ 0 │ 1 │ 1 │ 0 │ 0 │ - ├─────┼─────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ - │ '''0''' │ '''1''' │ 0 │ 0 │ 1 │ 1 │ 0 │ 1 │ - ├─────┼─────┼───────┼─────────┼────────┼─────────┼─────────┼─────────┤ - │ '''0''' │ '''0''' │ 1 │ 0 │ 0 │ 0 │ 1 │ 1 │ - └─────┴─────┴───────┴─────────┴────────┴─────────┴─────────┴─────────┘ - [[Relational Operations]] return '''negative one''' (-1, all bits set) and '''zero''' - (0, no bits set) for '''true''' and '''false''', respectively. This allows relational - tests to be inverted and combined using the bitwise logical operations. -{{FixedEnd}} diff --git a/internal/help/Template%3AOpenGLTypesPlugin_10000000%3110001110000100000.txt b/internal/help/Template%3AOpenGLTypesPlugin_10000000%3110001110000100000.txt deleted file mode 100644 index c1cfeba5c..000000000 --- a/internal/help/Template%3AOpenGLTypesPlugin_10000000%3110001110000100000.txt +++ /dev/null @@ -1,49 +0,0 @@ -{{QBDLDATE:08-02-2022}} -{{QBDLTIME:22:55:59}} -{{FixedStart}} - ┌──────────────┬────────────────┬──────────────────────────────────────────┠- │ '''OpenGL''' │ '''C/C++''' │ '''QB64''' │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLenum │ unsigned int │ [[_UNSIGNED]] [[LONG]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLboolean │ unsigned char │ [[_UNSIGNED]] [[_BYTE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLbitfield │ unsigned int │ [[_UNSIGNED]] [[LONG]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLbyte │ signed char │ [[_BYTE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLshort │ short │ [[INTEGER]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLint │ int │ [[LONG]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLsizei │ int │ [[LONG]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLubyte │ unsigned char │ [[_UNSIGNED]] [[_BYTE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLushort │ unsigned short │ [[_UNSIGNED]] [[INTEGER]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLuint │ unsigned int │ [[_UNSIGNED]] [[LONG]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLfloat │ float │ [[SINGLE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLclampf │ float │ [[SINGLE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLdouble │ double │ [[DOUBLE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLclampd │ double │ [[DOUBLE]] │ - ├──────────────┼────────────────┼──────────────────────────────────────────┤ - │ GLvoid '''(1)''' │ void │ [[_OFFSET]](any fixed lenght string or [[_BYTE]] │ - │ │ │ array element) │ - └──────────────┴────────────────┴──────────────────────────────────────────┘ - - '''Note:''' If a parameter has an asterisk (*) in front, then it's a pointer to - the designated OpenGL variable type, rather than a value of that type. - Those must be passed using the [[_OFFSET]](...) notation. - - '''E.g.''' GLuint *anyParam is actually the offset of a [[_UNSIGNED]] [[LONG]] (~&) - variable or array, which must be passed as [[_OFFSET]](anyVar~&) or - [[_OFFSET]](anyArr~&()) respectively. - - '''(1)''' This type is regularly only used for pointers (with asterisk (*)) to - any byte sized memory data, hence [[_BYTE]] or fixed length strings. -{{FixedEnd}} diff --git a/internal/help/UBOUND_111111.txt b/internal/help/UBOUND_111111.txt deleted file mode 100644 index 002da65a7..000000000 --- a/internal/help/UBOUND_111111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:27}} -The {{KW|UBOUND}} function returns the largest valid index (upper bound) of an array dimension. - - -{{PageSyntax}} -:''result%'' = {{KW|UBOUND}}(arrayName[, dimension%]) - - -{{PageDescription}} -* {{Parameter|arrayName}} specifies the name of the array. - -* {{Parameter|dimension%}} specifies the dimension number, starting with '''1''' for the first dimension. -** If omitted, {{Parameter|dimension%}} is assumed to be '''1'''. -** If {{Parameter|dimension%}} is less than '''1''' or is greater than the number of dimensions, a [[ERROR Codes|subscript out of range]] error occurs. - -* {{KW|UBOUND}}, along with {{KW|LBOUND}}, is used to determine the range of valid indexes of an array. - - -{{PageExamples}} -{{CodeStart}}{{Cl|DIM}} myArray(5) {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} myOtherArray(1 to 2, 3 to 4) {{Cl|AS}} {{Cl|INTEGER}} - -{{Cl|PRINT}} {{Cl|UBOUND}}(myArray) -{{Cl|PRINT}} {{Cl|UBOUND}}(myOtherArray, 2) -{{CodeEnd}} -{{OutputStart}} 5 - 4 -{{OutputEnd}} - - -{{PageSeeAlso}} -* {{KW|Arrays}}, {{KW|LBOUND}} -* {{KW|DIM}}, {{KW|COMMON}}, {{KW|STATIC}}, {{KW|SHARED}} - - -{{PageNavigation}} diff --git a/internal/help/UCASE$_11111$.txt b/internal/help/UCASE$_11111$.txt deleted file mode 100644 index b3d548be0..000000000 --- a/internal/help/UCASE$_11111$.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:28}} -The [[UCASE$]] function outputs an all-uppercase version of a [[STRING]]. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[UCASE$]]({{Parameter|text$}}) - - -{{PageDescription}} -* Used to guarantee that all alphabetical characters in a [[STRING]] are capitalized. -* Does not affect non-alphabetical characters. - - -{{PageExamples}} -''Example:'' The following code guarantees that all letter key entries are capitalized: -{{CodeStart}}{{Cl|PRINT}} "Do you want to continue? (y/n)" - -{{Cl|DO...LOOP|DO}} - K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) -{{Cl|DO...LOOP|LOOP}} {{Cl|DO...LOOP|UNTIL}} K$ = "Y" {{Cl|OR}} K$ = "N" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[LCASE$]] {{text|(lower case)}} -* [[INKEY$]] -* [[INPUT$]] - - -{{PageNavigation}} diff --git a/internal/help/UEVENT_111111.txt b/internal/help/UEVENT_111111.txt deleted file mode 100644 index da6ac70ca..000000000 --- a/internal/help/UEVENT_111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:29}} -The '''UEVENT''' Statement uses ON, OFF or STOP to enable, turn off or suspend user event trapping. - - -{{PageSyntax}} -:::UEVENT {ON|STOP|OFF} - - -*'''[[Keywords currently not supported by QB64|Currently NOT supported in QB64!]]''' -* UEVENT ON enables user defined event-trapping as defined by the [[ON UEVENT]] statement. - -* UEVENT OFF disables the event-trapping routine. All events are ignored and are not remembered. - -* UEVENT STOP suspends the event-trapping routine. An event is remembered, and the event-trapping routine will be performed as soon as a UEVENT ON statement re-enables the trapping. - - -''See also:'' -* [[ON UEVENT]] - - -{{PageNavigation}} diff --git a/internal/help/UNLOCK_111111.txt b/internal/help/UNLOCK_111111.txt deleted file mode 100644 index c79f29631..000000000 --- a/internal/help/UNLOCK_111111.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:30}} -This statement opens access to parts or all of a file to other programs and network users. - - -{{PageSyntax}} -: [[UNLOCK]] [#]{{Parameter|fileNumber%}} -: [[UNLOCK]] [#]{{Parameter|fileNumber%}}, {{Parameter|record&}} -: [[UNLOCK]] [#]{{Parameter|fileNumber%}}, [{{Parameter|firstRecord&}}] TO {{Parameter|lastRecord&}} - - -{{PageDescription}} -* {{Parameter|fileNumber%}} is the file number of the file to unlock. -* In the first syntax, the entire file is unlocked. -* In the second syntax, {{Parameter|record&}} is the record number of the file to unlock. -* In the third syntax, the records or bytes in the range [{{Parameter|firstRecord&}},{{Parameter|lastRecord&}}] are unlocked. If {{Parameter|firstRecord&}} is omitted, it is assumed to be the first record or byte. -* For files opened in [[BINARY]] mode, each record corresponds to a single byte. -* [[LOCK]] and [[UNLOCK]] statements are always used in pairs and each statement must match the other one. -* Files must be unlocked before other programs can access them, and before the file is closed. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]] - - -{{PageSeeAlso}} -* [[LOCK]] -* [[OPEN]] -* [[ACCESS]] - - -{{PageNavigation}} diff --git a/internal/help/UNTIL_11111.txt b/internal/help/UNTIL_11111.txt deleted file mode 100644 index fa55fafa8..000000000 --- a/internal/help/UNTIL_11111.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:31}} -The '''UNTIL''' condition is used in [[DO...LOOP]] exit verifications. - - - -{{PageSyntax}} -:: DO [UNTIL] evaluation -:: . -:: . -:: . -:: LOOP UNTIL evaluation - - -* Only one conditional evaluation can be made at the start or the end of a [[DO...LOOP]]. -* DO UNTIL evaluates a condition before and inside of the loop. The loop may not run at all. -* LOOP UNTIL evaluates a condition inside of the loop. It has to loop once. -* Skips the loop or loops until an evaluation becomes True. - - -{{RelationalTable}} - - -''See also:'' -*[[WHILE]] -*[[DO...LOOP]] -*[[WHILE...WEND]] - -{{PageNavigation}} diff --git a/internal/help/Underscore_1000000000.txt b/internal/help/Underscore_1000000000.txt deleted file mode 100644 index 810823abb..000000000 --- a/internal/help/Underscore_1000000000.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:01}} -An '''underscore''' can be used at the end of a line of code to continue a code line to the next line. - - - -''Usage:'' IF x + y > 500 AND x + y < 600 THEN_ -:::PRINT x + y - - -* '''Only QB64 keywords can use a leading underscore! Leading underscores are reserved for QB64 procedure names only!''' -* The underscore can be anywhere after the code on that line to continue the code to the next line in QB64. -* Multiple underscores can be used for the same line of code in QB64 only. -* Underscores can be used in the middle of variable, sub procedure or [[CONST|constant]] names. -* '''The underscore is NOT compatible with QBasic! The QBasic IDE will remove or move code with leading underscores!''' -* In [[PRINT USING]] an underscore can precede a formatting character to display that character as text in a template [[STRING]]. - - -''See also:'' - -* [[Colon]], [[Comma]], [[Semicolon]] -* [[IF...THEN]] - - -{{PageNavigation}} diff --git a/internal/help/VAL_111.txt b/internal/help/VAL_111.txt deleted file mode 100644 index 793dffcc5..000000000 --- a/internal/help/VAL_111.txt +++ /dev/null @@ -1,76 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:32}} -The '''VAL''' Function returns the decimal numerical equivalent value of a [[STRING]] numerical value. - - -{{PageSyntax}} -:: value = VAL(string_value$) - - -* VAL converts string numbers to numerical values including decimal point values and prefixed "[[&H]]" hexadecimal, "[[&O]]" octal. -* VAL conversion stops at non-numeric characters except for letter "D" or "E" exponential notation values. -:String values with "D" and "E" letters between numbers may be converted also! EX: '''{{text|VAL("9D4") = 90000|green}}''' -* If the first string character is not a number VAL returns 0. VAL may return erratic values with "%" or "&" starting characters. -* Hexadecimal [[HEX$]] string values with the "[[&H]]" prefix can be converted to a decimal value with digits 0 to 9 and letters A to F, like; dec = VAL("&H"+hexvar$). -* Octal [[OCT$]] string values with the "[[&O]]" prefix can be converted to a decimal value with digits from 0 to 7 only. -* Presently VAL '''cannot''' convert QB64 binary [[&B]] prefixed strings from binary to decimal in '''QB64'''. -* For character values of [[ASCII]] data use [[ASC]] to get the value. -* In QB64 use an [[INTEGER]] return variable to hold integer values returned by VAL [[HEX$|Hex]] strings: '''{{text|value% = VAL("&HFFFF") = -1|green}}''' - - -''Example 1:'' Differences in values returned with QBasic and QB64: -{{CodeStart}} -{{Cl|PRINT}} {{Cl|VAL}}("{{Cl|&H}}") '203 in QB, 0 in QB64 -{{Cl|PRINT}} {{Cl|VAL}}("{{Cl|&H}}FFFF") ' -1 QB, 65535 in QB64 -{{Cl|PRINT}} {{Cl|VAL}}("{{Cl|&H}}FFFF&") '65535 in both -{{CodeEnd}} -:''Explanation:'' A quirk in QBasic returned VAL values of 203 for "&" and "&H" that was never fixed until PDS(7.1). - - -''Example 2:'' Converting a string with some number characters -{{CodeStart}} - text$ = "1.23Hello" - number! = VAL(text$) - PRINT number! -{{CodeEnd}} -{{OutputStart}} -1.23 -{{OutputEnd}} - - -''Example 3:'' Converting literal and variable [[STRING|string]] values to numerical values. -{{CodeStart}} - a$ = "33" - PRINT VAL("10") + VAL(a$) + 1 -{{CodeEnd}} -{{OutputStart}} -44 -{{OutputEnd}} -:''Explanation:'' 10 + 33 + 1 = 44, the strings were converted to values. - -:You have to convert the string to values in order to use them in a mathematical expression also since mixing strings with numbers isn't allowed. VAL will stop at a text letter so VAL("123G56) would return 123. - -:If VAL wasn't used the program would break with an error, as you can't add the value 1 to a string, if the 1 was a string ("1") then the program would return "10331", but now since we used VAL, the numbers were added as they should. - - -''Example 4:'' Converting a hexadecimal value to decimal value using HEX$ with VAL. -{{CodeStart}} - decnumber% = 96 - hexnumber$ = "&H" + {{Cl|HEX$}}(decnumber%) 'convert decimal value to hex and add hex prefix - PRINT hexnumber$ - decimal% = {{Cl|VAL}}(hexnumber$) - PRINT decimal% -{{CodeEnd}} -{{OutputStart}} -&H60 - 96 -{{OutputEnd}} -: ''Explanation:'' [[HEX$]] converts a decimal number to hexadecimal, but [[VAL]] will only recognize it as a valid value with the "&H" prefix. Especially since hexadecimal numbers can use "A" through "F" in them. Create a converter function from this code! - - -''See also:'' -* [[STR$]], [[HEX$]] -* [[OCT$]], [[ASC]] - - -{{PageNavigation}} diff --git a/internal/help/VARPTR$_111111$.txt b/internal/help/VARPTR$_111111$.txt deleted file mode 100644 index 2edbe7617..000000000 --- a/internal/help/VARPTR$_111111$.txt +++ /dev/null @@ -1,80 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:34}} -'''VARPTR$''' is a memory function that returns a [[STRING]] representation of a variable's memory address value for use in a [[DRAW]] or [[PLAY]] statement. - - -{{PageSyntax}} -:: string_value$ = VARPTR$(''variable'') - - -* Can use any [[STRING|string]] or numerical variable reference '''existing''' in memory. -* If the parameter value is from an array it must be dimensioned already. Cannot use fixed length string arrays. -* When using '''numerical''' ''variable'' values in [[DRAW]] strings, use an = sign after the function letter. "TA=" + VARPTR$(''variable%'') -* Always use variable X as in "X" + VARPTR$(''string_variable$'') to [[DRAW]] or [[PLAY]] another [[STRING]] value. -* DRAW relative Moves use a + or - before the equal sign. EX: DRAW "M+=" + VARPTR$(x%) + ",-=" + VARPTR$(y%) - - -''Example 1:'' How VARPTR$ reads consecutive values from memory. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 2 -{{Cl|CLS}} -WIND$ = "r10 d7 l10 u7 br20" 'create draw string to be read by function -ROW$ = "x"+{{Cl|VARPTR$}}(WIND$)+"x"+{{Cl|VARPTR$}}(WIND$)+"x"+{{Cl|VARPTR$}}(WIND$)+" x"+{{Cl|VARPTR$}}(WIND$)+"bl80 bd11" -{{Cl|LINE}} (100, 50)-(200, 160), , B -{{Cl|DRAW}} "bm 115,52" -{{Cl|FOR...NEXT|FOR}} I = 1 {{Cl|TO}} 10 - {{Cl|DRAW}} "x" + {{Cl|VARPTR$}}(ROW$) -{{Cl|NEXT}} -{{CodeEnd}} -:''NOTE:'' '''GWBasic''' allows '''semicolons''' to be used in the ROW$ definition, but QBasic and '''QB64''' MUST use '''+''' concatenation. - - -''Example 2:'' Using the function to change a Turn Angle value using DRAW. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 - 'Demonstrates how string DRAW angles are used with TA -{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 360 {{Cl|STEP}} 30 'mark clock hours every 30 degrees - angle$ = {{Cl|STR$}}(i) 'change degree value i to a string - {{Cl|PSET}} (175, 250), 6 'clock center - {{Cl|DRAW}} "TA" + angle$ + "BU100" 'add string angle to Turn Angle and draw blind up - {{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 12 'place a circle at end of Up line - {{Cl|DRAW}} "P9, 12" - {{Cl|_DELAY}} .5 -{{Cl|NEXT}} - 'Demonstrates how VARPTR$ is used with TA= -{{Cl|DO}}: sec$ = {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) 'get current second value from time - degree = {{Cl|VAL}}(sec$) * -6 'use a negative value to Turn Angle clockwise - {{Cl|PSET}} (175, 250), 9 'clock center - {{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(degree) + "U90" 'VARPTR$ value requires = in DRAW - {{Cl|DO}}: {{Cl|_LIMIT}} 30: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) <> sec$ 'loop until seconds value changes - {{Cl|IF}} {{Cl|INKEY$}} <> "" {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|PSET}} (175, 250), 0 - {{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(degree) + "U90" 'erase previous second hand draw -{{Cl|LOOP}} -{{CodeEnd}} -:''Explanation:'' When the VARPTR$ value is used in DRAW, '''=''' MUST be used to pass the value to the draw! Negative Turn Angle values move clockwise and each second moves the hand 6 degrees. '''TA''' uses actual degree angles starting at 0 or noon. - - -''Example 3:'' Comparing DRAW moves using VARPTR$ and [[STR$]] values. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|PSET}} (200, 200), 12 -{{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 10 -A = 100: B = 100 -{{Cl|DRAW}} "M+=" + {{Cl|VARPTR$}}(A) + ",-=" + {{Cl|VARPTR$}}(B) - -{{Cl|PSET}} (400, 400), 10 -{{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 12 -C = 100: D = -100 -{{Cl|DRAW}} "M+" + {{Cl|STR$}}(C) + "," + {{Cl|STR$}}(D) 'must add + for positive relative moves -{{Cl|END}} -{{CodeEnd}} -: ''Explanation:'' A negative STR$ value will move the DRAW relatively where VARPTR$ won't without the sign before the equal. - - -''See also:'' -* [[VARPTR]], [[STR$]] -* [[DRAW]], [[PLAY]] - - -{{PageNavigation}} diff --git a/internal/help/VARPTR_111111.txt b/internal/help/VARPTR_111111.txt deleted file mode 100644 index 34d4ed633..000000000 --- a/internal/help/VARPTR_111111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:33}} -The '''VARPTR''' function returns an [[INTEGER]] value that is the offset part of the variable or array memory address within it's segment. - - -{{PageSyntax}} -:: offset% = VARPTR(variable_name[(reference_index%)]) - - -* If variablename is not defined before VARPTR or [[VARSEG]] is called, the variable is created and it's address is returned. -* Reference index is used to set the offset address of an array index, not necessarily the lowest index. -* When a string variable, VARPTR returns the offset address location of the first byte of the string. -* Because many QBasic statements change the locations of variables in memory, use the values returned by VARPTR and VARSEG immediately after the functions are used! -* Integer array sizes are limited to 32767 elements when using [[VARPTR]] in QB and '''QB64'''!. Create a larger array using [[_BYTE]]. Example: [[DIM]] [[SHARED]] Memory (65535) AS [[_UNSIGNED]] [[_BYTE]] -* '''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.''' - - -''See also:'' -* [[BSAVE]], [[BLOAD]] -* [[SADD]], [[DEF SEG]] -* [[VARPTR$]], [[VARSEG]], -* [[POKE]], [[PEEK]] - - -{{PageNavigation}} diff --git a/internal/help/VARSEG_111111.txt b/internal/help/VARSEG_111111.txt deleted file mode 100644 index ee2afcd3b..000000000 --- a/internal/help/VARSEG_111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:36}} -The '''VARSEG''' function returns an [[INTEGER]] value that is the segment part of a variable or array memory address. - - - -{{PageSyntax}} -:: [[DEF SEG]] = VARSEG(variable_name[(start_index)]) - - -* If variablename is not defined before [[VARPTR]] or VARSEG is called, the variable is created and its address is returned. -* The start index is the lowest index of an array variable when used. -* When a string variable, VARSEG returns the segment location address of the first byte of the string. -* Because many QBasic statements change the locations of variables in memory, use the values returned by VARPTR and VARSEG immediately after the functions are used! -* Integer array sizes are limited to 32767 elements when using [[VARSEG]] in QB and '''QB64'''!. Create a larger array using [[_BYTE]]. Example: [[DIM]] [[SHARED]] Memory (65535) AS [[_UNSIGNED]] [[_BYTE]] -* '''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.''' - - -''See also:'' -* [[BSAVE]], [[BLOAD]] -* [[SADD]], [[DEF SEG]] -* [[VARPTR]], [[VARPTR$]] -* [[POKE]], [[PEEK]] - - -{{PageNavigation}} diff --git a/internal/help/VIEW_1111.txt b/internal/help/VIEW_1111.txt deleted file mode 100644 index 94e61d74a..000000000 --- a/internal/help/VIEW_1111.txt +++ /dev/null @@ -1,44 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:37}} -The '''VIEW''' statement creates a graphics view port area by defining the coordinate limits to be viewed. - - -{{PageSyntax}} -:: '''VIEW''' [[SCREEN] (column1, row1)-(column2, row2)[, color][, border]]] - - -* When the SCREEN option is used, all coordinates are absolute and only graphics within the viewport area are plotted. -* When the SCREEN option is not used, all coordinates are relative to the view port with the values of column1 and row1 being automatically added before plotting the point. -* Coordinate values are for the top left and bottom right values of a box area of the screen mode used. -* The color parameter specifies a background fill color for the area. None when omitted. -* Border requires any valid color attribute to draw a line around the VIEW area if there is room for it. -* VIEW without any parameters disables the previous viewport. [[RUN]] and [[SCREEN]] can also disable any VIEW port. -* [[CLS]] or [[CLS|CLS 1]] clears the active graphics VIEW port area only. Disable a viewport before attempting to clear the entire screen! -* '''Note: QB64 [[RUN]] statements will not close [[VIEW PRINT]], [[VIEW]] or [[WINDOW]] view ports presently!''' - - -''Example 1:'' Using SCREEN option with absolute screen coordinates. -{{CodeStart}} - SCREEN 12 - VIEW SCREEN (200, 200)-(400, 400), 1, 9 ' blue BG with light blue border - CIRCLE (220, 220), 20, 11 ' using the actual screen coordinates -{{CodeEnd}} - - -''Example 2:'' Using coordinates relative to the viewport box area. -{{CodeStart}} - SCREEN 12 - VIEW (200, 200)-(400, 400), 1, 9 - CIRCLE (20, 20), 20, 11 ' using coordinates inside of the viewport -{{CodeEnd}} - -:''Explanation:'' The relative coordinates are automatically adjusted to place the object correctly. Any values outside of the box's area will not be displayed. Both examples should display the same screen image. - - -''See also:'' -* [[VIEW PRINT]] {{text|(text view port)}} -* [[WINDOW]] {{text|(window view port)}} -* [[SCREEN]], [[CLS]] - - -{{PageNavigation}} diff --git a/internal/help/VIEW_PRINT_1111_11111.txt b/internal/help/VIEW_PRINT_1111_11111.txt deleted file mode 100644 index b4cf4e719..000000000 --- a/internal/help/VIEW_PRINT_1111_11111.txt +++ /dev/null @@ -1,62 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:38}} -The [[VIEW PRINT]] statement defines the boundaries of a text viewport {{KW|PRINT}} area. - - -{{PageSyntax}} -: '''VIEW PRINT''' [{{Parameter|topRow%}} '''TO''' {{Parameter|bottomRow%}}] - - -{{Parameters}} -* {{Parameter|topRow%}} and {{Parameter|bottomRow%}} specify the upper and lower rows of the text viewport. -* If {{Parameter|topRow%}} and {{Parameter|bottomRow%}} are not specified when first used, the text viewport is defined to be the entire screen. - - -{{PageDescription}} -* A second [[VIEW PRINT]] statement without parameters can also disable a viewport when no longer needed. -* [[CLS]] or [[CLS|CLS 2]] statement will clear the active text viewport area only, and reset the cursor location to {{Parameter|topRow%}}. -* A {{KW|SCREEN}} mode change or {{KW|RUN}} statement can also clear and disable viewports. -* After active viewport is disabled, normal screen printing and clearing can begin. -* Row coordinates may vary when a [[WIDTH]] statement has been used. -* '''Note: QB64 [[RUN]] statements will not close [[VIEW PRINT]], [[VIEW]] or [[WINDOW]] view ports presently!''' - - -''Example:'' Demonstrates how text scrolls within the text viewport. -{{CodeStart}}' clear the entire screen and show the boundaries of the new text viewport -{{Cl|CLS}} -{{Cl|PRINT}} "Start at top..." -{{Cl|LOCATE}} 9, 1: {{Cl|PRINT}} "<- row 9 ->" -{{Cl|LOCATE}} 21, 1: {{Cl|PRINT}} "<- row 21 ->" - -' define new text viewport boundaries -{{Cl|VIEW PRINT}} 10 {{Cl|TO}} 20 - -' print some text that will scroll the text viewport -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 15 - {{Cl|PRINT}} "This is viewport line:"; i - {{Cl|SLEEP}} 1 -{{Cl|NEXT}} i - -' clear only the active text viewport with CLS or CLS 2 -{{Cl|CLS}} -{{Cl|PRINT}} "After clearing, the cursor location is reset to the top of the text viewport." - -' disable the viewport -{{Cl|VIEW PRINT}} -{{Cl|_DELAY}} 4 -{{Cl|LOCATE}} 20, 20: {{Cl|PRINT}} "Print anywhere after view port is disabled" -{{Cl|_DELAY}} 4 -{{Cl|CLS}} -{{Cl|PRINT}} "Back to top left after CLS!" -{{CodeEnd}} -: ''Note:'' The bottom row of the VIEW PRINT port can be used only when located or prints end with semicolons. - - -{{PageSeeAlso}} -* [[CLS]] -* [[WINDOW]] -* [[VIEW]] {{text|(graphics view port)}} -* [[LOCATE]], [[PRINT]] - - -{{PageNavigation}} diff --git a/internal/help/WAIT_1111.txt b/internal/help/WAIT_1111.txt deleted file mode 100644 index a189cbee8..000000000 --- a/internal/help/WAIT_1111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:39}} -The {{KW|WAIT}} statement waits until the value read from an I/O port has certain bits set. - - -{{PageSyntax}} -:{{KW|WAIT}} {{Parameter|port%}}, {{Parameter|andMask%}}[, {{Parameter|xorMask%}}] - - -{{PageDescription}} -* The {{KW|WAIT}} statement reads a value from {{Parameter|port%}} using {{KW|INP}}. -* If {{Parameter|xorMask%}} is specified, the value is {{KW|XOR}}'d with {{Parameter|xorMask%}}. It has the effect of "toggle these bits". -* The value is then {{KW|AND}}'d with {{Parameter|andMask%}}. It has the effect of "check if these bits are set". -* If the final value is non-zero, {{KW|WAIT}} returns. Otherwise, another value is read from {{Parameter|port%}} and checked again. -* The {{KW|WAIT}} statement returns immediately if {{Parameter|port%}} is not supported. - - -{{PageExamples}} -:Waiting for vertical retrace -{{CodeStart}}' Either statement can be used to try to reduce screen flickering. -' If both statements are used, try changing the order. - -WAIT &H3DA, 8 ' finishes whenever the screen isn't being written to -WAIT &H3DA, 8, 8 ' finishes whenever the screen is being written to -{{CodeEnd}} - - -{{PageSeeAlso}} -* {{KW|INP}}, {{KW|OUT}} -* [[Scancodes]] - - -{{PageNavigation}} diff --git a/internal/help/WEND_1111.txt b/internal/help/WEND_1111.txt deleted file mode 100644 index 66178b42f..000000000 --- a/internal/help/WEND_1111.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:40}} -See page [[WHILE...WEND]] diff --git a/internal/help/WHILE...WEND_11111...1111.txt b/internal/help/WHILE...WEND_11111...1111.txt deleted file mode 100644 index ccf98a0d7..000000000 --- a/internal/help/WHILE...WEND_11111...1111.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:42}} -The {{KW|WHILE...WEND}} statement is used to repeat a block of statements while the condition is met. - - -{{PageSyntax}} -:{{KW|WHILE}} {{Parameter|condition}} -:. -:. -:. -:{{KW|WEND}} - - -{{PageDescription}} -* {{Parameter|condition}} is a numeric expression used to determine if the loop will execute. -* {{Parameter|statements}} will execute repeatedly while {{Parameter|condition}} is a non-zero value. -* [[EXIT]] WHILE can be used for emergency exits from the loop in QB64 only. -* A [[DO...LOOP]] can use the same DO WHILE condition to get the same results. -* WHILE loops only run if the WHILE condition is True. - - -{{RelationalTable}} - - -{{PageExamples}} -''Example 1:'' Reading an entire file. Example assumes the program has a [[OPEN|file opened]] as #1 - -{{CodeStart}} -{{Cl|OPEN}} "Readme.txt" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 -{{Cl|WHILE...WEND|WHILE}} {{Cl|NOT}} {{Cl|EOF}}(1) - {{Cl|_LIMIT}} 1 'limit line prints to one per second - {{Cl|LINE INPUT (file statement)|LINE INPUT #}}1, text$ - IF {{Cl|INKEY$}} = {{Cl|CHR$}}(27) THEN {{Cl|EXIT}} {{Cl|WHILE}} 'ESC key exits - {{Cl|PRINT}} text$ -{{Cl|WEND}} -{{CodeEnd}} - -''Example 2:'' Clearing the keyboard buffer. -{{CodeStart}} -{{Cl|WHILE}} {{Cl|INKEY$}} <> "" : {{Cl|WEND}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[DO...LOOP]] -* [[FOR...NEXT]] -* [[UNTIL]] (condition) -* [[_CONTINUE]] - - -{{PageNavigation}} diff --git a/internal/help/WHILE_11111.txt b/internal/help/WHILE_11111.txt deleted file mode 100644 index c5488845c..000000000 --- a/internal/help/WHILE_11111.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:41}} -See page [[WHILE...WEND]] diff --git a/internal/help/WIDTH_11111.txt b/internal/help/WIDTH_11111.txt deleted file mode 100644 index 7bcda7a4f..000000000 --- a/internal/help/WIDTH_11111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:43}} -The {{KW|WIDTH}} statement changes the text dimensions of certain {{KW|SCREEN (statement)|SCREEN}} modes. - - -== ''SCREEN'' Syntax == -::: '''WIDTH''' ['''{{Parameter|columns%}}'''][''', {{Parameter|rows%}}'''] - -== ''File'' Syntax == -::: '''WIDTH''' {'''''file_number''''' | '''''device'''''}, '''''columnwidth%''''' - - -{{Parameters}} -* When parameters are not specified, columns defaults to 80 with 25 (30 in [[SCREEN]] 11 or 12) rows. - - -''Usage:'' -* WIDTH should be used AFTER a program SCREEN statement! It does not affect screen graphics or graphic coordinates. -* Affects SCREEN 0 Window size and alters the text block size of each screen mode listed in QBasic: -:* SCREEN 0 can use 80 or 40 columns and 25, 43 or 50 rows. Default is WIDTH 80, 25. -:* SCREEN 9 can use 80 columns and 25 or 43(not supported on many monitors) rows. Default WIDTH 80, 25 fullscreen. -:* SCREEN 10 can use 80 columns and 25 or 43 rows. Default is WIDTH 80, 25 fullscreen. -:* SCREEN 11 and 12 can use 80 columns and 30 or 60 rows. Default is WIDTH 80, 30 fullscreen. -* '''QB64''' can alter all [[SCREEN]] mode widths and heights which may also affect text or [[_FONT]] block sizes. -* If a [[$CONSOLE]] window is active and you set [[_DEST]] [[_CONSOLE]], WIDTH will affect the console output window size (Windows only). -* '''Note:''' WIDTH changes may change screen color settings in QBasic. Use [[PALETTE]] to reset to default colors. -*'''[[Keywords currently not supported by QB64|WIDTH LPRINT is not supported in QB64.]]''' - - -{{PageSeeAlso}} -* [[SCREEN]], [[COLOR]], [[OUT]] -* [[_PRINTWIDTH]] {{text|(function)}} -* [[_WIDTH (function)]], [[_HEIGHT]] {{text|(function)}} -* [[_FONT]], [[_FONTWIDTH]], [[_FONTHEIGHT]] - - -{{PageNavigation}} diff --git a/internal/help/WINDOW_111111.txt b/internal/help/WINDOW_111111.txt deleted file mode 100644 index ef61ae601..000000000 --- a/internal/help/WINDOW_111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:45}} -The '''WINDOW''' command scales the graphics coordinate system of the current [[_DEST]] image, optionally inverting the direction of the vertical axis. Any coordinates used in drawing commands made to the image are scaled such that the image seems have have the dimensions requested. - -{{PageSyntax}} -: '''WINDOW''' [ [ '''SCREEN'''] (''x1!'', ''y1!'') - (''x2!'', ''y2!'')] - -{{PageParameters}} -Where (''x1!'', ''y1!'')-(''x2!'', ''y2!'') specifies the new dimensions of the image to scale to. Non-integer values may be used. -Using '''WINDOW''' with no parameters reverts the effect of any previous calls to it. - -{{PageDescription}} -When a command such as [[LINE]], [[CIRCLE]] or [[_PUTIMAGE]] needs a position in an image specified, it is given as a combination of x (horizontal) and y (vertical) coordinates. Usually these values are measured as pixels from the top-left origin. The '''WINDOW''' command changes the way these values are measured. This is best illustrated with an example: -{{TextStart}} -{{Cb|SCREEN}} {{Cb|_NEWIMAGE}}(600, 600, 32) '600 pixels in x and y directions and displayed on screen -{{Cb|WINDOW}} {{Cb|SCREEN}} (0, 0)-(6, 6) -{{TextEnd}} -The coordinates of the image now run from 0 to 6 in both the x and y directions. The centre of the screen is now referred to as (3, 3) and the bottom-right corner of the screen is (6, 6). The image has not actually just changed size or the number of pixels, just the way the program refers to positions on the image. Despite this example, there is no requirement for the image or scaling coordinates to be square; each direction is scaled independently, and can result in commands such as LINE (0, 0)-(10, 10), , BF drawing a rectangle instead of a square. - -If the '''SCREEN''' part is omitted, the y axis is inverted. Thus the origin is now at the bottom-left, and y coordinates increase as you move up the screen. Such a system may be more familiar to mathematically-oriented programmers. - -'''WINDOW''' does not change any of the content already on the image; it only modifies coordinates used while it is in effect. The scaling is relative to the original image, so successive invocations do not compound upon each other. - -Although '''WINDOW''' affects all coordinates, it does not affect all graphics operations entirely. [[_PUTIMAGE]], if only given one destination coordinate, will not scale or stretch the image being drawn. [[CIRCLE]] will scale its radius such that it matches the horizontal axis. This means it always draws perfect circles even if the scaling of the two axes are not the same, but the radius measured against the vertical scale may not be correct. - -The location of the graphics cursor (used to calculate relative positions for STEP) is not affected. It will remain in the same position on the image, but the relative coordinates that are specified with STEP will be scaled as described above. - -{{PageExamples}} -Demonstrate a circle's radius only matching the scaling in the horizontal direction by comparing against a box: -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) 'Not a square image -{{Cl|WINDOW}} {{Cl|SCREEN}} (0, 0)-(10, 10) 'SCREEN keeps the axis direction the same -{{Cl|LINE}} (4, 4)-(6, 6), {{Cl|_RGB32}}(255, 0, 0), BF 'Red square centred on (5, 5); will be stretched into a rectangle -{{Cl|CIRCLE}} (5, 5), 1, {{Cl|_RGB32}}(0, 255, 0) 'Green circle at (5, 5) with radius 1 -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[PMAP]] -* [[VIEW]] -* [[VIEW PRINT]] - -{{PageNavigation}} diff --git a/internal/help/WRITE_(file_statement)_11111_(0000_000000000).txt b/internal/help/WRITE_(file_statement)_11111_(0000_000000000).txt deleted file mode 100644 index 871a4fb31..000000000 --- a/internal/help/WRITE_(file_statement)_11111_(0000_000000000).txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:47}} -The [[WRITE (file statement)|WRITE #]] file statement writes a list of comma separated variable values to a sequential file or port. - - -{{PageSyntax}} -:{{KW|WRITE (file statement)|WRITE #}}{{Parameter|filenumber&}}[, {{Parameter|expressionList}}] - - -{{PageDescription}} -* {{Parameter|filenumber&}} is the number of the file or device {{KW|OPEN}}ed in the {{KW|OUTPUT}} or {{KW|APPEND}} modes. See: {{KW|FREEFILE}}. -* {{Parameter|expressionList}} is a comma-separated list of values to be written to the file or device. -* WRITE can place any number and types of variable values needed in a file record separated by commas. -* String values will have quotation marks although quotes are not required to read strings in CSV files with [[INPUT (file statement)|INPUT]] #. -* Data files using WRITE normally will have the same number of values listed on each file line. -* Data containing commas must be in quotation marks. Number commas are illegal! -* WRITE created files are normally read with INPUT #. -* CSV files created can be read by Excel using a .CSV file name extension. Strings may or may not include quotation marks. -* [[Semicolon]]s cannot be used in or following the WRITE statement! - - -''Example:'' Writes new data to a text file sequentially and reads it back to the program screen. -{{CodeStart}} -filename$ = "testfile.dat" -x = 1: y = 2: z$ = "Three" - -{{Cl|OPEN}} filename$ {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 'opens and clears an existing file or creates new empty file - -{{Cl|WRITE (file statement)|WRITE}} #1, x, y, z$ - -{{Cl|CLOSE}} #1 - -{{Cl|PRINT}} "File created with data. Press a key!" - -K$ = {{Cl|INPUT$}}(1) 'press a key - -{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #2 'opens a file to read it - -{{Cl|INPUT (file statement)|INPUT}} #2, a, b, c$ - -{{Cl|CLOSE}} #2 - -{{Cl|PRINT}} a, b, c$ -{{Cl|WRITE}} a, b, c$ - -{{Cl|END}} -{{CodeEnd}} -: ''File content:'' [[WRITE]] string values will include quotation marks, but they are not required to read the file. -{{TextStart}} -1,2,"Three" -{{TextEnd}} -: ''Screen output:'' [[PRINT]] string values will not display enclosing quotes. [[WRITE]] screen displays will. -{{OutputStart}} 1 2 Three -1,2,"Three" -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[PRINT (file statement)|PRINT #]] -* [[INPUT (file statement)|INPUT #]] -* [[LINE INPUT (file statement)|LINE INPUT #]] -* [[SQL Client]] {{text|(library)}} - - -{{PageNavigation}} diff --git a/internal/help/WRITE_11111.txt b/internal/help/WRITE_11111.txt deleted file mode 100644 index b2fae9481..000000000 --- a/internal/help/WRITE_11111.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:46}} -The {{KW|WRITE}} statement writes a [[comma]]-separated list of values to the screen without spacing. - - -{{PageSyntax}} -:{{KW|WRITE}} [{{Parameter|expression, List}}] - - -{{PageDescription}} -* {{Parameter|expressionList}} is a comma-separated list of variable or literal values to be written to the screen. -* Write statement separates displayed values using [[comma]] separators(required) that will display on the screen. -* Leading and trailing number spaces are omitted when displaying numerical values. -* [[STRING|String]] [[quotation mark]]s will also be displayed. -* [[Semicolon]]s cannot be used in or following the WRITE statement! - - -''Example:'' Comparing WRITE to the same PRINT statement. -{{CodeStart}}a% = 123 -b$ = "Hello" -c! = 3.1415 - -{{Cl|PRINT}} a%, b$, c! 'commas display tab spaced data -{{Cl|WRITE}} a%, b$, c! 'displays commas between values, strings retain end quotes -{{CodeEnd}} -{{OutputStart}} -123 Hello 3.1415 -123,"Hello",3.1415 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[WRITE (file statement)|WRITE #]] -* [[INPUT (file statement)|INPUT #]] -* [[PRINT]], [[PRINT (file statement)|PRINT #]] -* [[PRINT USING]] - - -{{PageNavigation}} diff --git a/internal/help/XOR_111.txt b/internal/help/XOR_111.txt deleted file mode 100644 index f095b7c38..000000000 --- a/internal/help/XOR_111.txt +++ /dev/null @@ -1,94 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:48}} -Bitwise operators are much like the regular mathematics operators (+, * etc.) but are defined in terms of the individual bits of their operands. The full list of bitwise operators, with a brief summary of its operation: -* '''AND''': True if both inputs are true -* '''OR''': True if one or both inputs are true -* '''NOT''': Invert all bits -* '''XOR''': True if exactly one input is true -* '''IMP''': True if both inputs are the same -* '''EQV''': True unless first input is true and second is false - -{{PageSyntax}} -With the exception of NOT, all the bitwise operators take two operands: -: ''result'' = ''value1'' '''AND''' ''value2'' -NOT goes before the value it operates on: -: ''result'' = '''NOT''' ''value1'' -If ''value1'' or ''value2'' are non-integer numeric types, they are rounded to the nearest integer. - -{{PageDescription}} -Bitwise operators work by comparing the corresponding bits in each of the input values to generate a single bit in the output value. The operators differ in how they do the comparison. The table below shows the output bit for each pair of input bits: -{{LogicalTruthTable}} -Again, note that the NOT operator only has one operand. It is shown in the same table for convenience. - -If one input has more bits than the other (say, an INTEGER vs a LONG) the shorter will be considered to have 0's in the missing bit positions if it is positive, or 1's if it is negative. This scheme comes about because of the [[wikipedia:Two's_complement|Two's Complement]] system for representing negative numbers. As a general rule, there should not be any surprises. - -=== Use as logical operators === -QB64 does not have AND/OR/NOT operators dedicated to operating on the overall truth of values. A numeric value is defined to be ''false'' if it is equal to 0, and ''true'' for any other value, though -1 is the standard ''true'' value, returned by the <, <= etc. operators. One can use the bitwise operators mostly like regular logical operators, but with caution. For instance, 3 is a true value, so as a logical operator NOT 3 would be 0 (false). Because it is in fact a bitwise operator, it evaluates to -4. - -{{PageExamples}} -;Example 1:Use '''AND''' to mask certain bits in a value. In this example, the 1's in the mask (y&) specify which bits in (x&) we are interested in, forcing all others to 0. -{{CodeStart}} -x& = VAL("&B101010") 'Arbitrary collection of bits -y& = VAL("&B001100") 'A bit mask -PRINT "Input 1: "; BIN$(x&, 6) '6 indicates we want 6 bits of output -PRINT "Input 2: "; BIN$(y&, 6) -PRINT "Output: "; BIN$(x& AND y&, 6) - -'Converts the number n& to a string of binary digits, digits& long (padding or truncating as necessary). -FUNCTION BIN$ (n&, digits&) - FOR i& = digits& - 1 TO 0 STEP -1 - IF (n& AND 2 ^ i&) THEN B$ = B$ + "1" ELSE B$ = B$ + "0" - NEXT - BIN$ = B$ -END FUNCTION -{{CodeEnd}} -{{OutputStart}} -Input 1: 101010 -Input 2: 001100 -Output: 001000 -{{OutputEnd}} - -;Example 2:Use '''OR''' to combine bit flags into a single value. The presence of a flag can then be tested by using the flag as a mask with '''AND'''. -{{CodeStart}} -'The trick here is to give each flag a value corresponding to a different bit being 1 -FLAG_A& = VAL("&B0001") -FLAG_B& = VAL("&B0010") -FLAG_C& = VAL("&B0100") -FLAG_D& = VAL("&B1000") - -flags& = FLAG_A& OR FLAG_C& 'Set flags A, C - -'Use each flag as a bitmask to test for its presence: -IF flags& AND FLAG_A& THEN PRINT "Flag A is set" -IF flags& AND FLAG_B& THEN PRINT "Flag B is set" -IF flags& AND FLAG_C& THEN PRINT "Flag C is set" -IF flags& AND FLAG_D& THEN PRINT "Flag D is set" -{{CodeEnd}} -{{OutputStart}} -Flag A is set -Flag C is set -{{OutputEnd}} - -;Example 3:Use '''XOR''' to toggle a bit flag (that is, change its state to the opposite of what it was). This example is the same as the '''OR''' example above, but with one extra line added. This time we enable flags A & C, then toggle flags A & B. This will disable flag A and enable B. -{{CodeStart}} -'The trick here is to give each flag a value corresponding to a different bit being 1 -FLAG_A& = VAL("&B0001") -FLAG_B& = VAL("&B0010") -FLAG_C& = VAL("&B0100") -FLAG_D& = VAL("&B1000") - -flags& = FLAG_A& OR FLAG_C& 'Set flags A, C -flags& = flags& XOR FLAG_A& XOR FLAG_B& 'Toggle flags A, B - -'Use each flag as a bitmask to test for its presence: -IF flags& AND FLAG_A& THEN PRINT "Flag A is set" -IF flags& AND FLAG_B& THEN PRINT "Flag B is set" -IF flags& AND FLAG_C& THEN PRINT "Flag C is set" -IF flags& AND FLAG_D& THEN PRINT "Flag D is set" -{{CodeEnd}} -{{OutputStart}} -Flag B is set -Flag C is set -{{OutputEnd}} - -{{PageNavigation}} diff --git a/internal/help/^_^.txt b/internal/help/^_^.txt deleted file mode 100644 index a774fddf5..000000000 --- a/internal/help/^_^.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:54:10}} -The '''^''' operation raises a numerical value to an exponential value expressing how many times the value is multiplied by itself. - - -{{PageSyntax}} -::'' return_value = number '''^''' {whole_exponent|(fractional_exponent)} - - -{{PageDescription}} - -* The number value can be any type literal or variable numerical value. -* Exponents can be any positive or negative integer or fractional numerical value inside of parenthesis brackets. -* If the exponent is zero, the value returned is 1. -* Fractional(or decimal point) exponents MUST be enclosed in '''() brackets''' and will return the fractional exponential root of a value. -* Exponential operations are done first in the QBasic order of operations. -* The square root of a number can be returned by the [[SQR]] function or by using an exponent of (1 [[/]] 2). Brackets required. -* Values returned may be expressed using exponential or [[Scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision. -* WARNING: Exponential returns may exceed numerical type limitations and create an [[ERROR Codes|overflow error]]! - - -''Example:'' Getting the cube root of a number. - -{{CodeStart}} - - {{Cl|INPUT}} "Enter a number to calculate it's cube root: ", num$ - number! = {{Cl|VAL}}(num$) 'gets single number value - cuberoot# = number! {{Cl|^}} (1 {{Cl|/}} 3) - PRINT cuberoot# 'double type variable for accuracy - -{{CodeEnd}} - -''Details:'' The value returned will most likely be a [[SINGLE]] or [[DOUBLE]] value. Make sure that the return variable type matches the likely program operations! - -{{OutputStart}} - -Enter a number to calculate it's cube root: 144 -5.241482788417793 - -{{OutputEnd}} - - - - -''See also:'' - -[[SQR]], [[Mathematical Operations]] - - - -{{PageNavigation}} diff --git a/internal/help/_ACCEPTFILEDROP__11111111111111.txt b/internal/help/_ACCEPTFILEDROP__11111111111111.txt deleted file mode 100644 index 4ad416ca1..000000000 --- a/internal/help/_ACCEPTFILEDROP__11111111111111.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:58}} -{{DISPLAYTITLE:_ACCEPTFILEDROP}} -The [[_ACCEPTFILEDROP]] statement prepares a program window to receive files dropped from Windows Explorer in a drag/drop operation. - - -{{PageSyntax}} -: [[_ACCEPTFILEDROP]] [{ON|OFF}] - - -{{PageDescription}} -* Calling the statement with no parameters turns drag/dropping ON. -* To know when files have been dropped into your program's window, check that [[_TOTALDROPPEDFILES]] is greater than 0. -* Use [[_DROPPEDFILE]] to read the list, either sequentially or by index. -* If using [[_DROPPEDFILE]] with an index, you must call [[_FINISHDROP]] after you finish working with the list. -* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''. - - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example:'' Accepting files dragged from a folder and processing the list received sequentially. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0) - -{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality -{{Cl|PRINT}} "Drag files from a folder and drop them in this window..." - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}} - {{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}} - a$ = {{Cl|_DROPPEDFILE}} 'reads the list sequentially; when the result is empty ("") it means the list is over - {{Cl|COLOR}} 15 - {{Cl|PRINT}} i, - {{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 2: {{Cl|PRINT}} "file", - {{Cl|ELSE}} - {{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 3: {{Cl|PRINT}} "folder", - {{Cl|ELSE}} - {{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows? - {{Cl|END IF}} - {{Cl|END IF}} - {{Cl|COLOR}} 15 - {{Cl|PRINT}} a$ - {{Cl|NEXT}} - {{Cl|END IF}} - - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_TOTALDROPPEDFILES]], [[_DROPPEDFILE]], [[_FINISHDROP]] -* [[_FILEEXISTS]], [[_DIREXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_ACOSH__11111.txt b/internal/help/_ACOSH__11111.txt deleted file mode 100644 index 9d4defd23..000000000 --- a/internal/help/_ACOSH__11111.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:00}} -{{DISPLAYTITLE:_ACOSH}} -The [[_ACOSH]] returns the nonnegative arc hyperbolic cosine of {{Parameter|x!}}, expressed in radians. - - -{{PageSyntax}} -: {{Parameter|return_value!}} = [[_ACOSH]]({{Parameter|x!}}) - -{{PageSeeAlso}} -* [[_D2G]] {{text|(degree to gradient}}, [[_D2R]] {{text|(degree to radian)}} -* [[_G2D]] {{text|(gradient to degree)}}, [[_G2R]] {{text|(gradient to degree)}} -* [[_R2D]] {{text|(radian to degree)}}, [[_R2G]] {{text|(radian to gradient)}} -* [[COS]] {{text|(cosine)}}, [[SIN]] {{text|(sine)}}, [[TAN]] {{text|(tangent)}} -* [[_ACOS]] {{text|(arc cosine)}}, [[_ASIN]] {{text|(arc sine)}}, [[ATN]] {{text|(arc tangent)}} -* [[_ASINH]] {{text|(arc hyperbolic sine)}}, [[_ATANH]] {{text|(arc hyperbolic tangent)}} -* [[_ATAN2]] {{text|(Compute arc tangent with two parameters)}} -* [[_HYPOT]] {{text|(hypotenuse)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_ACOS__1111.txt b/internal/help/_ACOS__1111.txt deleted file mode 100644 index d51067ed1..000000000 --- a/internal/help/_ACOS__1111.txt +++ /dev/null @@ -1,87 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:35:59}} -{{DISPLAYTITLE:_ACOS}} -The [[_ACOS]] function returns the angle measured in radians based on an input [[COS]]ine value ranging from -1 to 1. - - -{{PageSyntax}} -: {{Parameter|radian_angle!}} = [[_ACOS]]({{Parameter|cosine_value!}}) - -{{PageDescription}} -* The ''cosine_value!'' must be measured >= -1 and <= 1, or an error will be generated. (PRINT _ACOS(1.2) would give the result of -1.#IND, which is basically QB64's way of telling us that the number doesn't exist, much like 1/0 would.) -* ARCCOSINE is the inverse function of [[COS]]ine, which lets us turn a [[COS]]ine value back into an angle. -* Note: Due to rounding with floating point math, the _ACOS may not always give a perfect match for the COS angle which generated this. You can reduce the number of rounding errors by increasing the precision of your calculations by using [[DOUBLE]] or [[_FLOAT]] precision variables instead of [[SINGLE]]. - - -==Availability== -* '''Version 1.000 and up.''' - - -{{PageExamples}} -''Example:'' Converting a radian angle to its COSine and using that value to find the angle in degrees again using _ACOS: -{{CodeStart}} -{{Cl|DEFDBL}} A-Z - -{{Cl|INPUT}} "Give me an Angle (in Degrees) => "; Angle -{{Cl|PRINT}} -C = {{Cl|COS}}({{Cl|_D2R}}(Angle)) '_D2R is the command to convert Degrees to Radians, which is what COS expects -{{Cl|PRINT}} "The COSINE of the Angle is: "; C -A = {{Cl|_ACOS}}(C) -{{Cl|PRINT}} "The ACOS of "; C; " is: "; A -{{Cl|PRINT}} "Notice, A is the Angle in Radians. If we convert it to degrees, the value is "; {{Cl|_R2D}}(A) -{{CodeEnd}} -{{small|Example by SMcNeill}} -{{OutputStart}} -Give me an Angle (in Degrees) => ? 60 - -The COSINE of the Angle is: .5000000000000001 -The ACOS of .5000000000000001 is: 1.047197551196598 -Notice, A is the Angle in Radians. If we convert it to degrees, we discover the value is 60 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]] {{text|(degree to gradient}}, [[_D2R]] {{text|(degree to radian)}} -* [[_G2D]] {{text|(gradient to degree)}}, [[_G2R]] {{text|(gradient to degree}} -* [[_R2D]] {{text|(radian to degree)}}, [[_R2G]] {{text|(radian to gradient}} -* [[COS]] {{text|(cosine)}}, [[SIN]] {{text|(sine)}}, [[TAN]] {{text|(tangent)}} -* [[_ASIN]] {{text|(arc sine)}}, [[ATN]] {{text|(arc tangent)}} -* [[_ACOSH]] {{text|(arc hyperbolic cosine)}}, [[_ASINH]] {{text|(arc hyperbolic sine)}}, [[_ATANH]] {{text|(arc hyperbolic tangent)}} -* [[_ATAN2]] {{text|(Compute arc tangent with two parameters)}} -* [[_HYPOT]] {{text|(hypotenuse)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} - -Templates used on this page: - -Template:Cl (view source) -Template:CodeEnd (view source) -Template:CodeStart (view source) -Template:OutputEnd (view source) -Template:OutputStart (view source) -Template:PageDescription (view source) -Template:PageExamples (view source) -Template:PageNavigation (view source) -Template:PageSeeAlso (view source) -Template:PageSyntax (view source) -Template:Parameter (view source) -Template:Small (view source) -Template:Text (view source) -Return to ACOS. - -Navigation menu -Log inPageDiscussionReadView sourceView historySearch -Search QB64 Wiki -Main page -Recent changes -Random page -Help about MediaWiki -Tools -What links here -Related changes -Special pages -Page information -Privacy policyAbout QB64 WikiDisclaimersPowered by MediaWiki diff --git a/internal/help/_ALLOWFULLSCREEN__111111111111111.txt b/internal/help/_ALLOWFULLSCREEN__111111111111111.txt deleted file mode 100644 index 3a5ccab93..000000000 --- a/internal/help/_ALLOWFULLSCREEN__111111111111111.txt +++ /dev/null @@ -1,78 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:01}} -{{DISPLAYTITLE:_ALLOWFULLSCREEN}} -The [[_ALLOWFULLSCREEN]] statement allows setting the behavior of the ALT+ENTER combo. - - -{{PageSyntax}} -: [[_ALLOWFULLSCREEN]] [{_STRETCH|_SQUAREPIXELS|OFF|_ALL}][, {_SMOOTH|OFF|_ALL}] - - -{{PageDescription}} -* Calling the statement with no parameters enables all four possible full screen modes (and is the default state when a program is started): both [[_STRETCH]] ([[_SMOOTH]] and [[_OFF]]) and [[_SQUAREPIXELS]] ([[_SMOOTH]] and [[_OFF]]). -** Using [[_ALLOWFULLSCREEN]] [[_ALL]], [[_ALL]] has the same effect. -* [[_ALLOWFULLSCREEN]] only affects the behavior of ALT+ENTER. The [[_FULLSCREEN]] statement is not bound by [[_ALLOWFULLSCREEN]]'s settings so all modes can be accessed programmatically. -* To limit just the mode but allow both _SMOOTH + _OFF antialiasing modes, pass just the first parameter: ''Example:'' [[_ALLOWFULLSCREEN]] _SQUAREPIXELS -* To allow multiple modes with _SMOOTH or _OFF as default, pass just the second parameter. ''Example:'' [[_ALLOWFULLSCREEN]] , _SMOOTH -* Any possible permutation of the parameters is allowed. -* With [[_ALLOWFULLSCREEN]] _OFF you can trap Alt+Enter manually in your program and reassign it. See example 2 below. - - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example 1:'' Allowing only one fullscreen mode with square pixels and no antialiasing: -{{CodeStart}} -{{Cl|_ALLOWFULLSCREEN}} {{Cl|_SQUAREPIXELS}}, {{Cl|OFF}} -{{CodeEnd}} - - -''Example 2:'' Disabling _FULLSCREEN with Alt+ENTER so the combo can be manually trapped: -{{CodeStart}} -{{Cl|DO}} - {{Cl|CLS}} - - {{Cl|LOCATE}} 7 - {{Cl|PRINT}} " - Press ALT+ENTER to test trapping the combo..." - {{Cl|PRINT}} " _ Press SPACEBAR to allow fullscreen again..." - - k& = {{Cl|_KEYHIT}} - - {{Cl|IF}} k& = 13 {{Cl|THEN}} - {{Cl|IF}} {{Cl|_KEYDOWN}}(100307) {{Cl|OR}} {{Cl|_KEYDOWN}}(100308) {{Cl|THEN}} - altEnter = altEnter + 1 - {{Cl|END IF}} - {{Cl|ELSEIF}} k& = 32 {{Cl|THEN}} - fullscreenEnabled = {{Cl|NOT}} fullscreenEnabled - {{Cl|END IF}} - - {{Cl|LOCATE}} 14 - {{Cl|IF}} fullscreenEnabled {{Cl|THEN}} - {{Cl|_ALLOWFULLSCREEN}} {{Cl|_ALL}}, {{Cl|_ALL}} - altEnter = 0 - {{Cl|PRINT}} "_ALLOWFULLSCREEN _ALL, _ALL" - - {{Cl|LOCATE}} 18 - {{Cl|PRINT}} "ALT+ENTER will trigger all four fullscreen modes now." - {{Cl|ELSE}} - {{Cl|_ALLOWFULLSCREEN}} {{Cl|OFF}} - {{Cl|PRINT}} "_ALLOWFULLSCREEN OFF" - {{Cl|END IF}} - - {{Cl|IF}} altEnter {{Cl|THEN}} - {{Cl|LOCATE}} 18 - {{Cl|PRINT}} "ALT+ENTER manually trapped"; altEnter; "times." - {{Cl|END IF}} - - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - -{{PageSeeAlso}} -* [[_FULLSCREEN]], [[_SMOOTH (function)]] - - -{{PageNavigation}} diff --git a/internal/help/_ALPHA32__1111132.txt b/internal/help/_ALPHA32__1111132.txt deleted file mode 100644 index bb213ec3c..000000000 --- a/internal/help/_ALPHA32__1111132.txt +++ /dev/null @@ -1,51 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:04}} -{{DISPLAYTITLE:_ALPHA32}} -The [[_ALPHA32]] function returns the alpha transparency level of a 32 bit color value. - - -{{PageSyntax}} -:{{Parameter|alpha&}} = [[_ALPHA32]]({{Parameter|color32~&}})''' - -{{Parameters}} -* {{Parameter|color32&}} is the [[_UNSIGNED]] [[LONG]] 32 bit color value used to retrieve the alpha level. -** Color values that are set as a [[_CLEARCOLOR]] always have an alpha level of 0 (transparent). -** [[_SETALPHA]] can set any alpha level from 0 (or fully transparent) to 255 (or opaque). -** Normal color values that are set by [[_RGB]] or [[_RGB32]] always have an alpha level of 255 (opaque). - - -{{PageDescription}} -* In 4-bit (16 colors) or 8-bit (256 colors) palette screens the function will return 0. -* [[_RED32]], [[_GREEN32]], [[_BLUE32]] and [[_ALPHA32]] are all equivalent to [[_RED]], [[_GREEN]], [[_BLUE]] and [[_ALPHA]] but they are highly optimized and only accept a 32-bit color (RGBA) value. Using these in your code (opposed to dividing then ANDing 32-bit color values) makes code easy to read. -* '''NOTE: 32 bit [[_NEWIMAGE]] screen page backgrounds are transparent black or [[_ALPHA]] 0. Use [[_DONTBLEND]] or [[CLS]] for opaque!''' - - -{{PageExamples}} -''Example:'' Finding the alpha transparency level in a 32 bit screen using an [[_RGBA]] [[_UNSIGNED]] [[LONG]] color value. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) - -clr~& = {{Cl|_RGBA}}(255, 0, 255, 192) -{{Cl|PRINT}} "Color:"; clr~& - -{{Cl|COLOR}} clr~& -{{Cl|PRINT}} "Alpha32:"; {{Cl|_ALPHA32}}(clr~&) - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}}{{text|Color: 3237937407|#FFFFFF}} -{{text|Alpha32: 192|#FF00FF}} -{{OutputEnd}} -: ''Notes:'' The color value is equivalent to [[&H|hexadecimal]] &HC0FF00FF where &HC0 equals 192. [[_RGB]] alphas are always &HFF(255). - - -{{PageSeeAlso}} -* [[_ALPHA]], [[_SETALPHA]] -* [[_RGBA]], [[_RGBA32]] {{text|(set color with alpha)}} -* [[_RED]], [[_GREEN]], [[_BLUE]] -* [[_RED32]], [[_GREEN32]]. [[_BLUE32]] -* [[_CLEARCOLOR]], [[_CLEARCOLOR (function)]] -* [[Images]] - - -{{PageNavigation}} diff --git a/internal/help/_ALPHA__11111.txt b/internal/help/_ALPHA__11111.txt deleted file mode 100644 index 55e34f0d3..000000000 --- a/internal/help/_ALPHA__11111.txt +++ /dev/null @@ -1,66 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:03}} -{{DISPLAYTITLE:_ALPHA}} -The [[_ALPHA]] function returns the alpha channel transparency level of a color value used on a screen page or image. - - -{{PageSyntax}} -:{{Parameter|result&}} = [[_ALPHA]]({{Parameter|color~&}} [, {{Parameter|imageHandle&}}]) - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is omitted, it is assumed to be the current write page. Invalid handles will create [[ERROR Codes|Illegal function call]] errors. -* [[_NEWIMAGE]] 32 bit [[SCREEN]] modes will always use an [[_UNSIGNED]] [[LONG]] ''color~&'' value. -** Color values that are set as a [[_CLEARCOLOR]] always have an alpha level of 0 (transparent). -** [[_SETALPHA]] can set any alpha level from 0 (or fully transparent) to 255 (or opaque). -** Normal color values that are set by [[_RGB]] or [[_RGB32]] always have an alpha level of 255(opaque). -* In 4 (16 color) or 8 (256 color) bit palette screens the function will always return 255. -*[[_RED32]], [[_GREEN32]], [[_BLUE32]] and [[_ALPHA32]] are all equivalent to [[_RED]], [[_GREEN]], [[_BLUE]] and [[_ALPHA]] but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using them (opposed to dividing then ANDing 32-bit color values manually) makes code easy to read. -* '''NOTE: 32 bit [[_NEWIMAGE]] screen page backgrounds are transparent black or [[_ALPHA]] 0. Use [[_DONTBLEND]] or [[CLS]] for opaque.''' - - -{{PageExamples}} -''Example 1:'' Alpha transparency levels are always 255 in 4 or 8 bit screen modes. -{{CodeStart}} -{{Cl|SCREEN}} 13 - -clr~& = {{Cl|_RGBA}}(255, 0, 255, 192) 'returns closest palette color attribute -{{Cl|PRINT}} "Color:"; clr~& - -{{Cl|COLOR}} clr~& -{{Cl|PRINT}} "Alpha:"; {{Cl|_ALPHA}}(clr~&) - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}}{{text|Color 36|#FFFFFF}} -{{text|Alpha: 255|#FF00FF}} -{{OutputEnd}} -: ''Explanation:'' [[_RGBA]] cannot change the [[_ALPHA]] level. [[_ALPHA32]] would return 0 on any non-32 bit image or page. - - -''Example 2:'' Finding the transparency of a 32 bit screen mode's background before and after [[CLS]]. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -BG& = {{Cl|POINT}}(1, 1) -{{Cl|PRINT}} "Alpha ="; {{Cl|_ALPHA}}(BG&); "Press a key to use CLS!" -K$ = INPUT$(1) -{{Cl|CLS}} -BG& = {{Cl|POINT}}(1, 1) -{{Cl|PRINT}} "CLS Alpha ="; {{Cl|_ALPHA}}(BG&) -{{CodeEnd}} -{{OutputStart}}CLS Alpha = 255 {{OutputEnd}} -: ''Explanation:'' Set the ALPHA value to 255 using [[CLS]] to make the background opaque when overlaying pages. - - -{{PageSeeAlso}} -* [[_ALPHA32]], [[_SETALPHA]] -* [[_RGBA]], [[_RGBA32]] {{text|(set color with alpha)}} -* [[_CLEARCOLOR]], [[_CLEARCOLOR (function)]] -* [[_RED]], [[_GREEN]], [[_BLUE]] -* [[_RED32]], [[_GREEN32]]. [[_BLUE32]] -* [[CLS]], [[COLOR]], [[Images]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_ASINH__11111.txt b/internal/help/_ASINH__11111.txt deleted file mode 100644 index 4d6305436..000000000 --- a/internal/help/_ASINH__11111.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:07}} -{{DISPLAYTITLE:_ASINH}} -The [[_ASINH]] returns the arc hyperbolic sine of x, expressed in radians. - - -{{PageSyntax}} -: {{Parameter|return_value!}} = [[_ASINH]]({{Parameter|x!}}) - - -{{PageSeeAlso}} -* [[_D2G]] {{text|(degree to gradient}}, [[_D2R]] {{text|(degree to radian)}} -* [[_G2D]] {{text|(gradient to degree)}}, [[_G2R]] {{text|(gradient to degree)}} -* [[_R2D]] {{text|(radian to degree)}}, [[_R2G]] {{text|(radian to gradient)}} -* [[COS]] {{text|(cosine)}}, [[SIN]] {{text|(sine)}}, [[TAN]] {{text|(tangent)}} -* [[_ACOS]] {{text|(arc cosine)}}, [[_ASIN]] {{text|(arc sine)}}, [[ATN]] {{text|(arc tangent)}} -* [[_ACOSH]] {{text|(arc hyperbolic cosine)}}, [[_ATANH]] {{text|(arc hyperbolic tangent)}} -* [[_ATAN2]] {{text|(Compute arc tangent with two parameters)}} -* [[_HYPOT]] {{text|(hypotenuse)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/_ASIN__1111.txt b/internal/help/_ASIN__1111.txt deleted file mode 100644 index 2f02f8957..000000000 --- a/internal/help/_ASIN__1111.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:06}} -{{DISPLAYTITLE:_ASIN}} -The [[_ASIN]] function returns the angle measured in radians based on an input [[SIN]]e value ranging from -1 to 1. - - -{{PageSyntax}} -: {{Parameter|radian_angle!}} = [[_ASIN]]({{Parameter|sine_value!}}) - - -{{PageDescription}} -* The {{Parameter|sine_value!}} must be measured >= -1 and <= 1, or else it will generate a return value of '''-1.#IND''', which is basically QB64's way of telling us that the number doesn't exist. -* ARCSINE is the inverse function of [[SIN]]e, and turns a [[SIN]]e value back into an angle. -* Note: Due to rounding with floating point math, the [[_ASIN]] may not always give a perfect match for the [[SIN]] angle which generated this. You can reduce the number of rounding errors by increasing the precision of your calculations by using [[DOUBLE]] or [[_FLOAT]] precision variables instead of [[SINGLE]]. - - -==Availability== -* '''Version 1.000 and up''' - - -{{PageExamples}} -''Example:'' Converting a radian angle to its SINe and using that value to find the angle in degrees again using _ASIN: -{{CodeStart}} -{{Cl|DEFDBL}} A-Z - -{{Cl|INPUT}} "Give me an Angle (in Degrees) => "; Angle -{{Cl|PRINT}} -C = {{Cl|SIN}}({{Cl|_D2R}}(Angle)) '_D2R is the command to convert Degrees to Radians, which is what SIN expects -{{Cl|PRINT}} "The SINE of the Angle is: "; C -A = {{Cl|_ASIN}}(C) -{{Cl|PRINT}} "The ASIN of "; C; " is: "; A -{{Cl|PRINT}} "Notice, A is the Angle in Radians. If we convert it to degrees, the value is "; {{Cl|_R2D}}(A) -{{CodeEnd}} -{{small|Example by SMcNeill}} -{{OutputStart}} -Give me an Angle (in Degrees) => ? 60 - -The SINE of the Angle is: .8660254037844386 -The ACOS of .8660254037844386 is: 1.047197551196598 -Notice, A is the Angle in Radians. If we convert it to degrees, we discover the value is 60 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]] {{text|(degree to gradient}}, [[_D2R]] {{text|(degree to radian)}} -* [[_G2D]] {{text|(gradient to degree)}}, [[_G2R]] {{text|(gradient to degree}} -* [[_R2D]] {{text|(radian to degree)}}, [[_R2G]] {{text|(radian to gradient}} -* [[COS]] {{text|(cosine)}}, [[SIN]] {{text|(sine)}}, [[TAN]] {{text|(tangent)}} -* [[_ACOS]] {{text|(arc cosine)}}, [[ATN]] {{text|(arc tangent)}} -* [[_ACOSH]] {{text|(arc hyperbolic cosine)}}, [[_ASINH]] {{text|(arc hyperbolic sine)}}, [[_ATANH]] {{text|(arc hyperbolic tangent)}} -* [[_ATAN2]] {{text|(Compute arc tangent with two parameters)}} -* [[_HYPOT]] {{text|(hypotenuse)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} diff --git a/internal/help/_ASSERT__111111.txt b/internal/help/_ASSERT__111111.txt deleted file mode 100644 index f489aaac0..000000000 --- a/internal/help/_ASSERT__111111.txt +++ /dev/null @@ -1,49 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:09}} -{{DISPLAYTITLE:_ASSERT}} -The [[_ASSERT]] statement can be used to perform tests in code that's in development, for debugging purposes. - - -{{PageSyntax}} -:[[_ASSERT]] {{Parameter|condition}}[, {{Parameter|errorMessage$}}] - - -{{PageDescription}} -* {{Parameter|condition}} is the condition that must be met in order to consider the _ASSERT valid. -* Optional {{Parameter|errorMessage$}} is the message to be displayed in the console window if [[$ASSERTS|$ASSERTS:CONSOLE]] is used. -* If the condition is not met (that is, if it evaluates to 0), an error occurs ("_ASSERT failed on line #") and program execution stops. - - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example:'' Adding test checks for parameter inputs in a function. -{{CodeStart}} -{{Cl|$ASSERTS}}:CONSOLE - -{{Cl|DO}} - a = {{Cl|INT}}({{Cl|RND}} * 10) - b$ = myFunc$(a) - {{Cl|PRINT}} a, , b$ - {{Cl|_LIMIT}} 3 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_KEYHIT}} - -{{Cl|FUNCTION}} myFunc$ (value {{Cl|AS}} {{Cl|SINGLE}}) - {{Cl|_ASSERT}} value > 0, "Value cannot be zero" - {{Cl|_ASSERT}} value <= 10, "Value cannot exceed 10" - - {{Cl|IF}} value > 1 {{Cl|THEN}} plural$ = "s" - myFunc$ = {{Cl|STRING$}}(value, "*") + {{Cl|STR$}}(value) + " star" + plural$ + " :-)" -{{Cl|END}} {{Cl|FUNCTION}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$ASSERTS]] -* [[$CHECKING]] -* [[Relational Operations]] - - -{{PageNavigation}} diff --git a/internal/help/_ATAN2__11112.txt b/internal/help/_ATAN2__11112.txt deleted file mode 100644 index adf034daa..000000000 --- a/internal/help/_ATAN2__11112.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:11}} -{{DISPLAYTITLE:_ATAN2}} -The [[_ATAN2]] function returns the radian angle between the positive x-axis of a plane and the point given by the coordinates (x, y). - - -{{PageSyntax}} -: {{Parameter|angle!}} = [[_ATAN2]]({{Parameter|y}}, {{Parameter|x}}) - - -{{Parameters}} -* {{Parameter|y}} is the vertical axis position (row) as a positive, zero or negative floating point value. -* {{Parameter|x}} is the horizontal axis position (column) as a positive, zero or negative floating point value. - - -{{PageDescription}} -* The [[DOUBLE]] radian angle returned is '''positive''' for upper row values where y > 0. -::* _ATAN2(y, x) = [[ATN]](y# / x#) when x > 0 -::* _ATAN2(y, x) = [[ATN]](y# / x#) + [[_PI]] when x < 0 -::* _ATAN2(y, x) = [[_PI]] / 2 when x = 0 -* The [[DOUBLE]] radian angle returned is 0 when x > 0 and [[_PI]] when x < 0 where y = 0 -* The [[DOUBLE]] radian angle returned is '''negative''' for lower row values where y < 0. -::* _ATAN2(y, x) = [[ATN]](y# / x#) when x > 0 -::* _ATAN2(y, x) = [[ATN]](y# / x#) - [[_PI]] when x < 0 -::* _ATAN2(y, x) = -[[_PI]] / 2 when x = 0 -* _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error. - - -{{PageErrors}} -* With [[ATN]](y / x), x can never be 0 as that would create a Division by Zero [[ERROR Codes|error]] 11 or #IND. - - -{{PageSeeAlso}} -* [[ATN]] {{text|(arctangent)}} -* [[_PI]] {{text|(QB64 function)}} -* [[Mathematical Operations]] -* [https://en.wikipedia.org/wiki/Atan2 Atan2 reference] - - -{{PageNavigation}} diff --git a/internal/help/_ATANH__11111.txt b/internal/help/_ATANH__11111.txt deleted file mode 100644 index aed70eccd..000000000 --- a/internal/help/_ATANH__11111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:12}} -{{DISPLAYTITLE:_ATANH}} -The [[_ATANH]] returns the arc hyperbolic tangent of {{Parameter|x!}}, expressed in radians. - - -{{PageSyntax}} -: {{Parameter|return_value!}} = [[_ATANH]]({{Parameter|x!}}) - - -{{PageSeeAlso}} -* [[_D2G]] {{text|(degree to gradient}}, [[_D2R]] {{text|(degree to radian)}} -* [[_G2D]] {{text|(gradient to degree)}}, [[_G2R]] {{text|(gradient to degree)}} -* [[_R2D]] {{text|(radian to degree)}}, [[_R2G]] {{text|(radian to gradient)}} -* [[COS]] {{text|(cosine)}}, [[SIN]] {{text|(sine)}}, [[TAN]] {{text|(tangent)}} -* [[_ACOS]] {{text|(arc cosine)}}, [[_ASIN]] {{text|(arc sine)}}, [[ATN]] {{text|(arc tangent)}} -* [[_ACOSH]] {{text|(arc hyperbolic cosine)}}, [[_ASINH]] {{text|(arc hyperbolic sine)}} -* [[_ATAN2]] {{text|(Compute arc tangent with two parameters)}} -* [[_HYPOT]] {{text|(hypotenuse)}} -*[[Mathematical Operations]] -*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_AUTODISPLAY_(function)__11111111111_(00000000).txt b/internal/help/_AUTODISPLAY_(function)__11111111111_(00000000).txt deleted file mode 100644 index 08ea0a7de..000000000 --- a/internal/help/_AUTODISPLAY_(function)__11111111111_(00000000).txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:15}} -{{DISPLAYTITLE:_AUTODISPLAY (function)}} -The [[_AUTODISPLAY (function)|_AUTODISPLAY]] function returns the current display mode as true (-1) if automatic or false (0) if disabled using [[_DISPLAY]]. - - -{{PageSyntax}} -: {{Parameter|displayStatus%%}} = [[_AUTODISPLAY (function)|_AUTODISPLAY]] - - -{{PageDescription}} -* The function returns true (-1) if [[_AUTODISPLAY]] is enabled. This is the default state and indicates that every screen change (text or graphics) is displayed immediately to the user. -* If [[_DISPLAY]] is used, then [[_AUTODISPLAY (function)|_AUTODISPLAY]] returns 0, to indicate that screen changes (text or graphics) are only displayed per request, by calling [[_DISPLAY]] again to refresh the screen. - - -{{PageAvailability}} -* '''QB64 1.2 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[_AUTODISPLAY]] -* [[_DISPLAY]] - - -{{PageNavigation}} diff --git a/internal/help/_AUTODISPLAY__11111111111.txt b/internal/help/_AUTODISPLAY__11111111111.txt deleted file mode 100644 index 79ecba879..000000000 --- a/internal/help/_AUTODISPLAY__11111111111.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:14}} -{{DISPLAYTITLE:_AUTODISPLAY}} -The [[_AUTODISPLAY]] statement enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]]. - - -{{PageSyntax}} -:[[_AUTODISPLAY]] - - -{{PageDescription}} -* [[_AUTODISPLAY]] is on by default and displays the screen at around 30 frames per second (normal vertical retrace speed). -* [[_DISPLAY]] disables automatic graphic displays, but it also eliminates having to use PCOPY or page flipping when used correctly. Placing _DISPLAY after screen draws or other screen changes assures completion of the changes before they are displayed. The speed of QB64 code execution makes this a viable option. -* The [[_AUTODISPLAY (function)]] can be used to detect the current display behavior. - - -{{PageSeeAlso}} -* [[_DISPLAY]] -* [[_AUTODISPLAY (function)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_AXIS__1111.txt b/internal/help/_AXIS__1111.txt deleted file mode 100644 index e43a73ee5..000000000 --- a/internal/help/_AXIS__1111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:16}} -{{DISPLAYTITLE:_AXIS}} -The [[_AXIS]] function returns the relative position of a specified axis number on a controller device. - - -{{PageSyntax}} -: {{Parameter|move!}} = [[_AXIS]]({{Parameter|axis_number%}}) - - -* [[SINGLE]] values returned range between -1 and 1 as maximums and 0 indicating minimum or axis center. -* When the mouse is moved on the program screen, moves left or above center are negative while below or right are positive. -* The ''axis_number'' must be a number which does not exceed the number of axis found by the [[_LASTAXIS]] function. -* '''The number of [[_DEVICES]] must be read before using [[_DEVICE$]], [[_DEVICEINPUT]] or [[_LASTAXIS]].''' - - -{{PageExamples}} -''Example:'' Reading multiple controller device buttons, axis and wheels. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}} - {{Cl|PRINT}} {{Cl|STR$}}(i) + ") " + {{Cl|_DEVICE$}}(i) + " Buttons:"; {{Cl|_LASTBUTTON}}(i); ",Axis:"; {{Cl|_LASTAXIS}}(i); ",Wheel:"; {{Cl|_LASTWHEEL}}(i) -{{Cl|NEXT}} - -{{Cl|DO...LOOP|DO}} - d& = {{Cl|_DEVICEINPUT}} - {{Cl|IF...THEN|IF}} d& {{Cl|THEN}} ' the device number cannot be zero! - {{Cl|PRINT}} "Found"; d&; - {{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} {{Cl|_LASTBUTTON}}(d&) - {{Cl|PRINT}} {{Cl|_BUTTONCHANGE}}(b); {{Cl|_BUTTON}}(b); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} {{Cl|_LASTAXIS}}(d&) - {{Cl|PRINT}} {{Cl|_AXIS}}(a); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} {{Cl|_LASTWHEEL}}(d&) - {{Cl|PRINT}} {{Cl|_WHEEL}}(w); - {{Cl|NEXT}} - {{Cl|PRINT}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} -{{CodeEnd}} -: ''Note:'' When there is no device control to read, a [[FOR...NEXT|FOR]] n = 1 TO 0 loop will not run thus avoiding a control function read error. - - -{{PageSeeAlso}} -* [[_LASTWHEEL]], [[_LASTBUTTON]], [[_LASTAXIS]] -* [[_WHEEL]], [[_BUTTON]], [[_BUTTONCHANGE]] -* [[_DEVICE$]], [[_DEVICES]] -* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative movement)}} -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_BACKGROUNDCOLOR__111111111111111.txt b/internal/help/_BACKGROUNDCOLOR__111111111111111.txt deleted file mode 100644 index 9adc1c212..000000000 --- a/internal/help/_BACKGROUNDCOLOR__111111111111111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:17}} -{{DISPLAYTITLE:_BACKGROUNDCOLOR}} -The [[_BACKGROUNDCOLOR]] function returns the current background color. - - -{{PageSyntax}} -:{{Parameter|BGcolor&}} = [[_BACKGROUNDCOLOR]] - - - -{{PageDescription}} -* Use it to get the current background color to restore later in a program. -* Returns the closest attribute value of the background color. - - -{{PageExamples}} -''Example 1:'' Storing a background color for later use. -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|COLOR}} 1, 3 -{{Cl|CLS}} -BG% = {{Cl|_BACKGROUNDCOLOR}} -{{Cl|PRINT}} BG% -{{CodeEnd}} -{{OutputStartBG3}}{{Text|3|#0000aa}} -{{OutputEnd}} - - -''Example 2:'' Understanding the function output -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|COLOR}} 1, 11 -{{Cl|CLS}} -BG% = {{Cl|_BACKGROUNDCOLOR}} -{{Cl|PRINT}} BG% 'prints the attribute as 3 instead of 11 -{{CodeEnd}} -{{OutputStartBG3}}{{Text|3|#0000aa}} -{{OutputEnd}} -:''Explanation: SCREEN 0 background colors over 7 will return the lower intensity color attribute values: EX: attribute - 8 - - -{{PageSeeAlso}} -* [[_DEFAULTCOLOR]] -* [[COLOR]], [[SCREEN]] -* [[SCREEN (function)]] -* [[Windows_Libraries#Color_Dialog_Box|Color Dialog Box]] - - -{{PageNavigation}} diff --git a/internal/help/_BIN$__111$.txt b/internal/help/_BIN$__111$.txt deleted file mode 100644 index dd0770d18..000000000 --- a/internal/help/_BIN$__111$.txt +++ /dev/null @@ -1,84 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:20}} -{{DISPLAYTITLE:_BIN$}} -This function returns the binary (base 2) representation of any numeric value. - - -{{PageSyntax}} -: {{Parameter|binvalue$}} = [[_BIN$]]({{Parameter|number}}) - - -{{PageParameters}} -* {{Parameter|number}} can be any [[INTEGER]], [[LONG]] or [[_INTEGER64]] value, positive or negative. -* {{Parameter|number}} can also be any [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] value, but only the integer part of the value is converted in that case. That is, from the value ''-123.45'' the function would convert the ''-123'' only. - - -{{PageDescription}} -* The function returns the base 2 (binary) representation of the given {{Parameter|number}} as [[STRING]]. -* Different from [[STR$]], this function does not return a leading sign placeholder space, so no [[LTRIM$]] to strip that space from positive numbers is necessary. -* [[VAL]] can convert the returned bin string value back to a decimal value by prefixing the string with "[[&B]]". -** Eg. {{InlineCode}}decimal = {{Cl|VAL}}("&B" + binvalue$){{InlineCodeEnd}}. - - -{{PageAvailability}} -* '''QB64 2.1 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -;Example 1:Comparing decimal, hexadecimal, octal and binary string values from 0 to 15. -{{CodeStart}} -tabletop$ = " Decimal | Hexadecimal | Octal | Binary " -tablesep$ = "---------+-------------+-------+--------" -tableout$ = " \ \ | \\ | \\ | \ \ " 'the PRINT USING template - -{{Cl|LOCATE}} 2, 10: {{Cl|PRINT}} tabletop$ -{{Cl|LOCATE}} 3, 10: {{Cl|PRINT}} tablesep$ -{{Cl|FOR...NEXT|FOR}} n% = 0 {{Cl|TO}} 15 - {{Cl|LOCATE}} 4 + n%, 10: {{Cl|PRINT USING}} tableout$; {{Cl|STR$}}(n%); {{Cl|HEX$}}(n%); {{Cl|OCT$}}(n%); {{Cl|_BIN$}}(n%) -{{Cl|NEXT}} n% -{{CodeEnd}} -;Note:Although the decimal numbers 0-15 have a maximum width of 2 digits only, an extra space in the ''tableout$'' template is needed when using the (fixed width string) slash output format, as [[STR$]] values contain a leading sign placeholder space. -{{OutputStart}} - Decimal | Hexadecimal | Octal | Binary - ---------+-------------+-------+-------- - 0 | 0 | 0 | 0 - 1 | 1 | 1 | 1 - 2 | 2 | 2 | 10 - 3 | 3 | 3 | 11 - 4 | 4 | 4 | 100 - 5 | 5 | 5 | 101 - 6 | 6 | 6 | 110 - 7 | 7 | 7 | 111 - 8 | 8 | 10 | 1000 - 9 | 9 | 11 | 1001 - 10 | A | 12 | 1010 - 11 | B | 13 | 1011 - 12 | C | 14 | 1100 - 13 | D | 15 | 1101 - 14 | E | 16 | 1110 - 15 | F | 17 | 1111 -{{OutputEnd}} - - -;Example 2:Converting a binary value to decimal. -{{CodeStart}} -binvalue$ = {{Cl|_BIN$}}(255) -{{Cl|PRINT}} "Bin: "; binvalue$ -{{Cl|PRINT}} "Converting Bin value to Decimal:"; {{Cl|VAL}}("&B" + binvalue$) -{{CodeEnd}} -{{OutputStart}} -Bin: 11111111 -Converting Bin value to Decimal: 255 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[HEX$]], [[OCT$]], [[STR$]] -* [[&B]] (binary), [[&H]] (hexadecimal), [[&O]] (octal), [[VAL]] -* [[Base Comparisons]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_BIT__111.txt b/internal/help/_BIT__111.txt deleted file mode 100644 index d102d048b..000000000 --- a/internal/help/_BIT__111.txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:18}} -{{DISPLAYTITLE:_BIT}} -The [[_BIT]] datatype can return only values of 0 (bit off) and -1 (bit on). - - -{{PageSyntax}} -: [[DIM]] {{Parameter|variable}} [[AS]] [{{KW|_UNSIGNED}}] [[_BIT]] [* {{Parameter|numberofbits}}] - -: [[_DEFINE]] {{Parameter|Letter}}[{{Parameter|-Range}}|,...] [[AS]] [{{KW|_UNSIGNED}}] [[_BIT]] [* {{Parameter|numberofbits}}] - - -{{PageDescription}} -* An [[_UNSIGNED]] _BIT can hold 0 or 1 instead of 0 and -1, if you set the numberofbits you can hold larger values depending on the number of bits you have set (_BIT * 8 can hold the same values as [[_BYTE]] for example) and the information below is compromised if setting any number of bits other than 1. -* If you set the variable to any other number then the least significant bit of that number will be set as the variables number, if the bit is 1 (on) then the variable will be -1 and if the bit is 0 (off) then the variable will be 0. -*The least significant bit is the last bit on a string of bits (11111) since that bit will only add 1 to the value if set. The most significant bit is the first bit on a string of bits and changes the value more dramatically (significantly) if set on or off. -*The _BIT datatype can be succesfully used as a [[Boolean]] (TRUE or FALSE) and it requires minimal amount of memory (the lowest amount possible actually, one byte can hold 8 bits, if you want to use bits in order to decrease memory usage, use them as arrays as a _BIT variable by itself allocates 4 bytes - DIM bitarray(800) AS _BIT uses 100 bytes). -* '''When a variable has not been assigned or has no type suffix, the value defaults to [[SINGLE]].''' -* '''[[Keywords_currently_not_supported_by_QB64|_BIT is not supported in User Defined TYPES.]]''' Use a [[_BYTE]] and assign up to 8 bit values as shown below. - - -*'''Suffix Symbols''' The [[_BIT]] type suffix used is below the grave accent (`), usually located under the tilde (~) key (not an apostrophe). Foreign keyboards may not have the ` key. Try Alt+96 in the IDE. - -:You can define a bit on-the-fly by adding a ` after the variable, like this: {{InlineCode}}variable` = -1{{InlineCodeEnd}} - -:If you want an unsigned bit you can define it on-the-fly by adding ~` instead, like this: {{InlineCode}}variable~` = 1{{InlineCodeEnd}} - -:You can set the number of bits on the fly by just adding that number - this defines it as being two bits: {{InlineCode}}variable`2 = -1{{InlineCodeEnd}} - - -
'''[[_BIT|BITS]]'''
-* The '''MSB''' is the most significant(largest) bit value and '''LSB''' is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte: - -:* '''"Big-endian"''': MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time. -:* '''"Little-endian"''': LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time. -{{WhiteStart}} - '''Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000''' - ---------------------------------- -------- - '''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240 - '''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15 -{{WhiteEnd}} -::The big-endian method compares exponents of 27 down to 20 while the little-endian method does the opposite. - -
'''[[_BYTE|BYTES]]'''
-* [[INTEGER]] values consist of 2 bytes called the '''HI''' and '''LO''' bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [[SINGLE]] or [[DOUBLE]] values! -{{WhiteStart}} '''16 BIT INTEGER OR REGISTER''' - '''AH (High Byte Bits) AL (Low Byte Bits)''' - BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0 - ---------------------------------------|-------------------------------------- - HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1 - | - DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1 -{{WhiteEnd}} -::The HI byte's '''MSB''' is often called the '''sign''' bit! When all 16 of the integer binary bits are on, the decimal return is -1. - - -{{PageExamples}} -''Example:'' Shifting bits in a value in QB64 versions prior to 1.3 (you can use [[_SHL]] and [[_SHR]] starting with version 1.3). -{{CodeStart}} -n = 24 -Shift = 3 - -{{Cl|PRINT}} LShift(n, Shift) -{{Cl|PRINT}} RShift(n, Shift) -{{Cl|END}} - -{{Cl|FUNCTION}} LShift&(n AS {{Cl|LONG}}, LS AS {{Cl|LONG}}) -IF LS < 0 THEN {{Cl|EXIT FUNCTION}} -LShift = {{Cl|INT}}(n * (2 ^ LS)) -{{Cl|END FUNCTION}} - -{{Cl|FUNCTION}} RShift&(n AS {{Cl|LONG}}, RS AS {{Cl|LONG}}) -IF RS < 0 THEN {{Cl|EXIT FUNCTION}} -RShift = {{Cl|INT}}(n / (2 ^ RS)) -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{small|Adapted from code by RThorpe}} -{{OutputStart}} 192 - 3 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[&B]] (binary), [[_BYTE]] -* [[_SHL]], [[_SHR]] -* [[_DEFINE]], [[_UNSIGNED]] -* [[DIM]] -* [[Binary]], [[Boolean]] -* [[Variable Types]] -* [[Converting Bytes to Bits]] - - -{{PageNavigation}} diff --git a/internal/help/_BLEND_(function)__11111_(00000000).txt b/internal/help/_BLEND_(function)__11111_(00000000).txt deleted file mode 100644 index af1e0760d..000000000 --- a/internal/help/_BLEND_(function)__11111_(00000000).txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:22}} -{{DISPLAYTITLE:_BLEND (function)}} -The [[_BLEND (function)|_BLEND]] function returns enabled or disabled for the current window or a specified image handle when 32 bit. - - -{{PageSyntax}} -:{{Parameter|result%}} = [[_BLEND (function)|_BLEND]] [({{Parameter|imageHandle&}})] - - -{{PageDescription}} -* _BLEND returns -1 if enabled or 0 if disabled by [[_DONTBLEND]] statement. -* '''Note: [[_DONTBLEND]] is faster than the default [[_BLEND]] unless you really need to use it in 32 bit.''' - - -{{PageSeeAlso}} -* [[_DONTBLEND]], [[_BLEND]] -* [[Images]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_BLEND__11111.txt b/internal/help/_BLEND__11111.txt deleted file mode 100644 index baca34eb0..000000000 --- a/internal/help/_BLEND__11111.txt +++ /dev/null @@ -1,58 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:21}} -{{DISPLAYTITLE:_BLEND}} -The [[_BLEND]] statement turns on 32 bit alpha blending for an image or screen mode and is on by default. - - -{{PageSyntax}} -: [[_BLEND]] [{{Parameter|imageHandle&}}] - -===Parameters=== -* {{Parameter|imageHandle&}} refers to an image in memory. If not specified, the current destination page (See [[_DEST]]) is affected. - - -{{PageDescription}} -* Alpha blending is on by default when loading a .PNG image to a 32-bit surface. -* Normally it is used to turn blending on after a previous [[_DONTBLEND]] call. -* [[_BLEND]] can only be used on 32-bit surfaces, otherwise it will produce the error [[ERROR Codes|Illegal Function Call]]. -* '''Note: [[_DONTBLEND]] is faster than the default [[_BLEND]] unless you really need to use it in 32 bit.''' -* '''32 bit screen surface backgrounds (black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.''' - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) - -'{{Cl|CLS}} , {{Cl|_RGB}}(128, 128, 128) 'change background color for other results - -{{Cl|_DONTBLEND}} - -bg& = {{Cl|POINT}}(0, 0) -{{Cl|PRINT}} {{Cl|_RED}}(bg&), {{Cl|_GREEN}}(bg&), {{Cl|_BLUE}}(bg&), {{Cl|_ALPHA}}(bg&) - -{{Cl|LINE}} (100, 100)-(200, 200), {{Cl|_RGBA32}}(255, 128, 0, 128), BF - -{{Cl|LINE}} (440, 100)-(540, 200), {{Cl|_RGBA32}}(0, 0, 255, 64), BF - -K$ = {{Cl|INPUT$}}(1) - -{{Cl|_BLEND}} - -{{Cl|LINE}} (270, 300)-(370, 400), {{Cl|_RGBA32}}(255, 128, 0, 128), BF -m& = {{Cl|POINT}}(303, 302) -{{Cl|PRINT}} {{Cl|_RED}}(m&), {{Cl|_GREEN}}(m&), {{Cl|_BLUE}}(m&), {{Cl|_ALPHA}}(m&) -K$ = {{Cl|INPUT$}}(1) - -{{Cl|LINE}} (270, 300)-(370, 400), {{Cl|_RGBA32}}(0, 0, 255, 64), BF -m& = {{Cl|POINT}}(303, 302) -{{Cl|PRINT}} {{Cl|_RED}}(m&), {{Cl|_GREEN}}(m&), {{Cl|_BLUE}}(m&), {{Cl|_ALPHA}}(m&) -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_DONTBLEND]], [[_BLEND (function)]] -* [[Images]] - - -{{PageNavigation}} diff --git a/internal/help/_BLINK_(function)__11111_(00000000).txt b/internal/help/_BLINK_(function)__11111_(00000000).txt deleted file mode 100644 index 9e237b7c1..000000000 --- a/internal/help/_BLINK_(function)__11111_(00000000).txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:25}} -{{DISPLAYTITLE:_BLINK (function)}} -The [[_BLINK]] function returns the current blink setting for SCREEN 0 colors. If enabled, returns -1 (default), otherwise returns 0. - - -{{PageSyntax}} -: {{Parameter|blinkState%%}} = [[_BLINK]] - - -{{PageAvailability}} -* '''QB64 1.2 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -{{CodeStart}}{{Cl|COLOR}} 16, 7 - -'Try uncommenting the line below: -'{{Cl|_BLINK}} OFF - -{{Cl|IF}} _BLINK {{Cl|THEN}} - {{Cl|PRINT}} "I'm blinking" -{{Cl|ELSE}} - {{Cl|PRINT}} "I'm not blinking" -{{Cl|END IF}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_BLINK]] (statement) -* [[OUT]] - -{{PageNavigation}} diff --git a/internal/help/_BLINK__11111.txt b/internal/help/_BLINK__11111.txt deleted file mode 100644 index 2b138f359..000000000 --- a/internal/help/_BLINK__11111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:24}} -{{DISPLAYTITLE:_BLINK}} -The [[_BLINK]] statement toggles blinking colors in text mode (SCREEN 0). Default state is ON. - - -{{PageSyntax}} -: [[_BLINK]] {ON|OFF} - - -{{PageDescription}} -* SCREEN 0 emulates the VGA palette with regular colors from 0 to 15 and blinking colors from 16-31 (these are the same colors as 0-15, except their blink attribute is set to on). [[_BLINK]] OFF emulates writing to the video memory and disabling blinking for colors 16-31. -* Using colors 16-31 for the foreground with [[_BLINK]] set to OFF will produce high intensity background colors. -* [[_BLINK]] is only effective in SCREEN 0. It's ignored in graphic modes. -* IF [[_DISPLAY]] is used, blinking is disabled, even if _BLINK is ON, but high intensity backgrounds aren't enabled in this case. - - -==Availability:== -* Build 20170816/61 up (August 16, 2017). - - -{{PageExamples}} -{{CodeStart}}{{Cl|COLOR}} 16, 7 -{{Cl|PRINT}} "This is printed in black over gray background. Black letters are blinking." -{{Cl|PRINT}} "Hit a key..." -{{Cl|SLEEP}} -{{Cl|_BLINK}} OFF -{{Cl|PRINT}} "Now the same text is printed in black over bright white, because blinking was disabled." -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_BLINK (function)]] -* [[OUT]] -* [[_DISPLAY]] - -{{PageNavigation}} diff --git a/internal/help/_BLUE32__111132.txt b/internal/help/_BLUE32__111132.txt deleted file mode 100644 index 906b546b1..000000000 --- a/internal/help/_BLUE32__111132.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:27}} -{{DISPLAYTITLE:_BLUE32}} -The [[_BLUE32]] function returns the blue component intensity of a 32-bit image or surface color. - - -{{PageSyntax}} -: {{Parameter|blue32color&}} = [[_BLUE32]]({{Parameter|rgbaColor&}}) - - -{{PageDescription}} -* {{Parameter|rgbaColor&}} is the 32-bit ''RGBA'' color value to retrieve the blue component intensity value from. -* ''RGBA'' color values are returned by the [[_PALETTECOLOR (function)|_PALETTECOLOR]], [[POINT]], [[_RGB]], [[_RGB32]], [[_RGBA]] or [[_RGBA32]] functions. -* [[LONG]] intensity values returned range from 0 (no intensity, not present) to 255 (full intensity). - - -{{PageExamples}} -* See the example for [[POINT]]. - - -{{PageSeeAlso}} -* [[_RED32]], [[_GREEN32]] -* [[_RGB32]], [[_BLUE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_BLUE__1111.txt b/internal/help/_BLUE__1111.txt deleted file mode 100644 index ea2bbf487..000000000 --- a/internal/help/_BLUE__1111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:26}} -{{DISPLAYTITLE:_BLUE}} -The [[_BLUE]] function returns the palette intensity or the blue component intensity of a 32-bit image color. - - -{{PageSyntax}} -: {{Parameter|blueintensity&}} = [[_BLUE]]({{Parameter|rgbaColorIndex&}}[, {{Parameter|imageHandle&}}]) - - -{{PageDescription}} -* {{Parameter|rgbaColorIndex&}} is the ''RGBA'' color value or palette index of the color to retrieve the blue component intensity from. -* The [[LONG]] intensity value returned ranges from 0 (no intensity, not present) to 255 (full intensity). -* If {{Parameter|imageHandle&}} specifies a 32-bit color image, {{Parameter|rgbaColorIndex&}} is interpreted as a 32-bit ''RGBA'' color value. -* If {{Parameter|imageHandle&}} specifies an image that uses a palette, {{Parameter|rgbaColorIndex&}} is interpreted as a palette index. -* If {{Parameter|imageHandle&}} is not specified, it is assumed to be the current write page. -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error will occur. -* If {{Parameter|rgbaColorIndex&}} is outside the range of valid indexes for a given image mode, an [[ERROR Codes|illegal function call]] error occurs. -* Uses index parameters passed by the [[_RGB]], [[_RGBA]], [[_RGB32]] or [[_RGBA32]] funtions. -* An image handle is optional. - - -{{PageExamples}} -* See the example for [[POINT]]. - - -{{PageSeeAlso}} -* [[_RED]], [[_GREEN]] -* [[_RGB]], [[RGB32]] -* [[_LOADIMAGE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_BUTTONCHANGE__111111111111.txt b/internal/help/_BUTTONCHANGE__111111111111.txt deleted file mode 100644 index e2b1f1a93..000000000 --- a/internal/help/_BUTTONCHANGE__111111111111.txt +++ /dev/null @@ -1,55 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:29}} -{{DISPLAYTITLE:_BUTTONCHANGE}} -The [[_BUTTONCHANGE]] function returns -1 or 1 when a specified button number on a controller device has been pressed or released. - - -{{PageSyntax}} -: {{Parameter|press%}} = [[_BUTTONCHANGE]]({{Parameter|button_number%}}) - - -{{PageDescription}} -* Values returned are -1 for a press and 1 when a button is released. No press or release event returns zero. -* The {{Parameter|button_number%}} must be a number which does not exceed the number of buttons found by the [[_LASTBUTTON]] function. -* '''The number of [[_DEVICES]] must be read before using [[_DEVICE$]], [[_DEVICEINPUT]] or [[_LASTBUTTON]].''' -* '''Note:''' The center mouse button is button number 2. Center can also be read using [[_MOUSEBUTTON]](3). - - -{{PageExamples}} -''Example:'' Reading multiple controller device buttons, axis and wheels. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}} - {{Cl|PRINT}} {{Cl|STR$}}(i) + ") " + {{Cl|_DEVICE$}}(i) + " Buttons:"; {{Cl|_LASTBUTTON}}(i); ",Axis:"; {{Cl|_LASTAXIS}}(i); ",Wheel:"; {{Cl|_LASTWHEEL}}(i) -{{Cl|NEXT}} - -{{Cl|DO...LOOP|DO}} - d& = {{Cl|_DEVICEINPUT}} - {{Cl|IF...THEN|IF}} d& {{Cl|THEN}} ' the device number cannot be zero! - {{Cl|PRINT}} "Found"; d&; - {{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} {{Cl|_LASTBUTTON}}(d&) - {{Cl|PRINT}} {{Cl|_BUTTONCHANGE}}(b); {{Cl|_BUTTON}}(b); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} {{Cl|_LASTAXIS}}(d&) - {{Cl|PRINT}} {{Cl|_AXIS}}(a); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} {{Cl|_LASTWHEEL}}(d&) - {{Cl|PRINT}} {{Cl|_WHEEL}}(w); - {{Cl|NEXT}} - {{Cl|PRINT}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} -{{CodeEnd}} -: ''Note:'' When there is no device control to read, a [[FOR...NEXT|FOR]] n = 1 TO 0 loop will not run thus avoiding a control function read error. - - -{{PageSeeAlso}} -* [[_LASTWHEEL]], [[_LASTBUTTON]], [[_LASTAXIS]] -* [[_AXIS]], [[_WHEEL]], [[_BUTTON]] -* [[_DEVICE$]], [[_DEVICES]] -* [[_MOUSEBUTTON]] -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_BUTTON__111111.txt b/internal/help/_BUTTON__111111.txt deleted file mode 100644 index 388a7fd49..000000000 --- a/internal/help/_BUTTON__111111.txt +++ /dev/null @@ -1,55 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:28}} -{{DISPLAYTITLE:_BUTTON}} -The [[_BUTTON]] function returns -1 when specified button number on a controller device is pressed. - - -{{PageSyntax}} -: {{Parameter|press%%}} = [[_BUTTON]]({{Parameter|button_number%}}) - - -{{PageDescription}} -* Values returned are -1 for a press and 0 when a button is released or not pressed. -* The {{Parameter|button_number%}} must be a number which does not exceed the number of buttons found by the [[_LASTBUTTON]] function. -* '''The number of [[_DEVICES]] must be read before using [[_DEVICE$]], [[_DEVICEINPUT]] or [[_LASTBUTTON]].''' -* '''Note:''' The number 2 button is the center button in this device configuration. Center is also designated as [[_MOUSEBUTTON]](3). - - -{{PageExamples}} -''Example:'' Reading multiple controller device buttons, axis and wheels. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}} - {{Cl|PRINT}} {{Cl|STR$}}(i) + ") " + {{Cl|_DEVICE$}}(i) + " Buttons:"; {{Cl|_LASTBUTTON}}(i); ",Axis:"; {{Cl|_LASTAXIS}}(i); ",Wheel:"; {{Cl|_LASTWHEEL}}(i) -{{Cl|NEXT}} - -{{Cl|DO...LOOP|DO}} - d& = {{Cl|_DEVICEINPUT}} - {{Cl|IF...THEN|IF}} d& {{Cl|THEN}} ' the device number cannot be zero! - {{Cl|PRINT}} "Found"; d&; - {{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} {{Cl|_LASTBUTTON}}(d&) - {{Cl|PRINT}} {{Cl|_BUTTONCHANGE}}(b); {{Cl|_BUTTON}}(b); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} {{Cl|_LASTAXIS}}(d&) - {{Cl|PRINT}} {{Cl|_AXIS}}(a); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} {{Cl|_LASTWHEEL}}(d&) - {{Cl|PRINT}} {{Cl|_WHEEL}}(w); - {{Cl|NEXT}} - {{Cl|PRINT}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} -{{CodeEnd}} -: ''Note:'' When there is no device control to read, a [[FOR...NEXT|FOR]] n = 1 TO 0 loop will not run thus avoiding a control function read error. - - -{{PageSeeAlso}} -* [[_LASTWHEEL]], [[_LASTBUTTON]], [[_LASTAXIS]] -* [[_AXIS]], [[_WHEEL]], [[_BUTTONCHANGE]] -* [[_DEVICE$]], [[_DEVICES]] -* [[_MOUSEBUTTON]] -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_BYTE__1111.txt b/internal/help/_BYTE__1111.txt deleted file mode 100644 index 01cde9943..000000000 --- a/internal/help/_BYTE__1111.txt +++ /dev/null @@ -1,104 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:30}} -{{DISPLAYTITLE:_BYTE}} -A [[_BYTE]] variable can hold signed variable values from -128 to 127 (one byte or 8 [[_BIT]]s). [[_UNSIGNED|Unsigned]] from 0 to 255. - - -{{PageSyntax}} -: [[DIM]] {{Parameter|byte}} [[AS]] [[[_UNSIGNED]]] [[_BYTE]] - - -{{PageDescription}} -* Signed _BYTE values can range from -128 to 127. -* [[_UNSIGNED]] _BYTEs can hold values from 0 to 255. [[_UNSIGNED]] expands the range of positive values. -* Can be defined in a '''QB64''' [[_DEFINE]] statement using a starting letter range of variable names. -* Also can be used in a subroutine parameter [[AS]] _BYTE variable definitions. -* Define a byte using the suffix %% after the variable name: {{Parameter|variable%%}} = -54 -* Define an unsigned byte by adding the suffix ~%% after the variable name: variable~%% = 54 -* '''When a variable has not been assigned or has no type suffix, the value defaults to [[SINGLE]].''' - - -
'''[[_BIT|BITS]]'''
-* The '''MSB''' is the most significant(largest) bit value and '''LSB''' is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte: - -:* '''"Big-endian"''': MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time. -:* '''"Little-endian"''': LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time. -{{WhiteStart}} - '''Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000''' - ---------------------------------- -------- - '''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240 - '''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15 -{{WhiteEnd}} -::The big-endian method compares exponents of 27 down to 20 while the little-endian method does the opposite. - - -
'''[[_BYTE|BYTES]]'''
-* [[INTEGER]] values consist of 2 bytes called the '''HI''' and '''LO''' bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [[SINGLE]] or [[DOUBLE]] values! -{{WhiteStart}} '''16 BIT INTEGER OR REGISTER''' - '''AH (High Byte Bits) AL (Low Byte Bits)''' - BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0 - ---------------------------------------|-------------------------------------- - HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1 - | - DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1 -{{WhiteEnd}} -::The HI byte's '''MSB''' is often called the '''sign''' bit! When all 16 of the integer binary bits are on, the decimal return is -1. - - - -{{PageExamples}} -:How negative assignments affect the _UNSIGNED value returned by a byte (8 bits). - -{{CodeStart}} -{{Cl|DIM}} unsig {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|DIM}} sig {{Cl|AS}} {{Cl|_BYTE}} - -{{Cl|CLS}} -unsig = 1 -sig = 1 -{{Cl|PRINT}} "00000001 = unsigned & signed are both" + {{Cl|STR$}}(unsig {{Cl|AND}} sig) - -unsig = 127 -sig = 127 -{{Cl|PRINT}} "&B01111111 = unsigned & signed are both" + {{Cl|STR$}}(unsig {{Cl|AND}} sig) - -unsig = 255 -sig = 255 -{{Cl|PRINT}} "&B11111111 = unsigned is" + {{Cl|STR$}}(unsig) + " but signed is " + {{Cl|STR$}}(sig) - -unsig = 254 -sig = 254 -{{Cl|PRINT}} "&B11111110 = unsigned is" + {{Cl|STR$}}(unsig) + " but signed is " + {{Cl|STR$}}(sig) - -unsig = 253 -sig = 253 -{{Cl|PRINT}} "&B11111101 = unsigned is" + {{Cl|STR$}}(unsig) + " but signed is " + {{Cl|STR$}}(sig) - -{{Cl|PRINT}} -{{Cl|PRINT}} "The signed value needs the MSB bit for the sign." -{{Cl|PRINT}} "The most significant bit is furthest to the left." -{{CodeEnd}} -{{OutputStart}} -&B00000001 = unsigned & signed are both 1 -&B01111111 = unsigned & signed are both 127 -&B11111111 = unsigned is 255 but signed is -1 -&B11111110 = unsigned is 254 but signed is -2 -&B11111101 = unsigned is 253 but signed is -3 - -The signed value needs the MSB bit for the sign. -The most significant bit is furthest to the left. -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_BIT]], [[&B]] -* [[_DEFINE]], [[DIM]] -* [[_UNSIGNED]] -* [[_SHL]], [[_SHR]] -* [[Mathematical Operations]] -* [[Screen Memory]] -* [[Variable Types]] -* [[Converting Bytes to Bits]] - - -{{PageNavigation}} diff --git a/internal/help/_CAPSLOCK_(function)__11111111_(00000000).txt b/internal/help/_CAPSLOCK_(function)__11111111_(00000000).txt deleted file mode 100644 index a36a57a72..000000000 --- a/internal/help/_CAPSLOCK_(function)__11111111_(00000000).txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:31}} -{{DISPLAYTITLE:_CAPSLOCK (function)}} -The [[_CAPSLOCK (function)| _CAPSLOCK]] function returns the current state of the Caps Lock key as on (-1) or off (0). - - -{{PageSyntax}} -: {{Parameter|keyStatus%%}} = [[_CAPSLOCK (function)| _CAPSLOCK]] - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_NUMLOCK (function)]], [[_SCROLLLOCK (function)]] -* [[_CAPSLOCK]] (statement), [[_NUMLOCK]] (statement), [[_SCROLLLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_CAPSLOCK__11111111.txt b/internal/help/_CAPSLOCK__11111111.txt deleted file mode 100644 index 67eb28f7d..000000000 --- a/internal/help/_CAPSLOCK__11111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:33}} -{{DISPLAYTITLE:_CAPSLOCK}} -The [[_CAPSLOCK]] statement sets the state of the Caps Lock key. - - -{{PageSyntax}} -: [[_CAPSLOCK]] {ON|OFF|_TOGGLE} - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_CAPSLOCK (function)]], [[_NUMLOCK (function)]], [[_SCROLLLOCK (function)]] -* [[_NUMLOCK]] (statement), [[_SCROLLLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_CEIL__1111.txt b/internal/help/_CEIL__1111.txt deleted file mode 100644 index 1245c16e3..000000000 --- a/internal/help/_CEIL__1111.txt +++ /dev/null @@ -1,38 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:35}} -{{DISPLAYTITLE:_CEIL}} -The [[_CEIL]] function rounds a numeric value up to the next whole number or [[INTEGER]] value. - - -{{PageSyntax}} -: {{Parameter|result}} = [[_CEIL]]({{Parameter|expression}}) - - -* [[_CEIL]] returns he smallest integral value that is greater than the numerical {{Parameter|expression}} (as a floating-point value). -* This means that [[_CEIL]] rounds up for both positive and negative numbers. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Displaying the rounding behavior of [[INT]], [[CINT]] and [[FIX]] vs [[_CEIL]]. -{{CodeStart}} -PRINT INT(2.5), CINT(2.5), FIX(2.5), _CEIL(2.5) -PRINT INT(-2.5), CINT(-2.5), FIX(-2.5), _CEIL(-2.5) -{{CodeEnd}} -{{OutputStart}} 2 2 2 3 --3 -2 -2 -2 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[INT]], [[FIX]] -* [[CINT]], [[CLNG]], -* [[CSNG]], [[CDBL]] -* [[_ROUND]] - - -{{PageNavigation}} diff --git a/internal/help/_CINP__1111.txt b/internal/help/_CINP__1111.txt deleted file mode 100644 index 845321e03..000000000 --- a/internal/help/_CINP__1111.txt +++ /dev/null @@ -1,63 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:36}} -{{DISPLAYTITLE:_CINP}} -The [[_CINP]] function returns keyboard key press codes from a [[$CONSOLE]] window. Windows-only. - - -{{PageSyntax}} -:{{Parameter|keycode&}} = [[_CINP]] - - -{{PageDescription}} -* Return values are the same as the ones for [[INP]] when used to read keyboard input. See table below. -:* '''Negative''' [[LONG]] values returned indicate that a key was released or a lock function key has been turned off. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - -{{WhiteStart}}' '''Extended Keyboard Press Scancodes''' -' -'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause''' -' 1 59 60 61 62 63 64 65 66 67 68 87 88 0 70 29 -' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -''' -' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 82 71 73 69 53 55 74 -' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/â–² 9/PU + ''' -' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 71 72 73 78 -' '''CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º E''' -' 58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77 '''n''' -' '''Shift Z X C V B N M ,< .> /? Shift â–² 1/End 2/â–¼ 3/PD t''' -' 42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 '''e''' -' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0/Insert ./Del r''' -' 29 {{text|91|purple}} 56 57 56 {{text|92 93|purple}} 29 75 80 77 82 83 28 -' -{{WhiteEnd}} - - -{{PageExamples}} -''Example 1:'' Reading individual key strokes from a console window (Windows). -{{CodeStart}} -{{Cl|$CONSOLE}}:ONLY -{{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}} - -{{Cl|PRINT}} "Press any key, and I'll give you the scan code for it. quits the demo." -{{Cl|PRINT}} -{{Cl|PRINT}} -{{Cl|DO}} - x = {{Cl|_CONSOLEINPUT}} - {{Cl|IF}} x = 1 {{Cl|THEN}} 'read only keyboard input ( = 1) - c = {{Cl|_CINP}} - {{Cl|PRINT}} c; - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} c = 1 -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$CONSOLE]], [[_CONSOLE]] -* [[_CONSOLEINPUT]] -* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] - - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CLEARCOLOR_(function)__1111111111_(00000000).txt b/internal/help/_CLEARCOLOR_(function)__1111111111_(00000000).txt deleted file mode 100644 index 5037e1890..000000000 --- a/internal/help/_CLEARCOLOR_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:37}} -{{DISPLAYTITLE:_CLEARCOLOR (function)}} -The [[_CLEARCOLOR (function)|_CLEARCOLOR]] function returns the current transparent color of an image or page. - - -{{PageSyntax}} -:''result&'' = [[_CLEARCOLOR (function)|_CLEARCOLOR]] [{{Parameter|Source_Handle&}}] - - -{{PageDescription}} -* If {{Parameter|Source_Handle&}} is omitted, it is assumed to be the current [[_DEST|destination]] write page. -* If {{Parameter|Source_Handle&}} is an invalid handle value(-1), then an [[ERROR Codes|invalid handle value]] is returned. -* In color modes using a palette, the index of the current transparent color value is returned, or -1 if no transparent color is set. -* In 32-bit color modes, zero is returned. -* Returns the color that currently is transparent, or if no color is transparent -1 without error. -* A [[_CLEARCOLOR]] statement can set the transparent color of an image or screen. -* '''NOTE: Default 32 bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.''' - - -{{PageSeeAlso}} -* [[_CLEARCOLOR]] {{text|(sets a clear color)}} -* [[_SETALPHA]] {{text|(sets color transparency)}} -* [[Images]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CLEARCOLOR__1111111111.txt b/internal/help/_CLEARCOLOR__1111111111.txt deleted file mode 100644 index e228ce525..000000000 --- a/internal/help/_CLEARCOLOR__1111111111.txt +++ /dev/null @@ -1,99 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:38}} -{{DISPLAYTITLE:_CLEARCOLOR}} -The [[_CLEARCOLOR]] statement sets a specific color to be treated as transparent when an image is later put (via [[_PUTIMAGE]]) onto another image. - -{|align="right" -|__TOC__ -|} - -{{PageSyntax}} -:[[_CLEARCOLOR]] {{{Parameter|color&}}|_NONE}[, {{Parameter|Dest_Handle&}}] - -{{Parameters}} -* In color modes using a palette, {{Parameter|color&}} is the palette index of the new transparent color value or _NONE designates no clear colors. -* If {{Parameter|color&}} is not a valid palette index, an [[ERROR Codes|illegal function call]] error will occur. -* In 32-bit color modes, {{Parameter|color&}} is the [[_LONG]] color value of the new transparent color. -* If {{Parameter|Dest_Handle&}} is omitted, the destination is assumed to be the current write page. Zero can designate the current program screen. - - -{{PageDescription}} -* If {{Parameter|Dest_Handle&}} is an invalid handle, then an [[ERROR Codes|invalid handle]] error is returned. Check for bad handle values of -1 first. -* In 32-bit color modes, it simply sets the Alpha to 0 for all pixels matching the specified color. -* In the second syntax, transparency is disabled for color modes using a palette. -* '''Note:''' [[_SETALPHA]] can affect any _CLEARCOLOR alpha setting within the color range set. -* '''NOTE: 32 bit [[_NEWIMAGE]] screen page backgrounds are transparent black or [[_ALPHA]] 0. Use [[_DONTBLEND]] or [[CLS]] for opaque.''' - - -{{PageExamples}} -''Example 1:'' Using _CLEARCOLOR to "mask" the background color of an image. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 13 -img& = {{Cl|_LOADIMAGE}}("qb64_trans.png") -{{Cl|_PUTIMAGE}} , img&, 0 'place actual image with background -K$ = INPUT$(1) -{{Cl|CLS}} , {{Cl|_RGB}}(255, 0, 0) 'clear screen with red background -{{Cl|_CLEARCOLOR}} {{Cl|_RGB}}(255, 255, 255), img& -{{Cl|_PUTIMAGE}} , img&, 0 'place image without white background -{{Cl|PRINT}} {{Cl|_CLEARCOLOR}}(img&) 'displays closest clear color attribute -{{Cl|END}} -{{CodeEnd}} - - -''Example 2:'' Using a _CLEARCOLOR transparency with images created on a [[_NEWIMAGE]] page. Does not require an image file. -{{CodeStart}}{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(512, 384, 32) ' screen uses handle value -{{Cl|CIRCLE}}(50, 50), 50, {{Cl|_RGB}}(128, 0, 0) ' create a red ball image -{{Cl|PAINT}}(50, 50), {{Cl|_RGB}}(255, 0, 0), {{Cl|_RGB}}(128, 0, 0) -redball = {{Cl|_NEWIMAGE}}(101, 101, 32) ' create a new image page -{{Cl|_PUTIMAGE}} , 0, redball,(0, 0)-(101, 101) ' put screen page 0 image onto redball page -{{Cl|_CLEARCOLOR}} {{Cl|_RGB}}(0, 0, 0), redball ' makes black become see-through -{{Cl|CLS}}, {{Cl|_RGB}}(0, 0, 255) ' erase original ball and create a blue background -{{Cl|DO...LOOP|DO}} -{{Cl|_PUTIMAGE| _PUTIMAGE}} ({{Cl|RND}} * 512, {{Cl|RND}} * 384), redball -{{Cl|SLEEP| SLEEP}} 1 ' one second delay -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{CodeEnd}} - - -''Example 3:'' Fading an image with a _CLEARCOLOR background using a new page image to prevent [[_SETALPHA]] changes. -{{CodeStart}} -mainscreen = {{Cl|_NEWIMAGE}}(640, 480, 32) ' Main Screen (viewable) -{{Cl|SCREEN}} mainscreen -{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} -Image1& = {{Cl|_LOADIMAGE}}("qb64_trans.png") '<<<<<< any image with one background color to clear - -{{Cl|IF...THEN|IF}} Image1& < -1 {{Cl|THEN}} 'check loaded image handle value before using! - {{Cl|_SOURCE}} Image1& - clr~& = {{Cl|POINT}}(0, 0) 'get background color from image source - {{Cl|_CLEARCOLOR}} clr~&, Image1& 'clear background color of loaded image - NewImage1& = {{Cl|_NEWIMAGE}}({{Cl|_WIDTH (function)|_WIDTH}}(Image1&), {{Cl|_HEIGHT}}(Image1&), 32) 'new image page - {{Cl|_PUTIMAGE}} , Image1&, NewImage1& 'put image without background color on new page - {{Cl|_FREEIMAGE}} Image1& 'free loaded image from memory -{{Cl|END IF}} -{{Cl|_DEST}} mainscreen: - -a& = 0: d = 1 -DO - {{Cl|_LIMIT}} 10 'regulate speed of fades - {{Cl|CLS}} - a& = a& + d - {{Cl|IF...THEN|IF}} a& = 255 {{Cl|THEN}} d = -d 'reverse fade - {{Cl|_SETALPHA}} a&, , NewImage1& 'sets alpha level of all colors to fade image page in/out - {{Cl|_PUTIMAGE}} (0, 342), NewImage1& - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "Alpha: "; a& - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} a& = 0 -{{Cl|END}} -{{CodeEnd}} -:''Note:'' If the _CLEARCOLOR image background was not put onto a separate page, [[_SETALPHA]] would display it also. - - - -{{PageSeeAlso}} -* [[_CLEARCOLOR (function)]] -* [[_SETALPHA]] {{text|(sets transparency level)}} -* [[_ALPHA]], [[_ALPHA32]] {{text|(read functions)}} -* [[Images]], [[Creating Sprite Masks]] - - -{{PageNavigation}} diff --git a/internal/help/_CLIPBOARD$_(statement)__111111111$_(000000000).txt b/internal/help/_CLIPBOARD$_(statement)__111111111$_(000000000).txt deleted file mode 100644 index 53a74ecc1..000000000 --- a/internal/help/_CLIPBOARD$_(statement)__111111111$_(000000000).txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:42}} -{{DISPLAYTITLE:_CLIPBOARD$ (statement)}} -The [[_CLIPBOARD$ (statement)|_CLIPBOARD$]] statement copies the [[STRING]] value into the system clipboard. - - -{{PageSyntax}} -:[[_CLIPBOARD$ (statement)|_CLIPBOARD$]] = {{Parameter|string_expression$}} - - -{{PageDescription}} -* {{Parameter|string_expression$}} is the string value to be sent to the clipboard. -* The string value will replace everything previously in the clipboard. -* Assemble long text into one string variable value before using this statement. -* Add CHR$(13) + CHR$(10) CRLF characters to move to a new clipboard line. -* When copying text files, end line CRLF characters 13 and 10 do not have to be added. -* Numerical values can be converted to strings using [[STR$]], [[_MK$]], [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]], [[HEX$]] or [[OCT$]]. -* The clipboard can be used to copy, paste and communicate between running programs. - - -{{PageExamples}} -''Example:'' Set 2 lines of text in the clipboard using a carriage return to end text lines -{{CodeStart}} -{{Cl|DIM}} CrLf AS {{Cl|STRING}} * 2 'define as 2 byte STRING -CrLf = {{Cl|CHR$}}(13) + {{Cl|CHR$}}(10) 'carriage return & line feed - -{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "This is line 1" + CrLf + "This is line 2" -{{Cl|PRINT}} {{Cl|_CLIPBOARD$}} 'display what is in the clipboard - -{{CodeEnd}} -{{OutputStart}}This is line 1 - -This is line 2 -{{OutputEnd}} -:''Note:'' The text in the clipboard could also be sent to a file using [[PRINT (file statement)|PRINT #1]] [[_CLIPBOARD$]]. - - -{{PageSeeAlso}} -* [[_CLIPBOARD$]] (function) -* [[_CLIPBOARDIMAGE (function)]], [[_CLIPBOARDIMAGE]] (statement) -* [[CHR$]], [[ASCII]] (code table) - - - -{{PageNavigation}} diff --git a/internal/help/_CLIPBOARD$__111111111$.txt b/internal/help/_CLIPBOARD$__111111111$.txt deleted file mode 100644 index dc32acbb4..000000000 --- a/internal/help/_CLIPBOARD$__111111111$.txt +++ /dev/null @@ -1,145 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:41}} -{{DISPLAYTITLE:_CLIPBOARD$}} -The [[_CLIPBOARD$]] function returns the current Operating System's clipboard contents as a [[STRING]]. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[_CLIPBOARD$]] - - -{{PageDescription}} -* Text returned can contain the entire contents of a copied file or web page or text from a previous [[_CLIPBOARD$ (statement)|_CLIPBOARD$]] statement. -* The string returned can also contain formatting like CRLF ([[CHR$]](13) + [[CHR$]](10)) end of line characters. -* The clipboard can be used to copy, paste and communicate between running programs. - - -{{PageExamples}} -''Example 1:'' Passing a string value between two running programs no matter where they are located. -: ''Program1:'' -{{CodeStart}} -{{Cl|PRINT}} "Start Program2 to read your text entries! Empty entry quits!" -{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "Entry program started!" 'set clipboard initially - -DO - {{Cl|LINE INPUT}} "Enter some text to send to other program: ", text$ - {{Cl|IF...THEN|IF}} text$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = text$ -{{Cl|LOOP}} - -{{Cl|SYSTEM}} -{{CodeEnd}} -:''Program2:'' -{{CodeStart}} -{{Cl|PRINT}} "Enter text in Program1 and this program will read it. Esc key quits!" - -DO: {{Cl|_LIMIT}} 100 - text$ = {{Cl|_CLIPBOARD$}} 'function returns clipboard contents - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(text$) {{Cl|THEN}} - {{Cl|PRINT}} text$ - {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "" 'clear clipboard after a read - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) - -{{Cl|END}} -{{CodeEnd}} -:''Explanation:'' Compile and run both programs at once to see the interaction. You could also run them on different paths. - - -''Example 2: A minimized program that pops up when Ctrl + Shift is entered anytime in '''Windows''' and adds clipboard text to be Pasted: -{{CodeStart}} -'"ClippyBoard" program uses GetKeyState Win API to monitor a specific key combination. -'This demo will maximize the window and focus on program when Shift+A is pressed. - -{{Cl|DECLARE DYNAMIC LIBRARY}} "user32" - {{Cl|FUNCTION}} FindWindowA%& ({{Cl|BYVAL}} ClassName {{Cl|AS}} {{Cl|_OFFSET}}, WindowName$) 'find process handle by title - {{Cl|FUNCTION}} GetKeyState% ({{Cl|BYVAL}} nVirtKey {{Cl|AS}} {{Cl|LONG}}) 'Windows virtual key presses - {{Cl|FUNCTION}} ShowWindow& ({{Cl|BYVAL}} hwnd {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} nCmdShow {{Cl|AS}} {{Cl|LONG}}) 'maximize process - {{Cl|FUNCTION}} GetForegroundWindow%& 'find currently focused process handle - {{Cl|FUNCTION}} SetForegroundWindow& ({{Cl|BYVAL}} hwnd {{Cl|AS}} {{Cl|_OFFSET}}) 'set foreground window process(focus) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -title$ = "Clippy Clipboard (Ctrl+Shift)" 'title of program window -{{Cl|_TITLE}} title$ 'set program title -hwnd%& = FindWindowA(0, title$ + {{Cl|CHR$}}(0)) 'find this program's process handle - -{{Cl|SCREEN}} 13 -{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} - -{{Cl|COLOR}} 10: {{Cl|PRINT}} -{{Cl|PRINT}} " Press Ctrl+Shift to see clipboard menu." - -{{Cl|_DELAY}} 4 -x& = ShowWindow&(hwnd%&, 2) 'minimize - -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 30 'save CPU usage while waiting for key press - - {{Cl|IF...THEN|IF}} GetKeyState(16) < 0 {{Cl|AND (boolean)|AND}} GetKeyState(17) < 0 {{Cl|THEN}} '<==== Shift+A - FGwin%& = GetForegroundWindow%& 'get current process in focus - y& = ShowWindow&(hwnd%&, 1) 'maximize minimized program - - {{Cl|IF...THEN|IF}} FGwin%& <> hwnd%& {{Cl|THEN}} z& = SetForegroundWindow&(hwnd%&) 'set focus when necessary - {{Cl|_DELAY}} 1 - GetKey - x& = ShowWindow&(hwnd%&, 2) 'minimize after letter key entry - {{Cl|COLOR}} 10: {{Cl|PRINT}} - {{Cl|PRINT}} " Press Ctrl+Shift to see clipboard menu." - {{Cl|END IF}} -{{Cl|LOOP}} - - -{{Cl|SUB}} GetKey -{{Cl|CLS}} -{{Cl|COLOR}} 12: {{Cl|PRINT}}: {{Cl|PRINT}} {{Cl|_CLIPBOARD$}} -{{Cl|DO...LOOP|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = "" -{{Cl|_DELAY}} 1 -{{Cl|CLS}} -{{Cl|COLOR}} 11: {{Cl|PRINT}} "Select a letter clipboard option:" -{{Cl|PRINT}} -{{Cl|PRINT}} "A = Address" -{{Cl|PRINT}} "C = Cell phone" -{{Cl|PRINT}} "E = Email" -{{Cl|PRINT}} "F = First Name" -{{Cl|PRINT}} "H = Home phone" -{{Cl|PRINT}} "L = Last Name" -{{Cl|PRINT}} "N = Name" -{{Cl|PRINT}} "M = MAC address" -{{Cl|PRINT}} "P = Password" -{{Cl|PRINT}} "W = Work name" -{{Cl|PRINT}} "X = QUIT!" -{{Cl|PRINT}} "Z = Zip code" -{{Cl|COLOR}} 14: {{Cl|PRINT}} -{{Cl|PRINT}} "Another letter will skip or X = {{Cl|EXIT}}!" - -K$ = {{Cl|UCASE$}}({{Cl|INPUT$}}(1)) - -{{Cl|SELECT CASE}} K$ 'The following text should be your personal user info: - {{Cl|CASE}} "A": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "my address" - {{Cl|CASE}} "C": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "cell number" - {{Cl|CASE}} "E": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "myemail" - {{Cl|CASE}} "F": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "formal name" - {{Cl|CASE}} "H": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "home number" - {{Cl|CASE}} "L": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "lastname" - {{Cl|CASE}} "M": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "modempassword" - {{Cl|CASE}} "N": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "name" - {{Cl|CASE}} "P": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "password" - {{Cl|CASE}} "X": {{Cl|END}} - {{Cl|CASE}} "Z": {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "zipcode" -{{Cl|END SELECT}} -{{Cl|CLS}} -{{Cl|PRINT}} -{{Cl|PRINT}} -{{Cl|COLOR}} 14: {{Cl|PRINT}} {{Cl|_CLIPBOARD$}} -{{Cl|BEEP}} -{{Cl|_DELAY}} 2 -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code by Ted Weissgerber}} -: ''Explanation:'' The program will run minimized until Ctrl + Shift is entered and will pop up to ask for a letter choice that contains the text you want in the clipboard. More letter choices can be added. Text can be pasted into a web page or entry box and the program will minimize until it is needed later. The program uses very little resources! - - -{{PageSeeAlso}} -* [[_CLIPBOARD$ (statement)]] -* [[_CLIPBOARDIMAGE (function)]], [[_CLIPBOARDIMAGE]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_CLIPBOARDIMAGE_(function)__11111111111111_(00000000).txt b/internal/help/_CLIPBOARDIMAGE_(function)__11111111111111_(00000000).txt deleted file mode 100644 index 09081991f..000000000 --- a/internal/help/_CLIPBOARDIMAGE_(function)__11111111111111_(00000000).txt +++ /dev/null @@ -1,53 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:43}} -{{DISPLAYTITLE:_CLIPBOARDIMAGE (function)}} -The [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]] function pastes an image from the clipboard into a new 32-bit image in memory. - - -{{PageSyntax}} -: {{Parameter|newImageHandle&}} = [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]] - - -{{PageDescription}} -* When the paste operation is successful, {{Parameter|newImageHandle&}} will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted. -* Use [[_FREEIMAGE]] to free the memory used by {{Parameter|newImageHandle&}} when it's no longer needed by your program. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -==Availability== -* '''Build 20170906/64''' onward. - - -{{PageExamples}} -''Example:'' Monitoring the clipboard for new images copied from other programs: -{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) -{{Cl|DO}} - {{Cl|CLS}} - {{Cl|COLOR}} {{Cl|_RGB32}}(177, 177, 177) - {{Cl|PRINT}} "Monitoring clipboard..." - {{Cl|IF}} img& < -1 {{Cl|THEN}} _FREEIMAGE img& - img& = {{Cl|_CLIPBOARDIMAGE}} - IF img& < -1 THEN - {{Cl|PRINT}} "Image found:" - {{Cl|COLOR}} _RGB32(255, 255, 255) - {{Cl|PRINT}} "Width :"; {{Cl|_WIDTH (function)|_WIDTH}}(img&) - {{Cl|PRINT}} "Height:"; {{Cl|_HEIGHT|_HEIGHT}}(img&) - w = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - {{Cl|_WIDTH (function)|_WIDTH}}(img&) / 2 - IF w < 0 THEN w = 0 - {{Cl|_PUTIMAGE}} (w, {{Cl|CSRLIN}} * {{Cl|_FONTHEIGHT}}), img& - ELSE - PRINT "No image found." - END IF - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 10 -{{Cl|LOOP}} -{{CodeEnd}} -{{small|Code by Fellippe Heitor}} - - -{{PageSeeAlso}} -* [[_CLIPBOARDIMAGE]] {{text|(statement - used to copy an image to the clipboard)}} -* [[_CLIPBOARD$]], [[_CLIPBOARD$ (statement)]] {{text|(used to copy/paste text)}} - - -{{PageNavigation}} diff --git a/internal/help/_CLIPBOARDIMAGE__11111111111111.txt b/internal/help/_CLIPBOARDIMAGE__11111111111111.txt deleted file mode 100644 index 4d0b813b7..000000000 --- a/internal/help/_CLIPBOARDIMAGE__11111111111111.txt +++ /dev/null @@ -1,58 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:44}} -{{DISPLAYTITLE:_CLIPBOARDIMAGE}} -The [[_CLIPBOARDIMAGE]] statement copies a valid QB64 image to the clipboard. - - -{{PageSyntax}} -: [[_CLIPBOARDIMAGE]] = {{Parameter|existingImageHandle&}} - - -{{PageDescription}} -* {{Parameter|existingImageHandle&}} is a valid handle to a graphic QB64 image in memory, created with [[_NEWIMAGE]], [[_LOADIMAGE]] or [[_COPYIMAGE]]. -* You can pass [[_SOURCE]], [[_DEST]] or [[_DISPLAY]] to copy the current source, destination or active display pages, as long as they are valid graphic images. -* SCREEN 0 handles (created either with [[_NEWIMAGE]] or passed using _DEST while in a text screen) are not valid and will create an [[ERROR Codes|Illegal Function Call]] or [[ERROR Codes|Invalid Handle]] error. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -==Availability== -* '''Build 20170906/64''' onward. - - -{{PageExamples}} -''Example:'' Create a sample image and copy it to the clipboard: -{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) - -'Create image in memory: -canvas& = {{Cl|_NEWIMAGE}}(300, 200, 32) -{{Cl|_DEST}} canvas& - -'Draw some random rectangles: -{{Cl|RANDOMIZE}} {{Cl|TIMER}} -{{Cl|FOR}} i = 1 {{Cl|TO}} 100 - {{Cl|LINE}} (-100 + RND * _WIDTH, -100 + RND * _HEIGHT)-STEP(RND * 150, RND * 150), _RGB(RND * 255, RND * 255, RND * 255), BF -{{Cl|NEXT}} -LINE (0, 0)-(_WIDTH - 1, _HEIGHT - 1), _RGB(255, 255, 255), B -{{Cl|COLOR}} {{Cl|_RGB}}(0, 0, 0), _RGB(255, 255, 255) -m$ = " Hello, world! " -{{Cl|_PRINTSTRING}} (_WIDTH / 2 - _PRINTWIDTH(m$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2), m$ - -'Show the image: -{{Cl|_DEST}} 0 -{{Cl|_PUTIMAGE}} (_WIDTH / 2 - _WIDTH(canvas&) / 2, _HEIGHT / 2 - _HEIGHT(canvas&) / 2), canvas& -{{Cl|PRINT}} "Image generated." - -'Copy to the clipboard: -{{Cl|_CLIPBOARDIMAGE}} = canvas& - -PRINT "Image copied to clipboard." -{{CodeEnd}} -{{small|Code by Fellippe Heitor}} - - -{{PageSeeAlso}} -* [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]] {{text|(function - used to paste an image from the clipboard)}} -* [[_CLIPBOARD$]], [[_CLIPBOARD$ (statement)]] {{text|(used to copy/paste text)}} - - -{{PageNavigation}} diff --git a/internal/help/_CLIP__1111.txt b/internal/help/_CLIP__1111.txt deleted file mode 100644 index 686c00668..000000000 --- a/internal/help/_CLIP__1111.txt +++ /dev/null @@ -1,53 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:39}} -{{DISPLAYTITLE:_CLIP}} -The [[_CLIP]] option is used in a QB64 graphics [[PUT (graphics statement)|PUT]] to allow placement of an image partially off of the screen. - - -{{PageSyntax}} -:[[PUT (graphics statement)|PUT]] [[[STEP]]]({{Parameter|column, row}}), {{Parameter|image_array(start)}}[, [[_CLIP]]] [{XOR|PSET|AND|OR|PRESET}][, {{Parameter|omitcolor}}] - - -{{PageDescription}} -* _CLIP should be placed immediately before the PUT action if used. XOR is default when not used. -* The offscreen portions of the image will be the omit color. -* [[GET (graphics statement)|GET]] can get portions of the images off screen in '''QB64'''. - - -{{PageExamples}} -''Example:'' Placing an image partially or fully offscreen. -{{CodeStart}} -{{Cl|DIM}} mypic(500) -{{Cl|SCREEN}} 13 - -{{Cl|CLS}} -{{Cl|CIRCLE}} (10,10),10 -{{Cl|GET (graphics statement)|GET}} (0,0)-(20,20), mypic(0) - -{{Cl|PRINT}} "This program puts an image off screen." -{{Cl|PRINT}} "Select which option you'd like to try." -{{Cl|PRINT}} "1 will produce an illegal function call." -{{Cl|PRINT}} "1 is putting without _CLIP." -{{Cl|PRINT}} "2 is putting with _CLIP PSET." -{{Cl|PRINT}} "3 is putting with _CLIP XOR." -{{Cl|PRINT}} "4 is putting with _CLIP PSET, 4." - -{{Cl|INPUT}} sel -{{Cl|IF...THEN|IF}} sel = 1 {{Cl|THEN}} {{Cl|PUT (graphics statement)|PUT}} (-10, 10), mypic(0), PSET ' this causes an illegal function call -{{Cl|IF...THEN|IF}} sel = 2 {{Cl|THEN}} {{Cl|PUT (graphics statement)|PUT}} (-10, 10), mypic(0), {{Cl|_CLIP}} PSET ' allows graphic to be drawn off-screen -{{Cl|IF...THEN|IF}} sel = 3 {{Cl|THEN}} {{Cl|PUT (graphics statement)|PUT}} (-10, 10), mypic(0), {{Cl|_CLIP}} ' uses the default PUT XOR operation -{{Cl|IF...THEN|IF}} sel = 4 {{Cl|THEN}} {{Cl|PUT (graphics statement)|PUT}} (-10, 10), mypic(0), {{Cl|_CLIP}} PSET, 4 ' doesn't draw red pixels - -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[PUT (graphics statement)]] -* [[GET (graphics statement)]] -* [[STEP]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_COMMANDCOUNT__111111111111.txt b/internal/help/_COMMANDCOUNT__111111111111.txt deleted file mode 100644 index c801a9c1a..000000000 --- a/internal/help/_COMMANDCOUNT__111111111111.txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:47}} -{{DISPLAYTITLE:_COMMANDCOUNT}} -The [[_COMMANDCOUNT]] function returns the number or arguments passed from the command line to the [[COMMAND$]] function. - - -{{PageSyntax}} -:{{Parameter|result&}} = [[_COMMANDCOUNT]] - - -{{PageDescription}} -* The function returns the number of arguments passed from the command line to a program when it's executed. -* Arguments are spaced as separate numerical or text values. Spaced text inside of quotes is considered as one argument. -* In C, this function would generally be regarded as 'argc' when the main program is defined as the following: '''int main(int argc, char *argv[])''' - - -{{PageExamples}} -''Example:'' The code below gets the number of parameters passed to our program from the command line with _COMMANDCOUNT: -{{CodeStart}}limit = {{Cl|_COMMANDCOUNT}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} limit - {{Cl|PRINT}} {{Cl|COMMAND$}}(i) -{{Cl|NEXT}} -{{CodeEnd}} -: ''Explanation:'' If we start ''ThisProgram.exe'' from the command window with '''ThisProgram -l "loadfile.txt" -s "savefile.txt"''', the _COMMANDCOUNT would be 4, "-l", "loadfile.txt", "-s", "savefile.txt" command arguments passed to the program, which we could then read separately with COMMAND$(n). - - -{{PageSeeAlso}} -* [[COMMAND$]] -* [[SHELL]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CONNECTED__111111111.txt b/internal/help/_CONNECTED__111111111.txt deleted file mode 100644 index 88b00af9f..000000000 --- a/internal/help/_CONNECTED__111111111.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:48}} -{{DISPLAYTITLE:_CONNECTED}} -The [[_CONNECTED]] function returns the status of a TCP/IP connection handle. - - -{{PageSyntax}} -:{{Parameter|result&}} = [[_CONNECTED]]({{Parameter|connectionHandle&}}) - - -{{PageDescription}} -* The handle can come from the [[_OPENHOST]], [[OPENCLIENT]] or [[_OPENCONNECTION]] QB64 TCP/IP functions. -* Returns -1 if still connected or 0 if connection has ended/failed. -* Do not rely solely on this function to check for ending communication. -* Use "time-out" checking as well and [[CLOSE]] any suspect connections. -* If this function indicates the handle is not connected, any unread messages can still be read using [[GET (TCP/IP statement)|GET #]]. -* Even if this function indicates the handle is not connected, it is important to [[CLOSE]] the connection anyway or important resources cannot be reallocated. - -{{PageSeeAlso}} -* [[_OPENCONNECTION]] -* [[_OPENHOST]] -* [[_OPENCLIENT]] -* [[_CONNECTIONADDRESS$]] -* [[Downloading Files]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CONNECTIONADDRESS$__11111111111111111$.txt b/internal/help/_CONNECTIONADDRESS$__11111111111111111$.txt deleted file mode 100644 index 5b38c726b..000000000 --- a/internal/help/_CONNECTIONADDRESS$__11111111111111111$.txt +++ /dev/null @@ -1,46 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:49}} -{{DISPLAYTITLE:_CONNECTIONADDRESS$}} -The [[_CONNECTIONADDRESS$]] function returns a connected user's [[STRING]] IP address value. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[_CONNECTIONADDRESS$]]({{Parameter|connectionHandle&}}) - - -{{PageDescription}} -* The handle can come from the [[_OPENHOST]], [[OPENCLIENT]] or [[_OPENCONNECTION]] QB64 TCP/IP functions. -* For '''[[_OPENHOST|HOST]]s''': It may return "TCP/IP:8080:213.23.32.5" where 8080 is the port it is listening on and 213.23.32.5 is the global IP address which any computer connected to the internet could use to locate your computer. If a connection to the internet is unavailable or your firewall blocks it, it returns your 'local IP' address (127.0.0.1). You might like to store this address somewhere where other computers can find it and connect to your host. Dynamic IPs which can change will need to be updated. -* For '''[[_OPENCLIENT|CLIENT]]s''': It may return "TCP/IP:8080:213.23.32.5" where 8080 is the port it used to connect to the listening host and 213.23.32.5 is the IP address of the host name it resolved. -* For '''[[_OPENCONNECTION|CONNECTION]]s''' (from clients): It may return "TCP/IP:8080:34.232.321.25" where 8080 was the host listening port it connected to and 34.232.321.25 is the IP address of the client that connected. This is very useful because the host can log the IP address of clients for future reference (or banning, for example). - - -{{PageExamples}} -''Example:'' A Host logging new chat clients in a Chat program. See the [[_OPENHOST]] example for the rest of the code used. -{{CodeStart}} -f = {{Cl|FREEFILE}} -{{Cl|OPEN}} "ChatLog.dat" {{Cl|FOR}} {{Cl|APPEND}} {{Cl|AS}} #f ' code at start of host section before DO loop. - - -newclient = {{Cl|_OPENCONNECTION}}(host) ' receive any new client connection handles -{{Cl|IF...THEN|IF}} newclient {{Cl|THEN}} - numclients = numclients + 1 ' increment index - Users(numclients) = newclient ' place handle into array - IP$ = {{Cl|_CONNECTIONADDRESS$}}(newclient) - {{Cl|PRINT}} IP$ + " has joined." ' displayed to Host only - {{Cl|PRINT (file statement)|PRINT #f}}, IP$, numclients ' print info to a log file - {{Cl|PRINT (file statement)|PRINT #}}Users(numclients),"Welcome!" ' from Host to new clients only -{{Cl|END IF}} -{{CodeEnd}} -: ''Explanation:'' The function returns the new client's IP address to the IP$ variable. Prints the IP and the original login position to a log file. The information can later be used by the host for referance if necessary. The host could set up a ban list too. - - -{{PageSeeAlso}} -* [[_OPENCONNECTION]] -* [[_OPENHOST]] -* [[_OPENCLIENT]] -* [[_CONNECTED]] -* [[WGET]] (HTTP and FTP file transfer) - - -{{PageNavigation}} diff --git a/internal/help/_CONSOLEINPUT__111111111111.txt b/internal/help/_CONSOLEINPUT__111111111111.txt deleted file mode 100644 index e879478d7..000000000 --- a/internal/help/_CONSOLEINPUT__111111111111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:53}} -{{DISPLAYTITLE:_CONSOLEINPUT}} -The [[_CONSOLEINPUT]] function is used to monitor any new mouse or keyboard input coming from a $CONSOLE window. It must be called in order for [[_CINP]] to return valid values. Windows-only. - - -{{PageSyntax}} -:{{Parameter|infoExists%%}} = [[_CONSOLEINPUT]] - - -{{PageDescription}} -* Returns 1 if new keyboard information is available, 2 if mouse information is available, otherwise it returns 0. -* Must be called before reading any of the other mouse functions and before reading [[_CINP]]. -* To clear all previous input data, read [[_CONSOLEINPUT]] in a loop until it returns 0. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageExamples}} -''Example 1:'' Reading individual key strokes from a console window (Windows). -{{CodeStart}} -{{Cl|$CONSOLE}}:ONLY -{{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}} - -{{Cl|PRINT}} "Press any key, and I'll give you the scan code for it. quits the demo." -{{Cl|PRINT}} -{{Cl|PRINT}} -{{Cl|DO}} - x = {{Cl|_CONSOLEINPUT}} - {{Cl|IF}} x = 1 {{Cl|THEN}} 'read only keyboard input ( = 1) - c = {{Cl|_CINP}} - {{Cl|PRINT}} c; - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} c = 1 -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$CONSOLE]], [[_CONSOLE]] -* [[_CINP]], [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]] -* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] - - - -{{PageNavigation}} diff --git a/internal/help/_CONSOLETITLE__111111111111.txt b/internal/help/_CONSOLETITLE__111111111111.txt deleted file mode 100644 index 8fcfe8fbd..000000000 --- a/internal/help/_CONSOLETITLE__111111111111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:54}} -{{DISPLAYTITLE:_CONSOLETITLE}} -The [[_CONSOLETITLE]] statement creates the title of the console window using a literal or variable [[STRING|string]]. - - -{{PageSyntax}} -: [[_CONSOLETITLE]] {{Parameter|text$}} - - -{{PageDescription}} -* The ''text$'' used can be a literal or variable [[STRING]] value. - - -{{PageExamples}} -''Example:'' Hiding the main program window while displaying the console window with a title. -{{CodeStart}} -{{Cl|$SCREENHIDE}} -{{Cl|_DELAY}} 4 -{{Cl|$CONSOLE}} -{{Cl|_CONSOLETITLE}} "Error Log" - -{{Cl|_DEST}} {{Cl|_CONSOLE}} -{{Cl|PRINT}} "Errors go here! (fyi, this line is not an error)" -{{Cl|END}} -{{CodeEnd}} - -:''Note:'' You can also use [[SHELL]] "title consoletitle" to set the title of the console window. However, '''the recommended practice is to use [[_CONSOLETITLE]]'''. - - -''See also:'' -* [[$CONSOLE]], [[_CONSOLE]] -* [[$SCREENHIDE]], [[$SCREENSHOW]] -* [[_SCREENHIDE]], [[_SCREENSHOW]] - - -{{PageNavigation}} diff --git a/internal/help/_CONSOLE__1111111.txt b/internal/help/_CONSOLE__1111111.txt deleted file mode 100644 index 5eb451053..000000000 --- a/internal/help/_CONSOLE__1111111.txt +++ /dev/null @@ -1,66 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:51}} -{{DISPLAYTITLE:_CONSOLE}} -The [[_CONSOLE]] statement can be used to turn a console window ON/OFF. - - -{{PageSyntax}} -: [[_CONSOLE]] {OFF|ON} -: _DEST [[_CONSOLE]] - - -* [[_CONSOLE]] OFF or ON must be used after the [[$CONSOLE]] [[Metacommand]] has established that a console window is desired. -* [[_CONSOLE]] OFF turns the console window off once a console has been established using [[$CONSOLE]]:ON or ONLY. -* [[_CONSOLE]] ON should only be used after the console window has been turned OFF previously. -* [[_DEST]] [[_CONSOLE]] can be used to send screen output to the console window using QB64 commands such as [[PRINT]]. -* [[_SCREENHIDE]] or [[_SCREENSHOW]] can be used to hide or display the main program window. -* The [[$SCREENHIDE]] [[Metacommand]] can hide the main program window throughout a program when only the console is used. -* '''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}} -{{Cl|_CONSOLE}} OFF 'close original console -{{Cl|_DELAY}} 2 -{{Cl|_CONSOLE}} ON 'place console above program window - -{{Cl|_DEST}} {{Cl|_CONSOLE}} -{{Cl|INPUT}} "Enter your name: ", nme$ 'get program input -{{Cl|_CONSOLE}} OFF 'close console - -{{Cl|_DEST}} 0 'destination program window -{{Cl|PRINT}} nme$ -{{Cl|END}} -{{CodeEnd}} -: ''Explanation:'' The [[_DEST|destination]] must be changed with [[_DEST]] [[_CONSOLE]] to get [[INPUT]] from the [[$CONSOLE]] screen. - - -''Example 2:'' [[_CONSOLETITLE]] can be used to create a console title, but it must be redone every time the console window is restored once turned off: -{{CodeStart}} -{{Cl|$CONSOLE}} - -{{Cl|_CONSOLETITLE}} "firstone" -{{Cl|_DELAY}} 10 - -{{Cl|_CONSOLE}} OFF -{{Cl|_DELAY}} 10 - -{{Cl|_CONSOLE}} ON -{{Cl|_CONSOLETITLE}} "secondone" -{{CodeEnd}} -: ''Note:'' Some versions of Windows may display the program path or Administrator: prefix in console title bars. - - -{{PageSeeAlso}} -* [[$CONSOLE]], [[_CONSOLETITLE]] -* [[$SCREENHIDE]], [[$SCREENSHOW]] {{text|(QB64 [[Metacommand]]s)}} -* [[_SCREENHIDE]], [[_SCREENSHOW]] -* [[_DEST]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CONTINUE__11111111.txt b/internal/help/_CONTINUE__11111111.txt deleted file mode 100644 index 4c522c628..000000000 --- a/internal/help/_CONTINUE__11111111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:55}} -{{DISPLAYTITLE:_CONTINUE}} - -The [[_CONTINUE]] statement is used in a [[DO...LOOP]], [[WHILE...WEND]] or [[FOR...NEXT]] block to skip the remaining lines of code in a block (without exiting it) and start the next iteration. It works as a shortcut to a [[GOTO]], but without the need for a [[line numbers|line label]]. - - -{{PageSyntax}} -: [[_CONTINUE]] - - -{{PageAvailability}} -* '''QB64 1.2 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|FOR}} i = 1 {{Cl|TO}} 10 - {{Cl|IF}} i = 5 {{Cl|THEN}} {{Cl|_CONTINUE}} - {{Cl|PRINT}} i; -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}} - 1 2 3 4 6 7 8 9 10 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[DO...LOOP]] -* [[WHILE...WEND]] -* [[FOR...NEXT]] -* [[GOTO]] - -{{PageNavigation}} diff --git a/internal/help/_CONTROLCHR_(function)__1111111111_(00000000).txt b/internal/help/_CONTROLCHR_(function)__1111111111_(00000000).txt deleted file mode 100644 index a7d10a6cf..000000000 --- a/internal/help/_CONTROLCHR_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:57}} -{{DISPLAYTITLE:_CONTROLCHR (function)}} - -The [[_CONTROLCHR (function)|_CONTROLCHR]] function returns the current state of the [[_CONTROLCHR]] statement as -1 when OFF and 0 when ON. - - -{{PageSyntax}} -:{{Parameter|status%}} = [[_CONTROLCHR (function)|_CONTROLCHR]] - - -{{PageDescription}} -* The function requires no parameters. -* Default return is 0 when the _CONTROLCHR statement has never been used previous to a function read. -* When the statement has been use to turn OFF control characters, the characters can be printed as text without screen formatting. - - -{{PageSeeAlso}} -* [[_CONTROLCHR]] -* [[CHR$]], [[ASC]] -* [[INKEY$]], [[_KEYHIT]] -* [[ASCII]] {{text|(codes)}} - - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CONTROLCHR__1111111111.txt b/internal/help/_CONTROLCHR__1111111111.txt deleted file mode 100644 index 74b6442d5..000000000 --- a/internal/help/_CONTROLCHR__1111111111.txt +++ /dev/null @@ -1,53 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:56}} -{{DISPLAYTITLE:_CONTROLCHR}} -The [[_CONTROLCHR]] statement can be used to turn OFF control character attributes and allow them to be printed. - - -{{PageSyntax}} -: [[_CONTROLCHR]] {OFF|ON} - - -{{PageDescription}} -* The [[OFF]] clause allows control characters 0 to 31 to be printed and not format printing as normal text characters. -::For example: '''{{text|PRINT CHR$(13)|green}}''' 'will not move the cursor to the next line and '''{{text|PRINT CHR$(9)|green}}''' 'will not tab. -* The default [[ON]] statement allows [[ASCII#Control_Characters|Control Characters]] to be used as control commands where some will not print or will format prints. -* '''Note:''' File prints may be affected also when using Carriage Return or Line Feed/Form Feed formatting. -* The QB64 IDE may allow Alt + number pad character entries, but they must be inside of [[STRING]] values. Otherwise the IDE may not recognize them. - - -{{PageExamples}} -''Example:'' Printing the 255 [[ASCII]] characters in [[SCREEN]] 0 with 32 colors. -{{CodeStart}} -{{Cl|DIM}} i {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|WIDTH}} 40, 25 -{{Cl|CLS}} -{{Cl|_CONTROLCHR}} OFF -i = 0 -DO - {{Cl|PRINT}} {{Cl|CHR$}}(i); - i = i + 1 - {{Cl|IF...THEN|IF}} (i {{Cl|AND (boolean)|AND}} {{Cl|&H}}F) = 0 {{Cl|THEN}} {{Cl|PRINT}} -{{Cl|LOOP}} {{Cl|WHILE}} i -{{Cl|LOCATE}} 1, 20 -DO - {{Cl|COLOR}} i {{Cl|AND (boolean)|AND}} {{Cl|&H}}F {{Cl|OR (boolean)|OR}} (i {{Cl|AND (boolean)|AND}} {{Cl|&H}}80) \ {{Cl|&H}}8, (i {{Cl|AND (boolean)|AND}} {{Cl|&H}}70) \ {{Cl|&H}}10 - {{Cl|PRINT}} {{Cl|CHR$}}(i); - i = i + 1 - {{Cl|IF...THEN|IF}} (i {{Cl|AND (boolean)|AND}} {{Cl|&H}}F) = 0 {{Cl|THEN}} {{Cl|LOCATE}} 1 + i \ {{Cl|&H}}10, 20 -{{Cl|LOOP}} {{Cl|WHILE}} i -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_CONTROLCHR (function)]] -* [[CHR$]], [[ASC]] -* [[INKEY$]], [[_KEYHIT]] -* [[ASCII]] {{text|(codes)}} -* [[ASCII#Control_Characters|Control Characters]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_COPYIMAGE__111111111.txt b/internal/help/_COPYIMAGE__111111111.txt deleted file mode 100644 index 60ae58bbc..000000000 --- a/internal/help/_COPYIMAGE__111111111.txt +++ /dev/null @@ -1,74 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:58}} -{{DISPLAYTITLE:_COPYIMAGE}} -This function creates an identical designated image in memory with a different negative [[LONG]] handle value. - - -{{PageSyntax}} -: newhandle& = [[_COPYIMAGE]]({{Parameter|imageHandle&}}[, {{Parameter|mode%}}]) - - -{{Parameters}} -* The [[LONG]] ''newhandle&'' value returned will be different than the source handle value supplied. -* If ''imageHandle&'' is designated being zero, the current software [[_DEST|destination]] screen or image is copied. -* If 1 is designated instead of an ''imageHandle&'', it designates the last OpenGL hardware surface to copy. -* ''Mode'' 32 can be used to convert 256 color images to 32 bit colors. -* ''Mode'' 33 images are hardware accelerated in '''version 1.000 and up''', and are created using [[_LOADIMAGE]] or [[_COPYIMAGE]]. - - -{{PageDescription}} -* The function copies any image or screen handle to a new and unique negative [[LONG]] handle value. -* Valid copy handles are less than -1. Invalid handles return -1 or 0 if it was never created. -* Every attribute of the passed image or program screen is copied to a new handle value in memory. -* '''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. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' -* '''It is important to free discarded images with [[_FREEIMAGE]] to prevent PC memory allocation errors!''' -* '''Do not try to free image handles currently being used as the active [[SCREEN]]. Change screen modes first.''' - - -{{PageExamples}} -;Example 1:Restoring a Legacy SCREEN using the _COPYIMAGE return value. -{{CodeStart}} -{{Cl|SCREEN}} 13 -{{Cl|CIRCLE}} (160, 100), 100, 40 -DO: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -'backup screen before changing {{Cl|SCREEN}} mode -oldmode& = {{Cl|_COPYIMAGE}}(0) 'the 0 value designates the current destination {{Cl|SCREEN}} - -s& = {{Cl|_NEWIMAGE}}(800, 600, 32) -{{Cl|SCREEN}} s& -{{Cl|LINE}} (100, 100)-(500, 500), {{Cl|_RGB}}(0, 255, 255), BF -DO: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SCREEN}} oldmode& 'restore original screen -{{Cl|IF...THEN|IF}} s& < -1 THEN {{Cl|_FREEIMAGE}} s& -{{Cl|END}} -{{CodeEnd}} -{{small|Code courtesy of Galleon}} -;Note:Only free valid handle values with [[_FREEIMAGE]] AFTER a new [[SCREEN]] mode is being used by the program. ----- -;Example 2:Program that copies desktop to a hardware image to form a 3D triangle ('''version 1.000 and up'''): -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -my_hardware_handle = {{Cl|_COPYIMAGE}}({{Cl|_SCREENIMAGE}}, 33) 'take a screenshot and use it as our texture -{{Cl|_MAPTRIANGLE}} (0, 0)-(500, 0)-(250, 500), my_hardware_handle TO_ -(-1, 0, -1)-(1, 0, -1)-(0, 5, -10), , _SMOOTH -{{Cl|_DISPLAY}} -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 30: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{CodeEnd}} -{{small|Code courtesy of Galleon}} - - -{{PageSeeAlso}} -* [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[_PUTIMAGE]], [[_MAPTRIANGLE]] -* [[_SOURCE]], [[_DEST]] -* [[_FREEIMAGE]] -* [[_FILELIST$ (function)]] {{text|(Demo of _COPYIMAGE)}} -* [[_DISPLAYORDER]] -* [[Hardware images]] - - -{{PageNavigation}} diff --git a/internal/help/_COPYPALETTE__11111111111.txt b/internal/help/_COPYPALETTE__11111111111.txt deleted file mode 100644 index e69ea6736..000000000 --- a/internal/help/_COPYPALETTE__11111111111.txt +++ /dev/null @@ -1,34 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:36:59}} -{{DISPLAYTITLE:_COPYPALETTE}} -The [[_COPYPALETTE]] statement copies the color palette intensities from one 4 or 8 BPP image to another image or a [[_NEWIMAGE]] screen page using 256 or less colors. - - -{{PageSyntax}} -:[[_COPYPALETTE]] [{{Parameter|sourceImageHandle&}}[, {{Parameter|destinationImageHandle&}}]] - - -{{PageDescription}} -* Palette Intensity settings are '''not''' used by 24/32 bit images. Use only with 4 or 8 BPP images. -* [[_PIXELSIZE]] function returns 1 to indicate that _COPYPALETTE can be used. 4 indicates 24/32 bit images. -* If {{Parameter|sourceImageHandle&}} is omitted, it is assumed to be the current read page. -* If {{Parameter|destinationImageHandle&}} is omitted, it is assumed to be the current write page. -* If either of the images specified by {{Parameter|sourceImageHandle&}} or {{Parameter|destinationImageHandle&}} do not use a palette, an [[ERROR Codes|illegal function call]] error is returned. -* If either {{Parameter|sourceImageHandle&}} or {{Parameter|destinationImageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error is returned. -* When loading 4 or 8 BPP image files, it is necessary to adopt the color palette of the image or it may not have the correct colors! - - -{{PageExamples}} -* See the example in [[SAVEIMAGE]]. - - -{{PageSeeAlso}} -* [[_LOADIMAGE]] -* [[_PIXELSIZE]] -* [[_PALETTECOLOR]], [[_PALETTECOLOR (function)]] -* [[PALETTE]], [[Images]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_CV__11.txt b/internal/help/_CV__11.txt deleted file mode 100644 index 7619b33f7..000000000 --- a/internal/help/_CV__11.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:01}} -{{DISPLAYTITLE:_CV}} -The [[_CV]] function is used to convert [[_MK$]], [[ASCII]], [[STRING]] values to numerical values. - - -{{PageSyntax}} -:{{Parameter|result}} = [[_CV]]({{Parameter|numericalType}}, {{Parameter|MKstringValue$}}) - - -{{Parameters}} -* {{Parameter|numericalType}} is any number type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_FLOAT]], [[_BYTE]] or [[_BIT]]. -* Integer, Long, Byte and Bit values can be signed or [[_UNSIGNED]]. -* The {{Parameter|MKstringvalue$}} parameter must be a string value generated by [[_MK$]] - - -{{PageDescription}} -* The {{Parameter|MKstringvalue$}} value type must match the numerical type parameter used. -* [[_MK$]] [[STRING|string]] values consist of [[ASCII]] characters in the same byte length as the number value type. - - -{{PageExamples}} -''Example:'' Using the _MK$ and _CV functions: -{{CodeStart}} -{{Cl|DIM}} i64 {{Cl|AS}} {{Cl|_INTEGER64}} -{{Cl|DIM}} i64str {{Cl|AS}} {{Cl|STRING}} - -i64 = 2 ^ 61 -i64str = {{Cl|_MK$}}({{Cl|_INTEGER64}}, i64) - -{{Cl|PRINT}} "I64:"; i64 -{{Cl|PRINT}} "_MK$: "; i64str - -i64 = {{Cl|_CV}}({{Cl|_INTEGER64}}, i64str) -{{Cl|PRINT}} "_CV:"; i64 -{{CodeEnd}} -{{OutputStart}} -I64: 2305843009213693952 -_MK$: -_CV: 2305843009213693952 -{{OutputEnd}} -:The _MK$ string result may not print anything to the screen, as in the example above, unless [[_CONTROLCHR]] is set to OFF. - - -{{PageSeeAlso}} -* [[_MK$]] {{text|(QB64 string conversion function)}} -* [[MKI$]], [[CVI]], [[INTEGER]] -* [[MKL$]], [[CVL]], [[LONG]] -* [[MKS$]], [[CVS]], [[SINGLE]] -* [[MKD$]], [[CVD]], [[DOUBLE]] -* [[MKSMBF$]], [[CVSMBF]] {{text|(Microsoft Binary Format)}} -* [[MKDMBF$]], [[CVDMBF]] {{text|(Microsoft Binary Format)}} -* [[PDS (7.1) Procedures#CURRENCY|CURRENCY]] -* [[_CONTROLCHR]] - - -{{PageNavigation}} diff --git a/internal/help/_CWD$__111$.txt b/internal/help/_CWD$__111$.txt deleted file mode 100644 index 1770af689..000000000 --- a/internal/help/_CWD$__111$.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:02}} -{{DISPLAYTITLE:_CWD$}} - -The [[_CWD$]] function returns the current working directory path as a string value without a trailing path separator. - - -{{PageSyntax}} -: {{Parameter|workingDirectory$}} = [[_CWD$]] - - -{{PageDescription}} -* By default, the initial working directory path is usually the same as the directory of the executable file run. -* The current working directory can be changed with the [[CHDIR]] or [[SHELL]] command; CHDIR sets it, _CWD$ returns it. -* Path returns will change only when the working path has changed. When in C:\ and run QB64\cwd.exe, it will still return C:\ -* The current working directory string can be used in [[OPEN]] statements and [[SHELL]] commands that deal with files. -* Works in Windows, macOS and Linux. [[_OS$]] can be used by a program to predict the proper slash separations in different OS's. - - -{{PageErrors}} -* If an error occurs while obtaining the working directory from the operating system, [[ERROR Codes|error code]] 51 (Internal Error) will be generated. - - -{{PageExamples}} -''Example:'' Get the current working directory, and move around the file system: -{{CodeStart}} -startdir$ = _CWD$ -{{Cl|PRINT}} "We started at "; startdir$ -{{Cl|MKDIR}} "a_temporary_dir" -{{Cl|CHDIR}} "a_temporary_dir" -{{Cl|PRINT}} "We are now in "; _CWD$ -{{Cl|CHDIR}} startdir$ -{{Cl|PRINT}} "And now we're back in "; _CWD$ -{{Cl|RMDIR}} "a_temporary_dir" -{{CodeEnd}} - -{{OutputStart}}We started at C:\QB64 -We are now in C:\QB64\a_temporary_dir -And now we're back in C:\QB64 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[CHDIR]] {{text|(Change the current working directory)}} -* [[RMDIR]] {{text|(Remove a directory in the file system)}} -* [[KILL]] {{text|(Delete a file in the file system)}} -* [[MKDIR]] {{text|(Create a directory in the file system)}} -* [[_OS$]] {{text|(returns current OS to program)}} -* [[_STARTDIR$]] {{text|(returns path the user called program from)}} - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_D2G__121.txt b/internal/help/_D2G__121.txt deleted file mode 100644 index 5a703a21d..000000000 --- a/internal/help/_D2G__121.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:03}} -{{DISPLAYTITLE:_D2G}} -The [[_D2G]] function converts a '''degree''' value into a '''gradient''' value. - - -{{PageSyntax}} -: {{Parameter|result}} = [[_D2G]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Degrees into Gradient. -{{CodeStart}} -INPUT "Give me an angle in Degrees ", D -R = _D2G(D) -PRINT "That angle in Gradient is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Degrees 60 -That angle in Gradient is 66.66666 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2R]] -* [[_G2D]], [[_G2R]] -* [[_R2D]], [[_R2G]] - - - -{{PageNavigation}} diff --git a/internal/help/_D2R__121.txt b/internal/help/_D2R__121.txt deleted file mode 100644 index f16ed38b9..000000000 --- a/internal/help/_D2R__121.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:04}} -{{DISPLAYTITLE:_D2R}} -The [[_D2R]] function converts a '''degree''' value into a '''radian''' value. - - -{{PageSyntax}} -:: {{Parameter|result}} = [[_D2R]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Degrees into Radians. -{{CodeStart}} -INPUT "Give me an angle in Degrees ", D -R = _D2R(D) -PRINT "That angle in Radians is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Degrees 60 -That angle in Radians is 1.047198 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]], [[_D2R]] -* [[_G2D]], [[_G2R]] -* [[_R2D]], [[_R2G]] - - - -{{PageNavigation}} diff --git a/internal/help/_DEFAULTCOLOR__111111111111.txt b/internal/help/_DEFAULTCOLOR__111111111111.txt deleted file mode 100644 index d4c453724..000000000 --- a/internal/help/_DEFAULTCOLOR__111111111111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:09}} -{{DISPLAYTITLE:_DEFAULTCOLOR}} -The [[_DEFAULTCOLOR]] function returns the current default text color for an image handle or page. - - -{{PageSyntax}} -:{{Parameter|result&}} = [[_DEFAULTCOLOR]] [({{Parameter|imageHandle&}})] - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is omitted, it is assumed to be the current write page or image designated by [[_DEST]]. -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error occurs. Check handle values first. -* Default foreground colors are: [[SCREEN]] 0 = 7, [[SCREEN]] 1 and 10 = 3, [[SCREEN]] 2 and 11 = 1. All other [[SCREEN]]s = 15. - - -{{PageExamples}} -''Example:'' The default color is the color assigned to the text foreground. The [[SCREEN]] 12 default is [[COLOR]] 15. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|OUT}} {{Cl|&H}}3C8, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 63: {{Cl|OUT}} {{Cl|&H}}3C9, 63: {{Cl|OUT}} {{Cl|&H}}3C9, 63 'assign background RGB intensities -{{Cl|OUT}} {{Cl|&H}}3C8, 8: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0 'assign RGB intensities to COLOR 8 -{{Cl|_PRINTMODE }} {{Cl|_KEEPBACKGROUND}} -{{Cl|COLOR}} 8 'assign color 8 to text foreground -{{Cl|PRINT}} "The default color is attribute"; {{Cl|_DEFAULTCOLOR}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[COLOR]] -* [[_DEST]] -* [[Images]] -* [[Windows_Libraries#Color_Dialog_Box|Color Dialog Box]] - - -{{PageNavigation}} diff --git a/internal/help/_DEFINE__111111.txt b/internal/help/_DEFINE__111111.txt deleted file mode 100644 index 2dcffafae..000000000 --- a/internal/help/_DEFINE__111111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:10}} -{{DISPLAYTITLE:_DEFINE}} -[[_DEFINE]] defines a set of variable names according to their first character as a specified data type. - - -{{PageSyntax}} -:[[_DEFINE]] {{Parameter|letter}}[{{Parameter|-range}}, ...] [[AS]] [{{KW|_UNSIGNED}}] data[[type]] - - -{{Parameters}} -* Variable start ''letter range'' is in the form firstletter-endingletter (like A-C) or just a single letter. -* ''Data types'': [[INTEGER]], [[SINGLE]], [[DOUBLE]], [[LONG]], [[STRING]], [[_BIT]], [[_BYTE]], [[_INTEGER64]], [[_FLOAT]], [[_OFFSET]], [[_MEM]] -* Can also use the [[_UNSIGNED]] definition for positive whole [[INTEGER]] type numerical values. - - -{{PageDescription}} -* '''When a variable has not been defined or has no type suffix, the value defaults to a [[SINGLE]] precision floating point value.''' -* _DEFINE 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). -* '''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.''' -* '''QBasic's IDE''' added 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. - - -{{PageExamples}} -''Example:'' Defining variables that start with the letters A, B, C or F as unsigned integers, including the ''Add2'' [[FUNCTION]]. -{{CodeStart}} -{{Cl|_DEFINE}} A-C, F {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|INTEGER}} - -{{Cl|PRINT}} Add2(-1.1, -2.2) - -{{Cl|END}} - -{{Cl|FUNCTION}} Add2 (one, two) -Add2 = one + two -{{Cl|END FUNCTION}} -{{CodeEnd}} -{{OutputStart}}65533 -{{OutputEnd}} -: ''Explanation:'' Unsigned integers can only return positive values while ordinary [[INTEGER|integers]] can also return negative values. - - -{{PageSeeAlso}} -* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]] -* [[DIM]], [[REDIM]] -* [[COMMON]], [[SHARED]] -* [[_UNSIGNED]] - - -{{PageNavigation}} diff --git a/internal/help/_DEFLATE$__1111111$.txt b/internal/help/_DEFLATE$__1111111$.txt deleted file mode 100644 index 2b87e0982..000000000 --- a/internal/help/_DEFLATE$__1111111$.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:11}} -{{DISPLAYTITLE:_DEFLATE$}} -The [[_DEFLATE$]] function compresses a [[STRING|string]]. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[_DEFLATE$]]({{Parameter|stringToCompress$}}) - - -{{PageDescription}} -* {{Parameter|result$}} will contain the compressed version of {{Parameter|stringToCompress$}}. -* To decompress the resulting string, use [[_INFLATE$]]. - - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' Compressing a long string of text. -{{CodeStart}} -a$ = "The quick brown fox jumps over the lazy dog. " -{{Cl|PRINT}} "Original string (a$): "; a$ -{{Cl|FOR}} i = 1 {{Cl|TO}} 15 - a$ = a$ + a$ -{{Cl|NEXT}} - -{{Cl|PRINT}} "After concatenating it into itself several times, LEN(a$) ="; {{Cl|LEN}}(a$) - -b$ = {{Cl|_DEFLATE$}}(a$) -{{Cl|PRINT}} "After using _DEFLATE$ to compress it, LEN ="; {{Cl|LEN}}(b$) -{{Cl|PRINT}} {{Cl|USING}} "(compressed size is #.###% of the original)"; (({{Cl|LEN}}(b$) * 100) / {{Cl|LEN}}(a$)) -c$ = {{Cl|_INFLATE$}}(b$) -PRINT "After using _INFLATE$ to decompress it, LEN ="; {{Cl|LEN}}(c$) - {{CodeEnd}} -{{OutputStart}} -Original string (a$): The quick brown fox jumps over the lazy dog -After concatenating it into itself several times, LEN(a$) = 1474560 -After using _DEFLATE$ to compress it, LEN = 4335 -(compressed size is 0.295% of the original) -After using _INFLATE$ to decompress it, LEN = 1474560 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_INFLATE$]] - - -{{PageNavigation}} diff --git a/internal/help/_DELAY__11111.txt b/internal/help/_DELAY__11111.txt deleted file mode 100644 index 54f4beb4d..000000000 --- a/internal/help/_DELAY__11111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:12}} -{{DISPLAYTITLE:_DELAY}} -The [[_DELAY]] statement suspends program execution for a [[SINGLE]] value of seconds. - - -{{PageSyntax}} -:[[_DELAY]] {{Parameter|seconds!}} - - -{{PageDescription}} -* {{Parameter|seconds!}} is the time to wait, accurate to nearest millisecond (.001). -* While waiting, cpu cycles are relinquished to other applications. -* Delays are not affected by midnight timer corrections. - - -{{PageSeeAlso}} -* [[_LIMIT]] -* [[TIMER]] -* [[ON TIMER(n)]] - - -{{PageNavigation}} diff --git a/internal/help/_DEPTHBUFFER__11111111111.txt b/internal/help/_DEPTHBUFFER__11111111111.txt deleted file mode 100644 index f4a77b89f..000000000 --- a/internal/help/_DEPTHBUFFER__11111111111.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:13}} -{{DISPLAYTITLE:_DEPTHBUFFER}} -The [[_DEPTHBUFFER]] statement turns depth buffering ON or OFF, LOCKs or _CLEARS the buffer. - - - -{{PageSyntax}} -: [[_DEPTHBUFFER]] {ON|OFF|LOCK|_CLEAR}[,handle&] - - -{{PageDescription}} -* Depth buffers store the distance of each pixel on an image/surface. When 3D drawing occurs new pixels are only drawn if they are closer than the existing pixels. After all content is drawn, it results in a scene which looks correct because content which is closer hides content which is further away. -* Depth buffers are automatically created for any hardware image or surface which is the target/destination of a 3D command (such as the 3D version of [[_MAPTRIANGLE]]). -* The buffering can be turned ON, OFF or LOCKed. The default state is ON. -* [[_DEPTHBUFFER]] _CLEAR can be used to reset/erase the depth buffer, meaning that future drawing will not be blocked by existing/previously buffered depth content. -* Whenever _DISPLAY is called the primary surface's depth buffer is automatically _CLEARed, so unless you are drawing onto a hardware image you may never need to use this option. -* LOCKing the depth buffer makes it read only. New content cannot be drawn unless it is closer than existing content, but when that new content is drawn it will not update the depth buffer. -* Turning OFF or LOCKing the depth buffer is typically performed when semi-transparent content is being drawn. - - - -{{PageSeeAlso}} -* [[_MAPTRIANGLE]] -* [[_PUTIMAGE]] -* [[_DISPLAY]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DESKTOPHEIGHT__1111111111111.txt b/internal/help/_DESKTOPHEIGHT__1111111111111.txt deleted file mode 100644 index 5639d42d6..000000000 --- a/internal/help/_DESKTOPHEIGHT__1111111111111.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:14}} -{{DISPLAYTITLE:_DESKTOPHEIGHT}} -The [[_DESKTOPHEIGHT]] function returns the height of the users current desktop. - - -{{PageSyntax}} -: {{Parameter|y&}} = [[_DESKTOPHEIGHT]] - - -{{PageDescription}} -* No parameters are needed for this function. -* This returns the height of the user's desktop, not the size of any screen or window which might be open on that desktop. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -{{CodeStart}} - - s& = {{Cl|_NEWIMAGE}}(800, 600, 256) - SCREEN s& - PRINT _DESKTOPWIDTH, _DESKTOPHEIGHT - PRINT _WIDTH, _HEIGHT - -{{CodeEnd}} - -: ''Explanation:'' This will print the size of the user desktop (for example ''1920, 1080'' for a standard hdmi monitor), and then the size of the current [[SCREEN|screen]] (800, 600). - - -{{PageSeeAlso}} -* [[_HEIGHT]], [[_DESKTOPWIDTH]] -* [[_WIDTH]], [[_SCREENIMAGE]] - - - -{{PageNavigation}} diff --git a/internal/help/_DESKTOPWIDTH__111111111111.txt b/internal/help/_DESKTOPWIDTH__111111111111.txt deleted file mode 100644 index 3a4a3df3c..000000000 --- a/internal/help/_DESKTOPWIDTH__111111111111.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:15}} -{{DISPLAYTITLE:_DESKTOPWIDTH}} -The [[_DESKTOPWIDTH]] function returns the width of the users current desktop. - - -{{PageSyntax}} -: {{Parameter|x&}} = [[_DESKTOPWIDTH]] - - -{{PageDescription}} -* No parameters are needed for this function. -* This returns the width of the user's desktop, not the size of any screen or window which might be open on that desktop. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -{{CodeStart}} - - s& = {{Cl|_NEWIMAGE}}(800, 600, 256) - SCREEN s& - PRINT _DESKTOPWIDTH, _DESKTOPHEIGHT - PRINT _WIDTH, _HEIGHT - -{{CodeEnd}} - -: ''Explanation:'' This will print the size of the user desktop (for example ''1920, 1080'' for a standard hdmi monitor), and then the size of the current [[SCREEN|screen]] (800, 600). - - -{{PageSeeAlso}} -* [[_HEIGHT]], [[_DESKTOPHEIGHT]] -* [[_WIDTH]], [[_SCREENIMAGE]] - - - -{{PageNavigation}} diff --git a/internal/help/_DEST_(function)__1111_(00000000).txt b/internal/help/_DEST_(function)__1111_(00000000).txt deleted file mode 100644 index 266667a35..000000000 --- a/internal/help/_DEST_(function)__1111_(00000000).txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:18}} -{{DISPLAYTITLE:_DEST (function)}} -The [[_DEST]] function returns the handle value of the current write page (the image used for drawing). - - -{{PageSyntax}} -:{{Parameter|result&}} = [[_DEST]] - - -{{PageDescription}} -* The current write page is where all drawing occurs by default. -* The value returned is the same as the latest [[SCREEN]]'s handle when creating custom screen modes using [[_NEWIMAGE]]. -* Keep the _NEWIMAGE handle values when you move to another SCREEN mode so that you can return to that screen later. You can go to another screen mode and return without having to redo the screen. -* [[_DEST]] return values do not change in legacy screen modes. The value will not help restore them. - - -{{PageSeeAlso}} -* [[_DEST]] -* [[_SOURCE (function)]] -* [[SCREEN]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DEST__1111.txt b/internal/help/_DEST__1111.txt deleted file mode 100644 index dc0e5917a..000000000 --- a/internal/help/_DEST__1111.txt +++ /dev/null @@ -1,117 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:17}} -{{DISPLAYTITLE:_DEST}} -The [[_DEST]] statement sets the current write image or page. All graphic and print changes will be done to this image. - - -{{PageSyntax}} -:[[_DEST]] {{Parameter|imageHandle&}} - - -{{PageDescription}} -* {{Parameter|imageHandle&}} is the handle of the image that will act as the current write page. -* '''_DEST 0''' refers to the present program [[SCREEN]]. You can use 0 to refer to the present program [[SCREEN]]. -* [[_DEST]] [[_CONSOLE]] can set the destination to send information to a console window using [[PRINT]] or [[INPUT]]. -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error occurs. Always check for valid handle values first ({{Parameter|imageHandle&}} < -1). -*''Note:'' Use [[_SOURCE]] when you need to read a page or image with [[POINT]], [[GET (graphics statement)|GET]] or the [[SCREEN (function)|SCREEN]] function. - - -{{PageExamples}} -''Example 1:'' Placing a center point and a circle using [[_CLEARCOLOR]] to eliminate the background color black. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 13 'program screen can use 256 colors -a& = {{Cl|_NEWIMAGE}}(320,200,13) 'create 2 screen page handles a& and b& -b& = {{Cl|_NEWIMAGE}}(320,200,13) -{{Cl|_DEST}} a& 'set destination image to handle a& -{{Cl|PSET}} (100, 100), 15 'draw a dot on the current destination handle a& -{{Cl|_DEST}} b& 'set destination image to handle b& -{{Cl|CIRCLE}} (100, 100), 50, 15 'draw a circle on the current destination handle b& -{{Cl|_CLEARCOLOR}} 0 'make page b color 0 (black) transparent -{{Cl|_PUTIMAGE}} , b&, a& 'put circle on image b to image a& (a PSET dot) -{{Cl|_PUTIMAGE}} , a&, 0 'put what is on image a& to the screen (handle 0) -{{CodeEnd}} - - -''Example 2:'' Demonstrates how [[PRINT|printed]] text can be stretched using [[_PUTIMAGE]] with [[_DEST]] pages. -{{CodeStart}} -{{Cl|DIM}} a(10) {{Cl|AS}} {{Cl|LONG}} -{{Cl|DIM}} b {{Cl|AS}} {{Cl|LONG}} - -{{Cl|REM}} Sets up a newimage for B then sets the screen to that. -b = {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|SCREEN (statement)|SCREEN}} b - -{{Cl|REM}} Make pages 48 pixels tall. If the image is not at least that it wont work -a(1) = {{Cl|_NEWIMAGE}}(240, 48, 32) -a(2) = {{Cl|_NEWIMAGE}}(240, 48, 32) -a(3) = {{Cl|_NEWIMAGE}}(98, 48, 32) - -xa = 100 -ya = 120 -xm = 4 -ym = 4 - -{{Cl|REM}} Some fun things for the bouncing text. -st$(0) = "doo" -st$(1) = "rey" -st$(2) = "mee" -st$(3) = "faa" -st$(4) = "soo" -st$(5) = "laa" -st$(6) = "tee" - -sta$(0) = "This is a demo" -sta$(1) = "showing how to use" -sta$(2) = "the _DEST command" -sta$(3) = "with PRINT" -sta$(4) = "and _PUTIMAGE" - -{{Cl|REM}} prints to a(3) image then switches back to the default 0 -{{Cl|_DEST}} a(3): f = {{Cl|INT}}({{Cl|RND}} * 6): {{Cl|PRINT}} st$(3): {{Cl|_DEST}} 0 - -DO - {{Cl|REM}} prints to a(1) and a(2) then switches bac to 0 - {{Cl|_DEST}} a(1) - {{Cl|CLS}} - {{Cl|PRINT}} sta(r) - {{Cl|_DEST}} a(2) - {{Cl|CLS}} - {{Cl|PRINT}} sta(r + 1) - {{Cl|_DEST}} 0 'destination zero is the main program page - - {{Cl|REM}} a loop to putimage the images in a(1) and a(2) in a way to make it look like its rolling - {{Cl|FOR...NEXT|FOR}} yat = 150 {{Cl|TO}} 380 {{Cl|STEP}} 4 - {{Cl|CLS}} - {{Cl|_PUTIMAGE}} (0, yat)-(640, 380), a(1) - {{Cl|_PUTIMAGE}} (0, 150)-(640, yat), a(2) - {{Cl|GOSUB}} bounce - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 20 - {{Cl|NEXT}} yat - - r = r + 1 - {{Cl|IF...THEN|IF}} r = 4 {{Cl|THEN}} r = 0 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -bounce: -{{Cl|IF...THEN|IF}} xa > 600 {{Cl|OR (boolean)|OR}} xa < 20 {{Cl|THEN}} xm = xm * -1: {{Cl|_DEST}} a(3): f = {{Cl|INT}}({{Cl|RND}} * 6): {{Cl|CLS}}: {{Cl|_CLEARCOLOR}} 0: {{Cl|PRINT}} st$(f): {{Cl|_DEST}} 0 -{{Cl|IF...THEN|IF}} ya > 400 {{Cl|OR (boolean)|OR}} ya < 20 {{Cl|THEN}} ym = ym * -1: {{Cl|_DEST}} a(3): f = {{Cl|INT}}({{Cl|RND}} * 7): {{Cl|CLS}}: {{Cl|_CLEARCOLOR}} 0: {{Cl|PRINT}} st$(f): {{Cl|_DEST}} 0 -{{Cl|_PUTIMAGE}} (xa, ya)-(xa + 150, ya + 80), a(3) -xa = xa + xm -ya = ya + ym -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Adapted from code by CodeViper}} - - -{{PageSeeAlso}} -* [[_DEST (function)]] -* [[_SOURCE]] -* [[_PUTIMAGE]] -* [[_CONSOLE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DEVICE$__111111$.txt b/internal/help/_DEVICE$__111111$.txt deleted file mode 100644 index bb2be6466..000000000 --- a/internal/help/_DEVICE$__111111$.txt +++ /dev/null @@ -1,72 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:19}} -{{DISPLAYTITLE:_DEVICE$}} -The '''_DEVICE$''' function returns a [[STRING]] value holding the controller type, name and input types of the input devices on a computer. - - -{{PageSyntax}} -: {{Parameter|device$}} = _DEVICE$({{Parameter|device_number}}) - - -* The '''[[_DEVICES]] function must be read first to get the number of devices and to enable [[_DEVICE$]] and [[_DEVICEINPUT]].''' -* The {{Parameter|device_number}} parameter indicates the number of the controller device to be read. -* Returns the [[STRING]] control type, name of the device and input types each can use included in brackets: -::* Control type: -::: [KEYBOARD] always listed as first device when keyboard(s) available. Only one keyboard will show. -::: [MOUSE]] always listed as second device when keyboard(s) and mouse(mice) are available. Only one mouse will show. -::: [CONTROLLER] subsequent devices are listed as controllers which include joysticks and game pads. -::* When [CONTROLLER] is returned it may also give the [[STRING]] [[NAME] [device description]] of the controller. -::* Returns the type of input after the device name as one or more of the following types: -::: [{{KW|BUTTON}}] indicates there are button types of input. [[_LASTBUTTON]] can return the number of buttons available. -::: [{{KW|AXIS}}] indicates there are stick types of input. [[_LASTAXIS]] can return the number of axis available. -::: [{{KW|WHEEL}}] indicates that a scrolling input can be read. [[_LASTWHEEL]] can return the number of wheels available. - -* '''Device numbers above the number of [[_DEVICES|devices]] found will return an OS error.''' -* Devices found include keyboard, mouse, joysticks, game pads and multiple stick game controllers. - - -{{PageExamples}} -''Example 1:'' Checking for the system's input devices and the number of buttons available. -{{CodeStart}} -devices = {{Cl|_DEVICES}} 'MUST be read in order for other 2 device functions to work! -PRINT "Number of input devices found ="; devices -FOR i = 1 TO devices - PRINT {{Cl|_DEVICE$}}(i) - PRINT "Buttons:"; {{Cl|_LASTBUTTON}}(i); "Axis:"; {{Cl|_LASTAXIS}}(i); "Wheels:"; {{Cl|_LASTWHEEL}}(i) -NEXT -{{CodeEnd}} -{{OutputStart}}Number of input devices found = 3 -[KEYBOARD][BUTTON] -Buttons: 512 Axis: 0 Wheels: 0 -[MOUSE][BUTTON][AXIS][WHEEL] -Buttons: 3 Axis: 2 Wheels: 3 -[CONTROLLER][[NAME][Microsoft Sidewinder Precision Pro (USB)]][BUTTON][AXIS] -Buttons: 9 Axis: 6 Wheels: 0 -{{OutputEnd}} -:Note: The [[STRIG]]/[[STICK]] commands won't read from the keyboard or mouse device the above example lists. They will only work on controllers. - - -''Example 2:'' Finding the number of mouse buttons available in QB64. This could also be used for other devices. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} d = 1 {{Cl|TO}} {{Cl|_DEVICES}} 'number of input devices found - dev$ = {{Cl|_DEVICE$}}(d) - {{Cl|IF...THEN|IF}} {{Cl|INSTR}}(dev$, "[MOUSE]") {{Cl|THEN}} buttons = {{Cl|_LASTBUTTON}}(d): {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} -{{Cl|NEXT}} -{{Cl|PRINT}} buttons; "mouse buttons available" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_DEVICES]], [[_DEVICEINPUT]] -* [[_LASTBUTTON]], [[_LASTAXIS]], [[_LASTWHEEL]] -* [[_BUTTON]], [[_BUTTONCHANGE]] -* [[_AXIS]], [[_WHEEL]] -* [[_MOUSEBUTTON]] -* [[STRIG]], [[STICK]] -* [[ON STRIG(n)]], [[STRIG(n)]] -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DEVICEINPUT__11111111111.txt b/internal/help/_DEVICEINPUT__11111111111.txt deleted file mode 100644 index de4012c57..000000000 --- a/internal/help/_DEVICEINPUT__11111111111.txt +++ /dev/null @@ -1,110 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:20}} -{{DISPLAYTITLE:_DEVICEINPUT}} -The '''_DEVICEINPUT''' function returns the device number when a controller device button, wheel or axis event occurs. - - -{{PageSyntax}} -: {{Parameter|device%}} = [[_DEVICEINPUT]] -: {{Parameter|device_active%}} = [[_DEVICEINPUT]]({{Parameter|device_number%}}) - - -{{Parameters}} -* Use the _DEVICEINPUT {{Parameter|device%}} [[INTEGER]] returned to find the number of the controller device being used. -* A literal specific {{Parameter|device_number%}} parameter can be used to return -1 if active or 0 if inactive. {{text|EX: '''WHILE _DEVICEINPUT(2)'''|green}} - - -{{PageDescription}} -* Use [[_DEVICES]] to find the number of controller devices available BEFORE using this function. -* [[_DEVICE$]] can be used to list the device names and control types using valid [[_DEVICES]] numbers. -* When a device button is pressed or a scroll wheel or axis is moved, the device number will be returned. -* Devices are numbered as 1 for keyboard and 2 for mouse. Other controller devices will be numbered 3 or higher if installed. -* [[_LASTBUTTON]], [[_LASTAXIS]], or [[_LASTWHEEL]] will indicate the number of functions available with the specified ''device'' number. -* User input events can be monitored reading valid numbered [[_AXIS]], [[_BUTTON]], [[_BUTTONCHANGE]] or [[_WHEEL]] functions. -* ''Note:'' [[ON...GOSUB|ON _DEVICEINPUT GOSUB]] keyboard, mouse, gamecontrol can be used to control the devices 1,2 and 3, etc. - - -{{PageExamples}} -''Example 1:'' Checking device controller interfaces and finding out what devices are being used. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}} - {{Cl|PRINT}} {{Cl|STR$}}(i) + ") " + {{Cl|_DEVICE$}}(i) - {{Cl|PRINT}} "Button:"; {{Cl|_LASTBUTTON}}(i); ",Axis:"; {{Cl|_LASTAXIS}}(i); ",Wheel:"; {{Cl|_LASTWHEEL}}(i) -{{Cl|NEXT}} - -{{Cl|PRINT}} -DO - x = {{Cl|_DEVICEINPUT}} - {{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|PRINT}} "Device ="; x; -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}}[KEYBOARD][BUTTON] -Buttons: 512 Axis: 0 Wheels: 0 -[MOUSE][BUTTON][AXIS][WHEEL] -Buttons: 3 Axis: 2 Wheels: 3 -[CONTROLLER][[NAME][Microsoft Sidewinder Precision Pro (USB)]][BUTTON][AXIS] -Buttons: 9 Axis: 6 Wheels: 0 - -Device = 2 Device = 2 -{{OutputEnd}} -: ''Note:'' Mouse events must be within the program screen area. Keyboard presses are registered only when program is in focus. - - -''Example 2:'' Why does a mouse have 3 wheels? Relative x and y movements can be read using the first 2 [[_WHEEL]] reads. -{{CodeStart}} -ignore = {{Cl|_MOUSEMOVEMENTX}} 'dummy call to put mouse into relative movement mode - -{{Cl|PRINT}} "Move your mouse and/or your mouse wheel (ESC to exit)" - -d = {{Cl|_DEVICES}} ' always read number of devices to enable device input -DO: {{Cl|_LIMIT}} 30 'main loop - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_DEVICEINPUT}}(2) 'loop only runs during a device 2 mouse event - {{Cl|PRINT}} {{Cl|_WHEEL}}(1), {{Cl|_WHEEL}}(2), {{Cl|_WHEEL}}(3) - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} -: ''Explanation:'' Referencing the [[_MOUSEMOVEMENTX]] function hides the mouse and sets the mouse to a relative movement mode which can be read by [[_WHEEL]]. [[_DEVICEINPUT]](2) returns -1 (true) only when the mouse is moved, scrolled or clicked. - - -''Example 3:'' Using [[ON...GOSUB]] with the [[_DEVICEINPUT]] number to add keyboard, mouse and game controller event procedures. -{{CodeStart}} -n = {{Cl|_DEVICES}} 'required when reading devices -{{Cl|PRINT}} "Number of devices found ="; n -{{Cl|FOR...NEXT|FOR}} i = 1 TO n - PRINT i; _DEVICE$(i) ' 1 = keyboard, 2 = mouse, 3 = other controller, etc. -{{Cl|NEXT}} -{{Cl|PRINT}} - -{{Cl|DO...LOOP|DO}}: device = {{Cl|_DEVICEINPUT}} - {{Cl|ON...GOSUB|ON device GOSUB}} keyboard, mouse, controller 'must be inside program loop -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{Cl|END}} - -keyboard: -{{Cl|PRINT}} device; "Keyboard"; -{{Cl|RETURN}} - -mouse: -{{Cl|PRINT}} device; "Mouse "; -{{Cl|RETURN}} - -controller: -{{Cl|PRINT}} device; "Game control "; -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -: ''Note:'' [[ON...GOSUB]] and [[ON...GOTO]] events require numerical values to match the order of line labels listed in the event used inside loops. - - -{{PageSeeAlso}} -* [[_DEVICES]], [[_DEVICE$]] -* [[_LASTBUTTON]], [[_LASTAXIS]], [[_LASTWHEEL]] -* [[_BUTTON]], [[_AXIS]], [[_WHEEL]] -* [[STRIG]], [[STICK]] -* [[ON...GOSUB]] {{text|(numerical events)}} -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_DEVICES__1111111.txt b/internal/help/_DEVICES__1111111.txt deleted file mode 100644 index 0f965e4f0..000000000 --- a/internal/help/_DEVICES__1111111.txt +++ /dev/null @@ -1,49 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:22}} -{{DISPLAYTITLE:_DEVICES}} -The [[_DEVICES]] function returns the number of INPUT devices on your computer including keyboard, mouse and game devices. - - -{{PageSyntax}} -: {{Parameter|device_count%}} = [[_DEVICES]] - - -{{PageDescription}} -* Returns the number of devices that can be listed separately with the [[_DEVICE$]] function by the device number. -* Devices include keyboard, mouse, joysticks, game pads and multiple stick game controllers. -* '''Note: This function must be read before trying to use the [[_DEVICE$]], [[_DEVICEINPUT]] or _LAST control functions.''' - - -{{PageExamples}} -''Example:'' Checking for the system's input devices. -{{CodeStart}} -devices = {{Cl|_DEVICES}} 'MUST be read in order for other 2 device functions to work! -PRINT "Number of input devices found ="; devices -FOR i = 1 TO devices - PRINT {{Cl|_DEVICE$}}(i) - PRINT "Buttons:"; {{Cl|_LASTBUTTON}}(i) -NEXT -{{CodeEnd}} -{{OutputStart}}Number of input devices found = 2 -[KEYBOARD][BUTTON] -Buttons: 512 -[MOUSE][BUTTON][AXIS][WHEEL] -Buttons: 3 -{{OutputEnd}} -:Note: The [[STRIG]]/[[STICK]] commands won't read from the keyboard or mouse device the above example lists. - - -{{PageSeeAlso}} -* [[_DEVICE$]], [[_DEVICEINPUT]] -* [[_LASTBUTTON]], [[_LASTAXIS]], [[_LASTWHEEL]] -* [[_BUTTON]], [[_BUTTONCHANGE]] -* [[_AXIS]], [[_WHEEL]] -* [[_MOUSEINPUT]], [[_MOUSEX]], [[_MOUSEBUTTON]] -* [[STRIG]], [[STICK]] -* [[ON STRIG(n)]], [[STRIG(n)]] -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DIR$__111$.txt b/internal/help/_DIR$__111$.txt deleted file mode 100644 index 3230ca666..000000000 --- a/internal/help/_DIR$__111$.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:23}} -{{DISPLAYTITLE:_DIR$}} -The [[_DIR$]] function returns common paths in '''Windows''' only such as My Documents, My Pictures, My Music, Desktop. - - -{{PageSyntax}} -: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}") - - -{{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 - - -{{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}} -{{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}} - - -{{PageSeeAlso}} -* [[_CWD$]] -* [[_STARTDIR$]] - - -{{PageNavigation}} diff --git a/internal/help/_DIREXISTS__111111111.txt b/internal/help/_DIREXISTS__111111111.txt deleted file mode 100644 index 7220d9e00..000000000 --- a/internal/help/_DIREXISTS__111111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:24}} -{{DISPLAYTITLE:_DIREXISTS}} -The [[_DIREXISTS]] function determines if a designated file path or folder exists and returns true (-1) or false (0). - - -{{PageSyntax}} -: {{Parameter|dirExists%}} = [[_DIREXISTS]]({{Parameter|filepath$}}) - - -{{PageDescription}} -* The {{Parameter|filepath$}} parameter can be a literal or variable [[STRING|string]] path value. -* The function returns -1 when a path or folder exists and 0 when it does not. -* The function reads the system information directly without using a [[SHELL]] procedure. -* The function will use the appropriate Operating System path separators. [[_OS$]] can determine the operating system. -* '''This function does not guarantee that a path can be accessed, only that it exists.''' -* '''NOTE: Checking if a folder exists in a CD drive may cause the tray to open automatically to request a disk when empty.''' To find drives in Windows, use this API Library: [[Windows Libraries#Disk Drives|Disk Drives]] - - -{{PageExamples}} -{{Parameter|Example:'' Checks if a folder exists before proceeding. -{{CodeStart}} -{{Cl|IF}} {{Cl|_DIREXISTS}}("internal\temp") THEN - {{Cl|PRINT}} "Folder found." -{{Cl|END IF}} -{{CodeEnd}}}} - - -{{PageSeeAlso}} -* [[_FILEEXISTS]] -* [[SHELL]] -* [[_OS$]] - - -{{PageNavigation}} diff --git a/internal/help/_DISPLAYORDER__111111111111.txt b/internal/help/_DISPLAYORDER__111111111111.txt deleted file mode 100644 index 6b503b36c..000000000 --- a/internal/help/_DISPLAYORDER__111111111111.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:28}} -{{DISPLAYTITLE:_DISPLAYORDER}} -The [[_DISPLAYORDER]] statement defines the order to render software, hardware and custom-OpenGL-code. - - -{{PageSyntax}} -: [[_DISPLAYORDER]] [{_SOFTWARE|_HARDWARE|_HARDWARE1|_GLRENDER}][, ...][, ...][, ...][, ...] - - -{{Parameters}} -* _SOFTWARE refers to software created surfaces or [[SCREEN]]s. -* _HARDWARE and _HARDWARE1 refer to surfaces created by OpenGL hardware acceleration. -* _GLRENDER refers to OpenGL code rendering order - - -{{PageDescription}} -* The default on program start is: _DISPLAYORDER _SOFTWARE, _HARDWARE, _GLRENDER, _HARDWARE1 -* Any content or combination order is allowed, except listing the same content twice consecutively. -* Simply using [[_DISPLAYORDER]] _HARDWARE will render hardware surfaces only. -* Use an [[underscore]] to continue a code line on a new text row in the IDE. -* After _DISPLAYORDER has been used, it must be used to make any changes, even to default. - - -{{PageErrors}} -* If a rendering content is not listed it will not be rendered except when using the startup default. -* Rendering the same content twice consecutively in a combination is not allowed. - - -==Availability== -* '''Version 1.000 and up.''' - - -{{PageSeeAlso}} -* [[_DISPLAY]] -* [[_PUTIMAGE]] -* [[_LOADIMAGE]] -* [[_COPYIMAGE]] -* [[Hardware images]] - - -{{PageNavigation}} diff --git a/internal/help/_DISPLAY_(function)__1111111_(00000000).txt b/internal/help/_DISPLAY_(function)__1111111_(00000000).txt deleted file mode 100644 index 9439c3bb1..000000000 --- a/internal/help/_DISPLAY_(function)__1111111_(00000000).txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:27}} -{{DISPLAYTITLE:_DISPLAY (function)}} -The [[_DISPLAY]] function returns the handle of the current image that is displayed on the screen. - - -{{PageSyntax}} -:{{Parameter|currentImage&}} = [[_DISPLAY]] - - -{{PageDescription}} -* Returns the current image handle value that is being displayed. Returns 0 if in the default [[SCREEN|screen]] image. -* Not to be confused with the [[_DISPLAY]] statement that displays the screen when not using [[_AUTODISPLAY]]. - - -{{PageExamples}} -''Example:'' Creating a mouse cursor using a page number that '''you create''' in memory without setting up page flipping. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) 'any graphics mode should work without setting up pages -{{Cl|_MOUSEHIDE}} -SetupCursor -{{Cl|PRINT}} "Hello World!" -{{Cl|DO}}: {{Cl|_LIMIT}} 30 - {{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}: {{Cl|LOOP}} 'main loop must contain _MOUSEINPUT -' other program code -{{Cl|LOOP}} - -{{Cl|SUB}} SetupCursor -{{Cl|ON TIMER(n)|ON TIMER}}(0.02) UpdateCursor -{{Cl|TIMER}} ON -{{Cl|END SUB}} - -{{Cl|SUB}} UpdateCursor -{{Cl|PCOPY}} {{Cl|_DISPLAY (function)|_DISPLAY}}, 100 'any page number as desination with the _DISPLAY function as source -{{Cl|PSET}} ({{Cl|_MOUSEX}}, {{Cl|_MOUSEY}}), {{Cl|_RGB}}(0, 255, 0) -{{Cl|DRAW}} "ND10F10L3F5L4H5L3" -{{Cl|_DISPLAY}} 'statement shows image -{{Cl|PCOPY}} 100, {{Cl|_DISPLAY (function)|_DISPLAY}} 'with the function return as destination page -{{Cl|END SUB}} -{{CodeEnd}} -''Note:'' Works with the '''_DISPLAY function''' return as the other page. If mouse reads are not crucial, put the [[_MOUSEINPUT]] loop inside of the UpdateCursor SUB. - - -{{PageSeeAlso}} -* [[SCREEN]] -* [[PCOPY]] -* [[_DISPLAY]] {{text|(statement)}} -* [[_AUTODISPLAY]] {{text|(default mode)}} -* [[_DISPLAYORDER]] {{text|(statement)}} - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DISPLAY__1111111.txt b/internal/help/_DISPLAY__1111111.txt deleted file mode 100644 index 2f1f58c03..000000000 --- a/internal/help/_DISPLAY__1111111.txt +++ /dev/null @@ -1,86 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:25}} -{{DISPLAYTITLE:_DISPLAY}} -The [[_DISPLAY]] statement turns off the automatic display while only displaying the screen changes when called. - - -{{PageSyntax}} -: [[_DISPLAY]] - - -{{PageDescription}} -* '''_DISPLAY''' turns off the auto refresh screen default [[_AUTODISPLAY]] behavior. Prevents screen flickering. -* Call _DISPLAY each time the screen graphics are to be displayed. Place call after the image has been changed. -* Re-enable automatic display refreshing by calling [[_AUTODISPLAY]]. If it isn't re-enabled, things may not be displayed later. -* _DISPLAY tells '''QB64''' to render all of the hardware [[_PUTIMAGE]] commands loaded into the buffer previously. -* The [[_AUTODISPLAY (function)]] can be used to detect the current display behavior. -* '''QB64''' can set the graphic rendering order of _SOFTWARE, _HARDWARE, and _GLRENDER with [[_DISPLAYORDER]]. - - -{{PageExamples}} -''Example 1:'' Displaying a circle bouncing around the screen. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -x = 21: y =31 'start position -dx = 3: dy = 3 'number of pixel moves per loop -{{Cl|DO}} - {{Cl|_LIMIT}} 100 ' set to 100 frames per second - x = x + dx: y = y + dy - {{Cl|IF...THEN|IF}} x < 0 {{Cl|OR}} x > 640 {{Cl|THEN}} dx = -dx 'limit columns and reverse column direction each side - {{Cl|IF...THEN|IF}} y < 0 {{Cl|OR}} y > 480 {{Cl|THEN}} dy = -dy 'limit rows and reverse row direction top or bottom - IF px <> x OR py <> y THEN FOR d = 1 to 20: CIRCLE (px, py), d, 0: NEXT 'erase - FOR c = 1 TO 20: {{Cl|CIRCLE}} (x, y), c, 6: NEXT 'draw new circle at new position - px = x: py = y 'save older coordinates to erase older circle next loop - {{Cl|_DISPLAY}} 'after new circle is set, show it -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = CHR$(27) -{{CodeEnd}} - -:''Explanation:'' The loop is set with [[_LIMIT]] to 100 frames per second to limit CPU usage and the speed of the ball. Each loop a circle is drawn while the previous one is erased when the coordinates change. _DISPLAY only shows the new circle position once each loop. The '''_DISPLAY''' routine eliminates the need for setting [[SCREEN (statement)|SCREEN]] swap pages, [[CLS]] and [[PCOPY]]. _DISPLAY keeps the image off of the screen until the changes have all completed. Drawing 40 circles every loop helps slow down the ball. - - -''Example 2:'' [[_DISPLAY]] must be used to render hardware images placed with [[_PUTIMAGE]] ('''version 1.000 and up'''). -{{CodeStart}} -{{Cl|CONST}} MenuHeight = 200 - - -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -'{{Cl|SLEEP}} 1 -{{Cl|LOCATE}} 20 -DO - {{Cl|_LIMIT}} 30 - DisplayMenu - k = {{Cl|_KEYHIT}} - {{Cl|IF...THEN|IF}} k <> 0 {{Cl|THEN}} {{Cl|PRINT}} k, -{{Cl|LOOP}} {{Cl|UNTIL}} k = 32 {{Cl|OR (boolean)|OR}} k = 27 - - -{{Cl|SUB}} DisplayMenu -{{Cl|STATIC}} init, MS_HW {{Cl|AS}} {{Cl|LONG}} -{{Cl|IF...THEN|IF}} {{Cl|NOT}} init {{Cl|THEN}} - init = -1 - MS = {{Cl|_NEWIMAGE}}(640, MenuHeight, 32) 'MenuScreen image - D = {{Cl|_DEST}}: {{Cl|_DEST}} MS - {{Cl|CLS}} , {{Cl|&H}}FFAAAAAA 'background color gray - {{Cl|_PRINTSTRING}} (20, 2), "Menu Test" 'image text - MS_HW = {{Cl|_COPYIMAGE}}(MS, 33) 'create the MenuScreen_HardWare image - {{Cl|_FREEIMAGE}} MS - {{Cl|_DEST}} D -{{Cl|END IF}} -{{Cl|_PUTIMAGE}} (0, 0)-(640, MenuHeight), MS_HW -{{Cl|_DISPLAY}} -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code adapted by Galleon}} -: ''Notes:'' When _DISPLAY is commented out, the hardware Menu Test screen portion will blink and key codes may be seen underneath. - - -{{PageSeeAlso}} -* [[_DISPLAY (function)]] -* [[_DISPLAYORDER]] -* [[_AUTODISPLAY]], [[_AUTODISPLAY (function)]] -* [[_PUTIMAGE]] -* [[PCOPY]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_DONTBLEND__111111111.txt b/internal/help/_DONTBLEND__111111111.txt deleted file mode 100644 index 901b80093..000000000 --- a/internal/help/_DONTBLEND__111111111.txt +++ /dev/null @@ -1,104 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:29}} -{{DISPLAYTITLE:_DONTBLEND}} -The [[_DONTBLEND]] statement turns off 32 bit alpha blending for the current image or screen mode where [[_BLEND]] is default. - - -{{PageSyntax}} -: [[_DONTBLEND]] [{{Parameter|imageHandle&}}] - - -{{Parameters}} -* If {{Parameter|imageHandle&}} is omitted, it is assumed to be the current [[_DEST]]ination write page. - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is not valid, an [[ERROR Codes|Invalid handle]] error will occur. -* [[_DONTBLEND]] is faster than the default [[_BLEND]]. '''You may want to disable it''', unless you really need to use it in 32 bit. -* '''32 bit screen surface backgrounds (black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.''' -* Use [[CLS]] to make a new surface background [[_ALPHA]] 255 or opaque. -* Both [[_SOURCE]] and [[_DEST]] must have [[_BLEND]] enabled, or else colors will NOT blend. - - -{{PageExamples}} -''Example 1:'' Use _DONTBLEND when you want the 32 bit screen surface to be opaque so that it covers up other backgrounds. [[CLS]] works too. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(1280, 720, 32) -'{{Cl|CLS}} -{{Cl|_DONTBLEND}} '<<< comment out to see the difference - -{{Cl|LINE}} (100, 100)-(500, 500), {{Cl|_RGB32}}(255, 255, 0), BF - -b& = SaveBackground& - -{{Cl|PRINT}} "This is just test junk" -{{Cl|PRINT}} -{{Cl|PRINT}} "Hit any key and the text should disappear, leaving us our pretty yellow box." -{{Cl|SLEEP}} -RestoreBackground b& - -{{Cl|END}} - -{{Cl|FUNCTION}} SaveBackground& -SaveBackground& = {{Cl|_COPYIMAGE}}(0) -{{Cl|END FUNCTION}} - -{{Cl|SUB}} RestoreBackground (Image {{Cl|AS}} {{Cl|LONG}}) -{{Cl|_PUTIMAGE}} , Image, 0 -{{Cl|END SUB}} -{{CodeEnd}} - - -''Example 2:'' Turning off blending to create transparency. -{{CodeStart}} - -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -alphaSprite& = {{Cl|_NEWIMAGE}}(64, 64, 32) - -{{Cl|_DONTBLEND}} alphaSprite& ' turn off alpha-blending - -'Create a simple sprite with transparency -{{Cl|_DEST}} alphaSprite& -{{Cl|FOR}} y = 0 {{Cl|TO}} 63 - {{Cl|FOR}} x = 0 {{Cl|TO}} 63 - alpha = {{Cl|SQR}}((x - 32) ^ 2 + (y - 32) ^ 2) / 32 - {{Cl|IF}} alpha < 0 {{Cl|THEN}} alpha = 0 - alpha = (1 - alpha * alpha) 'parabolic curve - {{Cl|PSET}} (x, y), {{Cl|_RGBA32}}(255, 255, 255, alpha * 255) - {{Cl|NEXT}} -{{Cl|NEXT}} - -'Make a simple background texture -{{Cl|_DEST}} 0 -{{Cl|FOR}} y = 1 {{Cl|TO}} 479 - {{Cl|FOR}} x = 0 {{Cl|TO}} 639 - {{Cl|PSET}} (x, y), {{Cl|_RGB32}}(x {{Cl|AND (boolean)|AND}} 255, y {{Cl|AND (boolean)|AND}} 255, (x {{Cl|XOR (boolean)|XOR}} y) {{Cl|AND (boolean)|AND}} 255) - {{Cl|NEXT}} -{{Cl|NEXT}} - -'Store background so we can show moveable objects on it -background& = {{Cl|_COPYIMAGE}} - -'Treat my alpha values as transparency -{{Cl|_BLEND}} alphaSprite& - -ph = 0 -{{Cl|DO}}: {{Cl|_LIMIT}} 60 - x = 320 - 250 * {{Cl|COS}}(ph) - ({{Cl|_WIDTH (function)|_WIDTH}}(alphaSprite&) \ 2) - y = 240 - 150 * {{Cl|COS}}(ph * 1.3) - ({{Cl|_HEIGHT}}(alphaSprite&) \ 2) - ph = ph + 0.03 - {{Cl|_PUTIMAGE}} , background&, 0 - {{Cl|_PUTIMAGE}} (x, y), alphaSprite&, 0 - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) -{{CodeEnd}}{{small|Code by Zom-B}} -''Explanation:'' To make the alpha image, turn alpha blending off. Otherwise PSET blends the pixel to instead of making the sprite transparent. - - -{{PageSeeAlso}} -* [[_BLEND]] -* [[_BLEND (function)]] -* [[Images]] - - -{{PageNavigation}} diff --git a/internal/help/_DONTWAIT__11111111.txt b/internal/help/_DONTWAIT__11111111.txt deleted file mode 100644 index 67be74c93..000000000 --- a/internal/help/_DONTWAIT__11111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:30}} -{{DISPLAYTITLE:_DONTWAIT}} -[[_DONTWAIT]] is used with the [[SHELL]] statement in '''QB64''' to specify that the program shouldn't wait until the external command/program is finished (which it otherwise does by default). - - -{{PageSyntax}} -: [[SHELL]] [{{KW|_DONTWAIT}}] [{{Parameter|commandLine$}}] - - -{{PageDescription}} -*Runs the command/program specified in {{Parameter|commandline$}} and lets the calling program continue at the same time in its current screen format. -*Especially useful when CMD /C or START is used in a SHELL command line to run another program. -* '''QB64''' automatically uses CMD /C or COMMAND /C when using SHELL. -* '''QB64''' program screens will not get distorted or minimized like QBasic fullscreen modes would. - - -{{PageExamples}} -{{CodeStart}} - -{{Cl|SHELL}} {{Cl|_DONTWAIT}} "notepad " + filename$ - -{{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} 5 - {{Cl|_LIMIT}} 1 - {{Cl|PRINT}} x -{{Cl|NEXT}} - -{{CodeEnd}} -(opens up notepad at the same time as counting to 5) -{{OutputStart}} - 1 - 2 - 3 - 4 - 5 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[SHELL]], [[_HIDE]] - - -{{PageNavigation}} diff --git a/internal/help/_DROPPEDFILE__11111111111.txt b/internal/help/_DROPPEDFILE__11111111111.txt deleted file mode 100644 index 291179d4d..000000000 --- a/internal/help/_DROPPEDFILE__11111111111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:31}} -{{DISPLAYTITLE:_DROPPEDFILE}} -The [[_DROPPEDFILE]] function returns the list of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled. - - -{{PageSyntax}} -''Syntax 1'' -: {{Parameter|nextItem$}} = [[_DROPPEDFILE]] - -''Syntax 2'' -: {{Parameter|nextItem$}} = [[_DROPPEDFILE]]({{Parameter|index&}}) - -{{PageDescription}} -* After [[_ACCEPTFILEDROP]] is enabled, once [[_TOTALDROPPEDFILES]] is greater than 0 the list of dropped items will be available for retrieval with [[_DROPPEDFILE]] -* When using [[_DROPPEDFILE]] to read the list sequentially (without specifying an ''index&''), an empty string ("") indicates the list is over and then [[_TOTALDROPPEDFILES]] gets reset to 0. -* When using [[_DROPPEDFILE]] with an index (which goes from 1 to [[_TOTALDROPPEDFILES]]), you must call [[_FINISHDROP]] after you finish working with the list. -* Because it returns a string, [[_DROPPEDFILE]] also accepts being followed by a string suffix ([[_DROPPEDFILE]]'''$''') -* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''. - - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example:'' Accepting files dragged from a folder and processing the list received by specifying an index. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0) - -{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality -{{Cl|PRINT}} "Drag files from a folder and drop them in this window..." - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}} - {{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}} - a$ = {{Cl|_DROPPEDFILE}}(i) - {{Cl|COLOR}} 15 - {{Cl|PRINT}} i, - {{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 2: {{Cl|PRINT}} "file", - {{Cl|ELSE}} - {{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 3: {{Cl|PRINT}} "folder", - {{Cl|ELSE}} - {{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows? - {{Cl|END IF}} - {{Cl|END IF}} - {{Cl|COLOR}} 15 - {{Cl|PRINT}} a$ - {{Cl|NEXT}} - {{Cl|_FINISHDROP}} - {{Cl|END IF}} - - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_ACCEPTFILEDROP]], [[_TOTALDROPPEDFILES]], [[_FINISHDROP]] -* [[_FILEEXISTS]], [[_DIREXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_ECHO__1111.txt b/internal/help/_ECHO__1111.txt deleted file mode 100644 index 88cb022a5..000000000 --- a/internal/help/_ECHO__1111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:32}} -{{DISPLAYTITLE:_ECHO}} -The [[_ECHO]] statement allows outputting text to a [[$CONSOLE]] window without having to alternate between [[_DEST]] pages. - - -{{PageSyntax}} -: [[_ECHO]] {''"text to output"'' | {{Parameter|textVariable$}}} - - -{{PageDescription}} -* [[_ECHO]] is a shorthand to saving current [[_DEST]], switching to [[_DEST]] [[_CONSOLE]], [[PRINT]]ing, then switching back to the previous [[_DEST]]. -* To output numbers, use the [[STR$]] function. - - -{{PageAvailability}} -* '''QB64 1.3 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -{{CodeStart}} -{{Cl|$CONSOLE}} -{{Cl|PRINT}} "this will show in the main window" -{{Cl|_ECHO}} "this will show in the console" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_DEST]] -* [[$CONSOLE]], [[_CONSOLE]] -* [[STR$]] - - -{{PageNavigation}} diff --git a/internal/help/_ENVIRONCOUNT__111111111111.txt b/internal/help/_ENVIRONCOUNT__111111111111.txt deleted file mode 100644 index 6f3084b80..000000000 --- a/internal/help/_ENVIRONCOUNT__111111111111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:37}} -{{DISPLAYTITLE:_ENVIRONCOUNT}} -The [[_ENVIRONCOUNT]] function returns the number of items (key/value pairs) currently stored in the system environment variables table. - - -{{PageSyntax}} -: {{Parameter|totalKeys&}} = [[_ENVIRONCOUNT]] - - -{{PageDescription}} -* Any changes made at runtime to the environment table are discarded when your program ends - - -{{PageAvailability}} -* '''QB64 2.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[ENVIRON$]], [[ENVIRON]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_ERRORLINE__111111111.txt b/internal/help/_ERRORLINE__111111111.txt deleted file mode 100644 index a0ee98ca5..000000000 --- a/internal/help/_ERRORLINE__111111111.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:39}} -{{DISPLAYTITLE:_ERRORLINE}} -The [[_ERRORLINE]] function returns the source code line number that caused the most recent runtime error. - - -{{PageSyntax}} -:{{Parameter|e%}} = [[_ERRORLINE]] - - -{{PageDescription}} -* Used in program error troubleshooting. -* Does not require that the program use line numbers as it counts the actual lines of code. -* The code line can be found using the QB64 IDE (Use the shortcut '''Ctrl+G''' to go to a specific line) or any other text editor such as Notepad. - - -{{PageExamples}} -''Example:'' Displaying the current program line using a simulated [[ERROR]] code. -{{CodeStart}} -{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine 'can't use {{Cl|GOSUB}} - -{{Cl|ERROR}} 250 'simulated error code - -{{Cl|END}} -DebugLine: -{{Cl|PRINT}} {{Cl|_ERRORLINE}} -{{Cl|RESUME}} {{Cl|NEXT}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[ON ERROR]] -* [[_INCLERRORLINE]], [[_INCLERRORFILE$]] -* [[ERR]], [[ERL]] -* [[ERROR]] -* [[ERROR Codes]] - - -{{PageNavigation}} diff --git a/internal/help/_ERRORMESSAGE$__111111111111$.txt b/internal/help/_ERRORMESSAGE$__111111111111$.txt deleted file mode 100644 index c4f908823..000000000 --- a/internal/help/_ERRORMESSAGE$__111111111111$.txt +++ /dev/null @@ -1,46 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:40}} -{{DISPLAYTITLE:_ERRORMESSAGE$}} -The [[_ERRORMESSAGE$]] function returns a human-readable description of the most recent runtime error, or the description of an arbitrary error code passed to it. - - -{{PageSyntax}} -:{{Parameter|e$}} = [[_ERRORMESSAGE$]] -:{{Parameter|e$}} = [[_ERRORMESSAGE$]]({{Parameter|errorCode%}}) - - -{{PageDescription}} -* Used in program error troubleshooting. -* The message returned is identical to the message shown in the dialog box that appears if your program has no error handler. See [[ERROR Codes]] for the full list of error codes and their messages. - -{{PageExamples}} -''Example 1:'' Using an error handler that ignores any error. - -{{CodeStart}} - {{Cl|ON ERROR}} {{Cl|GOTO}} Errhandler - ' Main module program error simulation code - {{Cl|ERROR}} 7 ' simulate an Out of Memory Error - PRINT "Error handled...ending program" - {{Cl|SLEEP}} 4 - {{Cl|SYSTEM}} ' end of program code - - Errhandler: 'error handler sub program line label - PRINT "Error"; {{Cl|ERR}}; "on program file line"; {{Cl|_ERRORLINE}} - PRINT "Description: "; {{Cl|_ERRORMESSAGE$}}; "." - {{Cl|BEEP}} ' warning beep - {{Cl|RESUME}} NEXT ' moves program to code following the error. -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[ON ERROR]] -* [[_ERRORLINE]] -* [[_INCLERRORLINE]], [[_INCLERRORFILE$]] -* [[ERR]], [[ERL]] -* [[ERROR]] -* [[ERROR Codes]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_EXIT_(function)__1111_(00000000).txt b/internal/help/_EXIT_(function)__1111_(00000000).txt deleted file mode 100644 index 2454cf97a..000000000 --- a/internal/help/_EXIT_(function)__1111_(00000000).txt +++ /dev/null @@ -1,68 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:42}} -{{DISPLAYTITLE:_EXIT (function)}} -The [[_EXIT]] function prevents the user from closing a program and indicates if a user has clicked the close button in the window title ('''X''' button) or used CTRL + BREAK. - - -{{PageSyntax}} -:{{Parameter|exitSignal%}} = [[_EXIT]] - - -{{PageDescription}} -* Once the [[_EXIT]] function is used, the user can no longer manually exit the program until it is ended with [[END]] or [[SYSTEM]]. -* [[_EXIT]] returns any exit requests made after the initial call as: -:: 0 = no exit request has been made since _EXIT monitoring began in the program. -:: 1 = exit attempted by clicking the window X (close) button since last function call. (Bit 0 set) -:: 2 = exit attempted with CTRL + BREAK since last call. (Bit 1 set) -:: 3 = both CTRL + BREAK and the X box have been used since last call. (Bit 0 and 1 set) -* If a return value is not 0 the program can handle an exit request at a more convenient time if necessary. -* After being read, the _EXIT value is reset to 0 so store the value when a program delays an exit request. -* '''Note: Once _EXIT has been used once, you must monitor your program by checking it for user _EXIT requests.''' -* Don't just use _EXIT once to prevent a user from exiting a program early, as that constitutes bad practice. - - -{{PageExamples}} -''Example 1:'' Using an ON TIMER check to read the _EXIT request return values. -{{CodeStart}} -q = {{Cl|_EXIT (function)|_EXIT}} 'function read prevents any program exit at start of program -{{Cl|ON TIMER (n)|ON TIMER}}(5) {{Cl|GOSUB}} quit -{{Cl|TIMER}} ON -{{Cl|PRINT}} " The Timer will check for exit request every 5 seconds." -{{Cl|PRINT}} "Click the X box and/or Ctrl - Break to see the {{Cl|_EXIT (function)|_EXIT}} return!" -{{Cl|PRINT}} " Any Key Quits" -{{Cl|PRINT}} -{{Cl|DO}}: {{Cl|_LIMIT}} 30 - ' ' simulated program loop -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -quit: -q = {{Cl|_EXIT (function)|_EXIT}} -{{Cl|IF}} q {{Cl|THEN}} {{Cl|PRINT}} q; -{{Cl|SELECT CASE}} q - {{Cl|CASE}} 1: {{Cl|PRINT}} "= X button was clicked" - {{Cl|CASE}} 2: {{Cl|PRINT}} "= Ctrl + Break keypress" - {{Cl|CASE}} 3: {{Cl|PRINT}} "= Both X and Ctrl + Break!" -{{Cl|END SELECT}} -{{Cl|RETURN}} -{{CodeEnd}} - - -''Example 2:'' Removing temporary files before closing a program upon a user's exit request. -{{CodeStart}} -x = {{Cl|_EXIT}} 'initial function call blocks a user exit -OPEN "t3mpdata.tmp" FOR APPEND AS #1 -DO -IF {{Cl|_EXIT}} THEN {{Cl|CLOSE}}: {{Cl|KILL}} "t3mpdata.tmp": {{Cl|_DELAY}} 1: {{Cl|SYSTEM}} -LOOP -{{CodeEnd}} -
{{text|Note: If you have a file named ''t3mpdata.tmp'' change the file name!|red}}
- - -{{PageSeeAlso}} -* [[SYSTEM]] -* [[END]] -* [[EXIT]] - - -{{PageNavigation}} diff --git a/internal/help/_FILEEXISTS__1111111111.txt b/internal/help/_FILEEXISTS__1111111111.txt deleted file mode 100644 index 7e2ca76b9..000000000 --- a/internal/help/_FILEEXISTS__1111111111.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:43}} -{{DISPLAYTITLE:_FILEEXISTS}} -The '''_FILEEXISTS''' function determines if a designated file name exists and returns true (-1) or false (0). - - -{{PageSyntax}} -: {{Parameter|theFileExists%}} = [[_FILEEXISTS]]({{Parameter|filename$}}) - - -{{PageDescription}} -* The {{Parameter|filename$}} parameter can be a literal or variable [[STRING|string]] value that can include a path. -* The function returns -1 when a file exists and 0 when it does not. -* The function reads the system information directly without using a [[SHELL]] procedure. -* The function will use the appropriate Operating System path separators. [[_OS$]] can determine the operating system. -* '''This function does not guarantee that a file can be accessed or opened, just that it exists.''' - - -{{PageExamples}} -{{Parameter|Example:'' Checks if a file exists before opening it. -{{CodeStart}} -{{Cl|IF}} {{Cl|_FILEEXISTS}}("mysettings.ini") THEN - {{Cl|PRINT}} "Settings file found." -{{Cl|END IF}} -{{CodeEnd}}}} - - -{{PageSeeAlso}} -* [[_DIREXISTS]], [[_OS$]] -* [[SHELL]], [[FILES]] -* [[KILL]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FINISHDROP__1111111111.txt b/internal/help/_FINISHDROP__1111111111.txt deleted file mode 100644 index ef1260059..000000000 --- a/internal/help/_FINISHDROP__1111111111.txt +++ /dev/null @@ -1,58 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:44}} -{{DISPLAYTITLE:_FINISHDROP}} -The [[_FINISHDROP]] statement resets [[_TOTALDROPPEDFILES]] and clears the [[_DROPPEDFILE]] list of items (files/folders). - - -{{PageSyntax}} -: [[_FINISHDROP]] - -{{PageDescription}} -* When using [[_DROPPEDFILE]] with an index (which goes from 1 to [[_TOTALDROPPEDFILES]]), you must call [[_FINISHDROP]] after you finish working with the list in order to prepare for the next drag/drop operation. -* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''. - - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example:'' Accepting files dragged from a folder and processing the list received by specifying an index. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0) - -{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality -{{Cl|PRINT}} "Drag files from a folder and drop them in this window..." - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}} - {{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}} - a$ = {{Cl|_DROPPEDFILE}}(i) - {{Cl|COLOR}} 15 - {{Cl|PRINT}} i, - {{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 2: {{Cl|PRINT}} "file", - {{Cl|ELSE}} - {{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}} - {{Cl|COLOR}} 3: {{Cl|PRINT}} "folder", - {{Cl|ELSE}} - {{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows? - {{Cl|END IF}} - {{Cl|END IF}} - {{Cl|COLOR}} 15 - {{Cl|PRINT}} a$ - {{Cl|NEXT}} - {{Cl|_FINISHDROP}} 'If _FINISHDROP isn't called here then _TOTALDROPPEDFILES never gets reset. - {{Cl|END IF}} - - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_ACCEPTFILEDROP]], [[_TOTALDROPPEDFILES]], [[_DROPPEDFILE]] -* [[_FILEEXISTS]], [[_DIREXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_FLOAT__11111.txt b/internal/help/_FLOAT__11111.txt deleted file mode 100644 index a5ae80be3..000000000 --- a/internal/help/_FLOAT__11111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:46}} -{{DISPLAYTITLE:_FLOAT}} -'''_FLOAT''' numerical values offer the maximum floating-point decimal precision available using '''QB64'''. - - -{{PageSyntax}} -::[[DIM]] {{Parameter|variable}} AS [[_FLOAT]] - - -{{PageDescription}} -* '''QB64''' always allocates 32 bytes to store this value. -* It is safe to assume this value is at least as precise as [[DOUBLE]]. -* Under the current implementation it is stored in a 10-byte floating point variable. -* [[_FLOAT]] variables can also use the ## variable name type suffix. -* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision. -* According to [http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html IEEE-754] this can store a value of up to 1.1897E+4932 compared to a DOUBLE which goes up to 1.7976E+308. -* Floating decimal point numerical values cannot be [[_UNSIGNED]]. -* Values can be converted to 32 byte [[ASCII]] strings using [[_MK$]] and back with [[_CV]]. -* '''When a variable has not been assigned or has no type suffix, the value defaults to [[SINGLE]].''' - - -{{PageSeeAlso}} -* [[DOUBLE]], [[SINGLE]] -* [[_MK$]], [[_CV]] -* [[_DEFINE]], [[DIM]] -* [[PDS (7.1) Procedures#CURRENCY|CURRENCY]] -* [[Variable Types]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FONTHEIGHT__1111111111.txt b/internal/help/_FONTHEIGHT__1111111111.txt deleted file mode 100644 index 5fe4fe9cf..000000000 --- a/internal/help/_FONTHEIGHT__1111111111.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:49}} -{{DISPLAYTITLE:_FONTHEIGHT}} -The [[_FONTHEIGHT]] function returns the font height of a font handle created by [[_LOADFONT]]. - - - -{{PageSyntax}} -:{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})] - - -{{PageDescription}} -* Returns the height of the last font used if a handle is not designated. -* If no font is set it returns the current screen mode's text block height. - - -{{PageExamples}} -''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes. -{{CodeStart}} -DO - {{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: ", scr$ - mode% = {{Cl|VAL}}(scr$) -{{Cl|LOOP}} {{Cl|UNTIL}} mode% > 0 -{{Cl|SELECT CASE}} mode% - {{Cl|CASE}} 1, 2, 7 {{Cl|TO}} 13: {{Cl|SCREEN}} mode% - {{Cl|CASE}} 256, 32: {{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, mode%) - {{Cl|CASE ELSE}}: {{Cl|PRINT}} "Invalid mode selected!": {{Cl|END}} -{{Cl|END SELECT}} - -{{Cl|INPUT}} "Enter first name of TTF font to use or hit enter for text block size: ", TTFont$ -{{Cl|IF...THEN|IF}} {{Cl|LEN}}(TTFont$) {{Cl|THEN}} {{Cl|INPUT}} "Enter font height: ", hi$ -height& = {{Cl|VAL}}(hi$) -{{Cl|IF...THEN|IF}} height& > 0 {{Cl|THEN}} - fnt& = {{Cl|_LOADFONT}}("C:\Windows\Fonts\" + TTFont$ + ".ttf", height&, style$) - {{Cl|IF...THEN|IF}} fnt& <= 0 {{Cl|THEN}} {{Cl|PRINT}} "Invalid Font handle!": {{Cl|END}} - {{Cl|_FONT}} fnt& -{{Cl|END IF}} - -TextSize wide&, high& 'get the font or current screen mode's text block pixel size - -{{Cl|_PRINTSTRING}} (20, 100), "Block size = " + {{Cl|CHR$}}(1) + {{Cl|STR$}}(wide&) + " X" + {{Cl|STR$}}(high&) + " " + {{Cl|CHR$}}(2) - -{{Cl|END}} - -{{Cl|SUB}} TextSize (TextWidth&, TextHeight&) -TextWidth& = {{Cl|_PRINTWIDTH}}("W") 'measure width of one font or text character -TextHeight& = {{Cl|_FONTHEIGHT}} 'can measure normal text block heights also -{{Cl|END SUB}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_FONTWIDTH]], [[_FONT]] -* [[_PRINTWIDTH]], [[_PRINTSTRING]] -* [[SCREEN]], [[_LOADFONT]] -* [[Text Using Graphics]] (Demo) - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FONTWIDTH__111111111.txt b/internal/help/_FONTWIDTH__111111111.txt deleted file mode 100644 index 8f135726f..000000000 --- a/internal/help/_FONTWIDTH__111111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:50}} -{{DISPLAYTITLE:_FONTWIDTH}} -The [[_FONTWIDTH]] function returns the font width of a MONOSPACE font handle created by [[_LOADFONT]]. - - -{{PageSyntax}} -:{{Parameter|pixelWidth%}} = [[_FONTWIDTH]][({{Parameter|fontHandle&}})] - - -* Returns the character width of the last font used if a handle is not specified. -* '''Variable width fonts always return {{Parameter|pixelWidth%}} = 0.''' Even fixed width fonts return 0 unless the [[LOADFONT|"MONOSPACE"]] style option is used. -* QB64 '''version 1.000 and up''' can load a variable width font as monospaced with the [[LOADFONT|"MONOSPACE"]] style parameter. -* The font width is generally 3/4 of the [[_FONTHEIGHT]] specified when loading the font. -* In '''graphics''' [[SCREEN (statement)|screen]] modes, [[_PRINTWIDTH]] can return the total '''pixel width''' of a literal or variable [[STRING|string]] of text. - - -{{PageSeeAlso}} -*[[_FONTHEIGHT]] -*[[_FONT]] -* [[_LOADFONT]] -* [[_PRINTWIDTH]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FONT_(function)__1111_(00000000).txt b/internal/help/_FONT_(function)__1111_(00000000).txt deleted file mode 100644 index 47731121d..000000000 --- a/internal/help/_FONT_(function)__1111_(00000000).txt +++ /dev/null @@ -1,20 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:48}} -{{DISPLAYTITLE:_FONT (function)}} -The [[_FONT]] function retrieves the font handle from the specified image handle or the current [[_DEST]]ination page's font. - - -{{PageSyntax}} -:{{Parameter|fontHandle&}} = [[_FONT]][({{Parameter|imageHandle&}})] - - -{{PageDescription}} -*imageHandle& is the handle to the image which you want to retrieve the font from. If not specified, it is assumed to be the current [[_DEST]]ination page. - - -{{PageSeeAlso}} -*[[_LOADFONT]], [[_FONT]] -*[[_DEST]] - - -{{PageNavigation}} diff --git a/internal/help/_FONT__1111.txt b/internal/help/_FONT__1111.txt deleted file mode 100644 index e2f75fc13..000000000 --- a/internal/help/_FONT__1111.txt +++ /dev/null @@ -1,83 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:47}} -{{DISPLAYTITLE:_FONT}} -The [[_FONT]] statement sets the current [[_LOADFONT]] function font handle to be used by [[PRINT]]. - - -{{PageSyntax}} -: [[_FONT]] {{Parameter|fontHandle&}}[, {{Parameter|imageHandle&}}] - - -{{Parameters}} -* {{Parameter|fontHandle&}} is the handle retrieved from [[_LOADFONT]] function, the [[_FONT (function)|_FONT]] function, or a predefined handle. -* If the image handle is omitted the current image [[_DEST]]ination is used. Zero can designate the current program [[SCREEN]]. - - -{{PageDescription}} -* Predefined '''QB64''' font handle numbers can be used before freeing a font: -**'''_FONT 8 ''' - default font for [[SCREEN (statement)|SCREEN]] 1, 2, 7, 8 or 13 -**'''_FONT 14''' - default font for [[SCREEN (statement)|SCREEN]] 9 or 10 -**'''_FONT 16''' - default font for [[SCREEN (statement)|SCREEN]] 0 ([[WIDTH]] 80, 25 text only), 11 or 12 -**'''_FONT 9, 15''' and '''17''' are the double width versions of 8, 14 and 16 respectively in text '''SCREEN 0 only'''. -* [[Unicode]] characters can be assigned to a monospace font that contains those unicode characters using the [[_MAPUNICODE]] TO [[ASCII]] mapping statement. The optional '''IME cyberbit.ttf''' font included with QB64 can also be used. -* Can alpha blend a font with a background screen created by [[_NEWIMAGE]] in 32 bit color. -* '''Check for valid handle values greater than 0 before using or freeing font handles.''' -* Free '''unused''' font handles with [[_FREEFONT]]. Freeing invalid handles will create an [[ERROR Codes|"illegal function call"]] error. -* '''NOTE: SCREEN 0 can only use one font type and style per viewed SCREEN page. Font size may also affect the window size.''' - - -{{PageExamples}} -''Example:'' Previewing a font in SCREEN 0. A different true type font can be substituted below. -{{CodeStart}} - -fontpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path. -{{Cl|DO}}: {{Cl|CLS}} - {{Cl|DO}} - style$ = "MONOSPACE" - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter A FONT Size 8 {{Cl|TO}} 25: ", fontsize% - {{Cl|LOOP}} {{Cl|UNTIL}} fontsize% > 7 and fontsize% < 26 - {{Cl|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter (0) for REGULAR {{Cl|OR}} (1) for ITALIC FONT: ", italic% - {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1 - {{Cl|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter (0) for REGULAR {{Cl|OR}} (1) for BOLD FONT: ", bold% - {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1 - {{Cl|IF}} italic% = 1 {{Cl|THEN}} style$ = style$ + ", ITALIC" - {{Cl|IF}} bold% = 1 then style$ = style$ + ", BOLD" - - {{Cl|GOSUB}} ClearFont - font& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$) - {{Cl|_FONT|_FONT }}font& - {{Cl|PRINT}} - {{Cl|PRINT}} "This is your LUCON font! Want to try another STYLE?(Y/N): "; - {{Cl|DO}}: {{Cl|SLEEP}}: K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}): {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "Y" {{Cl|OR}} K$ = "N" -{{Cl|LOOP}} {{Cl|UNTIL}} K$ = "N" -{{Cl|GOSUB}} ClearFont - -{{Cl|PRINT}} "This is the QB64 default {{Cl|_FONT|_FONT }}16!" -{{Cl|END}} - -ClearFont: -{{Cl|IF}} font& > 0 {{Cl|THEN}} - {{Cl|_FONT|_FONT }}16 'select inbuilt 8x16 default font - {{Cl|_FREEFONT}} font& -{{Cl|END IF}} -{{Cl|RETURN}} - -{{CodeEnd}} -'''NOTE:''' [[ENVIRON$]]("SYSTEMROOT") returns a string value of: "C:\WINDOWS". Add the "\FONTS\" folder and the '''.TTF''' font file name. - - - - -{{PageSeeAlso}} -* [[_FONT (function)]] -* [[_LOADFONT]], [[_FREEFONT]] -* [[Unicode]], [[_MAPUNICODE]] -* [[Windows_Libraries#Font_Dialog_Box|Windows Font Dialog Box]] - - -{{PageNavigation}} diff --git a/internal/help/_FREEFONT__11111111.txt b/internal/help/_FREEFONT__11111111.txt deleted file mode 100644 index ed2e021ea..000000000 --- a/internal/help/_FREEFONT__11111111.txt +++ /dev/null @@ -1,103 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:51}} -{{DISPLAYTITLE:_FREEFONT}} -The [[_FREEFONT]] statement frees a font handle that was created by [[_LOADFONT]]. - - - -{{PageSyntax}} -:[[_FREEFONT]] ({{Parameter|fontHandle&}}) - - -{{PageDescription}} -* Unloads fonts that are no longer in use or needed in order to free program memory and resources. -* You cannot free a font which is in use. Change the font to a QB64 default font size before freeing the handle (see example below). -* Predefined '''QB64''' font handle numbers can be used before freeing a font: -**'''_FONT 8 ''' - default font for [[SCREEN (statement)|SCREEN]] 1, 2, 7, 8 or 13 -**'''_FONT 14''' - default font for [[SCREEN (statement)|SCREEN]] 9 or 10 -**'''_FONT 16''' - default font for [[SCREEN (statement)|SCREEN]] 0 ({{KW|WIDTH}} 80, 25 text only), 11 or 12 -**'''_FONT 9, 15''' and '''17''' are the double width versions of 8, 14 and 16 respectively in text '''SCREEN 0'''. -* If the font handle is invalid (equals -1 or 0), an [[ERROR Codes|error]] will occur. '''Check handle values before using or freeing them.''' -* You cannot free inbuilt/default QB64 fonts nor do they ever need freed. - - -{{PageExamples}} -''Example 1:'' Previews and creates a file list of valid MONOSPACE TTF fonts by checking the [[_LOADFONT]] handle values. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -path$ = "C:\WINDOWS\Fonts\" 'path to the font folder -{{Cl|SHELL}} {{Cl|_HIDE}} "DIR /b " + path$ + "\*.ttf > TTFonts.INF" -style$ = "monospace" 'set style to MONOSPACE -{{Cl|OPEN}} "TTFonts.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 'list of TTF fonts only -{{Cl|OPEN}} "TTFMono.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #2 'will hold list of valid MONOSPACE fonts - -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1): found = found + 1 - {{Cl|LINE INPUT (file statement)|LINE INPUT}} #1, font$ - f& ={{Cl|_LOADFONT}}(path$ + font$, 30, style$) - {{Cl|IF}} f& > 0 {{Cl|THEN}} 'check for valid handle values > 0 - OK = OK + 1 - {{Cl|PRINT (file statement)|PRINT}} #2, font$ - {{Cl|_FONT}} f& 'will create error if handle is invalid! - {{Cl|PRINT}} "Hello World!" - {{Cl|PRINT}}: {{Cl|PRINT}}: {{Cl|PRINT}} font$; f& - {{Cl|PRINT}} "Press any key." - K$ = {{Cl|INPUT$}}(1) - {{Cl|_FONT}} 16 'use QB64 default font to free tested font - {{Cl|_FREEFONT}} f& 'returns an error if handle <= 0! - {{Cl|CLS}} - {{Cl|END IF}} - {{Cl|PRINT}} -{{Cl|IF}} K$ = {{Cl|CHR$}}(27) {{Cl|THEN}} {{Cl|EXIT DO}} -{{Cl|LOOP}} -{{Cl|CLOSE}} -{{Cl|PRINT}}: {{Cl|PRINT}}: {{Cl|PRINT}} "Found"; found; "TTF files,"; OK; "can use Monospace," -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -{{OutputStart}} -Found 106 TTF files, 13 can use Monospace. -{{OutputEnd}} - - -''Example 2:'' Using a _FREEFONT sub-procedure. -{{CodeStart}} -fontpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") + "\fonts\lucon.ttf" -style$ = "MONOSPACE, ITALIC, BOLD" -fontsize% = 20 - -{{Cl|_FONT|_FONT }}16 -{{Cl|PRINT}} -{{Cl|PRINT}} "This is the QB64 default {{Cl|_FONT|_FONT }}16! To change, press any key!" -{{Cl|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|GOSUB}} ClearFont 'call will not free anything if font& = 0 - -font& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$) -{{Cl|IF}} font > 0 THEN {{Cl|_FONT|_FONT}} font& 'NEVER try to load a font value less than 1! -{{Cl|PRINT}} -{{Cl|PRINT}} "A NEW {{Cl|_FONT|_FONT}} style. To change to default, press any key!" -{{Cl|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|GOSUB}} ClearFont 'call will free a valid font handle from memory - -{{Cl|END}} - -ClearFont: -{{Cl|IF}} font& > 0 {{Cl|THEN}} - {{Cl|_FONT|_FONT }}16 'change used font to the QB64 8x16 default font - {{Cl|_FREEFONT}} font& - {{Cl|PRINT}}: {{Cl|PRINT}} "The previous font was freed with _FREEFONT!" -{{Cl|ELSE}} : {{Cl|PRINT}}: {{Cl|PRINT}} "_FREEFONT was not used!" -{{Cl|END IF}} -{{Cl|RETURN}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_FONT]] -* [[_LOADFONT]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FREEIMAGE__111111111.txt b/internal/help/_FREEIMAGE__111111111.txt deleted file mode 100644 index 195e4252a..000000000 --- a/internal/help/_FREEIMAGE__111111111.txt +++ /dev/null @@ -1,44 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:52}} -{{DISPLAYTITLE:_FREEIMAGE}} -The '''_FREEIMAGE''' statement releases the designated file image created by the [[_LOADIMAGE]], [[_NEWIMAGE]] or [[_COPYIMAGE]] functions from memory when they are no longer needed. - - -{{PageSyntax}} -: [[_FREEIMAGE]] [{{Parameter|handle&}}] - - -{{PageDescription}} -*If {{Parameter|handle&}} is omitted, the current destination image is freed from memory. -*Freeing the destination image or source image will result in the display page being selected instead. -*'''Invalid image handle values of -1 or 0 cannot be freed or an [[ERROR Codes|"Illegal Function" error]] will occur.''' Check the handle value first. -* '''[[SCREEN]] modes in use cannot be freed or an [[ERROR Codes|"Illegal Function" error]] will occur.''' Change SCREEN modes before freeing. -*Once a specific image handle is no longer used or referenced by your program, it can be freed with [[_FREEIMAGE]]. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' -* '''It is important to free unused or unneeded images with [[_FREEIMAGE]] to prevent memory overflow errors.''' -* '''Do not try to free image handles currently being used as the active [[SCREEN]]. Change screen modes first.''' - - -{{PageExamples}} -''Example:'' Loading a program splash screen and freeing image when no longer necessary: -{{CodeStart}} -s& = {{Cl|_LOADIMAGE}}("SPLASH.BMP",32) 'load 32 bit(24 BPP) image -{{Cl|IF}} s& < -1 THEN {{Cl|SCREEN (statement)|SCREEN}} s& 'use image as a 32 bit SCREEN -{{Cl|_DELAY}} 6 'display splash screen for 6 seconds -{{Cl|SCREEN (statement)|SCREEN}} 0 'MUST change screen mode before freeing a SCREEN image! -{{Cl|IF}} s& < -1 THEN {{Cl|_FREEIMAGE}} s& 'handle value MUST be less than -1 or error! -{{Cl|CLS}} -{{CodeEnd}} -: ''Note:'' A valid image file name must be used by [[_LOADIMAGE]] or the invalid handle memory value will not need to be freed. - - -{{PageSeeAlso}} -* [[_NEWIMAGE]] -* [[_LOADIMAGE]] -* [[_SCREENIMAGE]] -* [[_COPYIMAGE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FREETIMER__111111111.txt b/internal/help/_FREETIMER__111111111.txt deleted file mode 100644 index 2f0490ac7..000000000 --- a/internal/help/_FREETIMER__111111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:54}} -{{DISPLAYTITLE:_FREETIMER}} -The [[_FREETIMER]] function returns a free [[TIMER]] number for multiple [[ON TIMER(n)]] events. - - -{{PageSyntax}} -: {{Parameter|timerhandle%}} = [[_FREETIMER]] - - -{{PageDescription}} -* QB64 can use an unlimited number of ON TIMER (number, seconds!) event [[INTEGER]] values at once. -* Every time _FREETIMER is called the [[INTEGER]] value returned will increase by one, starting at 1, whether it is used or not. -* Store multiple returns in different variable names to refer to separate events later. - - -{{PageSeeAlso}} -* [[ON TIMER(n)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FULLSCREEN_(function)__1111111111_(00000000).txt b/internal/help/_FULLSCREEN_(function)__1111111111_(00000000).txt deleted file mode 100644 index 42a30fedc..000000000 --- a/internal/help/_FULLSCREEN_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,110 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:56}} -{{DISPLAYTITLE:_FULLSCREEN (function)}} -The [[_FULLSCREEN]] function returns the present full screen mode setting of the screen window. - - -{{PageSyntax}} -: {{Parameter|full%}} = [[_FULLSCREEN (function)|_FULLSCREEN]] - - -{{PageDescription}} -* ''Function returns:'' -** 0 = _OFF (any positive non-0 value means fullscreen is on) -** 1 = _STRETCH -** 2 = _SQUAREPIXELS -* It '''cannot''' be assumed that calling [[_FULLSCREEN]] will succeed. It cannot be assumed that the type of full screen will match the requested one. '''Always check the [[_FULLSCREEN (function)]] return in your programs.''' -* '''Warning:''' Despite your software, the user's hardware, drivers and monitor may not function in some modes. Thus, it is highly recommended that you manually confirm with the user whether the switch to full screen was successful. This can be done "quietly" in some cases by getting the user to click on a button on screen with their mouse or press an unusual key. If the user does not respond after about 8 seconds, switch them back to windowed mode. -
'''Using large fonts with [[_FULLSCREEN]] can cause monitor or Windows Desktop problems or kill a program.'''
- - -{{PageExamples}} -''Example:'' Shows how fonts and the _FULLSCREEN mode can resize a program window. -{{CodeStart}} -{{Cl|CLS}} -fontpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path. -f& = {{Cl|_FONT (function)|_FONT}}: defaultf& = f& -{{Cl|DO}} - {{Cl|INPUT}} "1) DEFAULT 2) SIZE WINDOW 3) FULL SCREEN 4) FULL STRETCHED Q) QUIT: ", winmode$ - - {{Cl|IF}} {{Cl|UCASE$}}(winmode$) = "Q" {{Cl|THEN}} {{Cl|EXIT DO}} - - style$ = "MONOSPACE" - - {{Cl|SELECT CASE}} winmode$ - {{Cl|CASE}} "1" - full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode - {{Cl|IF}} full <> 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF - {{Cl|GOSUB}} ChangeFont - - {{Cl|CASE}} "2" - {{Cl|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter a FONT SIZE 5 to 25: ", fontsize% - {{Cl|LOOP}} {{Cl|UNTIL}} fontsize% > 4 {{Cl|AND (boolean)|AND}} fontsize% < 26 - - {{Cl|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter (0) for REGULAR or (1) for ITALIC FONT: ", italic% - {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1 - - {{Cl|DO}} - {{Cl|PRINT}} - {{Cl|INPUT}} "Enter (0) for REGULAR or (1) for BOLD FONT: ", bold% - {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1 - - {{Cl|IF}} italic% = 1 {{Cl|THEN}} style$ = style$ + ", ITALIC" - {{Cl|IF}} bold% = 1 {{Cl|THEN}} style$ = style$ + ", BOLD" - full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode - {{Cl|IF}} full <> 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF - {{Cl|GOSUB}} ChangeFont - - {{Cl|CASE}} "3" - {{Cl|GOSUB}} ChangeFont - {{Cl|_FULLSCREEN}} _SQUAREPIXELS - {{Cl|GOSUB}} CheckFull - - {{Cl|CASE}} "4" - {{Cl|GOSUB}} ChangeFont - {{Cl|_FULLSCREEN}} _STRETCH - {{Cl|GOSUB}} CheckFull - - {{Cl|END SELECT}} - - {{Cl|PRINT}}: {{Cl|PRINT}} "_FullScreen mode ="; {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} - {{Cl|PRINT}} -{{Cl|LOOP}} -{{Cl|GOSUB}} ChangeFont -{{Cl|END}} - -CheckFull: '<<<<<<<<<<<<<< turn off full screen if function returns 0! -full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode -{{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _{{Cl|OFF}}: {{Cl|SOUND}} 100, .75 -{{Cl|RETURN}} - -ChangeFont: -{{Cl|IF}} winmode$ <> "2" {{Cl|THEN}} - {{Cl|_FONT}} 16 'select inbuilt 8x16 default font - currentf& = {{Cl|_FONT (function)|_FONT}} -{{Cl|ELSE}} - currentf& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$) - {{Cl|_FONT}} currentf& -{{Cl|END IF}} - -{{Cl|IF}} currentf& <> f& {{Cl|AND (boolean)|AND}} f& <> defaultf& {{Cl|THEN}} {{Cl|_FREEFONT}} f& -f& = currentf& -{{Cl|RETURN}} -{{CodeEnd}} - -''Explanation:'' The '''_FULLSCREEN''' function can avoid screen display and monitor problems when used to monitor the success of the full screen operation. If a full screen mode is '''not''' achieved (the function will return 0), '''call [[_FULLSCREEN]] OFF''' - - -{{PageSeeAlso}} -* [[_FULLSCREEN]] (statement) -* [[_ALLOWFULLSCREEN]] -* [[_SCREENMOVE]], [[_SCREENX]], [[_SCREENY]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_FULLSCREEN__1111111111.txt b/internal/help/_FULLSCREEN__1111111111.txt deleted file mode 100644 index 44b9e94c5..000000000 --- a/internal/help/_FULLSCREEN__1111111111.txt +++ /dev/null @@ -1,137 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:55}} -{{DISPLAYTITLE:_FULLSCREEN}} -The [[_FULLSCREEN]] statement attempts to make the program window fullscreen. - - -{{PageSyntax}} -:[[_FULLSCREEN]] [''_STRETCH | _SQUAREPIXELS| _OFF''][, ''_SMOOTH''] - - -{{Parameters}} -* {{Parameter|_STRETCH}} default first choice attempts to mimic QBasic's full screens if possible. [[_FULLSCREEN (function)]] returns 1. -* {{Parameter|_SQUAREPIXELS}} alternate choice enlarges the pixels into squares on some monitors. [[_FULLSCREEN (function)|_FULLSCREEN]] returns 2 -* {{Parameter|_OFF}} turns _FULLSCREEN off after full screen has been enabled. [[_FULLSCREEN (function)]] returns 0. -* Second optional parameter ''_SMOOTH'' applies antialiasing to the stretched screen. - - -{{PageDescription}} -* '''Set the [[SCREEN]] mode and text [[WIDTH]] when necessary first.''' Otherwise there may be desktop view issues. -* _FULLSCREEN with no parameters chooses {{Parameter|_STRETCH}} or {{Parameter|_SQUAREPIXELS}} (prioritizes _STRETCH to mimic QBasic if possible) -* '''Check the fullscreen mode with the [[_FULLSCREEN (function)|_FULLSCREEN]] function in your programs when a method is required. -* It is advisable to get [[INPUT|input]] from the user to confirm that fullscreen was completed or there were possible monitor incompatibilities. -* If fullscreen is '''not confirmed''' with a [[_FULLSCREEN (function)]] return '''greater than 0''', then disable with '''_FULLSCREEN _OFF'''. -* '''NOTE:''' _FULLSCREEN can also be affected by custom [[_FONT]] size settings and make program screens too large. - - -{{PageExamples}} -''Example 1:'' Setting the screen mode first prevents enlargement of the desktop before the program window is set: -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|_FULLSCREEN}} -{{Cl|IF...THEN|IF}} {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF 'check that a full screen mode initialized - -{{Cl|LINE}} (100, 100)-(500, 400), 13, BF -{{CodeEnd}} - - -''Example 2:'' How fonts and _FULLSCREEN affect the program's window size. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 0 -{{Cl|DO}} - {{Cl|PRINT}} - {{Cl|LINE INPUT}} "Enter MODE 1) ENLARGE WINDOW 2) FULL _SQUAREPIXELS 3) FULL _STRETCH: ", WMODE$ - {{Cl|PRINT}} - {{Cl|IF}} WMODE$ = "1" {{Cl|THEN}} {{Cl|INPUT (file mode)|INPUT}} "SIZE 1 {{Cl|TO}} 9: ", ENLARGE% - - {{Cl|SELECT CASE}} ENLARGE% - {{Cl|CASE}} 1, 2, 3, 4, 5: STYLE$ = "MONOSPACE, BOLD" - {{Cl|CASE}} 6, 7, 8, 9: STYLE$ = "MONOSPACE" - {{Cl|CASE ELSE}}: STYLE$ = "MONOSPACE" - {{Cl|END SELECT}} - - {{Cl|SELECT CASE}} WMODE$ - {{Cl|CASE}} "1" - full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} - {{Cl|IF}} full > 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF - f& = {{Cl|_LOADFONT}}("c:\windows\fonts\lucon.ttf", 13 + ENLARGE%, STYLE$) - {{Cl|_FONT}} f& - {{Cl|CASE}} "2" - {{Cl|_FULLSCREEN}} _SQUAREPIXELS - full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} - {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} FCHECK - {{Cl|CASE}} "3" - {{Cl|_FULLSCREEN}} _STRETCH - full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} - {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} FCHECK - {{Cl|END SELECT}} - - mode = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} - {{Cl|PRINT}} - {{Cl|PRINT}} "_FULLSCREEN mode ="; mode, - {{Cl|PRINT}} "PRESS ESC {{Cl|TO}} {{Cl|END}} {{Cl|OR}} ENTER {{Cl|TO}} CONTINUE..." - - {{Cl|DO}}: {{Cl|SLEEP}}: B$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(13) {{Cl|OR}} B$ = {{Cl|CHR$}}(27) - - {{Cl|GOSUB}} ClearFont - -{{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(27) -ClearFont -{{Cl|END}} - -FCHECK: -Z3 = timer -{{Cl|DO}} -{{Cl|IF}} {{Cl|TIMER (statement)|TIMER }}< Z3 {{Cl|THEN}} Z3 = Z3 - {{Cl|TIMER}} -{{Cl|IF}} {{Cl|TIMER (statement)|TIMER }}- Z3 > 4 {{Cl|THEN}} {{Cl|EXIT DO}} -{{Cl|LOOP}} -full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} -{{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _{{Cl|OFF}}: {{Cl|SOUND}} 100, .75 -{{Cl|RETURN}} - -ClearFont: -{{Cl|IF}} f& > 0 {{Cl|THEN}} - {{Cl|_FONT}} 16 'select inbuilt 8x16 default font - {{Cl|_FREEFONT}} f& -{{Cl|END IF}} -{{Cl|RETURN}} - -{{CodeEnd}} - - -''Example 3:'' Testing all fullscreen methods. -{{CodeStart}} -{{Cl|PRINT}} "Hello, world!" -{{Cl|PRINT}} "Hit 1 for windowed mode; -{{Cl|PRINT}} " 2 for _STRETCH" -{{Cl|PRINT}} " 3 for _SQUAREPIXELS" -{{Cl|PRINT}} " 4 for _STRETCH, _SMOOTH" -{{Cl|PRINT}} " 5 for _SQUAREPIXELS, _SMOOTH" -{{Cl|DO}} - k$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} {{Cl|VAL}}(k$) - {{Cl|CASE}} 1 - {{Cl|_FULLSCREEN}} _OFF - {{Cl|CASE}} 2 - {{Cl|_FULLSCREEN}} _STRETCH - {{Cl|CASE}} 3 - {{Cl|_FULLSCREEN}} _SQUAREPIXELS - {{Cl|CASE}} 4 - {{Cl|_FULLSCREEN}} _STRETCH, _SMOOTH - {{Cl|CASE}} 5 - {{Cl|_FULLSCREEN}} _SQUAREPIXELS, _SMOOTH - {{Cl|END}} {{Cl|SELECT}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_EXIT (function)|_EXIT}} -{{Cl|SYSTEM}}{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_FULLSCREEN (function)]] -* [[_ALLOWFULLSCREEN]] -* [[_FONT]], [[SCREEN]] -* [[_SCREENIMAGE]] -* [[_SCREENMOVE]], [[_SCREENX]], [[_SCREENY]] - - -{{PageNavigation}} diff --git a/internal/help/_G2D__121.txt b/internal/help/_G2D__121.txt deleted file mode 100644 index 3e4a483ce..000000000 --- a/internal/help/_G2D__121.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:57}} -{{DISPLAYTITLE:_G2D}} -The [[_G2D]] function converts a '''gradient''' value into a '''degree''' value. - - -{{PageSyntax}} -: {{Parameter|result}} = [[_G2D]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Gradients into Degree. -{{CodeStart}} -INPUT "Give me an angle in Gradients ", D -R = _G2D(D) -PRINT "That angle in Degrees is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Gradients 60 -That angle in Degrees is 54 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]], [[_D2R]] -* [[_G2R]] -* [[_R2D]], [[_R2G]] - - -{{PageNavigation}} diff --git a/internal/help/_G2R__121.txt b/internal/help/_G2R__121.txt deleted file mode 100644 index ed67a0ac2..000000000 --- a/internal/help/_G2R__121.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:58}} -{{DISPLAYTITLE:_G2R}} -The [[_G2R]] function converts a '''gradient''' value into a '''radian''' value. - - -{{PageSyntax}} -: {{Parameter|result}} = [[_G2R]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Gradient into Radians. -{{CodeStart}} -INPUT "Give me an angle in Gradient ", D -R = _G2R(D) -PRINT "That angle in Radians is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Gradient 60 -That angle in Radians is .9424778 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]], [[_D2R]] -* [[_G2D]], [[_G2R]] -* [[_R2D]], [[_R2G]] - - -{{PageNavigation}} diff --git a/internal/help/_GLRENDER__11111111.txt b/internal/help/_GLRENDER__11111111.txt deleted file mode 100644 index 8fe3181da..000000000 --- a/internal/help/_GLRENDER__11111111.txt +++ /dev/null @@ -1,21 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:37:59}} -{{DISPLAYTITLE:_GLRENDER}} - -{{PageSyntax}} -:'''_GLRENDER '''''mode'' - - -{{PageParameters}} - -Mode can be: -* _BEHIND - renders OpenGL context behind the software rendering -* _ONTOP - renders OpenGL context on the top of the software rendering [default] -* _ONLY - renders OpenGL context only - - -''See also:'' -* [[Hardware images]] - - -{{PageNavigation}} diff --git a/internal/help/_GREEN32__1111132.txt b/internal/help/_GREEN32__1111132.txt deleted file mode 100644 index 0e6e9b132..000000000 --- a/internal/help/_GREEN32__1111132.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:01}} -{{DISPLAYTITLE:_GREEN32}} -The [[_GREEN32]] function returns the green component intensity of a 32-bit image or surface color. - - -{{PageSyntax}} -: green32color& = [[_GREEN32]]({{Parameter|rgbaColor&}}) - - -{{PageDescription}} -* {{Parameter|rgbaColor&}} is the 32-bit ''RGBA'' color value to retrieve the green component intensity value from. -* ''RGBA'' color values are returned by the [[_PALETTECOLOR (function)|_PALETTECOLOR]], [[POINT]], [[_RGB]], [[_RGB32]], [[_RGBA]] or [[_RGBA32]] functions. -* [[LONG]] intensity values returned range from 0 (no intensity, not present) to 255 (full intensity). - - -{{PageExamples}} -* See example in [[POINT]]. - - -{{PageSeeAlso}} -* [[_RED32]], [[_BLUE32]] -* [[_RGB32]], [[_GREEN]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_GREEN__11111.txt b/internal/help/_GREEN__11111.txt deleted file mode 100644 index 9c25ff04c..000000000 --- a/internal/help/_GREEN__11111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:00}} -{{DISPLAYTITLE:_GREEN}} -The [[_GREEN]] function returns the palette index or the green component intensity of a 32-bit image color. - - -{{PageSyntax}} -: {{Parameter|greenIntensity&}} = [[_GREEN]]({{Parameter|rgbaColorIndex&}}[, {{Parameter|imageHandle&}}]) - - -{{PageDescription}} -* {{Parameter|rgbaColorIndex&}} is the ''RGBA'' color value or palette index of the color to retrieve the green component intensity from. -* The [[LONG]] intensity value returned ranges from 0 (no intensity, not present) to 255 (full intensity). -* If {{Parameter|imageHandle&}} specifies a 32-bit color image, {{Parameter|rgbaColorIndex&}} is interpreted as a 32-bit ''RGBA'' color value. -* If {{Parameter|imageHandle&}} specifies an image that uses a palette, {{Parameter|rgbaColorIndex&}} is interpreted as a palette index. -* If {{Parameter|imageHandle&}} is not specified, it is assumed to be the current write page (See [[_DEST]]). -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error will occur. -* If {{Parameter|rgbaColorIndex&}} is outside the range of valid indexes for a given image mode, an [[ERROR Codes|illegal function call]] error occurs. -* Uses index parameters passed by the [[_RGB]], [[_RGBA]], [[_RGB32]] or [[_RGBA32]] functions. -* An image handle is optional. - - -{{PageExamples}} -* See example in [[POINT]]. - - -{{PageSeeAlso}} -* [[_RED]], [[_BLUE]] -* [[_RGB]], [[RGB32]] -* [[_LOADIMAGE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_HEIGHT__111111.txt b/internal/help/_HEIGHT__111111.txt deleted file mode 100644 index 840893ea6..000000000 --- a/internal/help/_HEIGHT__111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:03}} -{{DISPLAYTITLE:_HEIGHT}} -The [[_HEIGHT]] function returns the height of an image handle or of the current write page. - - -{{PageSyntax}} -: {{Parameter|columns&}} = [[_HEIGHT]][({{Parameter|imageHandle&}})] - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is omitted, it's assumed to be the handle of the current [[SCREEN]] or write page. -* To get the height of the current program [[SCREEN|screen]] window use zero for the handle value or nothing: {{Parameter|lines&}} = [[_HEIGHT]](0) ''or'' {{Parameter|lines&}} = [[_HEIGHT]] -* If the image specified by {{Parameter|imageHandle&}} is in text only([[SCREEN]] 0) mode, the number of characters per row is returned. -* If the image specified by {{Parameter|imageHandle&}} is in graphics mode, the number of pixels per row is returned. -* If {{Parameter|imageHandle&}} is an invalid handle, then an [[ERROR Codes|invalid handle error]] is returned. -* The last visible pixel coordinate of a program [[SCREEN|screen]] is '''[[_HEIGHT]] - 1'''. - - - -{{PageSeeAlso}} -* [[_WIDTH (function)]], [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[Bitmaps]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_HIDE__1111.txt b/internal/help/_HIDE__1111.txt deleted file mode 100644 index 267e7c996..000000000 --- a/internal/help/_HIDE__1111.txt +++ /dev/null @@ -1,64 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:04}} -{{DISPLAYTITLE:_HIDE}} -The [[_HIDE]] action is used to hide the console window opened by a [[SHELL]] statement. - - -{{PageSyntax}} -: [[SHELL]] ['''_HIDE'''] {{Parameter|StringCommandLine$}} - - -{{PageDescription}} -* Allows any command line window to be hidden from view without affecting the program. -* [[_HIDE]] must be used when sending ("piping") screen information to a file. -* '''Note:''' Some commands may not work without adding CMD /C to the start of the command line. - - -{{PageExamples}} -''Example:'' Subprogram that displays long and short filenames using the DIR /X option (WindowsNT or above) in SCREEN 12: -{{CodeStart}} -SUB LFN - IF LEN({{Cl|ENVIRON$}}("OS")) = 0 THEN EXIT SUB ' /X not available Win 9X and ME - SHELL {{Cl|_HIDE}} "cmd /c dir /x > DOS-DATA.INF" ' load display data to a file - OPEN "DOS-DATA.INF" FOR INPUT AS #1 - IF {{Cl|LOF}}(1) THEN - Header$ = SPACE$(10) + "Short" + SPACE$(16) + "Long" + SPACE$(20) + "Last Modified" - tmp$ = "\ \ \ \ &" ' print using template format - COLOR 14: LOCATE 2, 4: PRINT Header$ - DO UNTIL EOF(1) - {{Cl|LINE INPUT}} #1, line$ - IF LEN(line$) AND MID$(line$, 1, 1) <> SPACE$(1) THEN ' ignore other file data - cnt% = cnt% + 1 - last$ = MID$(line$, 1, 20): DIR$ = MID$(line$, 26, 3) - IF MID$(line$, 40, 1) <> SPACE$(1) THEN ' found line with short and long name - SHFN$ = MID$(line$, 40, INSTR(40, line$, SPACE$(1)) - 1) - LGFN$ = MID$(line$, 53) - ELSE : SHFN$ = MID$(line$, 53): LGFN$ = "" ' found short name only - END IF - IF cnt% MOD 25 = 0 THEN ' pause every 25 files - COLOR 14: LOCATE 29, 27 "Press a key for more files!" - DO: LOOP UNTIL INKEY$ <> "" - CLS: COLOR 14: LOCATE 2, 4: PRINT Header$ - END IF - COLOR 11: LOCATE (cnt% MOD 25) + 3, 4 - {{Cl|PRINT USING}} tmp$; DIR$; SHFN$; LGFN$ - LOCATE (cnt% MOD 25) + 3, 58: PRINT last$ - END IF - LOOP - END IF - COLOR 10: LOCATE {{Cl|CSRLIN}} + 1, 27 "Total folders and files ="; cnt% - CLOSE #1 -END SUB -{{CodeEnd}} - -''Explanation:'' The above routine can also be used to place the file name info into string arrays by using the count variable cnt% to determine the index. Long file names are normally returned by '''QB64'''. To keep older QBasic programs compatible, you may want to only use the short names when displaying the files on the screen. - - -{{PageSeeAlso}} -* [[SHELL]], [[_DONTWAIT]] -* [[FILELIST$ (function)]] ([[FILES]] function, member-contributed) - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_HYPOT__11111.txt b/internal/help/_HYPOT__11111.txt deleted file mode 100644 index 45ff4f058..000000000 --- a/internal/help/_HYPOT__11111.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:05}} -{{DISPLAYTITLE:_HYPOT}} -The [[_HYPOT]] function returns the hypotenuse of a right-angled triangle whose legs are x and y. - - -{{PageSyntax}} -: {{Parameter|result!}} = [[_HYPOT]]({{Parameter|x}}, {{Parameter|y}}) - - -{{Parameters}} -* {{Parameter|x}} and {{Parameter|y}} are the floating point values corresponding to the legs of a right-angled (90 degree) triangle for which the hypotenuse is computed. - - -{{PageDescription}} -* The function returns what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem). -* The hypotenuse is the longest side between the two 90 degree angle sides - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|DIM}} leg_x {{Cl|AS}} {{Cl|DOUBLE}}, leg_y {{Cl|AS}} {{Cl|DOUBLE}}, result {{Cl|AS}} {{Cl|DOUBLE}} -leg_x = 3 -leg_y = 4 -result = {{Cl|_HYPOT}}(leg_x, leg_y) -{{Cl|PRINT}} {{Cl|USING}} "## , ## and ## form a right-angled triangle."; leg_x; leg_y; result -{{CodeEnd}} - -{{OutputStart}} - 3 , 4 and 5 form a right-angled triangle. -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[ATN]] {{text|(arctangent)}} -* [[_PI]] {{text|(function)}} -* [[Mathematical Operations]] -* [http://www.cplusplus.com/reference/cmath/hypot/ C++ reference for hypot() - source of the text and sample above] - - -{{PageNavigation}} diff --git a/internal/help/_ICON__1111.txt b/internal/help/_ICON__1111.txt deleted file mode 100644 index e407b4450..000000000 --- a/internal/help/_ICON__1111.txt +++ /dev/null @@ -1,134 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:07}} -{{DISPLAYTITLE:_ICON}} -The [[_ICON]] statement uses an image handle from [[_LOADIMAGE]] for the program header and icon image in the OS. - - -{{PageSyntax}} -: [[_ICON]] [{{Parameter|mainImageHandle&}}[, {{Parameter|smallImageHandle&}}]] - - -{{Parameters}} -* {{Parameter|mainImageHandle&}} is the [[LONG]] handle value of the OS icon and title bar image pre-loaded with [[_LOADIMAGE]] when used alone. -* {{Parameter|smallImageHandle&}} is the [[LONG]] handle value of a different title bar image pre-loaded with [[_LOADIMAGE]] when used. -* No image handle designates use of the default QB64 icon or the embedded icon set by [[$EXEICON]]. - - -{{PageDescription}} -* If no image handle is passed, the default QB64 icon will be used (all versions). If the [[$EXEICON]] metacommand is used, [[_ICON]] without an image handle uses the embedded icon from the binary (Windows only). -* Beginning with '''version 1.000''', the following is considered: -:::{{Parameter|mainImageHandle&}} creates the image as the icon in the OS and the image in the program header (title bar). -:::{{Parameter|smallImageHandle&}} can be used for a different image in the program header bar. -*The header image will automatically be resized to fit the icon size of 16 X 16 if smaller or larger. -*Once the program's icon is set, the image handle can be discarded with [[_FREEIMAGE]]. - - -{{PageErrors}} -* '''NOTE: Icon files are not supported with [[_LOADIMAGE]] and an error will occur. See Example 2.''' -* Images used can be smaller or larger than 32 X 32 pixels, but image resolution may be affected. -* It is important to free unused or uneeded images with [[_FREEIMAGE]] to prevent memory overflow errors. -*In '''SCREEN 0''' (default text mode) you need to specify 32-bit mode in [[_LOADIMAGE]] to load images.''' - - -{{PageExamples}} -''Example 1:'' Loading an image to a 32 bit palette in SCREEN 0 (the default screen mode). -{{CodeStart}} -i& ={{Cl|_LOADIMAGE}}("RDSWU16.BMP", 32) '<<<<<<< use your image file name here - -{{Cl|IF}} i& < -1 THEN - {{Cl|_ICON}} i& - {{Cl|_FREEIMAGE}} i& ' release image handle after setting icon -{{Cl|END IF}} -{{CodeEnd}} -:''Note:'' _ICON images can be freed if the [[SCREEN]] mode stays the same. Freed image handles can on longer be referenced. - - -''Example 2:'' Function that converts an icon into a temporary bitmap for use in QB64. Function returns the available image count. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) -{{Cl|_TITLE}} "Icon Converter" -icon$ = "daphne.ico" '<<<<<<<<< change icon file name -bitmap$ = "tempfile.bmp" -indx% = 6 '1 minimum <<<<<<< higher values than count get highest entry image in icon file - -{{Cl|IF...THEN|IF}} Icon2BMP(icon$, bitmap$, indx%) {{Cl|THEN}} - img& = {{Cl|_LOADIMAGE}}(bitmap$) ' use 32 as color mode in SCREEN 0 - {{Cl|IF...THEN|IF}} img& < -1 {{Cl|THEN}} ' check that handle value is good before loading - {{Cl|_ICON}} img& ' place image in header - {{Cl|_PUTIMAGE}} (300, 250), img& 'place image on screen - {{Cl|_FREEIMAGE}} img& ' always free unused handles to save memory - {{Cl|KILL}} bitmap$ ' comment out and/or rename to save the bitmaps - {{Cl|END IF}} -{{Cl|END IF}} -{{Cl|END}} -' ---------------------------------------------------- - -{{Cl|FUNCTION}} Icon2BMP% (filein {{Cl|AS}} {{Cl|STRING}}, fileout {{Cl|AS}} {{Cl|STRING}}, index {{Cl|AS}} {{Cl|INTEGER}}) -'function creates a bitmap of the icon and returns the icon count -{{Cl|DIM}} byte {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}}, word {{Cl|AS}} {{Cl|INTEGER}}, dword {{Cl|AS}} {{Cl|LONG}} -{{Cl|DIM}} wide {{Cl|AS}} {{Cl|LONG}}, high {{Cl|AS}} {{Cl|LONG}}, BM {{Cl|AS}} {{Cl|INTEGER}}, bpp {{Cl|AS}} {{Cl|INTEGER}} - -rf = {{Cl|FREEFILE}} -{{Cl|IF...THEN|IF}} {{Cl|LCASE$}}({{Cl|RIGHT$}}(filein, 4)) = ".ico" {{Cl|THEN}} 'check file extension is ICO only - {{Cl|OPEN}} filein {{Cl|OPEN|FOR}} {{Cl|BINARY}} {{Cl|ACCESS}} {{Cl|ACCESS|READ}} {{Cl|AS}} rf -{{Cl|ELSE}} {{Cl|EXIT FUNCTION}} -{{Cl|END IF}} -{{Cl|GET}} rf, , word -{{Cl|GET}} rf, , word: icon = word -{{Cl|GET}} rf, , word: count = word -{{Cl|IF...THEN|IF}} icon <> 1 {{Cl|OR (boolean)|OR}} count = 0 {{Cl|THEN}} {{Cl|CLOSE}} rf: {{Cl|EXIT FUNCTION}} -'{{Cl|PRINT}} icon, count -{{Cl|IF...THEN|IF}} index > 0 {{Cl|AND (boolean)|AND}} index <= count {{Cl|THEN}} entry = 16 * (index - 1) {{Cl|ELSE}} entry = 16 * (count - 1) -{{Cl|SEEK}} rf, 1 + 6 + entry 'start of indexed Entry header -{{Cl|GET}} rf, , byte: wide = byte ' use this unsigned for images over 127 -{{Cl|GET}} rf, , byte: high = byte ' use this unsigned because it isn't doubled -{{Cl|GET}} rf, , word 'number of 4 BPP colors(256 & 32 = 0) & reserved bytes -{{Cl|GET}} rf, , dword '2 hot spots both normally 0 in icons, used for cursors -{{Cl|GET}} rf, , dword: size = dword 'this could be used, doesn't seem to matter -{{Cl|GET}} rf, , dword: offset = dword 'find where the specific index BMP header is -'{{Cl|PRINT}} wide; "X"; high, size, offset - -{{Cl|SEEK}} rf, 1 + offset + 14 'only read the BPP in BMP header -{{Cl|GET}} rf, , word: bpp = word -{{Cl|IF...THEN|IF}} bpp = 0 {{Cl|THEN}} {{Cl|CLOSE}} rf: {{Cl|EXIT FUNCTION}} -{{Cl|IF...THEN|IF}} bpp <= 24 {{Cl|THEN}} pixelbytes = bpp / 8 {{Cl|ELSE}} pixelbytes = 3 -{{Cl|IF...THEN|IF}} bpp > 1 {{Cl|AND (boolean)|AND}} bpp <= 8 {{Cl|THEN}} palettebytes = 4 * (2 ^ bpp) {{Cl|ELSE}} palettebytes = 0 -datasize& = (wide * high * pixelbytes) + palettebytes 'no padder should be necessary -filesize& = datasize& + 14 + 40 ' data and palette + header -bmpoffset& = palettebytes + 54 ' data offset from start of bitmap -readbytes& = datasize& + 28 ' (40 - 12) bytes left to read in BMP header and {{Cl|XOR}} mask only -'{{Cl|PRINT}} bpp, bmpoffset&, filesize& - -BM = {{Cl|CVI}}("BM") 'this will create "BM" in file like {{Cl|MKI$}} would -wf = {{Cl|FREEFILE}} -{{Cl|OPEN}} fileout {{Cl|OPEN|FOR}} {{Cl|BINARY}} {{Cl|AS}} wf -{{Cl|PUT}} wf, , BM -{{Cl|PUT}} wf, , filesize& -dword = 0 -{{Cl|PUT}} wf, , dword -{{Cl|PUT}} wf, , bmpoffset& 'byte location of end of palette or BMP header -dword = 40 -{{Cl|PUT}} wf, , dword ' start of 40 byte BMP header -{{Cl|PUT}} wf, , wide -{{Cl|PUT}} wf, , high -{{Cl|SEEK}} rf, 1 + offset + 12 ' after 12 bytes start copy of BMP header starting at planes -dat$ = {{Cl|STRING$}}(readbytes&, 0) 'create string to hold remaining bytes needed w/o {{Cl|AND}} mask data -{{Cl|GET}} rf, , dat$ ' copy lower header, palette(if used) and {{Cl|XOR}} mask -{{Cl|PUT}} wf, , dat$ ' put all of the string data in the bitmap all at once -{{Cl|CLOSE}} rf, wf -Icon2BMP = count ' return the number of icons available in the icon file -{{Cl|END FUNCTION}} -{{CodeEnd}}{{small|Code by Ted Weissgerber}} -: ''Note:'' Once the file has been loaded into memory, the image handle can still be used even after the file has been deleted. - - -{{PageSeeAlso}} -* [[_TITLE]] -* [[_LOADIMAGE]] -* [[$EXEICON]] -* [[Creating Icon Bitmaps]] {{text|(member-contributed program)}} -* [[Bitmaps]], [[Icons and Cursors]] -* [[Resource_Table_extraction#Extract_Icon|Icon Extraction]] - - -{{PageNavigation}} diff --git a/internal/help/_INCLERRORFILE$__1111111111111$.txt b/internal/help/_INCLERRORFILE$__1111111111111$.txt deleted file mode 100644 index 5bb97d062..000000000 --- a/internal/help/_INCLERRORFILE$__1111111111111$.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:08}} -{{DISPLAYTITLE:_INCLERRORFILE$}} -The [[_INCLERRORFILE$]] function returns the name of the original source code [[$INCLUDE]] module that caused the most recent error. - - - -{{PageSyntax}} -: {{Parameter|errfile$}} = [[_INCLERRORFILE$]] - - -{{PageDescription}} -If the last error occurred in the main module, [[_INCLERRORFILE$]] returns an empty string. - - -==Availability== -* '''Version 1.1 and up'''. - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine - -{{Cl|ERROR}} 250 'simulated error code - an error in the main module leaves _INCLERRORLINE empty (= 0) - -'{{Cl|$INCLUDE}}:'haserror.bi' - -{{Cl|END}} - -DebugLine: -{{Cl|PRINT}} "An error occurred. Please contact support with the following details: -{{Cl|PRINT}} "ERROR "; {{Cl|ERR}}; " ON LINE: "; {{Cl|_ERRORLINE}} -{{Cl|IF...THEN|IF}} {{Cl|_INCLERRORLINE}} {{Cl|THEN}} - {{Cl|PRINT}} " IN MODULE "; {{Cl|_INCLERRORFILE$}}; " (line"; {{Cl|_INCLERRORLINE}}; ")" -{{Cl|END IF}} -{{Cl|RESUME}} {{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}An error occurred. Please contact support with the following details: -ERROR 250 ON LINE: 6 - -An error occurred. Please contact support with the following details: -ERROR 250 ON LINE: 9 - IN MODULE haserror.bi ( line 1 ) -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_INCLERRORLINE]] -* [[ON ERROR]], [[ERR]] -* [[ERROR]] -* [[ERROR Codes]] -* [[$INCLUDE]] - - -{{PageNavigation}} diff --git a/internal/help/_INCLERRORLINE__1111111111111.txt b/internal/help/_INCLERRORLINE__1111111111111.txt deleted file mode 100644 index ab08bc7ca..000000000 --- a/internal/help/_INCLERRORLINE__1111111111111.txt +++ /dev/null @@ -1,58 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:09}} -{{DISPLAYTITLE:_INCLERRORLINE}} -The [[_INCLERRORFILE$]] function returns the line number in an [[$INCLUDE]] file that caused the most recent error. - - - -{{PageSyntax}} -: {{Parameter|errline&}} = [[_INCLERRORLINE]] - - -{{PageDescription}} -* If the last error occurred in the main module, _INCLERRORLINE returns 0. -* By checking _INCLERRORLINE you can report exactly what line inside an included module caused the last error. - - -==Availability== -* '''Version 1.1 and up'''. - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine - -{{Cl|ERROR}} 250 'simulated error code - an error in the main module leaves _INCLERRORLINE empty (= 0) - -'{{Cl|$INCLUDE}}:'haserror.bi' - -{{Cl|END}} - -DebugLine: -{{Cl|PRINT}} "An error occurred. Please contact support with the following details: -{{Cl|PRINT}} "ERROR "; {{Cl|ERR}}; " ON LINE: "; {{Cl|_ERRORLINE}} -{{Cl|IF...THEN|IF}} {{Cl|_INCLERRORLINE}} {{Cl|THEN}} - {{Cl|PRINT}} " IN MODULE "; {{Cl|_INCLERRORFILE$}}; " (line"; {{Cl|_INCLERRORLINE}}; ")" -{{Cl|END IF}} -{{Cl|RESUME}} {{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}An error occurred. Please contact support with the following details: -ERROR 250 ON LINE: 6 - -An error occurred. Please contact support with the following details: -ERROR 250 ON LINE: 9 - IN MODULE haserror.bi ( line 1 ) -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_INCLERRORFILE$]] -* [[ON ERROR]], [[ERR]] -* [[ERROR]] -* [[ERROR Codes]] -* [[$INCLUDE]] - - - -{{PageNavigation}} diff --git a/internal/help/_INFLATE$__1111111$.txt b/internal/help/_INFLATE$__1111111$.txt deleted file mode 100644 index abd4ece8b..000000000 --- a/internal/help/_INFLATE$__1111111$.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:10}} -{{DISPLAYTITLE:_INFLATE$}} -The [[_INFLATE$]] function decompresses a [[STRING|string]] compressed by the [[_DEFLATE$]] function. - - -{{PageSyntax}} -:{{Parameter|result$}} = [[_INFLATE$]]({{Parameter|stringToDecompress$[, originalSize&]}}) - - -{{PageDescription}} -* {{Parameter|result$}} will contain the original version of {{Parameter|stringToDecompress$}}. -* Optional parameter {{Parameter|originalSize&}} can be used if the original size of the uncompressed data is known beforehand, which makes the decompression routine run more efficiently. -** If unspecified, decompression still works as expected, but may use more steps and need to allocate more memory internally. - - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' Compressing a long string of text. -{{CodeStart}} -a$ = "The quick brown fox jumps over the lazy dog. " -{{Cl|PRINT}} "Original string (a$): "; a$ -{{Cl|FOR}} i = 1 {{Cl|TO}} 15 - a$ = a$ + a$ -{{Cl|NEXT}} - -{{Cl|PRINT}} "After concatenating it into itself several times, LEN(a$) ="; {{Cl|LEN}}(a$) - -b$ = {{Cl|_DEFLATE$}}(a$) -{{Cl|PRINT}} "After using _DEFLATE$ to compress it, LEN ="; {{Cl|LEN}}(b$) -{{Cl|PRINT}} {{Cl|USING}} "(compressed size is #.###% of the original)"; (({{Cl|LEN}}(b$) * 100) / {{Cl|LEN}}(a$)) -c$ = {{Cl|_INFLATE$}}(b$) -PRINT "After using _INFLATE$ to decompress it, LEN ="; {{Cl|LEN}}(c$) - {{CodeEnd}} -{{OutputStart}} -Original string (a$): The quick brown fox jumps over the lazy dog -After concatenating it into itself several times, LEN(a$) = 1474560 -After using _DEFLATE$ to compress it, LEN = 4335 -(compressed size is 0.295% of the original) -After using _INFLATE$ to decompress it, LEN = 1474560 -{{OutputEnd}} - -{{PageSeeAlso}} -* [[_DEFLATE$]] - - -{{PageNavigation}} diff --git a/internal/help/_INSTRREV__11111111.txt b/internal/help/_INSTRREV__11111111.txt deleted file mode 100644 index c0fa30b45..000000000 --- a/internal/help/_INSTRREV__11111111.txt +++ /dev/null @@ -1,75 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:12}} -{{DISPLAYTITLE:_INSTRREV}} -The [[_INSTRREV]] function searches for a substring inside another string, but unlike [[INSTR]] it searches from right to left. - - -{{PageSyntax}} -: {{Parameter|position%}} = [[_INSTRREV]]([{{Parameter|start%}},] {{Parameter|baseString$}}, {{Parameter|subString$}}) - - -{{Parameters}} -* The optional literal or variable [[INTEGER]] {{Parameter|start%}} indicates where in the {{Parameter|baseString$}} the search must start, counted from the left. -* The {{Parameter|baseString$}} is a literal or variable [[STRING]] value to be searched for an exact match including [[UCASE$|letter cases]]. -* The {{Parameter|subString$}} is a literal or variable [[STRING]] value being searched. - - -{{PageDescription}} -* The function returns the {{Parameter|position%}} in the {{Parameter|baseString$}} where the {{Parameter|subString$}} was found, from right to left. -* {{Parameter|position%}} will be 0 if the search found no matches in the base string. -* [[_INSTRREV]] returns 0 if an empty {{Parameter|baseString$}} is passed, and returns [[LEN]]({{Parameter|baseString$}}) with an empty {{Parameter|subString$}}. -* The {{Parameter|start%}} position is useful when making multiple searches in the same string. See the example below. -* The {{Parameter|subString$}} should be smaller or equal in [[LEN|length]] to the {{Parameter|baseString$}}, or 0 is returned. -* A {{Parameter|start%}} value of 0 or less starts search from the end of the {{Parameter|baseString$}} (same as not passing a {{Parameter|start%}} parameter). - - -{{PageExamples}} -''Example 1:'' Separating a file name from a full path. -{{CodeStart}} -fullPath$ = "C:\Documents and Settings\Administrator\Desktop\qb64\internal\c\libqb\os\win\libqb_1_2_000000000000.o" -file$ = {{Cl|MID$}}(fullPath$, {{Cl|_INSTRREV}}(fullPath$, "\") + 1) -{{Cl|PRINT}} file$ -{{CodeEnd}} -{{OutputStart}} -libqb_1_2_000000000000.o -{{OutputEnd}} - - -''Example 2:'' Searching for multiple instances of a substring inside a base string, going from the end to the start. -{{CodeStart}} -sentence$ = " This is a string full of spaces, including at start and end... " -{{Cl|PRINT}} sentence$ -{{Cl|DO}} - findPrevSpace% = {{Cl|_INSTRREV}}(findPrevSpace% - 1, sentence$, {{Cl|SPACE$}}(1)) - {{Cl|IF}} findPrevSpace% = 0 {{Cl|THEN}} - {{Cl|LOCATE}} 4, 1 - {{Cl|PRINT}} "No more spaces" - {{Cl|EXIT}} {{Cl|DO}} - {{Cl|END IF}} - - {{Cl|LOCATE}} 2, findPrevSpace% - {{Cl|PRINT}} "^" - totalSpaces = totalSpaces + 1 - - {{Cl|IF}} findPrevSpace% = 1 {{Cl|THEN}} - {{Cl|LOCATE}} 4, 1 - {{Cl|PRINT}} "Last space found at position 1" - {{Cl|EXIT}} {{Cl|DO}} - {{Cl|END IF}} -{{Cl|LOOP}} -{{Cl|PRINT}} "Total spaces found: "; totalSpaces -{{CodeEnd}} -{{OutputStart}} - This is a string full of spaces, including at start and end... -^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ - -Last space found at position 1 -Total spaces found: 13 -{{OutputEnd}} - -{{PageSeeAlso}} -* [[MID$]], [[INSTR]] -* [[SPACE$]] - - -{{PageNavigation}} diff --git a/internal/help/_INTEGER64__111111164.txt b/internal/help/_INTEGER64__111111164.txt deleted file mode 100644 index e5bad405a..000000000 --- a/internal/help/_INTEGER64__111111164.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:13}} -{{DISPLAYTITLE:_INTEGER64}} -[[_INTEGER64]] is an 8 byte number type definition that can hold whole numerical values. - - -{{PageSyntax}} -: [[DIM]] {{Parameter|variable}} [[AS]] [[_INTEGER64]] - - -{{PageDescription}} -* Can be used in 32 or 64 bit computers. -* Signed numerical values can range from -9223372036854775808 to 9223372036854775807. -* [[_UNSIGNED]] [[_INTEGER64]] values range from 0 to 18446744073709551615 on 64 bit computers. -* Variable type suffix is '''&&''' or '''~&&''' for [[_UNSIGNED]]. Suffix can also be placed after a literal or hexadecimal numerical value. -* Values can be converted to 8 byte [[ASCII]] character strings using [[_MK$]] and back using [[_CV]]. -* Equivalent to INT8 or unsigned as UINT8 in C programming. -* '''When a variable has not been assigned or has no type suffix, the value defaults to [[SINGLE]].''' - - -{{PageSeeAlso}} -* [[INTEGER]], [[LONG]] -* [[_DEFINE]], [[DIM]] -* [[_UNSIGNED]] -* [[_CV]], [[_MK$]] -* [[PDS (7.1) Procedures#CURRENCY|CURRENCY]] -* [[Variable Types]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_KEYCLEAR__11111111.txt b/internal/help/_KEYCLEAR__11111111.txt deleted file mode 100644 index ab5d9015e..000000000 --- a/internal/help/_KEYCLEAR__11111111.txt +++ /dev/null @@ -1,59 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:14}} -{{DISPLAYTITLE:_KEYCLEAR}} -[[_KEYCLEAR]] clears all keyboard input buffers. - -{{PageSyntax}} -:[[_KEYCLEAR]] [{{Parameter|buffer&}}] - -{{Parameters}} -*{{Parameter|buffer&}} indicates the buffer to be cleared: -** 1 - Clear the regular keyboard buffer, as used by all input command except the following: _KEYHIT, _KEYDOWN, INP(&H60. This is the same as the the emulated BIOS keyboard buffer, so legacy code reading from it via PEEK/POKE/CALL ABSOLUTE will also be affected. -** 2 - Clear the buffer used by _KEYHIT. -** 3 - Clear INP(&H60) buffer. (see '''Warning''' in the the description below) -* If no parameter is passed, all three buffers are cleared. - - -{{PageDescription}} -* The '''_KEYCLEAR''' command clears the specified keyboard input buffer. In effect, it is as if a loop has been used to read from the buffer until it is empty. All keys cleared are lost. -* '''Warning:''' The buffer read by INP(&H60) does not behave as the other buffers do. Whilst reading from the others will eventually empty after reading all data, this buffer will continue to return the last value. For this reason, [[_KEYCLEAR]] is of little effect, but is included for completeness (an internal flag indicating new data on the port is cleared). However, using [[INP]] for anything is strongly discouraged, and is for backwards compatibility only. -* This command is best used just before getting input, in order to clear stray key presses from commands such as SLEEP, or just random keyboard bashing by the user. The programmer also ought to be aware of key release events in the _KEYHIT buffer; consider the following code: - -{{CodeStart}} -INPUT "Name: ", name$ -_KEYCLEAR -_DELAY 2 'Simulate doing some processing that takes some time. -PRINT _KEYHIT -{{CodeEnd}} - -* The INPUT statement finishes as soon as the Enter key is struck; the program then proceeds to clear all input buffers. Because this is executed so quickly, it is likely that the user will release the Enter key after the _KEYCLEAR command is executed, leaving a -13 (Enter key release) event in the _KEYHIT buffer. -* As mentioned above, it is best to place the _KEYCLEAR after the processing, immediately before the PRINT _KEYHIT command: - -{{CodeStart}} -INPUT "Name: ", name$ -_DELAY 2 'Simulate doing some processing that takes some time. -_KEYCLEAR -PRINT _KEYHIT -{{CodeEnd}} - - -{{PageExamples}} -Example: -{{CodeStart}} -PRINT "Press a key" -SLEEP 'Wait for keypress -'Three alternative _KEYCLEAR calls. Try uncommenting different ones to see the effect. -'_KEYCLEAR -'_KEYCLEAR 1 -'_KEYCLEAR 2 -PRINT "In regular buffer, there is "; INKEY$ 'read regular buffer -PRINT "In _KEYHIT buffer, there is "; _KEYHIT 'read the _KEYHIT buffer -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[SLEEP]] -* [[INKEY$]], [[_KEYHIT]] - - -{{PageNavigation}} diff --git a/internal/help/_KEYDOWN__1111111.txt b/internal/help/_KEYDOWN__1111111.txt deleted file mode 100644 index 3e4ec73da..000000000 --- a/internal/help/_KEYDOWN__1111111.txt +++ /dev/null @@ -1,175 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:17}} -{{DISPLAYTITLE:_KEYDOWN}} -The '''_KEYDOWN''' function returns whether modifying keys like CTRL, ALT, SHIFT, and any other keys are pressed. - - -{{PageSyntax}} -:: return% = '''_KEYDOWN('''''code&''''')''' - - -* The ''return'' value is -1 if a specified key is pressed or 0 if it was not pressed. It can be used to monitor key combinations. -* The POSITIVE [[LONG]] ''code'' value can be from any function key that needs to be monitored in a key press combination. -* Unicode references: -:* 1) What is the glyph represented by that UNICODE value: [http://www.fileformat.info/info/unicode/char/search.htm Unicode Format Info] -:* 2) Which fonts support the characters I want to use: [http://en.wikipedia.org/wiki/Unicode_typefaces#Comparison_of_fonts Unicode Fonts] -:* 3) What was the format again?: [http://www.birds-eye.net/definition/u/unicode.shtml Unicode Formats] -:* A UTF32 value is usually(but by no means always!) the same as a UTF16 value just with the top 2 bytes set to 0. -* An important difference between [[INKEY$]] and [[_KEYHIT]] is how they work when '''CTRL, ALT''' or '''SHIFT''' are used. [[INKEY$]] returns a different code if you hold down CTRL, ALT or SHIFT before pressing F1 (for example). [[_KEYHIT]] will return the same code regardless of which modifiers were used but you can check _KEYDOWN to see which modifying keys are being used. -* '''Keyboards with Alt Gr key:''' [[_KEYHIT]] may return both Alt(100307) and Ctrl(100306) codes when key is pressed or released. -* '''Linux with foreign keyboards:''' [[SHELL]] [[_HIDE]] "setxkbmap us" will setup a keyboard to read US [[Scancodes]]. - - -{{WhiteStart}} '''The QB64 Virtual Key constant values used: ''' - - '''0-255''': [[ASCII|ASCII and Extended code]] values (Refer to [http://en.wikipedia.org/wiki/Code_page_437 CP437]) - - '''256-65535''': [[ASCII#Two Byte Codes|ASCII 2-byte]] character codes (unaffected by SHIFT/ALT/CTRL modifiers) - Use [[CVI]] to convert ASCII 2-byte codes to _KEYDOWN values. - -' '''_KEYDOWN Keyboard Values''' -' -''''Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause''' -' 27 15104 15360 15616 15872 16128 16384 16640 16896 17152 17408 34048 34304 +316 +302 +019 -''''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -''' -'126 33 64 35 36 37 94 38 42 40 41 95 43 8 20992 18176 18688 +300 47 42 45 -''' 96 49 50 51 52 53 54 55 56 57 48 45 61'' -''''Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/â–² 9PU + ''' -' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 21248 20224 20736 18176 18432 18688 43 -''' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 '' -''''CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º -'+301 65 83 68 70 71 72 74 75 76 58 34 13 19200 19456 19712 '''E''' -''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n''' -''''Shift Z X C V B N M ,< .> /? Shift â–² 1End 2/â–¼ 3PD t''' -'+304 90 88 67 86 66 78 77 60 62 63 +303 18432 20224 20480 20736 '''e''' -''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r''' -''''Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0Ins .Del ''' -'+306 +311 +308 32 +307 +312 +319 +305 19200 20480 19712 20992 21248 13 -' '' 48 46'' -' -' ''' Lower value = LCase/NumLock On __________________ + = add 100000 ''' -{{WhiteEnd}} -{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}} - - -{{WhiteStart}} '''65536-&H40000000: QB64-specific Virtual Key codes:''' - - CONST KEY_PAUSE& = 100019 - CONST KEY_NUMLOCK& = 100300 - CONST KEY_CAPSLOCK& = 100301 - CONST KEY_SCROLLOCK& = 100302 - CONST KEY_RSHIFT& = 100303 - CONST KEY_LSHIFT& = 100304 - CONST KEY_RCTRL& = 100305 - CONST KEY_LCTRL& = 100306 - CONST KEY_RALT& = 100307 - CONST KEY_LALT& = 100308 - CONST KEY_RMETA& = 100309 'Left 'Apple' key (MacOSX) - CONST KEY_LMETA& = 100310 'Right 'Apple' key (MacOSX) - CONST KEY_LSUPER& = 100311 'Left "Windows" key - CONST KEY_RSUPER& = 100312 'Right "Windows"key - CONST KEY_MODE& = 100313 '"AltGr" key - CONST KEY_COMPOSE& = 100314 - CONST KEY_HELP& = 100315 - CONST KEY_PRINT& = 100316 - CONST KEY_SYSREQ& = 100317 - CONST KEY_BREAK& = 100318 - CONST KEY_MENU& = 100319 - CONST KEY_POWER& = 100320 - CONST KEY_EURO& = 100321 - CONST KEY_UNDO& = 100322 - CONST KEY_KP0& = 100256 - CONST KEY_KP1& = 100257 - CONST KEY_KP2& = 100258 - CONST KEY_KP3& = 100259 - CONST KEY_KP4& = 100260 - CONST KEY_KP5& = 100261 - CONST KEY_KP6& = 100262 - CONST KEY_KP7& = 100263 - CONST KEY_KP8& = 100264 - CONST KEY_KP9& = 100265 - CONST KEY_KP_PERIOD& = 100266 - CONST KEY_KP_DIVIDE& = 100267 - CONST KEY_KP_MULTIPLY& = 100268 - CONST KEY_KP_MINUS& = 100269 - CONST KEY_KP_PLUS& = 100270 - CONST KEY_KP_ENTER& = 100271 - CONST KEY_KP_INSERT& = 200000 - CONST KEY_KP_END& = 200001 - CONST KEY_KP_DOWN& = 200002 - CONST KEY_KP_PAGE_DOWN& = 200003 - CONST KEY_KP_LEFT& = 200004 - CONST KEY_KP_MIDDLE& = 200005 - CONST KEY_KP_RIGHT& = 200006 - CONST KEY_KP_HOME& = 200007 - CONST KEY_KP_UP& = 200008 - CONST KEY_KP_PAGE_UP& = 200009 - CONST KEY_KP_DELETE& = 200010 - CONST KEY_SCROLL_LOCK_MODE& = 200011 - CONST KEY_INSERT_MODE& = 200012 - - '''&H40000000 up''': [[Unicode]] using the '''cyberbit.ttf''' font when available. - - '''Use [[_KEYHIT]] to find the key codes to be monitored by _KEYDOWN! ''' - -{{WhiteEnd}} - -''Example 1:'' Comparing the _KEYDOWN returns using [[CONST|constant]] values with 2 byte [[INKEY$]] returns. -{{CodeStart}} -{{Cl|CONST}} RSHIFT& = 100303 -{{Cl|CONST}} LSHIFT& = 100304 -{{Cl|DO}} - x = {{Cl|_KEYHIT}} - {{Cl|IF}} x = {{Cl|CVI}}({{Cl|CHR$}}(0) + {{Cl|CHR$}}(59)) {{Cl|THEN}} - {{Cl|IF}} {{Cl|_KEYDOWN}}(LSHIFT&) {{Cl|OR (boolean)|OR}} {{Cl|_KEYDOWN}}(RSHIFT&) {{Cl|THEN}} - {{Cl|PRINT}} "KEYHIT: SHIFT + F1" - {{Cl|ELSE}} - {{Cl|PRINT}} "KEYHIT: F1" - {{Cl|END IF}} - {{Cl|END IF}} - k$ = {{Cl|INKEY$}} 'compare key press return values - {{Cl|IF}} k$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(59) {{Cl|THEN}} {{Cl|PRINT}} "INKEY$: F1" - {{Cl|IF}} k$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(84) {{Cl|THEN}} {{Cl|PRINT}} "INKEY$: SHIFT+F1" -{{Cl|LOOP}} {{Cl|UNTIL}} k$ = {{Cl|CHR$}}(27) 'escape key exit -{{CodeEnd}} -{{small|Code by Galleon}} - - -''Example 2:'' How to calculate the _KEYDOWN codes of the 2 byte INKEY$ arrow key codes using [[CVI]]. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 - -x = 320: y = 240 -col = {{Cl|_RGB}}(255, 0, 0) -radius = 20 - -DO - {{Cl|CLS}} - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "Use the arrow keys to move the circle." - {{Cl|CIRCLE}} (x, y), radius, col - {{Cl|PAINT}} (x, y), col - - {{Cl|IF...THEN|IF}} {{Cl|_KEYDOWN}}({{Cl|CVI}}({{Cl|CHR$}}(0) + "P")) {{Cl|THEN}} y = y + 1 '_KEYDOWN(20480) - {{Cl|IF...THEN|IF}} {{Cl|_KEYDOWN}}({{Cl|CVI}}({{Cl|CHR$}}(0) + "H")) {{Cl|THEN}} y = y - 1 '_KEYDOWN(18432) - {{Cl|IF...THEN|IF}} {{Cl|_KEYDOWN}}({{Cl|CVI}}({{Cl|CHR$}}(0) + "K")) {{Cl|THEN}} x = x - 1 '_KEYDOWN(19200) - {{Cl|IF...THEN|IF}} {{Cl|_KEYDOWN}}({{Cl|CVI}}({{Cl|CHR$}}(0) + "M")) {{Cl|THEN}} x = x + 1 '_KEYDOWN(19712) - - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 100 'limit to 100 frames per second -{{Cl|LOOP}} -{{CodeEnd}} -{{small|Code by Galleon}} -:''Explanation:'' When [[CVI]] is used with a 2 byte code, the code of the first character(0) is added to the second character code which is multiplied by 256. In the example, code zero is added to the [[ASCII]] code of "P" which is 80. CVI multiplies 80 * 256 = 20480. - - -''See also: - -* [[_KEYHIT]], [[Unicode]], [[Code Pages]] (by region) -* [[_MAPUNICODE]], [[_MAPUNICODE (function)]] -* [[INKEY$]], [[ASCII]], [[CVI]] -* [[INP]](&H60), [[Scancodes]] -* [[ON KEY(n)]], [[KEY(n)]], [[KEY n]] -* [[Windows_Libraries#Hot_Keys_.28maximize.29|Windows hot keys]] - - -{{PageNavigation}} diff --git a/internal/help/_KEYHIT__111111.txt b/internal/help/_KEYHIT__111111.txt deleted file mode 100644 index 4970df010..000000000 --- a/internal/help/_KEYHIT__111111.txt +++ /dev/null @@ -1,118 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:15}} -{{DISPLAYTITLE:_KEYHIT}} -The [[_KEYHIT]] function returns [[ASCII]] one and two byte, OpenGL Virtual Key and Unicode keyboard key press codes. - - -{{PageSyntax}} -:{{Parameter|keycode&}} = [[_KEYHIT]] - - -{{PageDescription}} -* Return values range up to &H40000000 so use a [[LONG]] or [[_INTEGER64]] variable type. See the [[_KEYDOWN]] code list: -:* 0-255: [[ASCII]] values (Refer to [http://en.wikipedia.org/wiki/Code_page_437 CP437]). -:* 256-65535: [[ASCII#Two_Byte_Codes|2-byte]] character codes : code = [[CVI]]([[CHR$]](0) + [[CHR$]](scancode)) (unaffected by SHIFT/ALT/CTRL modifiers). -:* 65536-&H40000000: [[_KEYDOWN|QB64-specific Virtual Key codes]] (designated with + for 100000 on keyboard below) -:* '''Negative''' [[LONG]] values returned indicate that a key was released or a lock function key has been turned off. -* '''Note: _KEYHIT can only return one value at a time so use the [[_KEYDOWN]] keyhit value to find key combinations.''' -* To receive input from a [[$CONSOLE]] window, use [[_CINP]]. - -{{WhiteStart}}' '''_KEYHIT Keyboard Codes''' -' -' '''Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause''' -' 27 15104 15360 15616 15872 16128 16384 16640 16896 17152 17408 34048 34304 +316 +302 +019 -' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -''' -' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 20992 18176 18688 +300 47 42 45 -' '' 96 49 50 51 52 53 54 55 56 57 48 45 61'' -' '''Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/â–² 9PU + ''' -' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 21248 20224 20736 18176 18432 18688 43 -' '' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 '' -' '''CapL A S D F G H J K L ;: '" Enter 4/â—„- 5 6/-â–º -' +301 65 83 68 70 71 72 74 75 76 58 34 13 19200 19456 19712 '''E''' -' '' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n''' -' '''Shift Z X C V B N M ,< .> /? Shift â–² 1End 2/â–¼ 3PD t''' -' +304 90 88 67 86 66 78 77 60 62 63 +303 18432 20224 20480 20736 '''e''' -' '' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r''' -' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl â—„- â–¼ -â–º 0Ins .Del ''' -' +306 +311 +308 32 +307 +312 +319 +305 19200 20480 19712 20992 21248 13 -' '' 48 46'' -' -' ''' Lower value = LCase/NumLock On __________________ + = add 100000 ''' -{{WhiteEnd}} -{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}} - - -:* >= &H40000000: [[Unicode]]. - -* Font '''cyberbit.ttf''', included with QB64 ('''version 0.92 and up'''), is required to facilitate the '''IME'''(in Chinese settings) only. The 12.7 MB font is free for '''non-commercial''' use and is not loaded unless the user switches to the '''Input Mode Editor'''. Set to "UNICODE". -
'''[http://www.fileformat.info/tip/microsoft/enter_unicode.htm Setting up the Unicode Input Method Editor in Windows]'''
-
If you need help with IME support in '''Vista''' see the following article: [http://blogs.msdn.com/b/michkap/archive/2006/07/20/671835.aspx Setting up IME in Vista]
-* QB64 can use several Windows fonts when '''cyberbit''' is not present so it is not necessary to include with program packages. -* An '''important difference''' between [[INKEY$]] and _KEYHIT is how they work when '''CTRL, ALT''' or '''SHIFT''' are used. INKEY$ returns a different code if you hold down CTRL, ALT or SHIFT before pressing F1 (for example). _KEYHIT will return the same code regardless of which modifiers were used but you can check [[_KEYDOWN]] to see which modifying keys are being used. -* '''Keyboards with an Alt Gr key note:''' _KEYHIT may return both Alt (100307) and Ctrl (100306) codes when AltGr key is pressed or released. - - -{{PageExamples}} -''Example:'' This routine will return the codes for any keyboard presses. -{{CodeStart}} -{{Cl|DEFLNG}} A-Z -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 8) -{{Cl|CLS}} , 1 -font = {{Cl|_LOADFONT}}("cyberbit.ttf", 24) -unifont = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE") -{{Cl|_FONT}} font - -{{Cl|DO}} - x = {{Cl|_KEYHIT}} - {{Cl|IF}} x {{Cl|THEN}} - {{Cl|IF}} x < 0 {{Cl|THEN}} 'negative value means key released - {{Cl|COLOR}} 2 - {{Cl|PRINT}} "Released "; - x = -x - {{Cl|ELSE}} - {{Cl|COLOR}} 10 - {{Cl|PRINT}} "Pressed "; 'positive value means key pressed - {{Cl|END IF}} - {{Cl|IF}} x < 256 {{Cl|THEN}} 'ASCII code values - {{Cl|PRINT}} "{{Cl|ASC}}II "; x; - {{Cl|IF}} x >= 32 {{Cl|AND (boolean)|AND}} x <= 255 {{Cl|THEN}} {{Cl|PRINT}} "[" + {{Cl|CHR$}}(x) + "]" {{Cl|ELSE}} {{Cl|PRINT}} - {{Cl|END IF}} - {{Cl|IF}} x >= 256 {{Cl|AND (boolean)|AND}} x < 65536 {{Cl|THEN}} '2 byte key codes - {{Cl|PRINT}} "2-BYTE-{{Cl|COM}}BO "; x {{Cl|AND (boolean)|AND}} 255; x \ 256; - x2 = x \ 256 - {{Cl|IF}} x2 >= 32 {{Cl|AND (boolean)|AND}} x2 <= 255 {{Cl|THEN}} {{Cl|PRINT}} "[" + {{Cl|CHR$}}(x2) + "]" {{Cl|ELSE}} {{Cl|PRINT}} - {{Cl|END IF}} - {{Cl|IF}} x >= 100000 {{Cl|AND (boolean)|AND}} x < 200000 {{Cl|THEN}} 'QB84 Virtual Key codes - {{Cl|PRINT}} "SDL VK"; x - 100000 - {{Cl|END IF}} - {{Cl|IF}} x >= 200000 {{Cl|AND (boolean)|AND}} x < {{Cl|&H}}40000000 {{Cl|THEN}} - {{Cl|PRINT}} "QB64 VK"; x - 200000 - {{Cl|END IF}} - {{Cl|IF}} x >= {{Cl|&H}}40000000 {{Cl|THEN}} 'Unicode values (IME Input mode) - {{Cl|PRINT}} "UNICODE "; x - {{Cl|&H}}40000000; "0x" + {{Cl|HEX$}}(x - {{Cl|&H}}40000000) + " ..."; - cx = {{Cl|POS}}(1): cy = {{Cl|CSRLIN}} - {{Cl|_FONT}} unifont - {{Cl|LOCATE}} cy, cx - {{Cl|COLOR}} 15 - z$ = {{Cl|MKL$}}(x - {{Cl|&H}}40000000) + {{Cl|MKL$}}(0) - {{Cl|PRINT}} z$ + z$ + z$; - {{Cl|_FONT}} font - {{Cl|LOCATE}} cy, 1: {{Cl|PRINT}} - {{Cl|END IF}} - {{Cl|END IF}} -{{Cl|LOOP}} -{{CodeEnd}} -{{small|Code by Galleon}} - - -{{PageSeeAlso}} -* [[_KEYDOWN]], [[_CINP]] -* [[_MAPUNICODE]], [[_MAPUNICODE (function)]] -* [[INKEY$]], [[ASCII]] {{text|(code table)}}, -* [[Unicode]], [[Code Pages]] {{text|(by region)}} -* [[INP]]([[&H|&H60]]), [[Scancodes]] -* [[ON KEY(n)]], [[KEY(n)]], [[KEY n]] -* [[Windows_Libraries#Hot_Keys_.28maximize.29|Windows hot keys]] - - -{{PageNavigation}} diff --git a/internal/help/_LASTAXIS__11111111.txt b/internal/help/_LASTAXIS__11111111.txt deleted file mode 100644 index d58b3e927..000000000 --- a/internal/help/_LASTAXIS__11111111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:19}} -{{DISPLAYTITLE:_LASTAXIS}} -The [[_LASTAXIS]] function returns the number of axis a specified number INPUT device on your computer has. - - -{{PageSyntax}} -: {{Parameter|axisCount%}} = [[_LASTAXIS]]({{Parameter|deviceNumber}}) - - -{{PageDescription}} -* Returns the number of axis that can be read on a specified device number within the number of [[_DEVICES]] found. -* A valid number can be sent to the [[_AXIS]] function to find any relative axis movements. -* The devices are listed in a numerical order determined by the OS and can be read by the [[DEVICE$]] function. -* '''The [[_DEVICES]] function must be read before using _LASTAXIS or an [[ERROR Codes|"Illegal Function Call" error]] will occur.''' -* Devices include keyboard(1), mouse(2), joysticks, game pads and multiple stick game controllers. - - -{{PageExamples}} -''Example:'' Checking for the system's input devices and number of axis. -{{CodeStart}} -devices = {{Cl|_DEVICES}} 'MUST be read in order for other 2 device functions to work! -PRINT "Number of input devices found ="; devices -FOR i = 1 TO devices - PRINT {{Cl|_DEVICE$}}(i) - IF {{Cl|INSTR}}({{Cl|_DEVICE$}}(i), "[AXIS]") THEN PRINT "Axis:"; {{Cl|_LASTAXIS}}(i) -NEXT -{{CodeEnd}} -{{OutputStart}}Number of input devices found = 2 -[KEYBOARD][BUTTON] -[MOUSE][BUTTON][AXIS][WHEEL] -Axis: 2 -{{OutputEnd}} -:Note: The [[STRIG]]/[[STICK]] commands won't read from the keyboard or mouse device the above example lists. - - -{{PageSeeAlso}} -* [[_LASTBUTTON]], [[_LASTWHEEL]] -* [[_AXIS]], [[_BUTTON]], [[_WHEEL]] -* [[_DEVICE$]], [[_DEVICES]] -* [[_MOUSEBUTTON]] -* [[STRIG]], [[STICK]] -* [[ON STRIG(n)]], [[STRIG(n)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_LASTBUTTON__1111111111.txt b/internal/help/_LASTBUTTON__1111111111.txt deleted file mode 100644 index 41ce0a397..000000000 --- a/internal/help/_LASTBUTTON__1111111111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:20}} -{{DISPLAYTITLE:_LASTBUTTON}} -The [[_LASTBUTTON]] function returns the number of buttons a specified INPUT device on your computer has. - - -{{PageSyntax}} -: {{Parameter|buttonCount%}} = _[[_LASTBUTTON]]({{Parameter|deviceNumber}}) - - -* Returns the number of buttons that can be read on a specified device number within the number of [[_DEVICES]] found. -* A valid number can be sent to the [[_BUTTON]] or [[_BUTTONCHANGE]] function to find any button events. -* The specific device name and functions can be found by the [[_DEVICE$]] function [[STRING|string]]. -* The devices are listed in a numerical order determined by the OS and can be read by the [[DEVICE$]] function. -* '''The [[_DEVICES]] function must be read before using _LASTBUTTON or an [[ERROR Codes|"Illegal Function Call" error]] will occur.''' -* Devices include keyboard (reported as 1), mouse (reported as 2), joysticks, game pads and multiple stick game controllers. - - -{{PageExamples}} -''Example:'' Checking for the system's input devices. -{{CodeStart}} -devices = {{Cl|_DEVICES}} 'MUST be read in order for other 2 device functions to work! -PRINT "Number of input devices found ="; devices -FOR i = 1 TO devices - PRINT {{Cl|_DEVICE$}}(i) - PRINT "Buttons:"; {{Cl|_LASTBUTTON}}(i) -NEXT -{{CodeEnd}} -{{OutputStart}}Number of input devices found = 2 -[KEYBOARD][BUTTON] -Buttons: 512 -[MOUSE][BUTTON][AXIS][WHEEL] -Buttons: 3 -{{OutputEnd}} -:Note: The [[STRIG]]/[[STICK]] commands won't read from the keyboard or mouse device the above example lists. - - -{{PageSeeAlso}} -* [[_LASTAXIS]], [[_LASTWHEEL]] -* [[_AXIS]], [[_BUTTON]], [[_WHEEL]] -* [[_DEVICES]], [[_DEVICE$]] -* [[_DEVICEINPUT]] -* [[_MOUSEBUTTON]] -* [[STRIG]], [[STICK]] -* [[ON STRIG(n)]], [[STRIG(n)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_LASTWHEEL__111111111.txt b/internal/help/_LASTWHEEL__111111111.txt deleted file mode 100644 index 3aa12a76f..000000000 --- a/internal/help/_LASTWHEEL__111111111.txt +++ /dev/null @@ -1,47 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:21}} -{{DISPLAYTITLE:_LASTWHEEL}} -The [[_LASTWHEEL]] function returns the number of wheels a specified number INPUT device on your computer has. - - -{{PageSyntax}} -: {{Parameter|wheelCount%}} = [[_LASTWHEEL]]({{Parameter|deviceNumber}}) - - -* Returns the number of wheels that can be used on a specified device number within the number of [[_DEVICES]] found. -* A valid number can be sent to the [[_WHEEL]] function to find any relative positive or negative wheel movements. -* The devices are listed in a numerical order determined by the OS and can be read by the [[_DEVICE$]] function. -* '''The [[_DEVICES]] function must be read before using _LASTWHEEL or an [[ERROR Codes|"Illegal Function Call" error]] may occur.''' -* Devices include keyboard (reported as 1), mouse (reported as 2), joysticks, game pads and multiple stick game controllers. - - -{{PageExamples}} -''Example:'' Checking for the system's input devices and number of wheels available. -{{CodeStart}} -devices = {{Cl|_DEVICES}} 'MUST be read in order for other 2 device functions to work! -PRINT "Number of input devices found ="; devices -FOR i = 1 TO devices - PRINT {{Cl|_DEVICE$}}(i) - IF {{Cl|INSTR}}({{Cl|_DEVICE$}}(i), "[WHEEL]") THEN PRINT "Wheels:"; {{Cl|_LASTWHEEL}}(i) -NEXT -{{CodeEnd}} -{{OutputStart}}Number of input devices found = 2 -[KEYBOARD][BUTTON] -[MOUSE][BUTTON][AXIS][WHEEL] -Wheels: 3 -{{OutputEnd}} -: ''Note:'' A mouse may have 3 wheels listed when there is only one scroll wheel. - - -{{PageSeeAlso}} -* [[_LASTBUTTON]], [[_LASTAXIS]] -* [[_AXIS]], [[_BUTTON]], [[_WHEEL]] -* [[_DEVICE$]], [[_DEVICES]] -* [[_MOUSEBUTTON]] -* [[STRIG]], [[STICK]] -* [[ON STRIG(n)]], [[STRIG(n)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_LIMIT__11111.txt b/internal/help/_LIMIT__11111.txt deleted file mode 100644 index 49c406c2f..000000000 --- a/internal/help/_LIMIT__11111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:22}} -{{DISPLAYTITLE:_LIMIT}} -The [[_LIMIT]] statement sets the loop repeat rate of a program to so many per second, relinquishing spare CPU cycles to other applications. - - -{{PageSyntax}} -: [[_LIMIT]] {{Parameter|framesPerSecond!}} - - -* The {{Parameter|framesPerSecond!}} [[SINGLE]] parameter value adjusts the loops per second of a program loop. '''Do not use negative values.''' -* The loop code is executed before the loop is delayed. Loop cycles below once per second may delay program [[_EXIT]]s. -* _LIMIT measures its interval from the previous time that it was called and minor adjustments are automatically made to ensure that the number of times a loop is repeated is correct overall. -* Loop cycle rates of 1000 or less can '''significantly reduce CPU usage''' in programs. -* Do not use it to limit a loop to '''less than once every 60 seconds'''(.0167) or an [[ERROR Codes|ILLEGAL FUNCTION CALL error]] will occur. -* Do not use _LIMIT as a timing delay outside of loops. Use [[_DELAY]] instead. -* Use _LIMIT to slow down old QBasic program loops that run too fast and use too much CPU. - - -{{PageExamples}} -''Example:'' Limits loop execution to 30 frames per second and limits the program's CPU usage. -{{CodeStart}} -{{Cl|PRINT}} "To Quit press ESC key!" -{{Cl|DO}} - {{Cl|_LIMIT}} 30 - {{Cl|PRINT}} {{Cl|CHR$}}(26); - {{Cl|IF...THEN|IF}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) {{Cl|THEN}} {{Cl|EXIT DO}} -{{Cl|LOOP}} -{{CodeEnd}} -{{OutputStart}} -To Quit press ESC key! -→→→→→→→→→→→→→→→→→→→→ -{{OutputEnd}} -:''Note:'' In the above example, _LIMIT has to be within the loop. - - -{{PageSeeAlso}} -* [[_DELAY]] -* [[TIMER]], [[ON TIMER(n)]] -* [[SLEEP]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_LOADFONT__11111111.txt b/internal/help/_LOADFONT__11111111.txt deleted file mode 100644 index 5b4f02b64..000000000 --- a/internal/help/_LOADFONT__11111111.txt +++ /dev/null @@ -1,140 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:24}} -{{DISPLAYTITLE:_LOADFONT}} -The [[_LOADFONT]] function loads a TrueType font (.TTF) or an OpenType font (.OTF) file in a specific size and style and returns a [[LONG]] font handle. - - -{{PageSyntax}} -: {{Parameter|handle&}} = [[_LOADFONT]]({{Parameter|fontFileName$}}, {{Parameter|size%}}[, "{MONOSPACE|, BOLD|, ITALIC|, UNDERLINE|, UNICODE|, DONTBLEND}"]) - - -{{PageDescription}} -* The assigned [[LONG]] font {{Parameter|handle&}} variable return value designates a font style to be used somewhere in a program. Valid handle values are greater than 0 ('''{{Parameter|handle&}} > 0'''). -* {{Parameter|fontFileName$}} is the filename of a TrueType or OpenType font. Can include the path to the font file. Best practice is to include font files with a program. -* If no path is specified for {{Parameter|fontFileName$}} and the font file isn't in the same folder as the resulting binary, QB64 attempts to load from the default ''C:\Windows\Fonts'' path. -* {{Parameter|size%}} is the [[INTEGER]] height of the font. If the size is too large or small an [[ERROR Codes|error]] will occur. -* Optional comma separated ''style'' parameter(s) used are literal [[STRING]]s (in quotes) or can be contained in variable(s). -** '''"MONOSPACE"''' loads a font with all characters occupying the same width. Results may be too spaced out for fonts that aren't designed for monospace use. -** '''"BOLD", "ITALIC"''' or '''"UNDERLINE"''' create bold, italic or underlined fonts when available in font. -***(valid for QB64 versions prior to 1.000). -***For '''QB64 1.000 or later''', you must specify the proper file name according to the desired attributes. For example, Courier New is in font '''cour.ttf''' while Courier New Bold is in font '''courbd.ttf''', as shipped with Windows. -** '''"UNICODE"''' loads Unicode fonts such as ''cyberbit.ttf'' which is included in the QB64 downloads. -** '''"DONTBLEND"''' turns off [[_ALPHA]] blending of fonts. This can also be done with the [[_DONTBLEND]] statement. -:* You can pass different font styles using different predefined [[STRING]] variable lists. You '''can''' include an empty style string. -* '''Always check that font handle values are greater than 0 ('''{{Parameter|handle&}} > 0''') before using them or [[ERROR Codes|illegal function errors]] may occur.''' -* '''NOTE: SCREEN 0 can only use ONE font on a screen page. Thus a style like underline would affect the entire page.''' -* Font sizes can be found using the [[_FONTHEIGHT]] function. Font ''size''s can also affect [[SCREEN (statement)|SCREEN]] sizes. -* [[_FONTWIDTH]] can only measure monospaced fonts. '''"MONOSPACE" can be used to load a variable width font as a monospace font.''' -* [[_PRINTWIDTH]] can measure the width of a string of text in '''graphics modes only'''. Use one character to get the font's width. - - -
'''Font Handles'''
-* Multiple fonts will require multiple font variable handles unless used and freed consecutively. -* Font handles with values greater than 0 that are '''no longer used''' should be freed using [[_FREEFONT]]. -* '''Predefined QB64''' font handle numbers can be substituted before freeing a font handle: -**'''_FONT 8 ''' - default font for [[SCREEN (statement)|SCREEN]] 1, 2, 7, 8 or 13 -**'''_FONT 14''' - default font for [[SCREEN (statement)|SCREEN]] 9 or 10 -**'''_FONT 16''' - default font for [[SCREEN (statement)|SCREEN]] 0 ([[WIDTH]] 80, 25 text only), 11 or 12 -**'''_FONT 9, 15''' and '''17''' are the double width versions of 8, 14 and 16 respectively in text '''SCREEN 0 only'''. -* Once the font is changed to a predefined value, the font handle value can be freed using [[_FREEFONT]] for another font type. -* Font handle values of -1 (load failure) '''do not''' need to be freed. '''An [[ERROR Codes|error]] will occur if you try to free invalid handles.''' - - -
'''Font File Specs'''
-* Windows users should find '''TTF''' font files in the C:\WINDOWS\FONTS folder, but don't depend on unusual ones being there. -* '''Check the font file name. The name in the "viewer" is not necessarily the file's name. Use the name in properties (right click a font listed and choose Properties in the contextual menu)''' -* If a program is on a different drive than Windows, [[ENVIRON$]]("SYSTEMROOT") will return the path to the "WINDOWS" folder. Normally "C:\WINDOWS". Then add the "\FONTS\" folder and the font '''.TTF''' filename to the path [[STRING]]. - - -{{PageExamples}} -''Example 1:'' You need to know that if you are in a text mode (such as SCREEN 0 - the default) then you will only be able to use mono-spaced (fixed width) fonts. -{{CodeStart}} -rootpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") 'normally "C:\WINDOWS" -fontfile$ = rootpath$ + "\Fonts\cour.ttf" 'TTF file in Windows -style$ = "monospace" 'font style is not case sensitive -f& ={{Cl|_LOADFONT}}(fontfile$, 30, style$) -{{Cl|_FONT}} f& -{{Cl|PRINT}} "Hello!" - -{{CodeEnd}} -{{OutputStart}} - -Hello! - -{{OutputEnd}} - -''Note:'' 30 means each row of text (including vertical spacing) will be exactly 30 pixels high. This may make some program screens larger. If you don't want a style listed just use style$ = "" if using a [[STRING]] variable for different calls. - - - -''Example 2:'' In a 32-bit graphics mode you can alpha blend onto the background: - -{{CodeStart}} -i& ={{Cl|_NEWIMAGE}}(800,600,32) -{{Cl|SCREEN (statement)|SCREEN}} i& -{{Cl|COLOR}} &HC0FFFF00,&H200000FF -f& ={{Cl|_LOADFONT}}("C:\Windows\Fonts\times.ttf", 25) 'normal style -{{Cl|PRINT}} "Hello!" -{{CodeEnd}} - -{{OutputStart}}Hello! -{{OutputEnd}} - - -:''Note:'' You can load a fixed width font file without using the "monospace" option and it will be treated as variable width. This can be useful because LOCATE treats the horizontal position as an offset in pixels for variable width fonts. - - -''Example 3:'' Loading a [[Unicode]] font, ''cyberbit.ttf'', which was downloaded with QB64: -{{CodeStart}}{{Cl|SCREEN}} 12 - -{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav - {{Cl|FUNCTION}} GetModuleFileNameA& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) - {{Cl|FUNCTION}} GetModuleFileNameW& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -'=== SHOW CURRENT PROGRAM -FileName$ = {{Cl|SPACE$}}(512) - -Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) -{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} {{Cl|PRINT}} "CURRENT PROGRAM (ASCII): "; {{Cl|LEFT$}}(FileName$, Result) - -'load a unicode font -f = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE") -{{Cl|_FONT}} f -Result = GetModuleFileNameW(0, FileName$, {{Cl|LEN}}(FileName$) \ 2) -{{Cl|LOCATE}} 2, 1 -{{Cl|PRINT}} QuickCP437toUTF32$("CURRENT PROGRAM (UTF): ") + QuickUTF16toUTF32$({{Cl|LEFT$}}(FileName$, Result * 2)) -{{Cl|_FONT}} 16 'restore CP437 font - -{{Cl|FUNCTION}} QuickCP437toUTF32$ (a$) -b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 4, 0) -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$) - {{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i) -{{Cl|NEXT}} -QuickCP437toUTF32$ = b$ -{{Cl|END FUNCTION}} - -{{Cl|FUNCTION}} QuickUTF16toUTF32$ (a$) -b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 2, 0) -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$) \ 2 - {{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i * 2 - 1) - {{Cl|ASC}}(b$, i * 4 - 2) = {{Cl|ASC}}(a$, i * 2) -{{Cl|NEXT}} -QuickUTF16toUTF32$ = b$ -{{Cl|END FUNCTION}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_FONT]], [[_FONT (function)]] -* [[_FREEFONT]] -* [[_PRINTSTRING]], [[_PRINTWIDTH]] -* [[_PRINTMODE]], [[_PRINTMODE (function)]] -* [[_FONTHEIGHT]], [[_FONTWIDTH]] -* [[Text Using Graphics]] {{text|(Demo)}} -* [[Windows_Libraries#Font_Dialog_Box|Windows Font Dialog Box]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_LOADIMAGE__111111111.txt b/internal/help/_LOADIMAGE__111111111.txt deleted file mode 100644 index 60319f366..000000000 --- a/internal/help/_LOADIMAGE__111111111.txt +++ /dev/null @@ -1,94 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:25}} -{{DISPLAYTITLE:_LOADIMAGE}} - -The [[_LOADIMAGE]] function loads an image into memory and returns valid [[LONG]] image handle values that are less than -1. - - -{{PageSyntax}} - -:{{Parameter|handle&}} = [[_LOADIMAGE]]({{Parameter|filename$}}[, {{Parameter|mode%}}]) - - -{{Parameters}} - -*{{Parameter|filename$}} is literal or variable [[STRING]] file name value. -*Optional {{Parameter|mode%}} [[INTEGER]] values can be: -**32 = 32-bit -**33 = hardware image - - -{{PageDescription}} - -*Various common image file formats supported, like BMP, JPG, PNG, etc. A path can also be given. -*The {{Parameter|mode%}} can designate 32-bit color or 33 ('''version 1.000 and up'''). Omit to use the current graphic screen settings. -*Mode 33 images are '''hardware''' accelerated and are created using [[_LOADIMAGE]] or [[_COPYIMAGE]] ('''version 1.000 and up'''). -*Loaded images can be read invisibly using [[POINT]]. Image coordinates start at 0 up to the [[_WIDTH (function)|_WIDTH]] - 1 and [[_HEIGHT]] - 1. -*Images can be made into a program [[SCREEN (statement)|SCREEN]] or page adopting the size and palette settings or placed using [[_PUTIMAGE]]. -*Returns -1 as an invalid handle if it can't load the image. Valid [[LONG]] handle returns are less than -1 ({{Parameter|handle&}} < -1). -*Valid images only need to be loaded once. The handle can be used repeatedly until freed. -*'''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' - - -{{PageErrors}} - -*Some picture file images may not load when a {{Parameter|mode%}} value is designated. Try loading it without a {{Parameter|mode%}} designation. -*'''It is important to free unused or discarded images with [[_FREEIMAGE]] to prevent CPU memory overflow errors.''' -*'''In text-only [[SCREEN]] 0, {{Parameter|mode%}} 32 must be specified.''' When loading an [[_ICON]] image use 32 for the {{Parameter|mode%}} too. - - -{{PageExamples}} -''Example 1:'' To display an image in 32-bit color using its resolution as a program screen: -{{CodeStart}} -i& = {{Cl|_LOADIMAGE}}("mypic.jpg", 32) -{{Cl|SCREEN (statement)|SCREEN}} i& -{{CodeEnd}} - - -''Example 2:'' [[DRAW]]ing and rotating an image 360 degrees using Turn Angle. [[POINT]] is used to read the invisible image source. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) -img& = {{Cl|_LOADIMAGE}}("QB64.PNG") 'use any 24/32 bit image - -wide% = {{Cl|_WIDTH (function)|_WIDTH}}(img&): deep% = {{Cl|_HEIGHT}}(img&) -TLC$ = "BL" + {{Cl|STR$}}(wide% \ 2) + "BU" + {{Cl|STR$}}(deep% \ 2) 'start draw at top left corner -RET$ = "BD BL" + {{Cl|STR$}}(wide%) 'return to left side of image -{{Cl|_SOURCE}} img& -{{Cl|_DEST}} 0 -DO - {{Cl|FOR...NEXT|FOR}} angle% = 0 {{Cl|TO}} 360 {{Cl|STEP}} 15 - {{Cl|CLS}} - {{Cl|DRAW}} "BM400, 300" + "TA=" + {{Cl|VARPTR$}}(angle%) + TLC$ - {{Cl|FOR...NEXT|FOR}} y = 0 {{Cl|TO}} deep% - 1 - {{Cl|FOR...NEXT|FOR}} x = 0 {{Cl|TO}} wide% - 1 - {{Cl|DRAW}} "C" + {{Cl|STR$}}({{Cl|POINT}}(x, y)) + "R1" 'color and DRAW each pixel - {{Cl|NEXT}} - {{Cl|DRAW}} RET$ - {{Cl|NEXT}} - {{Cl|_DISPLAY}} 'NOTE: CPU usage will be HIGH! - {{Cl|NEXT}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} - - -===More examples=== - -*[[SAVEIMAGE]] (QB64 Image to Bitmap SUB by Galleon) -*[[Program ScreenShots]] (Member-contributed program for legacy screen modes) -*[[ThirtyTwoBit SUB]] (QB64 Image area to bitmap) - - -{{PageSeeAlso}} - -*[[_FREEIMAGE]], [[_ICON]] -*[[_PUTIMAGE]], [[_MAPTRIANGLE]] -*[[_NEWIMAGE]], [[_COPYIMAGE]] -*[[_PRINTIMAGE]] (printer) -*[[_PALETTECOLOR (function)]], [[_COPYPALETTE]], [[_ICON]] -*[[SCREEN (statement)]] -*[[Hardware images]] -*[[Bitmaps]], [[Icons and Cursors]], [[GIF Images]] - - -{{PageNavigation}} diff --git a/internal/help/_MAPTRIANGLE__11111111111.txt b/internal/help/_MAPTRIANGLE__11111111111.txt deleted file mode 100644 index 2b90b4510..000000000 --- a/internal/help/_MAPTRIANGLE__11111111111.txt +++ /dev/null @@ -1,709 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:26}} -{{DISPLAYTITLE:_MAPTRIANGLE}} -The [[_MAPTRIANGLE]] statement maps a triangular portion of an image onto a destination image or screen page. - - -{{PageSyntax}} -===2D drawing=== -:[[_MAPTRIANGLE]] [{_SEAMLESS}] '''('''{{Parameter|sx1}}''',''' {{Parameter|sy1}}''')-('''{{Parameter|sx2}}''',''' {{Parameter|sy2}}''')-('''{{Parameter|sx3}}''',''' {{Parameter|sy3}}'''),''' {{Parameter|source&}} '''TO ('''{{Parameter|dx1}}''',''' {{Parameter|dy1}}''')-('''{{Parameter|dx2}}''',''' {{Parameter|dy2}}''')-('''{{Parameter|dx3}}''',''' {{Parameter|dy3}}''')'''[, {{Parameter|destination&}}][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]] - - -===3D drawing (hardware images only)=== - -:[[_MAPTRIANGLE]] [{_CLOCKWISE|_ANTICLOCKWISE}] [{_SEAMLESS}] '''('''{{Parameter|sx1}}''',''' {{Parameter|sy1}}''')-('''{{Parameter|sx2}}''',''' {{Parameter|sy2}}''')-('''{{Parameter|sx3}}''',''' {{Parameter|sy3}}'''),''' {{Parameter|source&}} '''TO ('''{{Parameter|dx1}}''',''' {{Parameter|dy1}}''',''' {{Parameter|dz1}}''')-('''{{Parameter|dx2}}''',''' {{Parameter|dy2}}''',''' {{Parameter|dz2}}''')-('''{{Parameter|dx3}}''',''' {{Parameter|dy3}}''',''' {{Parameter|dz3}}''')'''[, {{Parameter|destination&}}][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]] - - -{{Parameters}} -* The '''_SEAMLESS''' option makes the triangle skip the right-most and bottom-most pixels of the triangle. When you make larger objects using several triangles, there can be a "seam" where they overlap when using alpha transparency and the seam would be twice as bright. '''_SEAMLESS''' is ignored when rendering 3D content and is not yet supported when drawing 2D hardware images.''' -* For 3D drawing use the '''_CLOCKWISE''' and '''_ANTICLOCKWISE''' arguments to only draw triangles in the correct direction. See ''Example 4''. -* Coordinates are [[SINGLE]] values where whole numbers represent the exact center of a pixel of the source texture. -* {{Parameter|source&}} and optional {{Parameter|destination&}} are [[LONG]] image or screen page handles. -* Supports an optional final argument '''_SMOOTH''' which applies linear filtering. See ''Example 3''. -* Use '''_SMOOTHSTRETCHED''' or '''_SMOOTHSHRUNK''' for when a pixelated/smooth effect is desirable but not both. - - -{{PageDescription}} -* This statement is used similar to [[_PUTIMAGE]] to place triangular sections of an image, but is more flexible. -* The [[STEP]] keyword can be used to for coordinates relative to the last graphic coordinates used. -* For 2D drawing, the destination coordinates are pixel coordinates either on-screen or on the destination image. -* For 3D drawing, the destination coordinates represent left (-x) to right (+x), bottom (-y) to top (+y) & furthest (-z) to nearest (z=-1). The center of the screen is therefore (0,0,-1). Note that a z value of 0 will result in off-screen content. The furthest visible z value is -10,000. -* When drawing '''software images''' coordinate positions are '''limited from -16383 to 16383''' -* The source coordinates can be positioned outside the boundary of the ''source'' image to achieve a tiled effect. -* If the {{Parameter|destination&}} image handle is the current [[SCREEN]] page, [[_DEST]] or hardware layer, then it can be omitted. -* '''Hardware images''' (created using mode 33 via [[_LOADIMAGE]] or [[_COPYIMAGE]]) can be used as the source or destination. - - -{{PageExamples}} -''Example 1:'' Rotating the an image using a rotation and zoom SUB with _MAPTRIANGLE. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) - -Image& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'any 24/32 bit image - -{{Cl|DO}} - {{Cl|CLS}} - RotoZoom 400, 300, Image&, 1.5 + {{Cl|SIN}}(zoom), angle - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "Angle:"; {{Cl|CINT}}(angle) - {{Cl|PRINT USING|PRINT}} "Zoom"; {{Cl|PRINT USING|USING}} "##.###"; 1.5 + {{Cl|SIN}}(zoom) - {{Cl|_DISPLAY}} - angle = angle + .5: {{Cl|IF...THEN|IF}} angle >= 360 {{Cl|THEN}} angle = angle - 360 - zoom = zoom + .01 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|END}} - -{{Cl|SUB}} RotoZoom (X {{Cl|AS}} {{Cl|LONG}}, Y {{Cl|AS}} {{Cl|LONG}}, Image {{Cl|AS}} {{Cl|LONG}}, Scale {{Cl|AS}} {{Cl|SINGLE}}, Rotation {{Cl|AS}} {{Cl|SINGLE}}) -{{Cl|DIM}} px(3) {{Cl|AS}} {{Cl|SINGLE}}: {{Cl|DIM}} py(3) {{Cl|AS}} {{Cl|SINGLE}} -W& = {{Cl|_WIDTH (function)|_WIDTH}}(Image&): H& = {{Cl|_HEIGHT}}(Image&) -px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2:py(1) = H& / 2 -px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2 -sinr! = {{Cl|SIN}}(-Rotation / 57.2957795131): cosr! = {{Cl|COS}}(-Rotation / 57.2957795131) -{{Cl|FOR...NEXT|FOR}} i& = 0 {{Cl|TO}} 3 - x2& = (px(i&) * cosr! + sinr! * py(i&)) * Scale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * Scale + Y - px(i&) = x2&: py(i&) = y2& -{{Cl|NEXT}} -{{Cl|_MAPTRIANGLE}} (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2)) -{{Cl|_MAPTRIANGLE}} (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2)) -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Galleon}} -{{WhiteStart}} - '''Triangle sections of image in code above __ ''' - '''|\2|''' - ''' 1→|_\|''' -{{WhiteEnd}} - - -''Example 2:'' A 3D Spinning Cube demo using a software image and [[_MAPTRIANGLE]]: -{{CodeStart}} -' Copyright (C) 2011 by Andrew L. Ayers - -{{Cl|DIM}} OBJECT(9, 9, 4, 2) {{Cl|AS}} {{Cl|LONG}} - -' OBJECTS DEFINED {{Cl|AS}} FOLLOWS: -' (#OBJECTS,#PLANES PER OBJECT,#{{Cl|POINT}}S PER PLANE, XYZ TRIPLE) - -{{Cl|DIM}} DPLANE2D(4, 1) {{Cl|AS}} {{Cl|LONG}} ' {{Cl|SCREEN}} PLANE COORDINATES - -' DPLANE2D DEFINED {{Cl|AS}} FOLLOWS: -' (#{{Cl|POINT}}S PER PLANE, XY {{Cl|DOUBLE}}) - -{{Cl|DIM}} DPLANE3D(4, 2) {{Cl|AS}} {{Cl|LONG}} ' 3D PLANE COORDINATES - -' DPLANE3D DEFINED {{Cl|AS}} FOLLOWS: -' (#{{Cl|POINT}}S PER PLANE, XYZ TRIPLE) - -{{Cl|DIM}} PLANECOL(9) {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} STAB(359), CTAB(359) ' SINE/COSINE TABLES -D& = 400: MX& = 0: MY& = 0: MZ& = -100 -' -' COMPUTE SINE/COSINE TABLES -{{Cl|FOR...NEXT|FOR}} t& = 0 {{Cl|TO}} 359 - STAB(t&) = {{Cl|SIN}}((6.282 / 360) * t&) - CTAB(t&) = {{Cl|COS}}((6.282 / 360) * t&) -{{Cl|NEXT}} -' -' BUILD CUBE IN OBJECT ARRAY -' PLANE 0 -OBJECT(0, 0, 0, 0) = -30: OBJECT(0, 0, 0, 1) = 30: OBJECT(0, 0, 0, 2) = -30 -OBJECT(0, 0, 1, 0) = -30: OBJECT(0, 0, 1, 1) = -30: OBJECT(0, 0, 1, 2) = -30 -OBJECT(0, 0, 2, 0) = 30: OBJECT(0, 0, 2, 1) = -30: OBJECT(0, 0, 2, 2) = -30 -OBJECT(0, 0, 3, 0) = 30: OBJECT(0, 0, 3, 1) = 30: OBJECT(0, 0, 3, 2) = -30 -OBJECT(0, 0, 4, 0) = 0: OBJECT(0, 0, 4, 1) = 0: OBJECT(0, 0, 4, 2) = -30 -' PLANE 1 -OBJECT(0, 1, 0, 0) = 30: OBJECT(0, 1, 0, 1) = 30: OBJECT(0, 1, 0, 2) = -30 -OBJECT(0, 1, 1, 0) = 30: OBJECT(0, 1, 1, 1) = -30: OBJECT(0, 1, 1, 2) = -30 -OBJECT(0, 1, 2, 0) = 30: OBJECT(0, 1, 2, 1) = -30: OBJECT(0, 1, 2, 2) = 30 -OBJECT(0, 1, 3, 0) = 30: OBJECT(0, 1, 3, 1) = 30: OBJECT(0, 1, 3, 2) = 30 -OBJECT(0, 1, 4, 0) = 30: OBJECT(0, 1, 4, 1) = 0: OBJECT(0, 1, 4, 2) = 0 -' PLANE 2 -OBJECT(0, 2, 0, 0) = 30: OBJECT(0, 2, 0, 1) = 30: OBJECT(0, 2, 0, 2) = 30 -OBJECT(0, 2, 1, 0) = 30: OBJECT(0, 2, 1, 1) = -30: OBJECT(0, 2, 1, 2) = 30 -OBJECT(0, 2, 2, 0) = -30: OBJECT(0, 2, 2, 1) = -30: OBJECT(0, 2, 2, 2) = 30 -OBJECT(0, 2, 3, 0) = -30: OBJECT(0, 2, 3, 1) = 30: OBJECT(0, 2, 3, 2) = 30 -OBJECT(0, 2, 4, 0) = 0: OBJECT(0, 2, 4, 1) = 0: OBJECT(0, 2, 4, 2) = 30 -' PLANE 3 -OBJECT(0, 3, 0, 0) = -30: OBJECT(0, 3, 0, 1) = 30: OBJECT(0, 3, 0, 2) = 30 -OBJECT(0, 3, 1, 0) = -30: OBJECT(0, 3, 1, 1) = -30: OBJECT(0, 3, 1, 2) = 30 -OBJECT(0, 3, 2, 0) = -30: OBJECT(0, 3, 2, 1) = -30: OBJECT(0, 3, 2, 2) = -30 -OBJECT(0, 3, 3, 0) = -30: OBJECT(0, 3, 3, 1) = 30: OBJECT(0, 3, 3, 2) = -30 -OBJECT(0, 3, 4, 0) = -30: OBJECT(0, 3, 4, 1) = 0: OBJECT(0, 3, 4, 2) = 0 -' PLANE 4 -OBJECT(0, 4, 0, 0) = -30: OBJECT(0, 4, 0, 1) = -30: OBJECT(0, 4, 0, 2) = -30 -OBJECT(0, 4, 1, 0) = -30: OBJECT(0, 4, 1, 1) = -30: OBJECT(0, 4, 1, 2) = 30 -OBJECT(0, 4, 2, 0) = 30: OBJECT(0, 4, 2, 1) = -30: OBJECT(0, 4, 2, 2) = 30 -OBJECT(0, 4, 3, 0) = 30: OBJECT(0, 4, 3, 1) = -30: OBJECT(0, 4, 3, 2) = -30 -OBJECT(0, 4, 4, 0) = 0: OBJECT(0, 4, 4, 1) = -30: OBJECT(0, 4, 4, 2) = 0 -' PLANE 5 -OBJECT(0, 5, 0, 0) = -30: OBJECT(0, 5, 0, 1) = 30: OBJECT(0, 5, 0, 2) = -30 -OBJECT(0, 5, 1, 0) = 30: OBJECT(0, 5, 1, 1) = 30: OBJECT(0, 5, 1, 2) = -30 -OBJECT(0, 5, 2, 0) = 30: OBJECT(0, 5, 2, 1) = 30: OBJECT(0, 5, 2, 2) = 30 -OBJECT(0, 5, 3, 0) = -30: OBJECT(0, 5, 3, 1) = 30: OBJECT(0, 5, 3, 2) = 30 -OBJECT(0, 5, 4, 0) = 0: OBJECT(0, 5, 4, 1) = 30: OBJECT(0, 5, 4, 2) = 0 -' SET UP PLANE {{Cl|COLOR}}S ON CUBE -' -PLANECOL(0) = 3 -PLANECOL(1) = 4 -PLANECOL(2) = 5 -PLANECOL(3) = 6 -PLANECOL(4) = 7 -PLANECOL(5) = 8 -' -{{Cl|_TITLE}} "QB64 _MAPTRIANGLE CUBE DEMO" -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) -TextureImage& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'any 24/32 bit image -'{{Cl|_PUTIMAGE}} , Image& - -DO - ' LIMIT {{Cl|TO}} 25 FPS - {{Cl|_LIMIT}} 25 - ' ERASE LAST IMAGE - {{Cl|CLS}} - - ' CALCULATE POSITION OF NEW IMAGE - {{Cl|FOR...NEXT|FOR}} OB& = 0 {{Cl|TO}} 0 ' UP {{Cl|TO}} 9 OBJECTS - SP = STAB(PIT(OB&)): CP = CTAB(PIT(OB&)) - SY = STAB(YAW(OB&)): CY = CTAB(YAW(OB&)) - SR = STAB(ROL(OB&)): CR = CTAB(ROL(OB&)) - {{Cl|FOR...NEXT|FOR}} PL& = 0 {{Cl|TO}} 5 ' CONSISTING OF UP {{Cl|TO}} 9 PLANES - ' - {{Cl|FOR...NEXT|FOR}} PN& = 0 {{Cl|TO}} 3 ' EACH PLANE WITH UP {{Cl|TO}} 4 {{Cl|POINT}}S (#5 {{Cl|TO}} {{Cl|PAINT}}) - ' - ' TRANSLATE, {{Cl|THEN}} ROTATE - TX& = OBJECT(OB&, PL&, PN&, 0) - TY& = OBJECT(OB&, PL&, PN&, 1) - TZ& = OBJECT(OB&, PL&, PN&, 2) - RX& = (TZ& * CP - TY& * SP) * SY - ((TZ& * SP + TY& * CP) * SR + TX& * CR) * CY - RY& = (TZ& * SP + TY& * CP) * CR - TX& * SR - RZ& = (TZ& * CP - TY& * SP) * CY + ((TZ& * SP + TY& * CP) * SR + TX& * CR) * SY - ' - ' ROTATE, {{Cl|THEN}} TRANSLATE - RX& = RX& + MX& - RY& = RY& + MY& - RZ& = RZ& + MZ& - ' - DPLANE3D(PN&, 0) = RX&: DPLANE3D(PN&, 1) = RY&: DPLANE3D(PN&, 2) = RZ& - DPLANE2D(PN&, 0) = 399 + (D& * RX& / RZ&) - DPLANE2D(PN&, 1) = 299 + (D& * RY& / RZ&) - {{Cl|NEXT}} - ' - ' CHECK {{Cl|TO}} SEE {{Cl|IF...THEN|IF}} PLANE IS VISIBLE - x1& = DPLANE3D(0, 0): y1& = DPLANE3D(0, 1): Z1& = DPLANE3D(0, 2) - x2& = DPLANE3D(1, 0): y2& = DPLANE3D(1, 1): Z2& = DPLANE3D(1, 2) - x3& = DPLANE3D(2, 0): y3& = DPLANE3D(2, 1): Z3& = DPLANE3D(2, 2) - T1& = -x1& * (y2& * Z3& - y3& * Z2&) - T2& = x2& * (y3& * Z1& - y1& * Z3&) - T3& = x3& * (y1& * Z2& - y2& * Z1&) - ' - VISIBLE& = T1& - T2& - T3& - {{Cl|IF...THEN|IF}} VISIBLE& > 0 {{Cl|THEN}} - ' DRAW PLANE - xx1% = DPLANE2D(0, 0): yy1% = DPLANE2D(0, 1) - xx2% = DPLANE2D(1, 0): yy2% = DPLANE2D(1, 1) - xx3% = DPLANE2D(2, 0): yy3% = DPLANE2D(2, 1) - col% = PLANECOL(PL&) - - {{Cl|_MAPTRIANGLE}} (0, 0)-(0, 255)-(255, 255), TextureImage& TO(xx3%, yy3%)-(xx2%, yy2%)-(xx1%, yy1%) - ' CALL DrawTriangle(xx1%, yy1%, xx2%, yy2%, xx3%, yy3%, col%) - xx1% = DPLANE2D(0, 0): yy1% = DPLANE2D(0, 1) - xx3% = DPLANE2D(2, 0): yy3% = DPLANE2D(2, 1) - xx4% = DPLANE2D(3, 0): yy4% = DPLANE2D(3, 1) - {{Cl|_MAPTRIANGLE}} (0, 0)-(255, 255)-(255, 0), TextureImage& TO(xx3%, yy3%)-(xx1%, yy1%)-(xx4%, yy4%) - 'CALL DrawTriangle(xx1%, yy1%, xx3%, yy3%, xx4%, yy4%, col%) - {{Cl|END IF}} - {{Cl|NEXT}} - ' - ' ROTATE OBJECT - PIT(OB&) = PIT(OB&) + 5 - {{Cl|IF...THEN|IF}} PIT(OB&) > 359 {{Cl|THEN}} PIT(OB&) = 0 - YAW(OB&) = YAW(OB&) + 7 - {{Cl|IF...THEN|IF}} YAW(OB&) > 359 {{Cl|THEN}} YAW(OB&) = 0 - ROL(OB&) = ROL(OB&) + 9 - {{Cl|IF...THEN|IF}} ROL(OB&) > 359 {{Cl|THEN}} ROL(OB&) = 0 - {{Cl|NEXT}} - ' - ' Calculate Frames per Second - frames% = frames% + 1 - {{Cl|IF...THEN|IF}} oldtime$ <> {{Cl|TIME$}} {{Cl|THEN}} - fps% = frames% - frames% = 1 - oldtime$ = {{Cl|TIME$}} - {{Cl|END IF}} - {{Cl|COLOR}} {{Cl|_RGB}}(255, 255, 255): {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "FPS :"; fps% - ' - ' Show Image on Screen - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|WIDTH}} 80: {{Cl|SCREEN}} 0: {{Cl|CLS}} - - -{{Cl|SUB}} DrawHline (fromx%, tox%, yy%, col%) - '{{Cl|DEF SEG}} = {{Cl|&H}}A000 - '{{Cl|IF...THEN|IF}} fromx% > tox% {{Cl|THEN}} {{Cl|SWAP}} fromx%, tox% - 'yyy& = yy% - 'sloc& = yyy& * 320 + fromx% - 'eloc& = sloc& + (tox% - fromx%) - '{{Cl|FOR...NEXT|FOR}} t& = sloc& {{Cl|TO}} eloc& - ' {{Cl|POKE}} t&, col% - '{{Cl|NEXT}} - '{{Cl|DEF SEG}} - {{Cl|LINE}} (fromx%, yy%)-(tox%, yy%), {{Cl|_RGB}}(255, 255, 255) 'col% -{{Cl|END SUB}} - -{{Cl|SUB}} DrawTriangle (x1%, y1%, x2%, y2%, x3%, y3%, col%) - DO - sflag% = 0 - {{Cl|IF...THEN|IF}} y1% > y2% {{Cl|THEN}} - sflag% = 1 - {{Cl|SWAP}} y1%, y2% - {{Cl|SWAP}} x1%, x2% - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} y2% > y3% {{Cl|THEN}} - sflag% = 1 - {{Cl|SWAP}} y2%, y3% - {{Cl|SWAP}} x2%, x3% - {{Cl|END IF}} - {{Cl|LOOP}} {{Cl|UNTIL}} sflag% = 0 - ' - {{Cl|IF...THEN|IF}} y2% = y3% {{Cl|THEN}} - ' Draw a flat bottomed triangle - ydiff1% = y2% - y1% - ydiff2% = y3% - y1% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x2% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x1%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x1% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y2% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - {{Cl|EXIT SUB}} - {{Cl|ELSE}} - {{Cl|IF...THEN|IF}} y1% = y2% {{Cl|THEN}} - ' - ' Draw a flat topped triangle - ydiff1% = y3% - y1% - ydiff2% = y3% - y2% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x3% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x2%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x2% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y3% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - x1% = sx!: x2% = ex! - {{Cl|EXIT SUB}} - {{Cl|ELSE}} - ' Draw a general purpose triangle - ' First draw the flat bottom portion (top half) - ydiff1% = y2% - y1% - ydiff2% = y3% - y1% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x2% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x1%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x1% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y2% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - ' Then draw the flat topped portion (bottom half) - x1% = x2% - x2% = ex! - y1% = y2% - ydiff1% = y3% - y1% - ydiff2% = y3% - y2% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x3% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x2%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x2% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y3% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - x1% = sx!: x2% = ex! - {{Cl|END IF}} - {{Cl|END IF}} - ' -{{Cl|END SUB}} -{{CodeEnd}}{{small|Demo by Andrew L. Ayers}} - - -''Example 3:'' A 3D Spinning Cube demo using a hardware image and '''QB64GL''' hardware acceleration with [[_MAPTRIANGLE]]: -{{CodeStart}} -' Copyright (C) 2011 by Andrew L. Ayers - -{{Cl|DIM}} OBJECT(9, 9, 4, 2) {{Cl|AS}} {{Cl|LONG}} - -' OBJECTS DEFINED {{Cl|AS}} FOLLOWS: -' (#OBJECTS,#PLANES PER OBJECT,#{{Cl|POINT}}S PER PLANE, XYZ TRIPLE) - -{{Cl|DIM}} DPLANE2D(4, 1) {{Cl|AS}} {{Cl|LONG}} ' {{Cl|SCREEN}} PLANE COORDINATES - -' DPLANE2D DEFINED {{Cl|AS}} FOLLOWS: -' (#{{Cl|POINT}}S PER PLANE, XY {{Cl|DOUBLE}}) - -{{Cl|DIM}} DPLANE3D(4, 2) {{Cl|AS}} {{Cl|LONG}} ' 3D PLANE COORDINATES - -' DPLANE3D DEFINED {{Cl|AS}} FOLLOWS: -' (#{{Cl|POINT}}S PER PLANE, XYZ TRIPLE) - -{{Cl|DIM}} PLANECOL(9) {{Cl|AS}} {{Cl|INTEGER}} -{{Cl|DIM}} STAB(359), CTAB(359) ' SINE/COSINE TABLES -D& = 400: MX& = 0: MY& = 0: MZ& = -100 -' -' COMPUTE SINE/COSINE TABLES -{{Cl|FOR...NEXT|FOR}} t& = 0 {{Cl|TO}} 359 - STAB(t&) = {{Cl|SIN}}((6.282 / 360) * t&) - CTAB(t&) = {{Cl|COS}}((6.282 / 360) * t&) -{{Cl|NEXT}} -' -' BUILD CUBE IN OBJECT ARRAY -' PLANE 0 -OBJECT(0, 0, 0, 0) = -30: OBJECT(0, 0, 0, 1) = 30: OBJECT(0, 0, 0, 2) = -30 -OBJECT(0, 0, 1, 0) = -30: OBJECT(0, 0, 1, 1) = -30: OBJECT(0, 0, 1, 2) = -30 -OBJECT(0, 0, 2, 0) = 30: OBJECT(0, 0, 2, 1) = -30: OBJECT(0, 0, 2, 2) = -30 -OBJECT(0, 0, 3, 0) = 30: OBJECT(0, 0, 3, 1) = 30: OBJECT(0, 0, 3, 2) = -30 -OBJECT(0, 0, 4, 0) = 0: OBJECT(0, 0, 4, 1) = 0: OBJECT(0, 0, 4, 2) = -30 -' PLANE 1 -OBJECT(0, 1, 0, 0) = 30: OBJECT(0, 1, 0, 1) = 30: OBJECT(0, 1, 0, 2) = -30 -OBJECT(0, 1, 1, 0) = 30: OBJECT(0, 1, 1, 1) = -30: OBJECT(0, 1, 1, 2) = -30 -OBJECT(0, 1, 2, 0) = 30: OBJECT(0, 1, 2, 1) = -30: OBJECT(0, 1, 2, 2) = 30 -OBJECT(0, 1, 3, 0) = 30: OBJECT(0, 1, 3, 1) = 30: OBJECT(0, 1, 3, 2) = 30 -OBJECT(0, 1, 4, 0) = 30: OBJECT(0, 1, 4, 1) = 0: OBJECT(0, 1, 4, 2) = 0 -' PLANE 2 -OBJECT(0, 2, 0, 0) = 30: OBJECT(0, 2, 0, 1) = 30: OBJECT(0, 2, 0, 2) = 30 -OBJECT(0, 2, 1, 0) = 30: OBJECT(0, 2, 1, 1) = -30: OBJECT(0, 2, 1, 2) = 30 -OBJECT(0, 2, 2, 0) = -30: OBJECT(0, 2, 2, 1) = -30: OBJECT(0, 2, 2, 2) = 30 -OBJECT(0, 2, 3, 0) = -30: OBJECT(0, 2, 3, 1) = 30: OBJECT(0, 2, 3, 2) = 30 -OBJECT(0, 2, 4, 0) = 0: OBJECT(0, 2, 4, 1) = 0: OBJECT(0, 2, 4, 2) = 30 -' PLANE 3 -OBJECT(0, 3, 0, 0) = -30: OBJECT(0, 3, 0, 1) = 30: OBJECT(0, 3, 0, 2) = 30 -OBJECT(0, 3, 1, 0) = -30: OBJECT(0, 3, 1, 1) = -30: OBJECT(0, 3, 1, 2) = 30 -OBJECT(0, 3, 2, 0) = -30: OBJECT(0, 3, 2, 1) = -30: OBJECT(0, 3, 2, 2) = -30 -OBJECT(0, 3, 3, 0) = -30: OBJECT(0, 3, 3, 1) = 30: OBJECT(0, 3, 3, 2) = -30 -OBJECT(0, 3, 4, 0) = -30: OBJECT(0, 3, 4, 1) = 0: OBJECT(0, 3, 4, 2) = 0 -' PLANE 4 -OBJECT(0, 4, 0, 0) = -30: OBJECT(0, 4, 0, 1) = -30: OBJECT(0, 4, 0, 2) = -30 -OBJECT(0, 4, 1, 0) = -30: OBJECT(0, 4, 1, 1) = -30: OBJECT(0, 4, 1, 2) = 30 -OBJECT(0, 4, 2, 0) = 30: OBJECT(0, 4, 2, 1) = -30: OBJECT(0, 4, 2, 2) = 30 -OBJECT(0, 4, 3, 0) = 30: OBJECT(0, 4, 3, 1) = -30: OBJECT(0, 4, 3, 2) = -30 -OBJECT(0, 4, 4, 0) = 0: OBJECT(0, 4, 4, 1) = -30: OBJECT(0, 4, 4, 2) = 0 -' PLANE 5 -OBJECT(0, 5, 0, 0) = -30: OBJECT(0, 5, 0, 1) = 30: OBJECT(0, 5, 0, 2) = -30 -OBJECT(0, 5, 1, 0) = 30: OBJECT(0, 5, 1, 1) = 30: OBJECT(0, 5, 1, 2) = -30 -OBJECT(0, 5, 2, 0) = 30: OBJECT(0, 5, 2, 1) = 30: OBJECT(0, 5, 2, 2) = 30 -OBJECT(0, 5, 3, 0) = -30: OBJECT(0, 5, 3, 1) = 30: OBJECT(0, 5, 3, 2) = 30 -OBJECT(0, 5, 4, 0) = 0: OBJECT(0, 5, 4, 1) = 30: OBJECT(0, 5, 4, 2) = 0 -' SET UP PLANE {{Cl|COLOR}}S ON CUBE -' -PLANECOL(0) = 3 -PLANECOL(1) = 4 -PLANECOL(2) = 5 -PLANECOL(3) = 6 -PLANECOL(4) = 7 -PLANECOL(5) = 8 -' -{{Cl|_TITLE}} "QB64 {{Cl|_MAPTRIANGLE}} CUBE DEMO" -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) - -TextureImage& = {{Cl|_LOADIMAGE}}("qb64_trans.png", 32) 'any 24/32 bit image -{{Cl|_SETALPHA}} 128, , TextureImage& -TextureImage& = {{Cl|_COPYIMAGE}}(TextureImage&, 33)'copy of hardware image - -'{{Cl|_PUTIMAGE}} , Image& - -DO - - ' LIMIT {{Cl|TO}} 25 FPS - '{{Cl|_LIMIT}} 25 - ' {{Cl|ERASE}} LAST IMAGE - '{{Cl|CLS}} , {{Cl|_RGB}}(0, 0, 160) - - ' CALCULATE POSITION OF NEW IMAGE - {{Cl|FOR...NEXT|FOR}} OB& = 0 {{Cl|TO}} 0 ' UP {{Cl|TO}} 9 OBJECTS - SP = STAB(PIT(OB&)): CP = CTAB(PIT(OB&)) - SY = STAB(YAW(OB&)): CY = CTAB(YAW(OB&)) - SR = STAB(ROL(OB&)): CR = CTAB(ROL(OB&)) - {{Cl|FOR...NEXT|FOR}} PL& = 0 {{Cl|TO}} 5 ' CONSISTING OF UP {{Cl|TO}} 9 PLANES - ' - {{Cl|FOR...NEXT|FOR}} PN& = 0 {{Cl|TO}} 3 ' EACH PLANE WITH UP {{Cl|TO}} 4 {{Cl|POINT}}S (#5 {{Cl|TO}} {{Cl|PAINT}}) - ' - ' TRANSLATE, {{Cl|THEN}} ROTATE - TX& = OBJECT(OB&, PL&, PN&, 0) - TY& = OBJECT(OB&, PL&, PN&, 1) - TZ& = OBJECT(OB&, PL&, PN&, 2) - RX& = (TZ& * CP - TY& * SP) * SY - ((TZ& * SP + TY& * CP) * SR + TX& * CR) * CY - RY& = (TZ& * SP + TY& * CP) * CR - TX& * SR - RZ& = (TZ& * CP - TY& * SP) * CY + ((TZ& * SP + TY& * CP) * SR + TX& * CR) * SY - ' - ' ROTATE, {{Cl|THEN}} TRANSLATE - RX& = RX& + MX& - RY& = RY& + MY& - RZ& = RZ& + MZ& - ' - DPLANE3D(PN&, 0) = RX&: DPLANE3D(PN&, 1) = RY&: DPLANE3D(PN&, 2) = RZ& - DPLANE2D(PN&, 0) = 399 + (D& * RX& / RZ&) - DPLANE2D(PN&, 1) = 299 + (D& * RY& / RZ&) - {{Cl|NEXT}} - ' - ' CHECK {{Cl|TO}} SEE {{Cl|IF...THEN|IF}} PLANE {{Cl|IS}} VISIBLE - x1& = DPLANE3D(0, 0): y1& = DPLANE3D(0, 1): Z1& = DPLANE3D(0, 2) - x2& = DPLANE3D(1, 0): y2& = DPLANE3D(1, 1): Z2& = DPLANE3D(1, 2) - x3& = DPLANE3D(2, 0): y3& = DPLANE3D(2, 1): Z3& = DPLANE3D(2, 2) - T1& = -x1& * (y2& * Z3& - y3& * Z2&) - T2& = x2& * (y3& * Z1& - y1& * Z3&) - T3& = x3& * (y1& * Z2& - y2& * Z1&) - ' - VISIBLE& = T1& - T2& - T3& - {{Cl|IF...THEN|IF}} VISIBLE& > 0 {{Cl|THEN}} - ' {{Cl|DRAW}} PLANE - xx1% = DPLANE2D(0, 0): yy1% = DPLANE2D(0, 1) - xx2% = DPLANE2D(1, 0): yy2% = DPLANE2D(1, 1) - xx3% = DPLANE2D(2, 0): yy3% = DPLANE2D(2, 1) - col% = PLANECOL(PL&) - - {{Cl|_BLEND}} TextureImage& - {{Cl|_MAPTRIANGLE}} (0, 0)-(0, 255)-(255, 255), TextureImage& TO(xx1%, yy1%)-(xx2%, yy2%)-(xx3%, yy3%) - - ' {{Cl|CALL}} DrawTriangle(xx1%, yy1%, xx2%, yy2%, xx3%, yy3%, col%) - xx1% = DPLANE2D(0, 0): yy1% = DPLANE2D(0, 1) - xx3% = DPLANE2D(2, 0): yy3% = DPLANE2D(2, 1) - xx4% = DPLANE2D(3, 0): yy4% = DPLANE2D(3, 1) - - {{Cl|_DONTBLEND}} TextureImage& - {{Cl|_MAPTRIANGLE}} (0, 0)-(255, 255)-(255, 0), TextureImage& TO(xx3%, yy3%)-(xx1%, yy1%)-(xx4%, yy4%), , _SMOOTH - '{{Cl|CALL}} DrawTriangle(xx1%, yy1%, xx3%, yy3%, xx4%, yy4%, col%) - {{Cl|END IF}} - {{Cl|NEXT}} - ' - ' ROTATE OBJECT - PIT(OB&) = PIT(OB&) + 5 - {{Cl|IF...THEN|IF}} PIT(OB&) > 359 {{Cl|THEN}} PIT(OB&) = 0 - YAW(OB&) = YAW(OB&) + 7 - {{Cl|IF...THEN|IF}} YAW(OB&) > 359 {{Cl|THEN}} YAW(OB&) = 0 - ROL(OB&) = ROL(OB&) + 9 - {{Cl|IF...THEN|IF}} ROL(OB&) > 359 {{Cl|THEN}} ROL(OB&) = 0 - {{Cl|NEXT}} - ' - ' Calculate Frames per Second - frames% = frames% + 1 - {{Cl|IF...THEN|IF}} oldtime$ <> {{Cl|TIME$}} {{Cl|THEN}} - fps% = frames% - frames% = 1 - oldtime$ = {{Cl|TIME$}} - {{Cl|END IF}} - {{Cl|COLOR}} {{Cl|_RGB}}(255, 255, 255): {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "FPS :"; fps% - ' - ' Show Image on Screen - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{Cl|WIDTH}} 80: {{Cl|SCREEN}} 0: {{Cl|CLS}} - -{{Cl|SUB}} DrawHline (fromx%, tox%, yy%, col%) -'{{Cl|DEF SEG}} = {{Cl|&H}}A000 -'{{Cl|IF...THEN|IF}} fromx% > tox% {{Cl|THEN}} {{Cl|SWAP}} fromx%, tox% -'yyy& = yy% -'sloc& = yyy& * 320 + fromx% -'eloc& = sloc& + (tox% - fromx%) -'{{Cl|FOR...NEXT|FOR}} t& = sloc& {{Cl|TO}} eloc& -' {{Cl|POKE}} t&, col% -'{{Cl|NEXT}} -'{{Cl|DEF SEG}} -{{Cl|LINE}} (fromx%, yy%)-(tox%, yy%), {{Cl|_RGB}}(255, 255, 255) 'col% -{{Cl|END SUB}} - -{{Cl|SUB}} DrawTriangle (x1%, y1%, x2%, y2%, x3%, y3%, col%) -DO - sflag% = 0 - {{Cl|IF...THEN|IF}} y1% > y2% {{Cl|THEN}} - sflag% = 1 - {{Cl|SWAP}} y1%, y2% - {{Cl|SWAP}} x1%, x2% - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} y2% > y3% {{Cl|THEN}} - sflag% = 1 - {{Cl|SWAP}} y2%, y3% - {{Cl|SWAP}} x2%, x3% - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} sflag% = 0 -' -{{Cl|IF...THEN|IF}} y2% = y3% {{Cl|THEN}} - ' Draw a flat bottomed triangle - ydiff1% = y2% - y1% - ydiff2% = y3% - y1% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x2% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x1%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x1% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y2% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - {{Cl|EXIT SUB}} -{{Cl|ELSE}} - {{Cl|IF...THEN|IF}} y1% = y2% {{Cl|THEN}} - ' - ' Draw a flat topped triangle - ydiff1% = y3% - y1% - ydiff2% = y3% - y2% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x3% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x2%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x2% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y3% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - x1% = sx!: x2% = ex! - {{Cl|EXIT SUB}} - {{Cl|ELSE}} - ' Draw a general purpose triangle - ' First draw the flat bottom portion (top half) - ydiff1% = y2% - y1% - ydiff2% = y3% - y1% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x2% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x1%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x1% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y2% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - ' Then draw the flat topped portion (bottom half) - x1% = x2% - x2% = ex! - y1% = y2% - ydiff1% = y3% - y1% - ydiff2% = y3% - y2% - {{Cl|IF...THEN|IF}} ydiff1% <> 0 {{Cl|THEN}} - slope1! = (x3% - x1%) / ydiff1% - {{Cl|ELSE}} - slope1! = 0 - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} ydiff2% <> 0 {{Cl|THEN}} - slope2! = (x3% - x2%) / ydiff2% - {{Cl|ELSE}} - slope2! = 0 - {{Cl|END IF}} - sx! = x1%: ex! = x2% - {{Cl|FOR...NEXT|FOR}} y% = y1% {{Cl|TO}} y3% - {{Cl|CALL}} DrawHline({{Cl|CINT}}(sx!), {{Cl|CINT}}(ex!), y%, col%) - sx! = sx! + slope1! - ex! = ex! + slope2! - {{Cl|NEXT}} - x1% = sx!: x2% = ex! - {{Cl|END IF}} -{{Cl|END IF}} -' -{{Cl|END SUB}} -{{CodeEnd}}{{small|Adapted from a demo by Andrew L. Ayers}} - - -''Example 4:'' Using a desktop image with _MAPTRIANGLE _ANTICLOCKWISE rendering. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) - -ss32 = {{Cl|_SCREENIMAGE}} 'take a 32bit software screenshot -{{Cl|_SETALPHA}} 128, , ss32 'make it a bit transparent -ss33 = {{Cl|_COPYIMAGE}}(ss32, 33) 'convert it to a hardware image (mode 33) -{{Cl|_FREEIMAGE}} ss32 'we don't need this anymore - -DO - {{Cl|CLS}} , {{Cl|_RGB}}(0, 128, 255) 'use our software screen as a blue backdrop - - 'rotate our destination points - 'the QB64 3D co-ordinate system is the same as OpenGL's: - ' negative z is in front of you, if it doesn't have a negative z value you won't see it! - ' x goes from left to right, 0 is the middle of the screen - ' y goes from bottom to top, 0 is the middle of the screen - scale = 10 - dist = -10 - angle = angle + 0.1 - x1 = {{Cl|SIN}}(angle) * scale - z1 = {{Cl|COS}}(angle) * scale - x2 = {{Cl|SIN}}(angle + 3.14) * scale 'adding 3.14 adds 180 degrees - z2 = {{Cl|COS}}(angle + 3.14) * scale - 'what we performed above is a 2D/horizontal rotation of points - '(3D rotations are beyond the scope of this example) - - 'draw the triangle - '_ANTICLOCKWISE makes it only draw when our triangle is facing the correct direction - '_SMOOTH applies linear filtering to avoid a pixelated look - - {{Cl|_MAPTRIANGLE}} '''_ANTICLOCKWISE''' ({{Cl|_WIDTH (function)|_WIDTH}}(ss33) / 2, 0)-(0, {{Cl|_HEIGHT}}(ss33))-({{Cl|_WIDTH (function)|_WIDTH}}(ss33),_ - {{Cl|_HEIGHT}}(ss33)), ss33 TO(0, scale, dist)-(x1, -scale, z1 + dist)-(x2, -scale, z2 + dist), , '''_SMOOTH''' - - {{Cl|_LIMIT}} 30 - {{Cl|_DISPLAY}} -{{Cl|LOOP}} -{{CodeEnd}} -: '''Tip:''' If you are using Linux you might want to replace "[[_SCREENIMAGE]]" with a [[_LOADIMAGE]] command if you don't see anything. - - -{{PageSeeAlso}} -* [[_PUTIMAGE]] -* [[_LOADIMAGE]] -* [[_COPYIMAGE]] -* [[GET (graphics statement)]], [[PUT (graphics statement)]] -* [[STEP]], [[SIN]], [[COS]] -* [[Hardware images]] - - -{{PageNavigation}} diff --git a/internal/help/_MAPUNICODE_(function)__1111111111_(00000000).txt b/internal/help/_MAPUNICODE_(function)__1111111111_(00000000).txt deleted file mode 100644 index 11aa2b585..000000000 --- a/internal/help/_MAPUNICODE_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:29}} -{{DISPLAYTITLE:_MAPUNICODE (function)}} -The [[_MAPUNICODE]] function returns the [[Unicode]] (UTF-32) code point value of a mapped [[ASCII]] character code. - - -{{PageSyntax}} -: {{Parameter|utfValue&}} = [[_MAPUNICODE]]({{Parameter|asciiCode%}}) - - -{{PageDescription}} -* UTF-32 values have 4-byte encoding so the return variable should be [[LONG]]. -* The {{Parameter|asciiCode%}} can be any [[INTEGER]] value from 0 to 255. -* Returns can be used to verify or catalog the present Unicode mapping. -* The function returns Unicode values for the control characters, CHR$(127) and extended characters without mapping them first. - - -{{PageExamples}} -''Example:'' Store function return values in an array for ASCII codes 0 to 255 to restore them later. -{{CodeStart}} -{{Cl|DIM}} Unicode&(255) -{{Cl|SCREEN (statement)|SCREEN}} 0 -{{Cl|_FONT}} {{Cl|_LOADFONT}}("C:\Windows\Fonts\Cour.ttf", 20, "MONOSPACE") 'select monospace font - -{{Cl|FOR...NEXT|FOR}} ascii = 0 {{Cl|TO}} 255 -Unicode&(ascii) = {{Cl|_MAPUNICODE (function)|_MAPUNICODE}}(ascii) 'read Unicode values -{{Cl|PRINT}} Unicode&(ascii); 'display values in demo -{{Cl|NEXT}} - 'rest of program -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MAPUNICODE]] {{text|(statement)}} -* [[Unicode]], [[Code Pages]] {{text|(by region)}} -* [[ASCII]], [[CHR$]], [[ASC]] -* [[Text Using Graphics]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MAPUNICODE__1111111111.txt b/internal/help/_MAPUNICODE__1111111111.txt deleted file mode 100644 index ab237f6be..000000000 --- a/internal/help/_MAPUNICODE__1111111111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:28}} -{{DISPLAYTITLE:_MAPUNICODE}} -The [[_MAPUNICODE]] statement maps a [[Unicode]] value to an [[ASCII]] character code value. - - - -{{PageSyntax}} -: [[_MAPUNICODE]] {{Parameter|unicode&}} '''TO''' {{Parameter|asciiCode%}} - - -* The [[LONG]] {{Parameter|unicode&}} value is a [[HEX$|hexadecimal]] or decimal code value from a [[Unicode]] [[Code Pages|Code Page]]. -* The {{Parameter|asciiCode%}} [[INTEGER]] parameter is any [[ASCII]] or Extended code value from 0 to 255. -* Use the Unicode Page Table values listed here: [http://en.wikipedia.org/wiki/Category:DOS_code_pages DOS Code Pages] or [http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/ Windows Mapping] -* Once the codes are mapped, key entries will display the unicode character in the '''monospace ''' [[_FONT|font]] selected. -* The [[_MAPUNICODE (function)|_MAPUNICODE]] function can be used to verify or read the present [[Unicode]] UTF32 code point settings. -* '''[[_MAPUNICODE]] can place the Unicode characters TO any [[ASCII]] code space you desire (0 to 255)'''. - - -{{PageExamples}} -''Example:'' Converting the extended [[ASCII]] characters to other characters using DATA from the Unicode [[Code Pages]]. -{{CodeStart}} -{{Cl|SCREEN}} 0 -{{Cl|_FONT}} {{Cl|_LOADFONT}}("C:\windows\fonts\cour.ttf", 20, "MONOSPACE") - -{{Cl|RESTORE}} Microsoft_pc_cpMIK -{{Cl|FOR...NEXT|FOR}} ASCIIcode = 128 {{Cl|TO}} 255 - {{Cl|READ}} unicode - {{Cl|_MAPUNICODE}} Unicode {{Cl|TO}} ASCIIcode -{{Cl|NEXT}} - - -{{Cl|FOR...NEXT|FOR}} i = 128 {{Cl|TO}} 255 - {{Cl|PRINT}} {{Cl|CHR$}}(i) + " "; - cnt = cnt + 1 - {{Cl|IF...THEN|IF}} cnt {{Cl|MOD}} 16 = 0 {{Cl|THEN}} {{Cl|PRINT}} -{{Cl|NEXT}} -{{Cl|END}} - -Microsoft_pc_cpMIK: -{{Cl|DATA}} 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055 -{{Cl|DATA}} 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071 -{{Cl|DATA}} 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087 -{{Cl|DATA}} 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103 -{{Cl|DATA}} 9492,9524,9516,9500,9472,9532,9571,9553,9562,9566,9577,9574,9568,9552,9580,9488 -{{Cl|DATA}} 9617,9618,9619,9474,9508,8470,167,9559,9565,9496,9484,9608,9604,9612,9616,9600 -{{Cl|DATA}} 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745 -{{Cl|DATA}} 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160 -{{CodeEnd}} -: ''Note:'' The Unicode data field is created by adding DATA before each line listed for the appropriate [[Code Pages|Code Page]]. - - - -{{PageSeeAlso}} -* [[_MAPUNICODE (function)]] -* [[ASCII]], [[Unicode]], [[_FONT]] -* [[_KEYHIT]], [[_KEYDOWN]] -* [[ASC]], [[INKEY$]], [[CHR$]] -* [[Code Pages]] {{text|(by region)}} -* [[Text Using Graphics]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MEMCOPY__1111111.txt b/internal/help/_MEMCOPY__1111111.txt deleted file mode 100644 index 37783478a..000000000 --- a/internal/help/_MEMCOPY__1111111.txt +++ /dev/null @@ -1,75 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:32}} -{{DISPLAYTITLE:_MEMCOPY}} -The [[_MEMCOPY]] statement copies a block of bytes from one memory offset to another offset in memory. - - -{{PageSyntax}} -: [[_MEMCOPY]] {{Parameter|sourceBlock}}, {{Parameter|sourceBlock.OFFSET}}, {{Parameter|sourceBlock.SIZE}} [[TO]] {{Parameter|destBlock}}, {{Parameter|destBlock.OFFSET}} - - -{{Parameters}} -* {{Parameter|sourceBlock}} is the source memory block name created AS [[_MEM]]. -* {{Parameter|sourceBlock.OFFSET}} is the dot [[_OFFSET]] within the source memory block to read from. -* {{Parameter|sourceBlock.SIZE}} is the total number of bytes to transfer based on actual size. -* {{Parameter|destBlock}} is the destination [[_MEM]] memory block name to transfer data to. -* {{Parameter|destBlock.OFFSET}} is the dot [[_OFFSET]] within the dest [[_MEM]] memory block to write to. - - -{{PageDescription}} -* The dot OFFSET is the memory block's start location in memory. Add bytes to place data further into the block. -* The dot SIZE is the total byte size of the memory block to transfer. You can transfer all or a portion of the data bytes. -* The memory block regions may overlap. -* '''Always free memory blocks after values have been transferred to variables and are no longer required.''' - - -{{PageExamples}} -''Example:'' Swapping data from one [[STRING]] variable to another. Fixed length strings are recommended for speed. -{{CodeStart}} -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -{{Cl|DIM}} n {{Cl|AS}} {{Cl|_MEM}} - -m = {{Cl|_MEMNEW}}(10) -n = {{Cl|_MEMNEW}}(100) - -{{Cl|_MEMPUT}} m, m.OFFSET, "1234567890" - -s$ = {{Cl|SPACE$}}(10) 'to load into a variable length string set its length first -{{Cl|_MEMGET}} m, m.OFFSET, s$ -{{Cl|PRINT}} "in:[" + s$ + "]" - -{{Cl|_MEMCOPY}} m, m.OFFSET, m.SIZE {{Cl|TO}} n, n.OFFSET 'put m into n - -b$ = {{Cl|SPACE$}}(10) -{{Cl|_MEMGET}} n, n.OFFSET, b$ -{{Cl|PRINT}} "out:[" + b$ + "]" -{{Cl|_MEMFREE}} m: {{Cl|_MEMFREE}} n 'always clear the memory when done -{{CodeEnd}} - - -''Snippet:'' Instead of copying each array element, one at a time in nested [[FOR...NEXT|FOR]] loops, _MEMCOPY does it in one statement instantly. -{{TextStart}} -'copy array a to array b one index at a time: -{{Cb|FOR...NEXT|FOR}} i1 = 0 {{Cb|TO}} 100 - {{Cb|FOR...NEXT|FOR}} i2 = 0 {{Cb|TO}} 100 - b(i1, i2) = a(i1, i2) - {{Cb|NEXT}} -{{Cb|NEXT}} - -'copy array a to array b in memory instantly: -{{Cb|DIM}} ma {{Cl|AS}} {{Cb|_MEM}}: ma = {{Cb|_MEM (function)|_MEM}}(a()) 'place array data into blocks -{{Cb|DIM}} mb {{Cl|AS}} {{Cb|_MEM}}: mb = {{Cb|_MEM (function)|_MEM}}(b()) -{{Cb|_MEMCOPY}} ma, ma.OFFSET, ma.SIZE {{Cb|TO}} mb, mb.OFFSET -{{Cb|_MEMFREE}} ma: {{Cb|_MEMFREE}} mb 'clear the memory when done -{{TextEnd}} - - -{{PageSeeAlso}} -* [[_MEM]], [[_MEM (function)]] -* [[_MEMNEW]], [[_MEMGET (function)]] -* [[_MEMIMAGE]], [[_MEMELEMENT]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMFILL]], [[_MEMFREE]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMELEMENT__1111111111.txt b/internal/help/_MEMELEMENT__1111111111.txt deleted file mode 100644 index 27e59c560..000000000 --- a/internal/help/_MEMELEMENT__1111111111.txt +++ /dev/null @@ -1,89 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:33}} -{{DISPLAYTITLE:_MEMELEMENT}} -The [[_MEMELEMENT]] function returns a [[_MEM]] block referring to a variable's memory, but not past it. - - -{{PageSyntax}} -: {{Parameter|memoryBlock}} = [[_MEMELEMENT]]({{Parameter|referenceVariable}}) - - -* The {{Parameter|referenceVariable}} parameter designates the existing variable name using the memory block. -* _MEMELEMENT is the same as [[_MEM]] but in an array it returns the specifications of an element, not the entire array. -* All values created by memory functions MUST be freed using [[_MEMFREE]] with a valid [[_MEM]] variable type. -* The _MEMELEMENT type contains the following '''read-only''' elements where ''name'' is the variable name: -:: ''name'''''.OFFSET''' is the beginning offset of the memory block AS [[_OFFSET]] -:: ''name'''''.SIZE''' returns the largest available region of memory of the ELEMENT in bytes AS [[_OFFSET]] -:: ''name'''''.ELEMENTSIZE''' is the [[_BYTE]] size of the elements within the block AS [[_OFFSET]] - -:::* 2 = [[INTEGER]] values have an element size of 2 bytes -:::* 4 = [[LONG]] integer and [[SINGLE]] float values have an element size of 4 bytes -:::* 8 = [[DOUBLE]] float and [[_INTEGER64]] values have an element size of 8 bytes -:::* 32 = [[_FLOAT]] values have an element size of 32 bytes -:::* [[LEN]] = [[STRING]] or [[_OFFSET]] byte sizes vary so use [[LEN]](variable) for the number of bytes. -:: ''name'''''.TYPE''' is the type (represented as bits combined to form a value) AS [[LONG]] (see below). - -==.TYPE values (version 1.000 and up)== -:::* 0 = UDT ([[TYPE|user defined type]]) or memory created by [[_MEMNEW]] -:::* 1 = 1 bit ELEMENT.SIZE=1 *Only used along with specific types (currently integers or floats) -:::* 2 = 2 bit. ELEMENT.SIZE=2 * -:::* 4 = 4 bit. ELEMENT.SIZE=4 * -:::* 8 = 8 bit. ELEMENT.SIZE=8 * -:::* 16 = 16 bit. ELEMENT.SIZE=16 * -:::* 32 = 32 bit. ELEMENT.SIZE=32 * -:::* 64 = 64 bit. ELEMENT.SIZE=64 * -:::* 128 = 128 bit. ELEMENT.SIZE=128 * -:::* 256 = 256 bit. ELEMENT.SIZE=256 * -:::* 512(+ bit*) = integer types only(ie. whole numbers) -:::* 1024(+ bit*) = floating point types only(ie. numbers that can have a decimal point) -:::* 2048 = [[STRING]] type only -:::* 4096(+ 512 + bit*) = [[_UNSIGNED]] integer type only -:::* 8192 = [[_MEM]] type only -:::* 16384(+ 512 + bit*)= [[_OFFSET]] type only -''Note: If a future integer, float or other type doesn't have a size that is 1,2,4,8,16,32,64,128 or 256 it won't have a size-bit set.'' - -===Versions prior to 1.000=== -:::* 1 = Integer types such as [[_BYTE]], [[INTEGER]], [[LONG]], [[_INTEGER64]] or [[_OFFSET]] -:::* 2 = [[_UNSIGNED]] variable types. Value must be added to the variable type value.(2 cannot be used by itself) -:::* 3 = ALL [[_UNSIGNED]] [[INTEGER]] type values.(add 1 + 2) -:::* 4 = Floating point types such as [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] -:::* 8 = [[STRING]] -:::* 0 = unknown(eg. created with [[_MEMNEW]]) or [[TYPE|user-defined-types]] - -
'''Note: [[_MEM]] and [[_OFFSET]] values cannot be cast to other variable types.'''
- - -{{PageExamples}} -''Example:'' Comparing the specifications returned by [[_MEM]] and _MEMELEMENT from an array. -{{CodeStart}} -{{Cl|DIM}} a(1 {{Cl|TO}} 100) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} - -{{Cl|DIM}} m1 {{Cl|AS}} {{Cl|_MEM}} -{{Cl|DIM}} m2 {{Cl|AS}} {{Cl|_MEM}} - -m1 = {{Cl|_MEM (function)|_MEM}}(a(50)) 'function returns information about array up to specific element -{{Cl|PRINT}} m1.OFFSET, m1.SIZE, m1.TYPE, m1.ELEMENTSIZE - -m2 = {{Cl|_MEMELEMENT}}(a(50)) 'function returns information about the specific element -{{Cl|PRINT}} m2.OFFSET, m2.SIZE, m2.TYPE, m2.ELEMENTSIZE - -{{Cl|END}} -{{CodeEnd}} -: Output using VERSION .954 ONLY .TYPE values: 1 (integer) + 2 (unsigned) -{{OutputStart}}28377205 51 3 1 -28377205 1 3 1 {{OutputEnd}} -: ''Explanation:'' [[_MEM]] returns the info about the array to that element while _MEMELEMENT returns info about that element only. -::* [[_MEM]] value returns the available array .SIZE as 51 bytes from the designated array element. -::* [[_MEMELEMENT]] value returns the available element .SIZE as one byte. - - -{{PageSeeAlso}} -* [[_MEM]] -* [[_MEMNEW]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMFREE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MEMEXISTS__111111111.txt b/internal/help/_MEMEXISTS__111111111.txt deleted file mode 100644 index da796b0fb..000000000 --- a/internal/help/_MEMEXISTS__111111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:35}} -{{DISPLAYTITLE:_MEMEXISTS}} -The [[_MEMEXISTS]] function returns true (-1) if the memory block variable name specified exists in memory and false (0) if it does not. - - -{{PageSyntax}} -: {{Parameter|result}} = [[_MEMEXISTS]]({{Parameter|memBlock}}) - - -{{PageDescription}} -* The {{Parameter|memBlock}} variable name must have been created using [[DIM]] memBlock [[AS]] [[_MEM]] type ([[DIM]]. -* The function verifies that the memory variable exists in memory before using a passed block, to avoid generating QB64 errors. -* Typically, this function is used by a [[DECLARE LIBRARY|LIBRARY]] [[SUB]] or [[FUNCTION]] which accepts a [[_MEM]] structure as input, to avoid an error. - - -{{Parameter|See Also:}} -* [[_MEM (function)]] -* [[_MEMELEMENT]], [[_MEMCOPY]] -* [[_MEMIMAGE]], [[_MEMNEW]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMFILL]], [[_MEMFREE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MEMFILL__1111111.txt b/internal/help/_MEMFILL__1111111.txt deleted file mode 100644 index 085603d74..000000000 --- a/internal/help/_MEMFILL__1111111.txt +++ /dev/null @@ -1,50 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:36}} -{{DISPLAYTITLE:_MEMFILL}} -The [[_MEMFILL]] statement converts a value to a specified type, then fills memory with that type including any non-whole remainder. - - -{{PageSyntax}} -: [[_MEMFILL]] {{Parameter|memoryBlock}}, {{Parameter|memoryBlock.OFFSET}}, {{Parameter|fillBytes}}, {{Parameter|value}} [AS {{Parameter|variableType}}] - - -{{Parameters}} -* The {{Parameter|memoryBlock}} [[_MEM]] memory block is the block referenced to be filled. -* {{Parameter|memoryBlock.OFFSET}} is the starting offset of the above referenced memory block. -* The {{Parameter|fillBytes}} is the number of bytes to fill the memory block. -* The {{Parameter|value}} is the value to place in the memory block at the designated OFFSET position. -* A literal or variable {{Parameter|value}} can be optionally set [[AS]] a variable [[type]] appropriate for the memory block. - - -{{PageDescription}} -* To clear previous data from a [[_MEMNEW]] memory block, use _MEMFILL with a {{Parameter|value}} of 0. - - -{{PageExamples}} -''Example:'' Filling array values quickly using FOR loops or a simple memory fill. -{{CodeStart}} -{{Cl|DIM}} a(100, 100) {{Cl|AS}} {{Cl|LONG}} -{{Cl|DIM}} b(100, 100) {{Cl|AS}} {{Cl|LONG}} - -'filling array a with value 13 -{{Cl|FOR...NEXT|FOR}} i1 = 0 {{Cl|TO}} 100 - {{Cl|FOR...NEXT|FOR}} i2 = 0 {{Cl|TO}} 100 - a(i1, i2) = 13 - {{Cl|NEXT}} -{{Cl|NEXT}} - -'filling array b with value 13 -{{Cl|DIM}} mema {{Cl|AS}} {{Cl|_MEM}} -mema = {{Cl|_MEM (function)|_MEM}}(b()) -{{Cl|_MEMFILL}} mema, mema.OFFSET, mema.SIZE, 13 {{Cl|AS}} {{Cl|LONG}} -{{Cl|_MEMFREE}} mema -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MEM]], [[_MEM (function)]] -* [[_MEMIMAGE]], [[_MEMNEW]] -* [[_MEMGET]], [[_MEMPUT]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMFREE__1111111.txt b/internal/help/_MEMFREE__1111111.txt deleted file mode 100644 index 5c3803d99..000000000 --- a/internal/help/_MEMFREE__1111111.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:37}} -{{DISPLAYTITLE:_MEMFREE}} -The [[_MEMFREE]] statement frees the designated memory block [[_MEM]] value and must be used with all memory functions. - - -{{PageSyntax}} -: [[_MEMFREE]] {{Parameter|memoryVariable}} - - -{{Parameters}} -* ALL designated [[_MEM]] type {{Parameter|memoryVariable}} values must be freed to conserve memory when they are no longer used or needed. - - -{{PageDescription}} -* Since [[_MEM]] type variables cannot use a suffix, use [[DIM]] {{Parameter|memoryVariable}} [[AS]] [[_MEM]] to create memory handle variables. -* All values created by memory functions must be freed using [[_MEMFREE]] with a valid [[_MEM]] variable. - - -{{PageSeeAlso}} -* [[_MEM]] {{text|(variable type)}} -* [[_MEM (function)]] -* [[_MEMNEW]] {{text|(function)}} -* [[_MEMIMAGE]] {{text|(function)}} -* [[_MEMELEMENT]] {{text|(function)}} -* [[_MEMGET (function)]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMGET_(function)__111111_(00000000).txt b/internal/help/_MEMGET_(function)__111111_(00000000).txt deleted file mode 100644 index ecd929c31..000000000 --- a/internal/help/_MEMGET_(function)__111111_(00000000).txt +++ /dev/null @@ -1,47 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:39}} -{{DISPLAYTITLE:_MEMGET (function)}} -The [[_MEMGET]] function returns a value from a specific memory block name at the specified OFFSET using a certain variable type. - - -{{PageSyntax}} -: {{Parameter|returnValue}} = [[_MEMGET]]({{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|variableType}}) - - -{{Parameters}} -* Returns a value of the {{Parameter|variableType}} designated. The holding variable must match that [[TYPE]]. -* {{Parameter|memoryBlock}} is a [[_MEM]] variable type memory block name created by [[_MEMNEW]] or the [[_MEM (function)|_MEM]] function. -* {{Parameter|bytePosition}} is the {{Parameter|memoryBlock}}.[[OFFSET]] memory start position plus any bytes to move into the block. -* {{Parameter|variableType}} is a variable [[TYPE]] like [[_BYTE]], [[INTEGER]], [[SINGLE]], [[DOUBLE]], etc. - - -{{PageDescription}} -* {{Parameter|memoryBlock}}.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block. -* The variable type held in the memory block can determine the next {{Parameter|bytePosition}} to read. -* [[LEN]] can be used to determine the byte size of numerical or user defined variable [[type]]s regardless of the value held. -* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found. -* '''_MEMGET variable values that are assigned a variable [[type]] other than a memory type do not need to be freed.''' - - -{{PageExamples}} -''Example:'' [[DEF SEG]] and [[VARPTR]] are no longer necessary to do things in memory just like [[POKE]] and [[PEEK]] do. -{{CodeStart}} -{{Cl|DIM}} o {{Cl|AS}} {{Cl|_MEM}} -o = {{Cl|_MEM (function)|_MEM}}(d&) 'OLD... o% = VARPTR(d&) -{{Cl|_MEMPUT}} o, o.OFFSET + 1, 3 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'a POKE -v = {{Cl|_MEMGET (function)|_MEMGET}}(o, o.OFFSET + 1, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) 'a PEEK -{{Cl|PRINT}} v 'prints 3 -{{Cl|PRINT}} d& 'prints 768 because the 2nd byte of d& has been set to 3 or 3 * 256 -{{Cl|_MEMFREE}} o -{{CodeEnd}} -:''Explanation:'' The memory block and OFFSET are given by [[_MEMPUT]] and the _MEMGET function, with the designated type. - - -{{PageSeeAlso}} -* [[_MEM]], [[MEM (function)]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMNEW]], [[_MEMFILL]] -* [[_MEMCOPY]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMGET__111111.txt b/internal/help/_MEMGET__111111.txt deleted file mode 100644 index 13c15597c..000000000 --- a/internal/help/_MEMGET__111111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:38}} -{{DISPLAYTITLE:_MEMGET}} -The [[_MEMGET]] statement reads a portion of a memory block at an OFFSET position into a variable, array or user defined type. - - -{{PageSyntax}} -: [[_MEMGET]] {{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|destinationVariable}} - - -* {{Parameter|memoryBlock}} is a [[_MEM]] variable type memory block name created by [[_MEMNEW]] or the [[_MEM (function)|_MEM]] function. -* {{Parameter|bytePosition}} is the {{Parameter|memoryBlock}}.[[OFFSET]] memory start position plus any bytes to move into the block. -* {{Parameter|destinationVariable}} is the variable assigned to hold the data. The number of bytes read is determined by the variable [[type]] used. - - -{{PageDescription}} -* The [[_MEMGET]] statement is similar to the [[GET]] statement used in files, but the position is required. -* The memory block name.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block. -* The variable type held in the memory block can determine the next {{Parameter|bytePosition}} to read. -* [[LEN]] can be used to determine the byte size of numerical or user defined variable [[type]]s regardless of the value held. -* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found. - - -{{PageExamples]] -''Example:'' Shows how to read the PSET color values from a program's [[SCREEN]] memory to an array. -{{CodeStart}} -{{Cl|SCREEN}} 13 -{{Cl|PSET}} (0, 0), 123 -{{Cl|PSET}} (1, 0), 222 'create screen image - -'here is an array -{{Cl|DIM}} screen_array(319, 199) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'use screen dimensions from 0 - -'here's how we can copy the screen to our array -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -m = {{Cl|_MEMIMAGE}} '0 or no handle necessary when accessing the current program screen -{{Cl|_MEMGET}} m, m.OFFSET, screen_array() - -'here's the proof -{{Cl|PRINT}} screen_array(0, 0) 'print 123 -{{Cl|PRINT}} screen_array(1, 0) 'print 222 -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MEMGET (function)]] -* [[_MEMPUT]] -* [[_MEM]] -* [[_MEMIMAGE]] -* [[_MEMFREE]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMIMAGE__11111111.txt b/internal/help/_MEMIMAGE__11111111.txt deleted file mode 100644 index fe0b11709..000000000 --- a/internal/help/_MEMIMAGE__11111111.txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:41}} -{{DISPLAYTITLE:_MEMIMAGE}} -The [[_MEMIMAGE]] function returns a [[_MEM]] value referring to an image's memory using a designated image handle. - - -{{PageSyntax}} -: {{Parameter|imageBlock}} = [[_MEMIMAGE]][({{Parameter|imageHandle&}})] - - -{{Parameters}} -* The {{Parameter|imageBlock}} [[_MEM]] type variable holds the read-only elements .OFFSET, .SIZE, .TYPE and .ELEMENTSIZE. -* If the optional {{Parameter|imageHandle&}} isn't passed, it is assumed to be the current [[_DEST]]ination program screen image. - - -{{PageDescription}} -* Use the function to place images into memory access blocks for faster data access. -* All values created by this function must be freed using [[_MEMFREE]] with a valid [[_MEM]] [[type]] variable. -* Image handle values and the memory used must still be freed using [[_FREEIMAGE]] when no longer required. - - -{{PageExamples}} -''Example 1:'' Darkening an image using memory with [[$CHECKING]]:OFF for greater speed. Use any 24 bit image file name on the second code line. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(1024, 768, 32) -i& = {{Cl|_LOADIMAGE}}("turtle.jpg") '<<<<<<<<<<<<< use any 24 bit image file - -{{Cl|FOR...NEXT|FOR}} n! = 1 {{Cl|TO}} 0.01 {{Cl|STEP}} -0.01 - i2& = {{Cl|_COPYIMAGE}}(i&) - DarkenImage i2&, n! - {{Cl|_PUTIMAGE}} (0, 0), i2& - {{Cl|_FREEIMAGE}} i2& - {{Cl|_DISPLAY}} -{{Cl|NEXT}} - -{{Cl|SUB}} DarkenImage (Image {{Cl|AS}} {{Cl|LONG}}, Value_From_0_To_1 {{Cl|AS}} {{Cl|SINGLE}}) -{{Cl|IF...THEN|IF}} Value_From_0_To_1 <= 0 {{Cl|OR (boolean)|OR}} Value_From_0_To_1 >= 1 {{Cl|OR (boolean)|OR}} {{Cl|_PIXELSIZE}}(Image) <> 4 {{Cl|THEN}} {{Cl|EXIT SUB}} -{{Cl|DIM}} Buffer {{Cl|AS}} {{Cl|_MEM}}: Buffer = {{Cl|_MEMIMAGE}}(Image) 'Get a memory reference to our image -{{Cl|DIM}} Frac_Value {{Cl|AS}} {{Cl|LONG}}: Frac_Value = Value_From_0_To_1 * 65536 'Used to avoid slow floating point calculations -{{Cl|DIM}} O {{Cl|AS}} {{Cl|_OFFSET}}, O_Last {{Cl|AS}} {{Cl|_OFFSET}} -O = Buffer.OFFSET 'We start at this offset -O_Last = Buffer.OFFSET + {{Cl|_WIDTH (function)|_WIDTH}}(Image) * {{Cl|_HEIGHT}}(Image) * 4 'We stop when we get to this offset -'use on error free code ONLY! -{{Cl|$CHECKING}}:OFF -DO - {{Cl|_MEMPUT}} Buffer, O, {{Cl|_MEMGET (function)|_MEMGET}}(Buffer, O, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) * Frac_Value \ 65536 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} - {{Cl|_MEMPUT}} Buffer, O + 1, {{Cl|_MEMGET (function)|_MEMGET}}(Buffer, O + 1, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) * Frac_Value \ 65536 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} - {{Cl|_MEMPUT}} Buffer, O + 2, {{Cl|_MEMGET (function)|_MEMGET}}(Buffer, O + 2, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) * Frac_Value \ 65536 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} - O = O + 4 -{{Cl|LOOP}} {{Cl|UNTIL}} O = O_Last -'turn checking back on when done! -{{Cl|$CHECKING}}:ON -{{Cl|_MEMFREE}} Buffer -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code by Galleon}} -: ''Explanation:'' The second value passed to DarkenImage is a value from 0.0 to 1.0 where 0.0 is full darkness and 1 is none. - - -''Example 2:'' Reading information stored in an image with [[_MEMIMAGE]] to print [[ASC]] text characters to the screen. -{{CodeStart}} -{{Cl|SCREEN}} 13 -{{Cl|_FULLSCREEN}} -{{Cl|PSET}} (0, 0), {{Cl|ASC}}("H") -{{Cl|PSET}} (1, 0), {{Cl|ASC}}("E") -{{Cl|PSET}} (2, 0), {{Cl|ASC}}("L") -{{Cl|PSET}} (3, 0), {{Cl|ASC}}("L") -{{Cl|PSET}} (4, 0), {{Cl|ASC}}("O") -{{Cl|PSET}} (5, 0), 32 -{{Cl|PSET}} (6, 0), {{Cl|ASC}}("W") -{{Cl|PSET}} (7, 0), {{Cl|ASC}}("O") -{{Cl|PSET}} (8, 0), {{Cl|ASC}}("R") -{{Cl|PSET}} (9, 0), {{Cl|ASC}}("L") -{{Cl|PSET}} (10, 0), {{Cl|ASC}}("D") -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -m = {{Cl|_MEMIMAGE}} -x1$ = {{Cl|_MEMGET (function)|_MEMGET}}(m, m.OFFSET, {{Cl|STRING}} * 11) 'convert numbers to ASCII text characters -{{Cl|_MEMFREE}} m 'free memory when done -{{Cl|LOCATE}} 10, 1: {{Cl|PRINT}} {{Cl|LEN}}(x1$) 'prints 11 as byte length -{{Cl|PRINT}} x1$ 'prints HELLO WORLD -{{Cl|END}} -{{CodeEnd}} -: ''Notes:'' The colors in the upper left corner are the text data used. An image could hold a hidden text message this way. - - -{{PageSeeAlso}} -* [[_MEM]] -* [[_MEMNEW]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMFREE]] -* [[$CHECKING]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMNEW__111111.txt b/internal/help/_MEMNEW__111111.txt deleted file mode 100644 index 8b3e7afd5..000000000 --- a/internal/help/_MEMNEW__111111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:42}} -{{DISPLAYTITLE:_MEMNEW}} -The [[_MEMNEW]] function allocates new memory and returns a [[_MEM]] memory block referring to it. - - -{{PageSyntax}} -: {{Parameter|memoryBlock}} = [[_MEMNEW]]({{Parameter|byteSize}}) - - -{{Parameters}} -* The {{Parameter|byteSize}} parameter is the desired byte size of the memory block based on the variable [[type]] it will hold. - - -{{PageDescription}} -* The {{Parameter|memoryBlock}} value created holds the elements .OFFSET, .SIZE, .TYPE and .ELEMENTSIZE. -* [[_MEMNEW]] does not clear the data previously in the memory block it allocates, for speed purposes. -* To clear previous data from a new memory block, use [[_MEMFILL]] with a byte value of 0. -* When a new memory block is created the memory .TYPE value will be 0. -* '''If the read only memory block .SIZE is 0, the memory block was not created.''' -* '''All values created by memory functions must be freed using [[_MEMFREE]] with a valid [[_MEM]] variable.''' - - -{{PageExamples}} -''Example:'' Shows how [[SINGLE]] numerical values can be passed, but non-fixed [[STRING]] lengths cannot get the value. -{{CodeStart}} -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -{{Cl|DIM}} f {{Cl|AS}} {{Cl|STRING}} * 5 -m = {{Cl|_MEMNEW}}(5) 'create new memory block of 5 bytes -a = 12345.6 -{{Cl|_MEMPUT}} m, m.OFFSET, a 'put single value -{{Cl|_MEMGET}} m, m.OFFSET, b 'get single value -{{Cl|PRINT}} "b = "; b -c$ = "Doggy" -{{Cl|_MEMPUT}} m, m.OFFSET, c$ 'put 5 byte string value -{{Cl|_MEMGET}} m, m.OFFSET, d$ 'get unfixed length string value -{{Cl|_MEMGET}} m, m.OFFSET, f 'get 5 byte string value -e$ = {{Cl|_MEMGET (function)|_MEMGET}}(m, m.OFFSET, {{Cl|STRING}} * 5) 'get 5 byte string value -{{Cl|PRINT}} "d$ = "; d$; {{Cl|LEN}}(d$) 'prints empty string -{{Cl|PRINT}} "e$ = "; e$; {{Cl|LEN}}(e$) -{{Cl|PRINT}} "f = "; f; {{Cl|LEN}}(f) -{{CodeEnd}} -{{OutputStart}}b = 12345.6 -d$ = 0 -e$ = Doggy 5 -f = Doggy 5 {{OutputEnd}} - - - -{{PageSeeAlso}} -* [[_MEM]], [[_MEMPUT]] -* [[_MEMGET]], [[_MEMGET (function)]] -* [[_MEMFILL]], [[_MEMFREE]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMPUT__111111.txt b/internal/help/_MEMPUT__111111.txt deleted file mode 100644 index 7553c5c9c..000000000 --- a/internal/help/_MEMPUT__111111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:43}} -{{DISPLAYTITLE:_MEMPUT}} -The [[_MEMPUT]] statement writes data to a portion of a designated memory block at an [[OFFSET]] position. - - -{{PageSyntax}} -: [[_MEMPUT]] {{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|sourceVariable}} [AS {{Parameter|type}}] - - -{{Parameters}} -* {{Parameter|memoryBlock}} is a [[_MEM]] variable type memory block name created by [[_MEMNEW]] or the [[_MEM (function)|_MEM]] function. -* {{Parameter|bytePosition}} is the {{Parameter|memoryBlock}}.[[OFFSET]] start position plus any bytes needed to read specific values. -* The {{Parameter|sourceVariable}} type designates the size and {{Parameter|bytePosition}} it should be written to. It can be a variable, [[arrays|array]] or user defined type. -* {{Parameter|bytePosition}} can be converted [[AS]] a specific variable ''[[TYPE|type]]'' before being written to the {{Parameter|memoryBlock}} as bytes. - - -{{PageDescription}} -* The _MEMPUT statement is similar to the [[PUT]] file statement, but {{Parameter|bytePosition}} is required. -* The {{Parameter|memoryBlock}}.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block. -* The variable type held in the memory block can determine the next ''byte position'' to write a value. -* [[LEN]] can be used to determine the byte size of numerical or user defined variable [[type]]s regardless of the value held. -* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found. - - -{{PageDescription}} -''Example:'' _MEMPUT can be used just like [[POKE]] without [[DEF SEG]]. -{{CodeStart}} -{{Cl|DIM}} o {{Cl|AS}} {{Cl|_MEM}} -o = {{Cl|_MEM (function)|_MEM}}(d&) -{{Cl|_MEMPUT}} o, o.OFFSET + 1, 3 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'POKE -v = {{Cl|_MEMGET (function)|_MEMGET}}(o, o.OFFSET + 1, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) 'PEEK -{{Cl|PRINT}} v 'prints 3 -{{Cl|PRINT}} d& 'print 768 because the 2nd byte of d& has been set to 3 or 3 * 256 -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MEMGET]], [[_MEMGET (function)]] -* [[_MEM]], [[_MEM (function)]] -* [[_MEMIMAGE]], [[_MEMNEW]] -* [[_MEMFREE]], [[_MEMCOPY]] - - -{{PageNavigation}} diff --git a/internal/help/_MEMSOUND__11111111.txt b/internal/help/_MEMSOUND__11111111.txt deleted file mode 100644 index c105d614a..000000000 --- a/internal/help/_MEMSOUND__11111111.txt +++ /dev/null @@ -1,93 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:44}} -{{DISPLAYTITLE:_MEMSOUND}} -The [[_MEMSOUND]] function returns a [[_MEM]] value referring to a sound's raw data in memory using a designated sound handle created by the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: {{Parameter|soundBlock}} = [[_MEMSOUND]][({{Parameter|soundHandle&}}, {{Parameter|channel%}})] - - -{{PageParameters}} -* The {{Parameter|soundBlock}} [[_MEM]] type variable holds the read-only elements .OFFSET, .SIZE, .ELEMENTSIZE, and .SOUND. -** .ELEMENTSIZE will contain the number of bytes-per-sample the audio contains. Usually returns 2 (16-bit audio). -** .SOUND will contain the same handle value as returned by the [[_SNDOPEN]] function. -* The second parameter {{Parameter| channel%}} must be 1 (left channel/mono) or 2 (right channel, for stereo files). - - -{{PageDescription}} -* Use the function to access raw sound data in memory for direct access. -* Sound handle values and the memory used must still be freed using [[_SNDCLOSE]] when no longer required. -* If .SIZE returns 0, that means the data could not be accessed. It may happen if you try to access the right channel in a mono file, for example. - - -{{PageAvailability}} -* '''QB64 1.5 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example 1:'' Checking that a sound file is stereo. -{{CodeStart}} -song& = {{Cl|_SNDOPEN}}("song.wav") 'replace song.wav with a sound file you have -{{Cl|IF}} song& = 0 {{Cl|THEN}} {{Cl|PRINT}} "Load failed.": {{Cl|END}} - -{{Cl|DIM}} leftchannel {{Cl|AS}} {{Cl|_MEM}}, rightchannel {{Cl|AS}} {{Cl|_MEM}} -leftchannel = {{Cl|_MEMSOUND}}(song&, 1) -rightchannel = {{Cl|_MEMSOUND}}(song&, 2) - -{{Cl|IF}} rightchannel.SIZE > 0 {{Cl|THEN}} {{Cl|PRINT}} "This file is STEREO" -{{Cl|IF}} rightchannel.SIZE = 0 {{Cl|AND}} leftchannel.SIZE > 0 {{Cl|THEN}} - {{Cl|PRINT}} "This file is MONO" -{{Cl|ELSEIF}} rightchannel.SIZE = 0 {{Cl|AND}} leftchannel.SIZE = 0 {{Cl|THEN}} - {{Cl|PRINT}} "An error occurred." -{{Cl|END IF}} - -{{Cl|_SNDCLOSE}} song& 'closing the sound releases the mem blocks -{{CodeEnd}} - - -''Example 2:'' Plotting a sound's waves. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 327, 32) -song& = {{Cl|_SNDOPEN}}("drums.ogg") 'replace drums.ogg with a sound file you have -{{Cl|IF}} song& = 0 {{Cl|THEN}} {{Cl|PRINT}} "Load failed.": {{Cl|END}} - -{{Cl|DIM}} leftchannel {{Cl|AS}} {{Cl|_MEM}} -leftchannel = {{Cl|_MEMSOUND}}(song&, 1) - -{{Cl|IF}} leftchannel.SIZE = 0 {{Cl|THEN}} - {{Cl|PRINT}} "An error occurred." - {{Cl|END}} -{{Cl|END IF}} - -{{Cl|DIM}} i {{Cl|AS}} {{Cl|_OFFSET}} -i = 0 -{{Cl|DO}} - {{Cl|_MEMGET}} leftchannel, leftchannel.OFFSET + i, a% 'get sound data - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} i; "/"; leftchannel.SIZE - {{Cl|LINE}} (x, {{Cl|_HEIGHT}} / 2)-{{Cl|STEP}}(0, a% / 100), {{Cl|_RGB32}}(0, 111, 0) 'plot wave - x = x + 1 - {{Cl|IF}} x > {{Cl|_WIDTH}} {{Cl|THEN}} - x = 0 - {{Cl|LINE}} (0, 0)-({{Cl|_WIDTH}}, {{Cl|_HEIGHT}}), {{Cl|_RGB32}}(0, 120), BF 'fade out screen - {{Cl|END}} {{Cl|IF}} - i = i + 2 - {{Cl|IF}} i + 2 > leftchannel.SIZE {{Cl|THEN}} {{Cl|EXIT}} {{Cl|DO}} - {{Cl|_LIMIT}} 500 -{{Cl|LOOP}} - -{{Cl|_SNDCLOSE}} song& 'closing the sound releases the mem blocks -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MEM]], [[_MEMIMAGE]] -* [[_MEMNEW]] -* [[_MEMGET]], [[_MEMPUT]] -* [[_MEMFREE]] -* [[$CHECKING]] - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MEM_(function)__111_(00000000).txt b/internal/help/_MEM_(function)__111_(00000000).txt deleted file mode 100644 index 124e3ca63..000000000 --- a/internal/help/_MEM_(function)__111_(00000000).txt +++ /dev/null @@ -1,73 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:30}} -{{DISPLAYTITLE:_MEM (function)}} -The [[_MEM]] function returns a _MEM block referring to the largest possible continuous memory region beginning at a variable's offset. - - -{{PageSyntax}} -: {{Parameter|memoryBlock}} = [[_MEM]]({{Parameter|referenceVariable}}) - -===Unsecure syntax=== -: {{Parameter|memoryBlock}} = [[_MEM]]({{Parameter|offset}}, {{Parameter|byteSize}}) - - -{{PageParameters}} -* The {{Parameter|memoryBlock}} created will hold the {{Parameter|referenceVariable}} or [[arrays|array]] value(s), type and byte size in a separate memory area. -* The secure syntax {{Parameter|referenceVariable}} is an existing variable's referenced memory block. -* The unsecure syntax's designated {{Parameter|offset}} and {{Parameter|byteSize}} cannot be guaranteed. '''Avoid if possible.''' - - -{{PageDescription}} -* The {{Parameter|memoryBlock}} [[_MEM]] type variable holds the following read-only elements: OFFSET, SIZE, TYPE and ELEMENTSIZE. -* All values created by memory functions MUST be freed using [[_MEMFREE]] with a valid [[_MEM]] variable type. -* '''_MEM function cannot reference variable length [[STRING]] variable values. String values must be designated as a fixed-[[LEN|length]] string.''' - - -{{PageExamples}} -''Example:'' Assigning values to reference variables in memory. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} m(3) {{Cl|AS}} {{Cl|_MEM}} -{{Cl|DIM}} {{Cl|SHARED}} Saved(3) - -m(1) = {{Cl|_MEM (function)|_MEM}}(x) -m(2) = {{Cl|_MEM (function)|_MEM}}(y) -m(3) = {{Cl|_MEM (function)|_MEM}}(z) - -x = 3: y = 5: z = 8 -{{Cl|PRINT}} x, y, z -Save x, y, z -x = 30: y = 50: z = 80 -{{Cl|PRINT}} x, y, z - -RestoreIt -{{Cl|PRINT}} x, y, z - -{{Cl|_MEMFREE}} m(1) -{{Cl|_MEMFREE}} m(2) -{{Cl|_MEMFREE}} m(3) -{{Cl|END}} - -{{Cl|SUB}} Save (n1, n2, n3) -Saved(1) = n1 -Saved(2) = n2 -Saved(3) = n3 -{{Cl|END SUB}} - -{{Cl|SUB}} RestoreIt -{{Cl|_MEMPUT}} m(1), m(1).OFFSET, Saved(1) -{{Cl|_MEMPUT}} m(2), m(2).OFFSET, Saved(2) -{{Cl|_MEMPUT}} m(3), m(3).OFFSET, Saved(3) -{{Cl|END SUB}} -{{CodeEnd}}{{small|Code by SMcNeill}} - - -{{PageSeeAlso}} -* [[_MEM]] {{text|(variable type)}} -* [[_MEMNEW]], [[_MEMCOPY]], [[_MEMFREE]] -* [[_MEMGET]], [[_MEMPUT]], [[_MEMFILL]] -* [[_MEMIMAGE]], [[_MEMSOUND]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MEM__111.txt b/internal/help/_MEM__111.txt deleted file mode 100644 index ef32d5c27..000000000 --- a/internal/help/_MEM__111.txt +++ /dev/null @@ -1,158 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:31}} -{{DISPLAYTITLE:_MEM}} -The [[_MEM]] variable type can be used when working with memory blocks. It has no variable [[Variable Types|type]] suffix. - - -{{PageSyntax}} -: [[DIM]] m [[AS]] [[_MEM]] - - -{{PageDescription}} -''Variable TYPE:'' -* Memory DOT values are actually part of the built in memory variable [[Variable Types|type]] in QB64. The following [[TYPE]] is built in: -{{WhiteStart}} -TYPE memory_type - OFFSET AS _OFFSET 'start location of block(changes with byte position) - SIZE AS _OFFSET 'size of block remaining at offset(changes with position) - TYPE AS _OFFSET 'type description of variable used(never changes) - ELEMENTSIZE AS _OFFSET 'byte size of values inside the block(never changes) - IMAGE AS LONG 'the image handle used when _MEMIMAGE(handle) is used - SOUND AS LONG 'the sound handle used when _MEMSOUND(handle) is used -END TYPE - -{{text|The above [[TYPE]] is for clarification purposes only. It '''doesn't need''' to be pasted in
a program to use _MEM.|red}} - -{{text|'''IMPORTANT NOTE:''' ''As of Build 20170802/57 onward (early v1.2 development), mem.TYPE has
been changed to be an _OFFSET, just as mem.SIZE and mem.ELEMENTSIZE.''|red}} -{{WhiteEnd}} - -===Usage=== -* The _MEM type contains the following '''read-only''' elements where ''name'' is the _MEM variable name: -:: ''name'''''.OFFSET''' is the current start position in the memory block AS [[_OFFSET]]. Add bytes to change position. -:: ''name'''''.SIZE''' is the remaining size of the block at current position in bytes AS [[_OFFSET]] -:: ''name'''''.TYPE''' is the type (represented as bits combined to form a value) AS [[_OFFSET]]: - -==.TYPE values (version 1.000 and up)== -:::* [bit 0] 1* byte types (_BYTE) -:::* [bit 1] 2* byte types (INTEGER) -:::* [bit 2] 4* byte types (LONG or SINGLE) -:::* [bit 3] 8* byte types (DOUBLE or _INTEGER64) -:::* [bit 4] 16* byte types (reserved for future use) -:::* [bit 5] 32* byte types (_FLOAT) -:::* [bit 6] 64* byte types (reserved for future use) -:::* [bit 7] 128 = integer types (_BYTE, INTEGER, LONG, _INTEGER64) (added to *) -:::* [bit 8] 256 = floating point types (SINGLE, DOUBLE, _FLOAT) (added to *) -:::* [bit 9] 512 = STRING types (fixed length or variable length) -:::* [bit 10] 1024 = _UNSIGNED types (added to *+128) -:::* [bit 11] 2048 = pixel data usually from _MEMIMAGE (added to 1+128+1024 for 256 color screens, or 2+128+1024 for text screens, or 4+128+1024 for 32-bit color screens) -:::* [bit 12] 4096 = _MEM TYPE structure (NOT added to 32768) -:::* [bit 13] 8192 = _OFFSET type (added to 4+128+[1024] or 8+128+[1024] or future_size+128+[1024]) -:::* [bit 14] 16384 = data created/defined by _MEMNEW(size) or _MEMNEW(offset,size) -:::* [bit 15] 32768 = a custom, user defined type (ie. created with TYPE name ... END TYPE) -:::* [bit 16] 65536 = an array of data (added to other type values defining the array's data type) -''Note: If a future integer, float or other type doesn't have a size that is 1,2,4,8,16,32,64,128 or 256 it won't have a size-bit set.'' - -===Versions prior to 1.000=== -:::* 1 = Integer types such as [[_BYTE]], [[INTEGER]], [[LONG]], [[_INTEGER64]] or [[_OFFSET]] -:::* 2 = [[_UNSIGNED]] variable types. Value must be added to the variable type value.(2 cannot be used by itself) -:::* 3 = ALL [[_UNSIGNED]] [[INTEGER]] type values.(add 1 + 2) -:::* 4 = Floating point types such as [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] -:::* 8 = [[STRING]] -:::* 0 = unknown(eg. created with [[_MEMNEW]]) or [[TYPE|user-defined-types]] - -* '''Note: [[_OFFSET]] values cannot be cast to other variable [[Variable Types|type]]s reliably. _MEM is a reserved custom variable [[Variable Types|type]].''' -* '''[[_MEM (function)|_MEM]] cannot reference variable length [[STRING]] variable values. String values must be designated as a fixed-[[LEN|length]] string.''' - - -{{PageExamples}} -''Example 1:'' Demonstration of .IMAGE to determine an image's dimensions, .TYPE to verify the type and [[_MEMEXISTS]] to check image has not been freed -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(500, 500, 32) -i = {{Cl|_LOADIMAGE}}("qb64_trans.png", 32) -{{Cl|_PUTIMAGE}} (0, 0), i -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -m = {{Cl|_MEMIMAGE}}(i) -'try uncommenting the following line and see what happens -'{{Cl|_MEMFREE}} m -t = m.{{Cl|TYPE}} -{{Cl|IF...THEN|IF}} t {{Cl|AND (boolean)|AND}} 2048 {{Cl|THEN}} - {{Cl|PRINT}} "this is/was an image" - {{Cl|IF...THEN|IF}} {{Cl|_MEMEXISTS}}(m) {{Cl|THEN}} 'check if memory m is still available - {{Cl|PRINT}} t {{Cl|AND (boolean)|AND}} 7; "bytes per pixel" - {{Cl|PRINT}} "image handle "; m.IMAGE - {{Cl|PRINT}} "image width"; {{Cl|_WIDTH (function)|_WIDTH}}(m.IMAGE) - {{Cl|PRINT}} "image height"; {{Cl|_HEIGHT}}(m.IMAGE) - {{Cl|ELSE}} {{Cl|PRINT}} "Memory already freed!" - {{Cl|END IF}} -{{Cl|END IF}} -{{CodeEnd}} - - -''Example 2:'' Converts the current [[_DEST|destination]] [[SCREEN]] 13 image memory altered by [[PSET]] to a [[STRING]] value. SCREEN 13 only. -{{CodeStart}} -{{Cl|SCREEN}} 13 -{{Cl|PSET}} (0, 0), {{Cl|ASC}}("H") 'top left corner of screen -{{Cl|PSET}} (1, 0), {{Cl|ASC}}("E") -{{Cl|PSET}} (2, 0), {{Cl|ASC}}("L") -{{Cl|PSET}} (3, 0), {{Cl|ASC}}("L") -{{Cl|PSET}} (4, 0), {{Cl|ASC}}("O") - -{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}} -m = {{Cl|_MEMIMAGE}}(0) 'copy the screen memory to m -x1$ = {{Cl|_MEMGET (function)|_MEMGET}}(m, m.OFFSET, {{Cl|STRING}} * 5) 'get at block start position -{{Cl|LOCATE}} 2, 1:{{Cl|PRINT}} {{Cl|LEN}}(x1$) 'prints 5 bytes as size is STRING * 5 -{{Cl|PRINT}} x1$ 'prints HELLO as ASCII character values -{{Cl|PRINT}} m.OFFSET; m.SIZE; m.ELEMENTSIZE -{{Cl|_MEMFREE}} m -{{CodeEnd}} -{{OutputStart}} - 5 -HELLO - 5448320 6400 1 -{{OutputEnd}} -: ''Explanation:'' When a numerical [[_BYTE]] value is converted to a [[STRING]], each byte is converted to an [[ASCII]] character. The QB64 IDE will capitalize _MEM dot values. -{{WhiteStart}} m.SIZE = 320 * 200 = 6400 bytes - m.ELEMENTSIZE = 1 byte -{{WhiteEnd}} - -''Example 3:'' Using _MEM to convert _OFFSET to _INTEGER64. -{{CodeStart}} -DIM x AS INTEGER -DIM m AS _MEM -m = _MEM(x) -PRINT m.OFFSET -PRINT ConvertOffset(m.OFFSET) - - -FUNCTION ConvertOffset&& (value AS _OFFSET) -$CHECKING:OFF -DIM m AS _MEM 'Define a memblock -m = _MEM(value) 'Point it to use value -$IF 64BIT THEN - 'On 64 bit OSes, an OFFSET is 8 bytes in size. We can put it directly into an Integer64 - _MEMGET m, m.OFFSET, ConvertOffset&& 'Get the contents of the memblock and put the values there directly into ConvertOffset&& -$ELSE - 'However, on 32 bit OSes, an OFFSET is only 4 bytes. We need to put it into a LONG variable first - _MEMGET m, m.OFFSET, temp& 'Like this - ConvertOffset&& = temp& 'And then assign that long value to ConvertOffset&& -$END IF -_MEMFREE m 'Free the memblock -$CHECKING:ON -END FUNCTION - -{{CodeEnd}} - -''Explanation:'' The above will print two numbers which should match. These numbers will vary, as they're representations of where X is stored in memory, and that position is going to vary every time the program is run. What it should illustrate, however, is a way to convert _OFFSET to _INTEGER64 values, which can sometimes be useful when trying to run calculations involving mem.SIZE, mem.TYPE, or mem.ELEMENTSIZE. - - - -{{PageSeeAlso}} -* [[_MEM (function)]], [[_MEMELEMENT]] -* [[_MEMNEW]], [[_MEMCOPY]], [[_MEMFREE]] -* [[_MEMGET]], [[_MEMPUT]], [[_MEMFILL]] -* [[_MEMIMAGE]], [[_MEMSOUND]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MK$__11$.txt b/internal/help/_MK$__11$.txt deleted file mode 100644 index 1a33c0495..000000000 --- a/internal/help/_MK$__11$.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:47}} -{{DISPLAYTITLE:_MK$}} -The [[_MK$]] function can convert any numerical type into an [[ASCII]] [[STRING]] value that can be converted back using [[_CV]]. - - -{{PageSyntax}} -:{{Parameter|string_value$}} = [[_MK$]]({{Parameter|numericalType}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalType}} is any QB64 numerical type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_BYTE]] or [[_BIT]]. -* Whole integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} must match the {{Parameter|numericalType}} used. - - -{{PageDescription}} -* Supports converting any QBasic or '''QB64''' numerical value into a string value. -* Some resulting [[ASCII]] string characters might not be able to be printed to the screen. - - -{{PageSeeAlso}} -* [[_CV]] {{text|(QB64 conversion function)}} -* [[MKI$]], [[CVI]], [[INTEGER]] -* [[MKL$]], [[CVL]], [[LONG]] -* [[MKS$]], [[CVS]], [[SINGLE]] -* [[MKD$]], [[CVD]], [[DOUBLE]] -* [[MKSMBF$]], [[CVSMBF]] {{text|(Microsoft Binary Format)}} -* [[MKDMBF$]], [[CVDMBF]] {{text|(Microsoft Binary Format)}} -* [[PDS(7.1) Procedures#CURRENCY|CURRENCY]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEBUTTON__11111111111.txt b/internal/help/_MOUSEBUTTON__11111111111.txt deleted file mode 100644 index ff556c7ee..000000000 --- a/internal/help/_MOUSEBUTTON__11111111111.txt +++ /dev/null @@ -1,175 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:48}} -{{DISPLAYTITLE:_MOUSEBUTTON}} -The [[_MOUSEBUTTON]] function returns the button status of a specified mouse button when read after [[_MOUSEINPUT]]. - - -{{PageSyntax}} -: {{Parameter|buttonStatus%%}} = [[_MOUSEBUTTON]]({{Parameter|buttoNumber}}) - - -{{Parameters}} -* [[INTEGER]] {{Parameter|buttoNumber}} designates the mouse button to read (See [[_DEVICES]] for more than 3). -** 1 = Left mouse button -** 2 = Right mouse button -** 3 = Center or scroll button - - -{{PageDescription}} -* Returns -1 if the corresponding {{Parameter|buttoNumber}} is pressed or zero when released. -* Read [[_MOUSEINPUT]] first to return the current button up or down status. (See Example 2) -* Button clicks and mouse movements will be remembered and should be cleared after an [[INPUT]] statement or other interruption. -* To clear unread mouse input, use a [[_MOUSEINPUT]] loop that loops until it returns 0. -* Use [[_DEVICE$]] to find the "[MOUSE]" [[_DEVICES]] number to find the number of buttons available using [[_LASTBUTTON]]. -* '''Note:''' The center mouse button can also be read as [[_BUTTON]](2) on [[_DEVICEINPUT]](2) when a mouse is present. - - -{{PageExamples}} -''Example 1:'' Finding the number of mouse buttons available in QB64. This could also be used for other controller devices. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} d = 1 {{Cl|TO}} {{Cl|_DEVICES}} 'number of input devices found - dev$ = {{Cl|_DEVICE$}}(d) - {{Cl|IF...THEN|IF}} {{Cl|INSTR}}(dev$, "[MOUSE]") {{Cl|THEN}} buttons = {{Cl|_LASTBUTTON}}(d): {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} -{{Cl|NEXT}} -{{Cl|PRINT}} buttons; "mouse buttons available" -{{CodeEnd}} - - -''Example 2:'' How to monitor when a button is down or wait until a mouse button is not held down. -{{CodeStart}} -{{Cl|PRINT}} "Hold down the left mouse button until you want to quit!" -DO - i = {{Cl|_MOUSEINPUT}} ' read #1 - {{Cl|IF...THEN|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|PRINT}} "Left button down!": {{Cl|EXIT DO}} -{{Cl|LOOP}} -{{Cl|DO...LOOP|DO}} ' need to wait - i = {{Cl|_MOUSEINPUT}} ' read #2 until the mouse -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|NOT}} {{Cl|_MOUSEBUTTON}}(1) ' button is released - -{{Cl|PRINT}} "DONE!" -{{CodeEnd}} - - -''Example 3:'' Checking for a click or a double-click by the user. -{{CodeStart}} -{{Cl|DO...LOOP|DO}} 'main program loop - - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} 'check mouse status - buttondown = {{Cl|_MOUSEBUTTON}}(1) - {{Cl|LOOP}} - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} buttondown 'check for button release - i = {{Cl|_MOUSEINPUT}} - buttondown = {{Cl|_MOUSEBUTTON}}(1) - Click = 1 - {{Cl|LOOP}} - - {{Cl|IF...THEN|IF}} Click = 1 {{Cl|THEN}} 'if button was pressed and released - t = {{Cl|TIMER}} + .3 - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|TIMER}} < t 'check for a second press within .3 seconds - i = {{Cl|_MOUSEINPUT}} - {{Cl|IF...THEN|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} Click = 2: {{Cl|EXIT DO}} - {{Cl|LOOP}} - {{Cl|IF...THEN|IF}} Click = 2 {{Cl|THEN}} {{Cl|PRINT}} "Double click" {{Cl|ELSE}} {{Cl|PRINT}} "Click" - {{Cl|END IF}} - Click = 0: buttondown = 0 'reset where needed -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} -: ''Explanation:'' To find the current button status read [[_MOUSEINPUT]] repeatedly. The [[TIMER]] loop looks for a second click. - - -''Example 4:'' Verifying that a user clicked and released a mouse button on a program button. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|LINE}} (250, 250)-(300, 300), 14, BF - -{{Cl|DO...LOOP|DO}} - Mouser mx, my, mb - {{Cl|IF...THEN|IF}} mb {{Cl|THEN}} - {{Cl|IF...THEN|IF}} mx >= 250 {{Cl|AND (boolean)|AND}} my >= 250 {{Cl|AND (boolean)|AND}} mx <= 300 {{Cl|AND (boolean)|AND}} my <= 300 {{Cl|THEN}} 'button down - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} mb 'wait for button release - Mouser mx, my, mb - {{Cl|LOOP}} - 'verify mouse still in box area - {{Cl|IF...THEN|IF}} mx >= 250 {{Cl|AND (boolean)|AND}} my >= 250 {{Cl|AND (boolean)|AND}} mx <= 300 {{Cl|AND (boolean)|AND}} my <= 300 {{Cl|THEN}} {{Cl|PRINT}} "Click verified on yellow box!" - {{Cl|END IF}} - {{Cl|END IF}} -{{Cl|LOOP}} - -{{Cl|SUB}} Mouser (x, y, b) -mi = {{Cl|_MOUSEINPUT}} -b = {{Cl|_MOUSEBUTTON}}(1) -x = {{Cl|_MOUSEX}} -y = {{Cl|_MOUSEY}} -{{Cl|END SUB}} -{{CodeEnd}} -: ''Explanation:'' The mouse SUB has no internal [[_MOUSEINPUT]] loop so that no button presses, releases or moves are missed. -: If the above read procedure goes to another one, it may be advisable to skip over unread input in a [[_MOUSEINPUT]] only loop. -{{TextStart}}{{Cb|SUB}} Catchup -{{Cb|DO...LOOP|DO}} {{Cb|WHILE}} {{Cb|_MOUSEINPUT}}: {{Cb|LOOP }} -{{Cb|END SUB}} -{{TextEnd}} -: The above procedure can be used to catch up after [[INPUT]], [[LINE INPUT]] or [[INPUT$]] delays when mouse input may accumulate. - - -''Example 5:'' Combining mouse button or keyboard selections in a menu or test: -{{CodeStart}} -{{Cl|DO...LOOP|DO}} 'main program loop in demo only - {{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} "A" 'position A, B & C in same position on every question - {{Cl|LOCATE}} 12, 10: {{Cl|PRINT}} "B" - {{Cl|LOCATE}} 14, 10: {{Cl|PRINT}} "C" 'demo only - - {{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 10 'get user answer loop - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}: {{Cl|LOOP}} 'read mouse - K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) 'read keypresses also - x% = {{Cl|_MOUSEX}} - y% = {{Cl|_MOUSEY}} - Lclick = {{Cl|_MOUSEBUTTON}}(1) - - {{Cl|LOCATE}} 20, 10: {{Cl|PRINT}} x%, y%, Lclick 'only used to find mouse coordinates - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 10 {{Cl|AND (boolean)|AND}} Lclick {{Cl|THEN}} 'position clicked - DO - i = {{Cl|_MOUSEINPUT}} - x% = {{Cl|_MOUSEX}} - y% = {{Cl|_MOUSEY}} - {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_MOUSEBUTTON}}(1) - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 10 {{Cl|THEN}} K$ = "A" 'position released - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 12 {{Cl|AND (boolean)|AND}} Lclick {{Cl|THEN}} 'position clicked - DO - i = {{Cl|_MOUSEINPUT}} - x% = {{Cl|_MOUSEX}} - y% = {{Cl|_MOUSEY}} - {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_MOUSEBUTTON}}(1) - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 12 {{Cl|THEN}} K$ = "B" 'position released - {{Cl|END IF}} - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 14 {{Cl|AND (boolean)|AND}} Lclick {{Cl|THEN}} 'position clicked - DO - i = {{Cl|_MOUSEINPUT}} - x% = {{Cl|_MOUSEX}} - y% = {{Cl|_MOUSEY}} - {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_MOUSEBUTTON}}(1) - {{Cl|IF...THEN|IF}} x% = 10 {{Cl|AND (boolean)|AND}} y% = 14 {{Cl|THEN}} K$ = "C" 'position released - {{Cl|END IF}} - {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "A" {{Cl|OR (boolean)|OR}} K$ = "B" {{Cl|OR (boolean)|OR}} K$ = "C" '{{Cl|GOTO}} next question - - {{Cl|IF...THEN|IF}} {{Cl|LEN}}(K$) {{Cl|THEN}} 'DEMO ONLY - {{Cl|LOCATE}} 22, 35: {{Cl|PRINT}} " Answer = "; K$ 'display user answer at location - {{Cl|_DELAY}} 2 'allow time for user to view answer - {{Cl|LOCATE}} 22, 35: {{Cl|PRINT}} "SELECT AGAIN" - K$ = "" 'reset K$ - {{Cl|END IF}} -{{Cl|LOOP}} 'DEMO only loop use red X box to quit -{{CodeEnd}} {{small|Code by Ted Weissgerber}} -: ''Explanation:'' User can cancel letter selection by moving pointer off letter before releasing the left mouse button. - - -{{PageSeeAlso}} -* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEWHEEL]] -* [[_MOUSEINPUT]], [[_MOUSEMOVE]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] -* [[_BUTTON]], [[_BUTTONCHANGE]] {{text|([[DEVICES|devices]])}} -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEHIDE__111111111.txt b/internal/help/_MOUSEHIDE__111111111.txt deleted file mode 100644 index 9d6dce0c4..000000000 --- a/internal/help/_MOUSEHIDE__111111111.txt +++ /dev/null @@ -1,19 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:49}} -{{DISPLAYTITLE:_MOUSEHIDE}} -The [[_MOUSEHIDE]] statement hides the mouse cursor. - - -{{PageSyntax}} -: [[_MOUSEHIDE]] - - -{{PageSeeAlso}} -* [[_MOUSESHOW]] -* [[_MOUSEINPUT]] -* [[_MOUSEMOVE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MOUSEINPUT__1111111111.txt b/internal/help/_MOUSEINPUT__1111111111.txt deleted file mode 100644 index 1ece5a33c..000000000 --- a/internal/help/_MOUSEINPUT__1111111111.txt +++ /dev/null @@ -1,91 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:50}} -{{DISPLAYTITLE:_MOUSEINPUT}} -The [[_MOUSEINPUT]] function is used to monitor any new mouse positions, button presses or movements of the scroll wheel. Must be called before other mouse information becomes available. - - -{{PageSyntax}} -:{{Parameter|infoExists%%}} = [[_MOUSEINPUT]] - - -{{PageDescription}} -* Returns -1 if new mouse information is available, otherwise it returns 0. -* Must be called before reading any of the other mouse functions. The function will not miss any mouse input even during an [[INPUT]] entry. -* Use in a loop to monitor the mouse buttons, scroll wheel and coordinate positions. -* To clear all previous mouse data, use [[_MOUSEINPUT]] in a loop until it returns 0. - - -{{PageExamples}} -''Example 1:'' Mouse coordinate, click and scroll events are returned sequentially inside of a _MOUSEINPUT loop. -{{CodeStart}} -DO - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} ' Check the mouse status - {{Cl|PRINT}} {{Cl|_MOUSEX}}, {{Cl|_MOUSEY}}, {{Cl|_MOUSEBUTTON}}(1), {{Cl|_MOUSEWHEEL}} - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" -{{CodeEnd}} -: ''Explanation:'' The latest mouse function status can be read after the loop. [[_LIMIT]] and [[_DELAY]] loops will slow returns down. - - -''Example 2:'' How to use a _MOUSEINPUT loop to locate [[PSET]] positions on a screen using a right mouse button click. -{{CodeStart}} -{{Cl|SCREEN}} 12 - -{{Cl|DO...LOOP|DO}} ' main program loop - - ' your program code - - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}'mouse status changes only - x = {{Cl|_MOUSEX}} - y = {{Cl|_MOUSEY}} - {{Cl|IF...THEN|IF}} x > 0 {{Cl|AND (boolean)|AND}} x < 640 {{Cl|AND (boolean)|AND}} y > 0 {{Cl|AND (boolean)|AND}} y < 480 {{Cl|THEN}} - {{Cl|IF...THEN|IF}} {{Cl|_MOUSEBUTTON}}(2) {{Cl|THEN}} - {{Cl|PSET}} (x, y), 15 - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} x, y - {{Cl|END IF}} - {{Cl|END IF}} - {{Cl|LOOP}} - - ' your program code - -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} - - -''Example 3:'' Clearing any mouse data read before or during an [[INPUT]] entry. Press "I" to enter input: -{{CodeStart}} -{{Cl|PRINT}} "Press I to enter input! Press Q to quit" -{{Cl|DO...LOOP|DO}} - K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) - {{Cl|DO...LOOP|DO}} - {{Cl|IF...THEN|IF}} {{Cl|_MOUSEBUTTON}}(1) = -1 {{Cl|THEN}} {{Cl|PRINT}} "*" 'indicates a mouse click event - {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - {{Cl|IF...THEN|IF}} K$ = "Q" {{Cl|THEN}} {{Cl|END}} - {{Cl|IF...THEN|IF}} K$ = "I" {{Cl|THEN}} 'press I to enter text - {{Cl|INPUT}} "Click the mouse and enter something: ", entry$ 'enter some text - {{Cl|GOSUB}} Clickcheck 'clear mouse data - {{Cl|END IF}} -{{Cl|LOOP}} - -{{Cl|END}} - -Clickcheck: -count = 0 -{{Cl|DO...LOOP|DO}} - count = count + 1 -{{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} -{{Cl|PRINT}} count 'returns the number of loops before mouse data is cleared -{{Cl|RETURN}} -{{CodeEnd}} -:''Explanation:'' Click the mouse a few times while entering [[INPUT]] text. When Enter is pressed, the number of loops are displayed. - - -{{PageSeeAlso}} -* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]], [[_MOUSEMOVE]] -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MOUSEMOVEMENTX__11111111111111.txt b/internal/help/_MOUSEMOVEMENTX__11111111111111.txt deleted file mode 100644 index 95a39868d..000000000 --- a/internal/help/_MOUSEMOVEMENTX__11111111111111.txt +++ /dev/null @@ -1,62 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:52}} -{{DISPLAYTITLE:_MOUSEMOVEMENTX}} -The [[_MOUSEMOVEMENTX]] function returns the relative horizontal position of the mouse cursor as positive or negative values. - - -{{PageSyntax}} -: ''horizontalMove'' = [[_MOUSEMOVEMENTX]] - - -* Returns the relative horizontal cursor pixel position compared to the previous cursor position. Negative values are moves to the left. -* '''Note:''' A [[_MOUSESHOW]] statement will disable [[_MOUSEMOVEMENTX]] or [[_MOUSEMOVEMENTY]] relative mouse movement reads. -* Can also be used to check for any mouse movements to enable a program or close [[Screen Saver Programs]]. -* Sets the mouse to a relative movement mode which can be read by [[_WHEEL]] instead of [[_AXIS]] as mouse [[_DEVICES|device]] 2. - - -{{PageExamples}} -''Example 1:'' Since values returned are relative to the last position, the returns can be positive or negative. -{{CodeStart}} -{{Cl|SCREEN}} 12 -PX = 320: PY = 240 'center position -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 200 - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - PX = PX + {{Cl|_MOUSEMOVEMENTX}} - PY = PY + {{Cl|_MOUSEMOVEMENTY}} - {{Cl|LOOP}} - {{Cl|CLS}} - {{Cl|CIRCLE}} (PX, PY), 10, 10 - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} PX, PY -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit -{{CodeEnd}} - - -''Example 2:'' MOD is used to keep horizontal movement of the circle and cursor inside of the SCREEN 13 window(320). -{{CodeStart}} -{{Cl|SCREEN}} 13, , 1, 0 -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 200 - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - x = x + {{Cl|_MOUSEMOVEMENTX}} - y = y + {{Cl|_MOUSEMOVEMENTY}} - {{Cl|LOOP}} - x = (x + 320) {{Cl|MOD}} 320 'keeps object on screen - y = (y + 200) {{Cl|MOD}} 200 'remove if off screen moves are desired - {{Cl|CLS}} - {{Cl|CIRCLE}} (x, y), 20 - {{Cl|PCOPY}} 1, 0 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'press any key to exit -{{CodeEnd}} -: '''NOTE:''' When using the function this way, give the user a keypress exit option. Make sure the user has some way to exit that is not dependent on clicking the X button. - - -{{PageSeeAlso}} -* [[_MOUSEMOVEMENTY]] -* [[_MOUSEINPUT]], [[_MOUSEX]] -* [[_DEVICES]], [[_DEVICEINPUT]] -* [[_WHEEL]], [[_LASTWHEEL]] -* [[_AXIS]], [[_LASTAXIS]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[Screen Saver Programs]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEMOVEMENTY__11111111111111.txt b/internal/help/_MOUSEMOVEMENTY__11111111111111.txt deleted file mode 100644 index 7260d5f42..000000000 --- a/internal/help/_MOUSEMOVEMENTY__11111111111111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:54}} -{{DISPLAYTITLE:_MOUSEMOVEMENTY}} -The [[_MOUSEMOVEMENTY]] function returns the relative vertical position of the mouse cursor as positive or negative values. - - -{{PageSyntax}} -: {{Parameter|verticalMove}} = [[_MOUSEMOVEMENTY]] - - -* Returns the relative vertical cursor pixel position compared to the previous cursor position. Negative values are up moves. -* '''Note:''' A [[_MOUSESHOW]] statement will disable [[_MOUSEMOVEMENTX]] or [[_MOUSEMOVEMENTY]] relative mouse movement reads. -* Can also be used to check for any mouse movements to enable a program or close [[Screen Saver Programs]]. -* Sets the mouse to a relative movement mode which can be read by [[_WHEEL]] instead of [[_AXIS]] as mouse [[_DEVICES|device]] 2. - - -''Example:'' MOD is used to keep vertical movement of circle and cursor inside of the SCREEN 13 window(200). -{{CodeStart}} -{{Cl|SCREEN}} 13, , 1, 0 -{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 200 - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - x = x + {{Cl|_MOUSEMOVEMENTX}} - y = y + {{Cl|_MOUSEMOVEMENTY}} - {{Cl|LOOP}} - x = (x + 320) {{Cl|MOD}} 320 'keeps object on screen - y = (y + 200) {{Cl|MOD}} 200 'remove if off screen moves are desired - {{Cl|CLS}} - {{Cl|CIRCLE}} (x, y), 20 - {{Cl|PCOPY}} 1, 0 -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'press any key to exit -{{CodeEnd}} -: '''NOTE:''' When using the function this way, give the user a keypress exit option. Make sure the user has some way to exit that is not dependent on clicking the X button. - - -{{PageSeeAlso}} -* [[_MOUSEMOVEMENTX]] -* [[_MOUSEINPUT]], [[_MOUSEX]] -* [[_DEVICES]], [[_DEVICEINPUT]] -* [[_WHEEL]], [[_LASTWHEEL]] -* [[_AXIS]], [[_LASTAXIS]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[Screen Saver Programs]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEMOVE__111111111.txt b/internal/help/_MOUSEMOVE__111111111.txt deleted file mode 100644 index f0287e57c..000000000 --- a/internal/help/_MOUSEMOVE__111111111.txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:51}} -{{DISPLAYTITLE:_MOUSEMOVE}} -The [[_MOUSEMOVE]] statement moves the mouse pointer to a new position on the screen as determined by the column and row coordinates. - - -{{PageSyntax}} -:[[_MOUSEMOVE]] {{Parameter|column%}}, {{Parameter|row%}} - - -{{Parameters}} -* {{Parameter|column%}} is the horizontal pixel coordinate to place the mouse pointer and can be any value from 0 to [[_WIDTH (function)|_WIDTH]](0) - 1. -* {{Parameter|row%}} is the vertical pixel position to place the mouse pointer and can be any value from 0 to [[_HEIGHT]](0) - 1 - - -{{PageDescription}} -* Maximum coordinate values are based on a program's current [[SCREEN]] mode resolution or the pixel size set by [[_NEWIMAGE]]. -* [[SCREEN]] 0 uses text block coordinates. '''Coordinates off the screen area will create an "Illegal Function Call" [[ERROR Codes|ERROR]]''' -* Can be used to position the pointer to a default dialog button or move the cursor away from a button so it is not clicked twice. -* Does not require [[_MOUSEINPUT]] to be used, but all moves will be remembered and can be read by mouse functions. - - -==Availability== -* '''Versions prior to 1.000''' (Version 1.000 had this function disabled for compatibility reasons.) -* '''Version 1.1 and up''' - - -{{PageExamples}} -''Example:'' How to move the mouse cursor using remembered mouse movements. Press any key to quit. -{{CodeStart}} -{{Cl|SCREEN}} 12 -i = {{Cl|_MOUSEINPUT}} 'start reading mouse events before INPUT to hold in memory -{{Cl|PRINT}} -{{Cl|INPUT}} "Move the mouse pointer and make a few clicks, then press Enter!", dummy$ -{{Cl|_MOUSEMOVE}} 1, 1 -DO: {{Cl|_LIMIT}} 30 - count = count + 1 - i = {{Cl|_MOUSEINPUT}} - x = {{Cl|_MOUSEX}}: y = {{Cl|_MOUSEY}} - b = {{Cl|_MOUSEBUTTON}}(1) - {{Cl|PRINT}} count, x, y, b - {{Cl|_MOUSEMOVE}} x, y -{{Cl|LOOP}} {{Cl|UNTIL}} i = 0 {{Cl|OR (boolean)|OR}} {{Cl|INKEY$}} > "" -{{Cl|PRINT}} "Done!" -{{CodeEnd}} -: ''Explanation:'' The [[_MOUSEINPUT]] function will hold previous and _MOUSEMOVE events so press any key when you want to quit. - -: '''Note: [[INPUT]], [[INPUT$]] and [[LINE INPUT]] will allow continued reading of mouse events while awaiting program user input!''' -: It is recommended that a [[WHILE]] [[_MOUSEINPUT]]: [[WEND]] loop be used immediately after to clear stored mouse events. - - -{{PageSeeAlso}} -* [[_MOUSEX]], [[_MOUSEY]] -* [[_NEWIMAGE]], [[_SCREENIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSESHOW__111111111.txt b/internal/help/_MOUSESHOW__111111111.txt deleted file mode 100644 index 6f74a580d..000000000 --- a/internal/help/_MOUSESHOW__111111111.txt +++ /dev/null @@ -1,55 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:55}} -{{DISPLAYTITLE:_MOUSESHOW}} -The [[_MOUSESHOW]] statement displays the mouse cursor and can change its shape. - - -{{PageSyntax}} -: [[_MOUSESHOW]] [{{Parameter|cursorShape$}}] - - -{{PageDescription}} -* Simply use the statement whenever [[_MOUSEHIDE]] has been used previously. -* In '''version 1.000 and up''' the following {{Parameter|cursorShape$}} can be displayed: -:_MOUSESHOW "LINK" will display an upward pointing hand cursor used to denote hypertext -:_MOUSESHOW "TEXT" will display the I cursor often used in text entry areas -:_MOUSESHOW "CROSSHAIR" will display a crosshair cursor -:_MOUSESHOW "VERTICAL" will display vertical arrow cursor for movement -:_MOUSESHOW "HORIZONTAL" will display horizontal arrow cursor for movement -:_MOUSESHOW "TOPLEFT_BOTTOMRIGHT" will display bottom diagonal arrow cursor for movement -:_MOUSESHOW "TOPRIGHT_BOTTOMLEFT" will display bottom diagonal arrow cursor for movement -:_MOUSESHOW "DEFAULT" can be used after a mouse cursor statement above was previously used. -* This statement will also disable [[_MOUSEMOVEMENTX]] or [[_MOUSEMOVEMENTY]] relative mouse movement reads. -* The mouse cursor will not interfere with any print or graphic screen changes in '''QB64'''. - - -===QBasic/QuickBASIC=== -* _MOUSEHIDE statements do not accumulate like they did with [[CALL ABSOLUTE|ABSOLUTE]] or [[INTERRUPT]] in QBasic. - - -{{PageExamples}} -''Example 1:'' '''QB64 1.000 and up''' allow special cursors to be displayed by using special string parameters: -{{CodeStart}} -{{Cl|_MOUSESHOW}} "default": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "link": {{Cl|_DELAY}} 0.5 'a hand, typically used in web browsers -{{Cl|_MOUSESHOW}} "text": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "crosshair": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "vertical": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "horizontal": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "topleft_bottomright": {{Cl|_DELAY}} 0.5 -{{Cl|_MOUSESHOW}} "topright_bottomleft": {{Cl|_DELAY}} 0.5 -{{CodeEnd}} -: '''Note:''' There is no hourglass, stopwatch or spinning colorful wheel in the list. The fact is that these typically only appear in a program when something has gone terribly wrong and the program has crashed or frozen. - - -{{PageSeeAlso}} -* [[_MOUSEHIDE]] -* [[_MOUSEINPUT]] -* [[_MOUSEMOVE]] -* [[_MOUSEX]], [[_MOUSEY]] -* [[_MOUSEBUTTON]] -* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] -* [[_DEVICES]], [[_DEVICE$]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEWHEEL__1111111111.txt b/internal/help/_MOUSEWHEEL__1111111111.txt deleted file mode 100644 index b5e0fd497..000000000 --- a/internal/help/_MOUSEWHEEL__1111111111.txt +++ /dev/null @@ -1,70 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:56}} -{{DISPLAYTITLE:_MOUSEWHEEL}} -The [[_MOUSEWHEEL]] function returns a positive or negative [[INTEGER]] value indicating mouse scroll events since the last read of [[_MOUSEINPUT]]. - - -{{PageSyntax}} -: {{Parameter|scrollAmount%}} = [[_MOUSEWHEEL]] - - -{{PageDescription}} -* Returns -1 when scrolling up and 1 when scrolling down with 0 indicating no movement since last read. -* After an event has been read, the value resets to 0 automatically so cumulative position values must be added. -* If no movement on the wheel has occurred since the last [[_MOUSEINPUT]] read, [[_MOUSEWHEEL]] returns 0. - - -{{PageExamples}} -''Example 1:'' Reading the cumulative mouse wheel "clicks". -{{CodeStart}} - DO: {{Cl|_LIMIT}} 100 - DO WHILE {{Cl|_MOUSEINPUT}} - Scroll = Scroll + {{Cl|_MOUSEWHEEL}} - LOCATE 10, 20: PRINT Scroll - LOOP - LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit -{{CodeEnd}} - - -''Example 2:'' A simple text scrolling routine using the mouse wheel value to read a text array. -{{CodeStart}} -{{Cl|DIM}} Array$(100) -{{Cl|LINE INPUT}} "Enter a file name with 100 or more lines of text: ", file$ -{{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO...LOOP|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) - inputcount = inputcount + 1 - {{Cl|LINE INPUT (file statement)|LINE INPUT}} #1, Array$(inputcount) - {{Cl|IF...THEN|IF}} inputcount = 100 {{Cl|THEN}} {{Cl|EXIT DO}} -{{Cl|LOOP}} -{{Cl|FOR...NEXT|FOR}} n = 1 {{Cl|TO}} 21: {{Cl|PRINT}} Array$(n): {{Cl|NEXT}} -{{Cl|CLOSE}} #1 -DO - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - {{Cl|IF...THEN|IF}} row >= 0 {{Cl|THEN}} row = row + {{Cl|_MOUSEWHEEL}} {{Cl|ELSE}} row = 0 'prevent under scrolling - {{Cl|IF...THEN|IF}} row > inputcount - 20 {{Cl|THEN}} row = inputcount - 20 'prevent over scrolling - {{Cl|IF...THEN|IF}} prevrow <> row {{Cl|THEN}} 'look for a change in row value - {{Cl|IF...THEN|IF}} row > 0 {{Cl|AND (boolean)|AND}} row <= inputcount - 20 {{Cl|THEN}} - {{Cl|CLS}}: {{Cl|LOCATE}} 2, 1 - {{Cl|FOR...NEXT|FOR}} n = row {{Cl|TO}} row + 20 - {{Cl|PRINT}} Array$(n) - {{Cl|NEXT}} - {{Cl|END IF}} - {{Cl|END IF}} - prevrow = row 'store previous row value - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -
Note: You will need a text file that is large enough for this example.
- - -{{PageSeeAlso}} -* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]] -* [[_MOUSEINPUT]], [[_MOUSEMOVE]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_MOUSEX__111111.txt b/internal/help/_MOUSEX__111111.txt deleted file mode 100644 index 3ce22c652..000000000 --- a/internal/help/_MOUSEX__111111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:57}} -{{DISPLAYTITLE:_MOUSEX}} -The [[_MOUSEX]] function returns the current horizontal (column) mouse cursor position when read after [[_MOUSEINPUT]]. - - -{{PageSyntax}} -: {{Parameter|pixelColumn%}} = [[_MOUSEX]] - - -{{PageDescription}} -* [[SCREEN]] 0 returns the [[INTEGER]] horizontal text column position (from build 20170817/62 onward); older versions return a [[SINGLE]] horizontal text column position. Use [[INTEGER]] variables to avoid floating decimal returns. -* Graphic screen modes 1, 2 and 7 to 13 and [[_NEWIMAGE]] 32 bit return the [[INTEGER]] pixel columns. -* To calculate text columns in graphic modes, divide the return by 8 or the [[_FONTWIDTH]] of [[_FONT]] characters. -* [[_MOUSEINPUT]] must be used to detect any changes in the mouse position and is '''required''' for any coordinate returns. - - -==QBasic/QuickBASIC== -* In [[SCREEN]] 0, QBasic's [[CALL ABSOLUTE|ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. - - -{{PageExamples}} -''Example:'' A simple mouse drawing board using [[_MOUSEX]] and [[_MOUSEY]] coordinate values. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -{{Cl|LINE}} (99, 9)-(601, 401), 7, BF -{{Cl|LINE}} (101, 11)-(599, 399), 8, BF -tm$ = " Column = ### Row = ### Button1 = ## Button2 = ## Button3 = ##" -{{Cl|LOCATE}} 29, 20: {{Cl|PRINT}} "LeftButton = draw - RightButton = Erase"; -{{Cl|DO}}: K$ = {{Cl|INKEY$}} - {{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}} - X = {{Cl|_MOUSEX}}: Y = {{Cl|_MOUSEY}} - {{Cl|IF}} X > 100 {{Cl|AND (boolean)|AND}} X < 600 {{Cl|AND (boolean)|AND}} PX > 100 {{Cl|AND (boolean)|AND}} PX < 600 {{Cl|THEN}} - {{Cl|IF}} Y > 10 {{Cl|AND (boolean)|AND}} Y < 400 {{Cl|AND (boolean)|AND}} PY > 10 {{Cl|AND (boolean)|AND}} PY < 400 {{Cl|THEN}} - {{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|LINE}} (PX, PY)-(X, Y), 15 - {{Cl|IF}} {{Cl|_MOUSEBUTTON}}(2) {{Cl|THEN}} {{Cl|LINE}} (101, 11)-(599, 399), 8, BF - {{Cl|END IF}} - {{Cl|END IF}} - PX = X: PY = Y - {{Cl|LOCATE}} 28, 10: {{Cl|PRINT USING}} tm$; X; Y; {{Cl|_MOUSEBUTTON}}(1); {{Cl|_MOUSEBUTTON}}(2); {{Cl|_MOUSEBUTTON}}(3) - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) -{{Cl|SYSTEM}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MOUSEY]] -* [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] -* [[_MOUSEINPUT]], [[_MOUSEMOVE]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}} -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_MOUSEY__111111.txt b/internal/help/_MOUSEY__111111.txt deleted file mode 100644 index 4fef98368..000000000 --- a/internal/help/_MOUSEY__111111.txt +++ /dev/null @@ -1,65 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:58}} -{{DISPLAYTITLE:_MOUSEY}} -The [[_MOUSEY]] function returns the current vertical (row) mouse cursor position when read after [[_MOUSEINPUT]]. - - -{{PageSyntax}} -: {{Parameter|pixelRow%}} = [[_MOUSEY]] - - -{{PageDescription}} -* [[SCREEN]] 0 returns the [[INTEGER]] vertical text row position (from build 20170817/62 onward); older versions return a [[SINGLE]] vertical text row position. Use [[INTEGER]] variables to avoid floating decimal returns. -* Graphic screen modes 1, 2 and 7 to 13 and [[_NEWIMAGE]] 32 bit return the [[INTEGER]] pixel columns. -* To calculate text rows in graphic modes divide the return by 16 or the [[_FONTHEIGHT]] of [[_FONT]] characters. -* [[_MOUSEINPUT]] must be used to detect any changes in the mouse position and is '''required''' for any coordinate returns. - - -==QBasic/QuickBASIC== -* In [[SCREEN]] 0, QBasic's [[CALL ABSOLUTE|ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. - - -{{PageExamples}} -''Example:'' Highlighting a row of text in Screen 0. -{{CodeStart}} -minX = 20: maxX = 60: minY = 10: maxY = 24 -selection = 0 'the screen Y coordinate of the previously highlighted item -{{Cl|FOR}} i% = 1 {{Cl|TO}} 25: {{Cl|LOCATE}} i%, 40: {{Cl|PRINT}} i%;: {{Cl|NEXT}} -{{Cl|DO}}: {{Cl|_LIMIT}} 100 - {{Cl|IF}} {{Cl|_MOUSEINPUT}} {{Cl|THEN}} - 'Un-highlight any selected row - {{Cl|IF}} selection {{Cl|THEN}} selectRow selection, minX, maxX, 0 - x = {{Cl|_MOUSEX}} - y = {{Cl|_MOUSEY}} - {{Cl|IF}} x >= minX {{Cl|AND (boolean)|AND}} x <= maxX {{Cl|AND (boolean)|AND}} y >= minY {{Cl|AND (boolean)|AND}} y <= maxY {{Cl|THEN}} - selection = y - {{Cl|ELSE}} - selection = 0 - {{Cl|END IF}} - 'Highlight any selected row - {{Cl|IF}} selection {{Cl|THEN}} SelectRow selection, minX, maxX, 2 - {{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|LOCATE}} 1, 2: {{Cl|PRINT}} x, y, selection - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SUB}} SelectRow (y, x1, x2, col) -{{Cl|DEF SEG}} = {{Cl|&H}}B800 -addr& = (x1 - 1 + (y - 1) * {{Cl|_WIDTH (function)|_WIDTH}}) * 2 + 1 -{{Cl|FOR}} x = x1 {{Cl|TO}} x2 - oldCol = {{Cl|PEEK}}(addr&) {{Cl|AND (boolean)|AND}} {{Cl|&B}}10001111 ' Mask foreground color and blink bit - {{Cl|POKE}} addr&, oldCol {{Cl|OR}} ((col {{Cl|AND (boolean)|AND}} {{Cl|&B}}111) * {{Cl|&B}}10000) ' Apply background color - addr& = addr& + 2 -{{Cl|NEXT}} -{{Cl|END SUB}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_MOUSEX]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] -* [[_MOUSEINPUT]], [[_MOUSEMOVE]] -* [[_MOUSESHOW]], [[_MOUSEHIDE]] -* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}} -* [[Controller Devices]] - - -{{PageNavigation}} diff --git a/internal/help/_NEWIMAGE__11111111.txt b/internal/help/_NEWIMAGE__11111111.txt deleted file mode 100644 index 9722af919..000000000 --- a/internal/help/_NEWIMAGE__11111111.txt +++ /dev/null @@ -1,103 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:00}} -{{DISPLAYTITLE:_NEWIMAGE}} -The [[_NEWIMAGE]] function prepares a window image surface and returns the [[LONG]] [[handle]] value. - - -{{PageSyntax}} -: {{Parameter|handle&}} = [[_NEWIMAGE]]({{Parameter|width&}}, {{Parameter|height&}}[, {''0''|''1''|''2''|''7''|''8''|''9''|''10''|''11''|''12''|''13''|''256''|''32''}]) - - -{{Parameters}} -* Minimum [[LONG]] screen dimensions are {{Parameter|width&}} >= 1, {{Parameter|height&}} >= 1 measured in pixels as [[INTEGER]] or [[LONG]] values. -** For mode 0 (text), {{Parameter|width&}} and {{Parameter|height&}} are measured in character blocks, not pixels. -* Mode is either a QBasic type [[SCREEN|screen]] mode (0 to 2 or 7 to 13), 256 colors or 32 bit (16 million colors) compatible. - - -{{PageDescription}} -* If the mode is omitted, an image will be created with the same BPP mode, font (which may block freeing of that font), palette, selected colors, transparent color, blend state and print method settings as the current [[_DEST]]ination image/[[SCREEN|screen]] page. -* Valid [[LONG]] [[handle]] returns are less than -1. Invalid handles equal -1 and a zero or positive value is also invalid. -* You can create any sized window (limited by the OS) in any emulated [[SCREEN]] mode or 32 bit using this function. -* Default text block size in emulated [[SCREEN]] modes 1, 2, 7, 8 and 13 is 8 X 8; 9 and 10 is 8 X 14; 11, 12, 256 and 32 bit is 8 X 16. The text block pixel size will allow you to calculate the available text rows and columns in a custom sized screen. -* To view the image page, just use [[SCREEN]] {{Parameter|handle&}}. Even if another procedure changes the screen mode and clears the screen, the image can be restored later by using the same SCREEN handle mode. -* Use the [[_COPYIMAGE]] function to preserve a SCREEN handle value when changing to another screen mode to restore it later. -* '''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. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' -* '''It is important to free unused or uneeded images with [[_FREEIMAGE]] to prevent CPU [[ERROR_Codes#Other_Errors|memory overflow errors]].''' -* '''Do not try to free image handles currently being used as the active [[SCREEN]]. Change screen modes first.''' - - -{{PageExamples}} -''Example 1:'' Shrinking a SCREEN 0 text window's size: -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(28, 25, 0) -{{CodeEnd}} - - -''Example 2:'' Creating an 800 by 600 window version of SCREEN 12 with 256 colors (text 37 X 100): -{{CodeStart}} -handle& = {{Cl|_NEWIMAGE}}(800, 600, 256) -{{Cl|SCREEN (statement)|SCREEN}} handle& -{{CodeEnd}} - - -''Example 3:'' Setting up a 32 bit SCREEN with _NEWIMAGE for page flipping in QB64. -{{CodeStart}} -SCREEN _NEWIMAGE(640, 480, 32), , 1, 0 -{{CodeEnd}} -: ''Note:'' [[_DISPLAY]] may be used as a substitute for page flipping or [[PCOPY]]. - - -''Example 4:'' Switching between two different SCREEN modes -{{CodeStart}} -{{Cl|_TITLE}} "Switching {{Cl|SCREEN}} modes" -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}} (800, 600, 256) -mode1& = {{Cl|_DEST}} 'get current screen mode handle -mode2& = {{Cl|_NEWIMAGE}} (300, 200, 13) - -{{Cl|_DEST}} mode2& 'prepare small window -{{Cl|COLOR}} 10: {{Cl|LOCATE}} 10, 13: {{Cl|PRINT}} "mode2& = "; mode2& -{{Cl|COLOR}} 13: {{Cl|LOCATE}} 16, 16: {{Cl|PRINT}} "First" - -{{Cl|_DEST}} mode1& 'work in main window -{{Cl|LOCATE}} 5 -{{Cl|FOR...NEXT|FOR}} c = 1 {{Cl|TO}} 248 - Color c: {{Cl|PRINT}} c; -{{Cl|NEXT}} -{{Cl|COLOR}} 12: {{Cl|LOCATE}} 20, 44: {{Cl|PRINT}} "mode1& = "; mode1& -{{Cl|COLOR}} 11: {{Cl|LOCATE}} 30, 34: {{Cl|PRINT}} "Press a key to goto Pop-up Window" -{{Cl|DO...LOOP|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SCREEN}} mode2& 'switch to small window -{{Cl|DO...LOOP|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SCREEN}} mode1& 'back to main window -{{Cl|COLOR}} 12: {{Cl|LOCATE}} 37, 43: {{Cl|PRINT}} "One more time!" -{{Cl|DO...LOOP|DO}}: {{Cl|SLEEP}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - -{{Cl|SCREEN}} mode2& 'back to small window -{{Cl|COLOR}} 14: {{Cl|LOCATE}} 16, 16: {{Cl|PRINT}} "LAST " -{{CodeEnd}} -:''Explanation:'' The [[_DEST (function)|_DEST]] function can determine the present screen mode destination handle. The second _NEWIMAGE handle is created using a SCREEN 13 palette(256 colors also). Each SCREEN is worked on after changing the destination with [[_DEST]] ''handle&'' statement. Images can be created before viewing them. When a key is pressed the second SCREEN created is displayed and so on. - -:'''Legacy SCREEN modes can also return a _DEST value, but the value will create a handle error.''' To restore legacy screens get the[[_COPYIMAGE]] function value before changing screens. Then restore it using SCREEN oldmode&. - - -===More examples=== -* [[SAVEIMAGE]] (Bitmap creation) -* [[_FILE$]] (restoring previous screen) -* [[_PIXELSIZE]] (GetImage function example) - - -{{PageSeeAlso}} -* [[_COPYIMAGE]] -* [[_LOADIMAGE]] -* [[_FREEIMAGE]] -* [[_PUTIMAGE]] -* [[_SCREENIMAGE]] -* [[_CLIPBOARDIMAGE (function)]] -* [[SCREEN]] - - -{{PageNavigation}} diff --git a/internal/help/_NUMLOCK_(function)__1111111_(00000000).txt b/internal/help/_NUMLOCK_(function)__1111111_(00000000).txt deleted file mode 100644 index 5a9cc15f0..000000000 --- a/internal/help/_NUMLOCK_(function)__1111111_(00000000).txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:02}} -{{DISPLAYTITLE: _NUMLOCK (function)}} -The [[_NUMLOCK (function)| _NUMLOCK]] function returns the current state of the Num Lock key as on (-1) or off (0). - - -{{PageSyntax}} -: {{Parameter|keyStatus%%}} = [[_NUMLOCK (function)| _NUMLOCK]] - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_CAPSLOCK (function)]], [[_SCROLLLOCK (function)]] -* [[_CAPSLOCK]] (statement), [[_NUMLOCK]] (statement), [[_SCROLLLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_NUMLOCK__1111111.txt b/internal/help/_NUMLOCK__1111111.txt deleted file mode 100644 index 5fbe6f505..000000000 --- a/internal/help/_NUMLOCK__1111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:03}} -{{DISPLAYTITLE: _NUMLOCK}} -The [[_NUMLOCK]] statement sets the state of the Num Lock key. - - -{{PageSyntax}} -: [[_NUMLOCK]] {ON|OFF|_TOGGLE} - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_CAPSLOCK (function)]], [[_NUMLOCK (function)]], [[_SCROLLLOCK (function)]] -* [[_CAPSLOCK]] (statement), [[_SCROLLLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_OFFSET_(function)__111111_(00000000).txt b/internal/help/_OFFSET_(function)__111111_(00000000).txt deleted file mode 100644 index 7c9d1af17..000000000 --- a/internal/help/_OFFSET_(function)__111111_(00000000).txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:04}} -{{DISPLAYTITLE:_OFFSET (function)}} -The [[_OFFSET]] function returns the memory offset of/within a given variable. - - -{{PageSyntax}} -: {{Parameter|offset%&}} = [[_OFFSET]]({{Parameter|variable}}) - - -{{PageDescription}} -* The {{Parameter|variable}} parameter can be any type of numerical or [[STRING|string]] variable name. -* API [[DECLARE LIBRARY|LIBRARY]] parameter or [[TYPE|type]] names may include '''lp, ptr''' or '''p''' which designates them as a pointer type. -* _OFFSET function return values should be stored in [[_OFFSET]] type variables. As no other variable type is 'elastic' like [[_OFFSET]], there can be no guarantee that any other variable type can hold the value of an _OFFSET. -* Returns the memory offset of variables, user-defined-types & elements, arrays & indices and the base offset of [[STRING]]s. -* Offset values are currently only useful when used in conjunction with [[_MEM]] or [[DECLARE LIBRARY]] procedures. -* OFFSET values are used as a part of the [[_MEM]] variable [[type]] in QB64; {{Parameter|variable}}.OFFSET returns or sets the current position in memory. -* '''Warning:''' QB64 variable length strings can move about in memory at any time. If you get the _OFFSET of a variable length sting on one line and use it on the next it may not be there anymore.''' To be safe, move variable length strings into fixed length strings first.''' - - -{{PageExamples}} -''Example:'' Using memcpy with the _OFFSET function values as parameters. -{{CodeStart}} -{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} - {{Cl|SUB}} memcpy ({{Cl|BYVAL}} dest {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} source {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} bytes {{Cl|AS}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -a$ = "1234567890" -b$ = "ABCDEFGHIJ" - -memcpy {{Cl|_OFFSET (function)|_OFFSET}}(a$) + 5, {{Cl|_OFFSET (function)|_OFFSET}}(b$) + 5, 5 -{{Cl|PRINT}} a$ -{{CodeEnd}} -{{OutputStart}}12345FGHIJ -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_OFFSET]] {{text|(variable type)}} -* [[DECLARE LIBRARY]] -* [[DECLARE DYNAMIC LIBRARY]] -* [[Using _OFFSET]] - - -{{PageNavigation}} diff --git a/internal/help/_OFFSET__111111.txt b/internal/help/_OFFSET__111111.txt deleted file mode 100644 index 593b42430..000000000 --- a/internal/help/_OFFSET__111111.txt +++ /dev/null @@ -1,76 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:05}} -{{DISPLAYTITLE:_OFFSET}} -The [[_OFFSET]] variable type stores the location of a value in memory. The byte size varies as required by the system. - - -{{PageSyntax}} -: [[DIM]] variable [[AS]] '''_OFFSET''' - - -{{PageDescription}} -* _OFFSET types can be created as signed or [[_UNSIGNED]] at the programmer's discretion. -* The type suffix for _OFFSET is '''%&''' which designates the integer value's flexible size. -* Offset values are only useful when used in conjunction with [[_MEM]] or [[DECLARE LIBRARY]] procedures. -* OFFSET values are used as a part of the [[_MEM]] variable [[type]] in QB64. Variable.OFFSET returns or sets the current position in memory. -* API [[DECLARE LIBRARY|LIBRARY]] parameter or [[TYPE|type]] names may include '''lp, ptr''' or '''p''' which designates them as a pointer type. -* '''Warning: _OFFSET values cannot be cast to other variable type values reliably.''' -* '''Warning: Variable length [[STRING]] values can move about in memory at any time.''' If you get the _OFFSET of a variable length sting on one code line and use it on the next it may not be there anymore.''' To be safe, move variable length strings into fixed length strings first.''' - - -{{PageExamples}} -''Example:'' The SHBrowseForFolder function receives information about the folder selected by the user in Windows XP and 7. -{{CodeStart}} -{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} - {{Cl|FUNCTION}} FindWindow& ({{Cl|BYVAL}} ClassName AS {{Cl|_OFFSET}}, WindowName$) -{{Cl|END}} {{Cl|DECLARE LIBRARY|DECLARE}} - -{{Cl|_TITLE}} "Super Window" -hwnd& = FindWindow(0, "Super Window" + {{Cl|CHR$}}(0)) - -{{Cl|TYPE}} BROWSEINFO 'typedef struct _browseinfo '[http://msdn.microsoft.com/en-us/library/bb773205%28v=vs.85%29.aspx Microsoft MSDN] - hwndOwner {{Cl|AS}} {{Cl|LONG}} ' ' HWND - pidlRoot {{Cl|AS}} {{Cl|_OFFSET}} ' ' PCIDLIST_ABSOLUTE - pszDisplayName {{Cl|AS}} {{Cl|_OFFSET}} ' ' LPTSTR - lpszTitle {{Cl|AS}} {{Cl|_OFFSET}} ' ' LPCTSTR - ulFlags {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}} ' UINT - lpfn {{Cl|AS}} {{Cl|_OFFSET}} ' ' BFFCALLBACK - lParam {{Cl|AS}} {{Cl|_OFFSET}} ' ' LPARAM - iImage {{Cl|AS}} {{Cl|LONG}} ' ' int -{{Cl|END}} {{Cl|TYPE}} 'BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO; - -{{Cl|DECLARE LIBRARY|DECLARE DYNAMIC LIBRARY}} "shell32" - {{Cl|FUNCTION}} SHBrowseForFolder%& (x {{Cl|AS}} BROWSEINFO) '[http://msdn.microsoft.com/en-us/library/bb762115%28v=vs.85%29.aspx Microsoft MSDN] - {{Cl|SUB}} SHGetPathFromIDList ({{Cl|BYVAL}} lpItem {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} szDir {{Cl|AS}} {{Cl|_OFFSET}}) '[http://msdn.microsoft.com/en-us/library/bb762194%28VS.85%29.aspx Microsoft MSDN] -{{Cl|DECLARE LIBRARY|END DECLARE}} - -{{Cl|DIM}} b {{Cl|AS}} BROWSEINFO -b.hwndOwner = hwnd -{{Cl|DIM}} s {{Cl|AS}} {{Cl|STRING}} * 1024 -b.pszDisplayName = {{Cl|_OFFSET (function)|_OFFSET}}(s$) -a$ = "Choose a folder!!!" + {{Cl|CHR$}}(0) -b.lpszTitle = {{Cl|_OFFSET (function)|_OFFSET}}(a$) -{{Cl|DIM}} o {{Cl|AS}} {{Cl|_OFFSET}} -o = SHBrowseForFolder(b) -{{Cl|IF...THEN|IF}} o {{Cl|THEN}} - {{Cl|PRINT}} {{Cl|LEFT$}}(s$, {{Cl|INSTR}}(s$, {{Cl|CHR$}}(0)) - 1) - {{Cl|DIM}} s2 {{Cl|AS}} {{Cl|STRING}} * 1024 - SHGetPathFromIDList o, {{Cl|_OFFSET (function)|_OFFSET}}(s2$) - {{Cl|PRINT}} {{Cl|LEFT$}}(s2$, {{Cl|INSTR}}(s2$, {{Cl|CHR$}}(0)) - 1) -{{Cl|ELSE}} - {{Cl|PRINT}} "Cancel?" -{{Cl|END IF}} -{{CodeEnd}} -{{small|Code by Galleon}} - - -{{PageSeeAlso}} -* [[_WINDOWHANDLE]] -* [[Using _OFFSET]] -* [[_OFFSET (function)]], [[_MEM]] -* [[DECLARE LIBRARY]] -* [[DECLARE DYNAMIC LIBRARY]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/_OPENCLIENT__1111111111.txt b/internal/help/_OPENCLIENT__1111111111.txt deleted file mode 100644 index 121b6818e..000000000 --- a/internal/help/_OPENCLIENT__1111111111.txt +++ /dev/null @@ -1,76 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:07}} -The [[_OPENCLIENT]] function connects to a Host on the Internet as a Client and returns the Client status handle.{{PageSyntax}} -:{{Parameter|clientHandle&}} = [[_OPENCLIENT]]('''"TCP/IP:8080:12:30:1:10"''') -{{PageDescription}} -*An [[ERROR Codes|Illegal Function Call]] error will be triggered if the function is called with a string argument of the wrong syntax. -*Connects to a host somewhere on the internet as a client. -*Valid {{Parameter|clientHandle&}} values are negative. 0 means that the connection failed. Always check that the handle returned is not 0. -*[[CLOSE]] client_handle closes the client. A failed handle of value 0 does not need to be closed. -{{PageExamples}}''Example 1:'' Attempting to connect to a local host(your host) as a client. A zero return indicates failure.{{CodeStart}} - -client = {{Cl|_OPENCLIENT}}("TCP/IP:7319:localhost") -{{Cl|IF...THEN|IF}} client {{Cl|THEN}} - {{Cl|PRINT}} "[Connected to " + {{Cl|_CONNECTIONADDRESS}}(client) + "]" -{{Cl|ELSE}} {{Cl|PRINT}} "[Connection Failed!]" -{{Cl|END IF}} -{{CodeEnd}} -:'''NOTE:''' Try a valid TCP/IP port setting to test this routine! -''Example 2:'' Using a "raw" Download function to download the QB64 bee image and displays it.{{CodeStart}} -'replace the fake image address below with a real image address you want to download -{{Cl|IF...THEN|IF}} Download("www.qb64.org/qb64.png", "qb64logo.png", 10) {{Cl|THEN}} ' timelimit = 10 seconds - {{Cl|SCREEN}} {{Cl|_LOADIMAGE}}("qb64logo.png",32) -{{Cl|ELSE}}: {{Cl|PRINT}} "Couldn't download image." -{{Cl|END IF}} -{{Cl|SLEEP}} -{{Cl|SYSTEM}} -' ---------- program end ----------- - -{{Cl|FUNCTION}} Download (url$, file$, timelimit) ' returns -1 if successful, 0 if not -url2$ = url$ -x = {{Cl|INSTR}}(url2$, "/") -{{Cl|IF...THEN|IF}} x {{Cl|THEN}} url2$ = {{Cl|LEFT$}}(url$, x - 1) -client = {{Cl|_OPENCLIENT}}("TCP/IP:80:" + url2$) -{{Cl|IF...THEN|IF}} client = 0 {{Cl|THEN}} {{Cl|EXIT FUNCTION}} -e$ = {{Cl|CHR$}}(13) + {{Cl|CHR$}}(10) ' end of line characters -url3$ = {{Cl|RIGHT$}}(url$, {{Cl|LEN}}(url$) - x + 1) -x$ = "GET " + url3$ + " HTTP/1.1" + e$ -x$ = x$ + "Host: " + url2$ + e$ + e$ -{{Cl|PUT (TCP/IP statement)|PUT}} #client, , x$ -t! = {{Cl|TIMER}} ' start time -{{Cl|DO}} - {{Cl|_DELAY}} 0.05 ' 50ms delay (20 checks per second) - {{Cl|GET (TCP/IP statement)|GET}} #client, , a2$ - a$ = a$ + a2$ - i = {{Cl|INSTR}}(a$, "Content-Length:") - {{Cl|IF...THEN|IF}} i {{Cl|THEN}} - i2 = {{Cl|INSTR}}(i, a$, e$) - {{Cl|IF...THEN|IF}} i2 {{Cl|THEN}} - l = {{Cl|VAL}}({{Cl|MID$}}(a$, i + 15, i2 - i -14)) - i3 = {{Cl|INSTR}}(i2, a$, e$ + e$) - {{Cl|IF...THEN|IF}} i3 {{Cl|THEN}} - i3 = i3 + 4 'move i3 to start of data - {{Cl|IF...THEN|IF}} ({{Cl|LEN}}(a$) - i3 + 1) = l {{Cl|THEN}} - {{Cl|CLOSE}} client ' CLOSE CLIENT - d$ = {{Cl|MID$}}(a$, i3, l) - fh = {{Cl|FREEFILE}} - {{Cl|OPEN}} file$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #fh: {{Cl|CLOSE}} #fh ' erase existing file? - - {{Cl|OPEN}} file$ {{Cl|FOR}} {{Cl|BINARY}} {{Cl|AS}} #fh - {{Cl|PUT}} #fh, , d$ - {{Cl|CLOSE}} #fh - Download = -1 'indicates download was successfull - {{Cl|EXIT FUNCTION}} - {{Cl|END IF}} ' availabledata = l - {{Cl|END IF}} ' i3 - {{Cl|END IF}} ' i2 - {{Cl|END IF}} ' i -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|TIMER}} > t! + timelimit ' (in seconds) -{{Cl|CLOSE}} client -{{Cl|END FUNCTION}} -{{CodeEnd}}{{PageSeeAlso}} -*[[_OPENHOST]], [[_OPENCONNECTION]] -*[[_CONNECTED]], [[_CONNECTIONADDRESS$]] -*[[Email Demo]], [[Inter-Program Data Sharing Demo]] -*[[Downloading Files]] -{{PageNavigation}} diff --git a/internal/help/_OPENCONNECTION__11111111111111.txt b/internal/help/_OPENCONNECTION__11111111111111.txt deleted file mode 100644 index 0f7ea5fa3..000000000 --- a/internal/help/_OPENCONNECTION__11111111111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:08}} -{{DISPLAYTITLE:_OPENCONNECTION}} -The [[_OPENCONNECTION]] function opens a connection from a client that the host has detected and returns a status handle. - - -{{PageSyntax}} -:{{Parameter|connectHandle}} = [[_OPENCONNECTION]]({{Parameter|hostHandle}}) - - -{{PageDescription}} -* Valid {{Parameter|connectHandle}} values returned are negative numbers. -* If the syntax is correct but they fail to begin/connect, a {{Parameter|connectHandle}} of 0 is returned. -* Always check if the handle returned is 0 (failed) before continuing. -* [[CLOSE]] #{{Parameter|connectHandle}} closes the connection. Failed connections({{Parameter|connectHandle}} = 0) do not need to be closed. -* As a '''Host''' you can check for new clients (users). Each will have a unique connection handle. -* Creates an [[ERROR Codes|Illegal Function Call]] error if called with a string argument of the wrong syntax. -* Handle values can be used as the open number by [[GET (TCP/IP statement)|GET #]] read statement and [[PUT (TCP/IP statement)|PUT #]] write statement. - - -{{PageSeeAlso}} -* [[_OPENHOST]], [[_OPENCLIENT]] -* [[_CONNECTED]], [[_CONNECTIONADDRESS]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_OPENHOST__11111111.txt b/internal/help/_OPENHOST__11111111.txt deleted file mode 100644 index 2fcaa4a94..000000000 --- a/internal/help/_OPENHOST__11111111.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:09}} -{{DISPLAYTITLE:_OPENHOST}} -The [[_OPENHOST]] function opens a Host which listens for new connections and returns a Host status handle. - - -{{PageSyntax}} -: {{Parameter|hostHandle}} = [[_OPENHOST]]('''"TCP/IP:8080"''') - - -{{PageDescription}} -* Creates an [[ERROR Codes|Illegal Function Call]] error if called with a string argument of the wrong syntax. -* The port used in the syntax example is 8080. -* Valid {{Parameter|hostHandle}} values are negative numbers. -* If the syntax is correct but they fail to begin/connect a {{Parameter|hostHandle}} of 0 is returned. -* Always check if the handle returned is 0 (failed) before continuing. -* [[CLOSE]] {{Parameter|hostHandle}} closes the host. A failed handle value of 0 does not need to be closed. - - - -{{PageSeeAlso}} -* [[_OPENCONNECTION]], [[_OPENCLIENT]] -* [[_CONNECTED]], [[_CONNECTIONADDRESS]] -* [[Email Demo]], [[Inter-Program Data Sharing Demo]] -* [[Downloading Files]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_OS$__11$.txt b/internal/help/_OS$__11$.txt deleted file mode 100644 index c227de5fd..000000000 --- a/internal/help/_OS$__11$.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:12}} -The [[_OS$]] function returns the operating system and QB64 compiler bit version used to compile a QB64 program. - - -{{PageSyntax}} -: {{Parameter|compilerVersion$}} = [[_OS$]] - - -{{PageDescription}} -* Returns a [[STRING]] listing the OS as [WINDOWS], [LINUX] or [MACOSX] and the compiler bit format of [32BIT] or [64BIT]. Example: {{text|[WINDOWS][32BIT]}} -* Allows a BAS program to be compiled with QB64 in Windows, Linux or MacOSX using different OS or language specifications. -* Use the return {{Parameter|compilerVersion$}} to specify the current OS code to use when a BAS program is compiled using another version of the QB64 compiler. -* Windows can use either a 32 (default) or 64 bit compiler. Linux and Mac use 64 bit by default. - - - -{{PageSeeAlso}} -* [[ENVIRON$]] - - -{{PageNavigation}} diff --git a/internal/help/_PALETTECOLOR_(function)__111111111111_(00000000).txt b/internal/help/_PALETTECOLOR_(function)__111111111111_(00000000).txt deleted file mode 100644 index fb1d6c374..000000000 --- a/internal/help/_PALETTECOLOR_(function)__111111111111_(00000000).txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:15}} -{{DISPLAYTITLE:_PALETTECOLOR (function)}} -The [[_PALETTECOLOR (function)|_PALETTECOLOR]] function is used to return the 32 bit attribute color setting of an image or screen page handle's palette. - - -{{PageSyntax}} -: {{Parameter|color32Value&}} = [[_PALETTECOLOR (function)|_PALETTECOLOR]]({{Parameter|attributeNumber%}}, {{Parameter|imgHandle&}}) - - -{{PageDescription}} -* {{Parameter|attributeNumber%}} is the color attribute value from 0 to 255 for 1, 4 or 8 bit images. -* {{Parameter|imgHandle&}} is the image handle being read for color data. Zero can be used to read the current screen mode palette. -* Returns the 32 bit color value to be used by the 32 bit RGB functions. -* For 32 bit images send the _PALETTECOLOR return value to [[_RED32]], [[_GREEN32]] and [[_BLUE32]] functions to get the red, green, and blue intensity values. -* '''Although 32 bit palette values are returned, the function cannot be used with 32 bit images or screen modes.''' - - -{{PageExamples}} -''Example:'' How _PALETTECOLOR works on 32 bit RGB compared to a 4 BPP(SCREEN 12) QBasic procedure. -{{CodeStart}} -SCREEN 12 'can use any QBasic legacy screen mode -DIM RGB(0 TO 47) AS INTEGER 'color intensity array -FOR c& = 0 TO 15 - 'OUT &H3C7, c& 'set color attribute to read - value32& = {{Cl|_PALETTECOLOR (function)|_PALETTECOLOR}}(c&, 0) 'sets color value to read of an image page handle. - 'red% = INP(&H3C9) - red% = {{Cl|_RED32}}(value32&) - 'green% = INP(&H3C9) - green% = {{Cl|_GREEN32}}(value32&) - 'blue% = INP(&H3C9) - blue% = {{Cl|_BLUE32}}(value32&) - RGB(c& * 3) = red%: RGB((c& * 3) + 1) = green%: RGB((c& * 3) + 2) = blue% -NEXT -FOR i = 0 TO 47 STEP 3 - RGBval$ = LTRIM$(STR$(RGB(i))) + "," + STR$(RGB(i + 1)) + "," + STR$(RGB(i + 2)) + ")" - PRINT "Color"; i / 3, "_RGB(" + RGBval$; - PRINT -NEXT -END -{{CodeEnd}} - -:''Explanation:'' To save a bitmap or other image you need the RGB color settings or the colors will look all wrong. You can store that information into a larger image array and [[GET (graphics statement)|GET]] the image AFTER the color settings. Just GET the image starting at Array(48). - - -{{PageSeeAlso}} -* [[_PALETTECOLOR]] (statement) -* [[_NEWIMAGE]], [[_LOADIMAGE]] -* [[SAVEIMAGE]] (example code) - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_PALETTECOLOR__111111111111.txt b/internal/help/_PALETTECOLOR__111111111111.txt deleted file mode 100644 index f493747c6..000000000 --- a/internal/help/_PALETTECOLOR__111111111111.txt +++ /dev/null @@ -1,79 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:13}} -{{DISPLAYTITLE:_PALETTECOLOR}} -The [[_PALETTECOLOR]] statement sets the color value of a palette entry of an image using 256 color modes or less (4 or 8 BPP). - - -{{PageSyntax}} -:[[_PALETTECOLOR]] {{Parameter|attribute%}}, {{Parameter|newColor&}}[, {{Parameter|destHandle&}}] - - -{{PageDescription}} -* The {{Parameter|attribute%}} is the palette index number of the color to set, ranging from 0 to 15 (4 bit) or 0 to 255 (8 bit) color modes. -* The [[LONG]] {{Parameter|newColor&}} is the new color value to set using [[_RGB32]] or [[_RGBA32]] values or using [[HEX$ 32 Bit Values]]. -* If {{Parameter|destHandle&}} is omitted, [[_DEST|destination]] is assumed to be the current write page or screen surface. -* If {{Parameter|attribute%}} is outside of image or [[SCREEN|screen]] mode attribute range (0 to 15 or 0 to 255), an [[ERROR Codes|illegal function call]] error will occur. -* If {{Parameter|destHandle&}} does not use a palette, an [[ERROR Codes|illegal function call]] error occurs. '''Will not work in 24/32 bit color palette modes.''' -* If {{Parameter|destHandle&}} is an invalid handle value, an [[ERROR Codes|invalid handle]] error occurs. - - -
'''Basic's 16 Default Color Attributes (non-[[DAC]])'''
-{{OutputStart}}{{text|  Attribute    Description     Red   Green   Blue 32 HEX HTML Name |Gold}} -  0 Black 0 0 0 000000 Black -{{text|  1 Dark Blue 0 0 42 00008B DarkBlue|#00208B}} -{{text|  2 Dark Green 0 42 0 006400 DarkGreen|#006400}} -{{text|  3 Dark Cyan 0 42 42 008B8B DarkCyan|#008B8B}} -{{text|  4 Dark Red 42 0 0 8B0000 DarkRed|#8B0000}} -{{text|  5 Dark Magenta 42 0 42 8B008B DarkMagenta|#8B008B}} -{{text|  6 Dark Yellow 42 21 0 DAA520 GoldenRod|#DAA520}} -{{text|  7 Light Grey 42 42 42 D3D3D3 LightGrey|#D3D3D3}} -{{text| 8 Dark Grey 21 21 21 696969 DimGray|#696969}} -{{text|  9 Blue 21 21 63 0000FF Blue|#1515FF}} -{{text| 10 Green 21 63 21 15FF15 Lime|#15FF15}} -{{text| 11 Cyan 21 63 63 15FFFF Cyan|#15FFFF}} -{{text| 12 Red 63 21 21 FF1515 Red|#FF1515}} -{{text| 13 Magenta 63 21 63 FF15FF Magenta|#FF15FF}} -{{text| 14 Yellow 63 63 21 FFFF00 Yellow|#FFFF00}} -{{text| 15 White 63 63 63 FFFFFF White|#FFFFFF}} -{{OutputEnd}} -
[http://www.w3schools.com/html/html_colornames.asp HTML Color Table Values and Names] or [http://www.tayloredmktg.com/rgb/#OR Other RGB colors]
-::: ''Note:'' '''QB64''' 32 bit color intensity values from 0 to 255 can be found by multiplying above values by 4. - -''Summary:'' The red, green, and blue intensity values can be changed using [[OUT]] or [[PALETTE]] statements. Some '''QBasic''' RGB color attribute values can be changed in [[DAC]] [[SCREEN (statement)|SCREEN]] modes and the [[DAC]] RGB intensity settings may be different. - - -{{PageExamples}} -''Example:'' Creating custom background colors in SCREEN 0 that follow the text. [[CLS]] makes entire background one color. -{{CodeStart}} -{{Cl|_PALETTECOLOR}} 1, {{Cl|_RGB32}}(255, 255, 255) ' white. -{{Cl|_PALETTECOLOR}} 2, {{Cl|_RGB32}}(255, 170, 170) ' lighter red. -{{Cl|_PALETTECOLOR}} 3, {{Cl|_RGB32}}(255, 85, 85) ' light red. -{{Cl|_PALETTECOLOR}} 4, {{Cl|_RGB32}}(255, 0, 0) ' red. -{{Cl|_PALETTECOLOR}} 5, {{Cl|_RGB32}}(170, 0, 0) ' dark red. -{{Cl|_PALETTECOLOR}} 6, {{Cl|_RGB32}}(85, 0, 0) ' darker red. - -{{Cl|COLOR}} 0, 1: {{Cl|PRINT}} "black on white." -{{Cl|COLOR}} 0, 2: {{Cl|PRINT}} "black on lighter red." -{{Cl|COLOR}} 0, 3: {{Cl|PRINT}} "black on light red." -{{Cl|COLOR}} 0, 4: {{Cl|PRINT}} "black on red." -{{Cl|COLOR}} 0, 5: {{Cl|PRINT}} "black on dark red." -{{Cl|COLOR}} 0, 6: {{Cl|PRINT}} "black on darker red. - -{{Cl|COLOR}} 1, 6: {{Cl|PRINT}} "white on darker red" -{{Cl|COLOR}} 2, 6: {{Cl|PRINT}} "ligher red on darker red" -{{CodeEnd}} - -: ''Note:'' [[_PALETTECOLOR]] expects [[LONG]] [[_RGB32]] or [[_RGBA32]] 32 bit color values, not [[_RGB]] or [[_RGBA]] palette attribute values. - - -{{PageSeeAlso}} -* [[COLOR]], [[_RGB32]], [[_RGBA32]] -* [[_PALETTECOLOR (function)]] -* [[PALETTE]], [[OUT]], [[INP]] -* [[Images]] -* [[HEX$ 32 Bit Values]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_PIXELSIZE__111111111.txt b/internal/help/_PIXELSIZE__111111111.txt deleted file mode 100644 index a6cd8b55b..000000000 --- a/internal/help/_PIXELSIZE__111111111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:17}} -{{DISPLAYTITLE:_PIXELSIZE}} -The [[_PIXELSIZE]] function returns the color depth (Bits Per Pixel) of an image as 0 for text, 1 for 1 to 8 BPP or 4 for 32 bit. - - -{{PageSyntax}} -: {{Parameter|pixelSize%}} = [[_PIXELSIZE]][({{Parameter|imageHandle&}})] - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is omitted, it is assumed to be the current write page. -* Returns: -** 0 if the image or screen page specified by {{Parameter|imageHandle&}} is in text mode. -** 1 if the image specified by {{Parameter|imageHandle&}} is in 1 (B & W), 4 (16 colors) or 8 (256 colors) BPP mode. -** 4 if the image specified is a 24/32-bit compatible mode. Pixels use three bytes, one per red, green and blue color intensity. -* The [[SCREEN]] or [[_NEWIMAGE]] or [[_LOADIMAGE]] color mode (256 or 32) can influence the pixel sizes that can be returned. -* If {{Parameter|imageHandle&}} is an invalid handle, then an [[ERROR Codes|invalid handle]] error occurs. - - -{{PageExamples}} -''Snippet:'' Saving Images for later program use. Handle values could be saved to an array. -{{TextStart}} - -handle1& = _Getimage(sx1, sy1, sx2, sy2, sourcehandle&) ' function call - -{{Cb|FUNCTION}} GetImage& (sx1, sy1, sx2, sy2, sourcehandle&) -bytespp = {{Cb|_PIXELSIZE}}(sourcehandle&) -{{Cb|IF...THEN|IF}} bytespp = 4 {{Cb|THEN}} Pal = 32 {{Cb|ELSE}} {{Cb|IF...THEN|IF}} bytespp = 1 {{Cb|THEN}} Pal = 256 {{Cb|ELSE}} {{Cb|EXIT FUNCTION}} -h& = {{Cb|_NEWIMAGE}}({{Cb|ABS}}(sx2 - sx1) + 1, {{Cb|ABS}}(sy2 - sy1) + 1, Pal) -{{Cb|_PUTIMAGE}} (0, 0), sourcehandle&, h&, (sx1, sy1)-(sx2, sy2) 'image is not displayed -GetImage& = h& -{{Cb|END FUNCTION}} -{{TextEnd}} -{{small|Adapted from code by Galleon}} - - -===More examples=== -* [[SAVEIMAGE]] {{text|(SUB to convert image to bitmap)}} -* [[SaveIcon32]] {{text|(convert any image to icon)}} -* [[ThirtyTwoBit SUB]] {{text|(convert partial image to bitmap)}} -* [[Bitmaps]] - - -{{PageSeeAlso}} -* [[_LOADIMAGE]] -* [[_NEWIMAGE]] -* [[_PUTIMAGE]] -* [[_COPYPALETTE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_PI__11.txt b/internal/help/_PI__11.txt deleted file mode 100644 index 6d3928bb1..000000000 --- a/internal/help/_PI__11.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:16}} -{{DISPLAYTITLE: _PI}} -The [[_PI]] function returns '''ã''' as a [[_FLOAT]] value with an optional multiplier parameter. - - -{{PageSyntax}} -: {{Parameter|circumference}} = [[_PI]][({{Parameter|multiplier}})] - - -{{Parameters}} -* Optional {{Parameter|multiplier}} (''2 * radius'' in above syntax) allows multiplication of the Ï€ value. - - -{{PageDescription}} -* Function can be used in to supply Ï€ or multiples in a program. -* Accuracy is determined by the return variable type [[AS]] [[SINGLE]], [[DOUBLE]] or [[_FLOAT]]. -* The ã value can also be derived using 4 * [[ATN]](1) for a [[SINGLE]] value. - - -{{PageExamples}} -''Example:'' Calculating the area of a circle using a [[SINGLE]] variable in this case. -{{CodeStart}}radius = 5 -circlearea = {{Cl|_PI}}(radius ^ 2) -PRINT circlearea -{{CodeEnd}} -{{OutputStart}} 78.53982 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_ATAN2]], [[TAN]] -* [[ATN]] {{text|(arctangent)}} -* [[SIN]], [[COS]] - - -{{PageNavigation}} diff --git a/internal/help/_PRESERVE__11111111.txt b/internal/help/_PRESERVE__11111111.txt deleted file mode 100644 index 8bdede437..000000000 --- a/internal/help/_PRESERVE__11111111.txt +++ /dev/null @@ -1,72 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:18}} -{{DISPLAYTITLE:_PRESERVE}} -The [[_PRESERVE]] [[REDIM]] action preserves the current contents of [[$DYNAMIC|dynamic]] [[arrays]], when resizing or changing indices. - - -{{PageSyntax}} -: [[REDIM]] [[_PRESERVE]] array({{Parameter|newLowerIndex&}} [TO {{Parameter|newUpperIndex&}}]) [AS variabletype] - - -{{PageDescription}} -* [[REDIM]] or the [[$DYNAMIC]] metacommand must be used when the array is first created to be able to resize and preserve. -* If [[_PRESERVE]] is not used, the current contents of the array are cleared by [[REDIM]]. -** All element values of an array are preserved if the array size is increased. -** The remaining elements of the array are preserved if the array size is decreased. -** If the new index range is different from the original, all values will be moved to the new corresponding indices. -* '''REDIM [[_PRESERVE]] cannot change the number of array dimensions, but can change the number of elements.''' -* '''Always use the same array [[TYPE]] suffix ([[AS]] type) or a new array type with the same name may be created.''' - - -{{PageErrors}} -* [[SUB]] or [[FUNCTION]] arrays created using [[REDIM]] require that they be recreated to be used after arrays are [[ERASE]]d. -* '''Warning:''' Do not use negative upper array index values as an "Out of Memory" [[ERROR Codes|error]] (or global Operating System errors) will occur.''' -* Use [[_PRESERVE]] before [[SHARED]] or an "invalid variable name" error will occur. - - -{{PageExamples}} -''Example 1:'' Changing the upper and lower array bounds - -{{CodeStart}} -{{Cl|REDIM}} a(5 {{Cl|TO}} 10) ' create array as dynamic using REDIM -a(5) = 123 -{{Cl|REDIM}} {{Cl|_PRESERVE}} a(20 {{Cl|TO}} 40) -{{Cl|PRINT}} a(20) -{{CodeEnd}} -:''Explanation:'' a(20) is now the 123 value a(5) was. The upper or lower bounds of arrays can be changed, but the type cannot. New array indices like a(40) are null(0) or empty strings. If the array element count is not reduced, all of the data will be preserved. - - -''Example 2:'' Sizing an array while storing file data. - -{{CodeStart}} -{{Cl|REDIM}} Array$(1) 'create a dynamic string array -filename$ = "Readme.txt" 'QB64 information text file -{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 -{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1) - count = count + 1 - {{Cl|IF}} count > {{Cl|UBOUND}}(Array$) {{Cl|THEN}} - {{Cl|REDIM}} {{Cl|_PRESERVE}} Array$(count * 3 / 2)'increase array's size by 50% without losing data - {{cl|END IF}} - - {{Cl|LINE INPUT (file statement)|LINE INPUT}} #1, textline$ - Array$(count) = textline$ -{{Cl|LOOP}} -{{Cl|CLOSE}} #1 -{{Cl|FOR...NEXT|FOR}} c = 1 {{Cl|TO}} count -{{Cl|PRINT}} Array$(c) -{{Cl|IF...THEN|IF}} c {{Cl|MOD}} 20 = 0 {{Cl|THEN}} k$ = {{Cl|INPUT$}}(1) -{{Cl|NEXT}} -{{Cl|END}} -{{CodeEnd}} - - - -{{PageSeeAlso}} -* [[REDIM]] -* [[$DYNAMIC]] -* [[Arrays]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_PRINTIMAGE__1111111111.txt b/internal/help/_PRINTIMAGE__1111111111.txt deleted file mode 100644 index 4729383fa..000000000 --- a/internal/help/_PRINTIMAGE__1111111111.txt +++ /dev/null @@ -1,174 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:19}} -{{DISPLAYTITLE:_PRINTIMAGE}} -The [[_PRINTIMAGE]] statement prints a colored image on the printer, stretching it to full paper size first. - - -{{PageSyntax}} -: [[_PRINTIMAGE]] {{Parameter|imageHandle&}} - - - -* {{Parameter|imageHandle&}} is created by the [[_LOADIMAGE]], [[_NEWIMAGE]] or [[_COPYIMAGE]] functions. -* Use a white background to save ink. {{InlineCode}}[[CLS]] , _RGB(255, 255, 255){{InlineCodeEnd}} can be used to set the white background in any [[SCREEN]] mode. -* The image may be stretched disproportionately using normal screen sizes. To compensate, use a [[_NEWIMAGE]] screen that is proportional to the paper size. ''e.g.'' A 640 X 900 SCREEN page is roughly the same as 3 times a 210mm X 297mm paper size. -* [[_NEWIMAGE]] or graphic screen pages can use [[_PRINTSTRING]] to print different sized text [[_FONT]]s. -* [[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 1:'' Shows how to transfer custom font text on screen pages to the printer in Windows. Change the font path for other OS's. -{{CodeStart}}PageScale = 10 -PageHeight = 297 * PageScale 'A4 paper size is 210 X 297 mm -PageWidth = 210 * PageScale -Page& = {{Cl|_NEWIMAGE}}(PageWidth, PageHeight, 32) -{{Cl|_DEST}} Page&: {{Cl|CLS}} , {{Cl|_RGB}}(255, 255, 255): {{Cl|_DEST}} 0 'make background white to save ink! -CursorPosY = 0 - -'example text to print -PointSize = 12 -text$ = "The rain in Spain falls mainly on the plain." -{{Cl|GOSUB}} PrintText - -PointSize = 50 -text$ = "BUT!" -{{Cl|GOSUB}} PrintText - -PointSize = 12 -text$ = "In Hartford, Hereford, and Hampshire, hurricanes hardly happen." -{{Cl|GOSUB}} PrintText - -{{Cl|INPUT}} "Preview (Y/N)?", i$ 'print preview of screen (optional) -{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(i$) = "Y" {{Cl|THEN}} - Prev& = {{Cl|_NEWIMAGE}}(600, 900, 32) 'print preview smaller image - _PUTIMAGE Page&, Prev& - {{Cl|SCREEN (statement)|SCREEN}} Prev& - DO: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" - {{Cl|SCREEN (statement)|SCREEN}} 0 -{{Cl|END IF}} - -{{Cl|INPUT}} "Print on printer (Y/N)?", i$ 'print screen page on printer -{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(i$) = "Y" {{Cl|THEN}} - {{Cl|_PRINTIMAGE}} Page& -{{Cl|END IF}} - -{{Cl|END}} - -PrintText: -FontHeight = {{Cl|INT}}(PointSize * 0.3527 * PageScale) -FontHandle = {{Cl|_LOADFONT}}("c:\windows\fonts\times.ttf", FontHeight) -{{Cl|_DEST}} Page& -{{Cl|_FONT}} FontHandle -{{Cl|COLOR}} {{Cl|_RGB}}(255, 0, 0), {{Cl|_RGBA}}(0, 0, 0, 0) 'RED text on clear black background -{{Cl|_PRINTSTRING}} (0, CursorPosY), text$ -{{Cl|_FONT}} 16 'change to the QB64 default font to free it -{{Cl|_FREEFONT}} FontHandle -{{Cl|_DEST}} 0 -CursorPosY = CursorPosY + FontHeight 'adjust print position down -{{Cl|RETURN}} -{{CodeEnd}} -{{small|Code by Galleon}} -:''Explanation:'' CLS with the color white makes sure that the background is not printed a color. The PrintText [[GOSUB]] sets the [[COLOR]] of the text to red with a transparent background using [[_RGBA]] to set the [[_ALPHA]] transparency to zero or clear black. - - -''Example 2:'' Printing an old SCREEN 12 [[ASCII]] table using a deeper sized page to prevent stretching by [[_PRINTIMAGE]]. -{{CodeStart}} -{{Cl|_TITLE}} "Print Preview ASCII Table" -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 900, 256) 'size is proportional to 210mm X 297mm(8-1/2 X 11) paper - -{{Cl|OUT}} {{Cl|&H}}3C8, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 63: {{Cl|OUT}} {{Cl|&H}}3C9, 63: {{Cl|OUT}} {{Cl|&H}}3C9, 63 'white background saves ink! - -Align 8, 2, "ASCII and Extended Character Code Table using {{Cl|CHR$}}(n%)" -{{Cl|PRINT}} {{Cl|STRING$}}(80, 223) -{{Cl|COLOR}} 40 -{{Cl|PRINT}} " "; -{{Cl|FOR...NEXT|FOR}} i% = 0 {{Cl|TO}} 13 - {{Cl|PRINT}} i%;: SetCHR {{Cl|CSRLIN}}, {{Cl|POS}}(0), 40, i% - {{Cl|LOCATE}} {{Cl|CSRLIN}}, {{Cl|POS}}(0) + 1 -{{Cl|NEXT}} i% -{{Cl|FOR...NEXT|FOR}} i% = 14 {{Cl|TO}} 16 - {{Cl|PRINT}} i%; {{Cl|CHR$}}(i%); -{{Cl|NEXT}} -{{Cl|LOCATE}} {{Cl|CSRLIN}} + 1, 2 -{{Cl|FOR...NEXT|FOR}} i = 17 {{Cl|TO}} 27 - {{Cl|PRINT}} i; {{Cl|CHR$}}(i); -{{Cl|NEXT}} -{{Cl|FOR...NEXT|FOR}} i% = 28 {{Cl|TO}} 31 - {{Cl|PRINT}} i%;: SetCHR {{Cl|CSRLIN}}, {{Cl|POS}}(0), 40, i% - {{Cl|LOCATE}} {{Cl|CSRLIN}}, {{Cl|POS}}(0) + 1 -{{Cl|NEXT}} i% -{{Cl|LOCATE}} {{Cl|CSRLIN}} + 1, 2 -{{Cl|COLOR}} 2: {{Cl|PRINT}} 32; {{Cl|CHR$}}(32); -{{Cl|FOR...NEXT|FOR}} i% = 33 {{Cl|TO}} 255 - {{Cl|SELECT CASE}} i% - {{Cl|CASE}} 45, 58, 71, 84: {{Cl|LOCATE}} {{Cl|CSRLIN}} + 1, 1 - {{Cl|CASE}} {{Cl|IS}} > 96: {{Cl|IF...THEN|IF}} (i% - 97) {{Cl|MOD}} 11 = 0 {{Cl|THEN}} {{Cl|LOCATE}} {{Cl|CSRLIN}} + 1, 1 - {{Cl|END SELECT}} - {{Cl|SELECT CASE}} i% - {{Cl|CASE}} 48 {{Cl|TO}} 57: {{Cl|COLOR}} 9 'denotes number keys 48 to 57 - {{Cl|CASE}} 65 {{Cl|TO}} 90: {{Cl|COLOR}} 5 ' A to Z keys 65 to 90 - {{Cl|CASE}} 97 {{Cl|TO}} 122: {{Cl|COLOR}} 36 'a to z keys 97 to 122 - {{Cl|CASE}} 127 {{Cl|TO}} 175: {{Cl|COLOR}} 42 - {{Cl|CASE}} 176 {{Cl|TO}} 223: {{Cl|COLOR}} 6 'drawing characters 176 to 223 - {{Cl|CASE}} {{Cl|IS}} > 223: {{Cl|COLOR}} 42 - {{Cl|CASE ELSE}}: {{Cl|COLOR}} 2 - {{Cl|END SELECT}} - {{Cl|IF...THEN|IF}} i% = 98 {{Cl|OR (boolean)|OR}} i% = 99 {{Cl|OR (boolean)|OR}} i% = 100 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|SPACE$}}(1); - {{Cl|PRINT}} " "; i%; {{Cl|CHR$}}(i%); -{{Cl|NEXT}} i% -{{Cl|COLOR}} 3: {{Cl|PRINT}} "= NBSP(Non-Breaking Space)" -{{Cl|COLOR}} 8: {{Cl|PRINT}} {{Cl|STRING$}}(80, {{Cl|CHR$}}(220)) -Border 8 -{{Cl|COLOR}} 4: {{Cl|LOCATE}} 27, 4: {{Cl|PRINT}} "7) BELL, 8) Backspace, 9) Tab, 10) LineFeed(printer), 12) FormFeed(printer)" -{{Cl|LOCATE}} 28, 4: {{Cl|PRINT}} " 13) Return, 26) End Of File, 27) Escape 30) Line up, 31) Line down " - -Align 13, 29, "Press Ctrl + P to PRINT!" - -DO: {{Cl|SLEEP}}: K$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} K$ <> "" -Align 13, 29, {{Cl|SPACE$}}(50) -{{Cl|IF...THEN|IF}} K$ = {{Cl|CHR$}}(16) {{Cl|THEN}} - {{Cl|_PRINTIMAGE}} 0 '<<<<<<<<<<<< to PRINTER - Align 11, 29, "Use the ASCII Table for a reference of the codes!" - {{Cl|SOUND}} 700, 4 -{{Cl|END IF}} -K$ = {{Cl|INPUT$}}(1) -{{Cl|SYSTEM}} - -{{Cl|SUB}} Align (Tclr, Trow, txt$) -Tcol = 41 - ({{Cl|LEN}}(txt$) \ 2) -{{Cl|COLOR}} Tclr: {{Cl|LOCATE}} Trow, Tcol: {{Cl|PRINT}} txt$; -{{Cl|END SUB}} - -{{Cl|SUB}} Border (clr%) -{{Cl|COLOR}} clr% -{{Cl|FOR...NEXT|FOR}} row = 1 {{Cl|TO}} 30 - {{Cl|LOCATE}} row, 1: {{Cl|PRINT}} {{Cl|CHR$}}(179); - {{Cl|LOCATE}} row, 80: {{Cl|PRINT}} {{Cl|CHR$}}(179); -{{Cl|NEXT}} row -{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} {{Cl|STRING$}}(80, 196); -{{Cl|LOCATE}} 30, 1: {{Cl|PRINT}} {{Cl|STRING$}}(80, 196); -{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} {{Cl|CHR$}}(218); -{{Cl|LOCATE}} 1, 80: {{Cl|PRINT}} {{Cl|CHR$}}(191); -{{Cl|LOCATE}} 30, 1: {{Cl|PRINT}} {{Cl|CHR$}}(192); -{{Cl|LOCATE}} 30, 80: {{Cl|PRINT}} {{Cl|CHR$}}(217); -{{Cl|END SUB}} - -{{Cl|SUB}} SetCHR (Trow, Tcol, FG, ASCode) -Srow = 16 * (Trow - 1): Scol = 8 * (Tcol - 1) 'convert text to graphic coordinates -{{Cl|COLOR}} FG: {{Cl|_PRINTSTRING}} (Scol, Srow), {{Cl|CHR$}}(ASCode) -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -:''Explanation:'' The [[ASCII]] character table was originally made in [[SCREEN]] 12 (640 X 480) and was adapted to 256 colors. - - -{{PageSeeAlso}} -* [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[_COPYIMAGE]] -* [[LPRINT]] -* [[Windows Printer Settings]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_PRINTMODE_(function)__111111111_(00000000).txt b/internal/help/_PRINTMODE_(function)__111111111_(00000000).txt deleted file mode 100644 index 78d81be22..000000000 --- a/internal/help/_PRINTMODE_(function)__111111111_(00000000).txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:22}} -{{DISPLAYTITLE:_PRINTMODE (function)}} -The [[_PRINTMODE (function)|_PRINTMODE]] function returns the current [[_PRINTMODE]] status as a numerical value from 1 to 3 in graphic screen modes. - - -{{PageSyntax}} -: {{Parameter|currentPrintMode}} = [[_PRINTMODE (function)|_PRINTMODE]][({{Parameter|imageHandle&}})] - - -{{Parameters}} -* If no {{Parameter|imageHandle&}} is given, the current [[_DEST|destination]] [[SCREEN]] page or image is assumed. - - -{{PageDescription}} -* Returns a status value from 1 to 3 designating the current mode setting: -** '''1''': mode is _KEEPBACKGROUND -** '''2''': mode is _ONLYBACKGROUND -** '''3''': mode is _FILLBACKGROUND '''(default)''' -* '''The [[_PRINTMODE]] statement and function can only be used in graphic screen modes, not SCREEN 0''' - - -{{PageSeeAlso}} -* [[_PRINTMODE]] -* [[_LOADFONT]] -* [[_NEWIMAGE]] -* [[_PRINTSTRING]] - - -{{PageNavigation}} diff --git a/internal/help/_PRINTMODE__111111111.txt b/internal/help/_PRINTMODE__111111111.txt deleted file mode 100644 index bed49ee38..000000000 --- a/internal/help/_PRINTMODE__111111111.txt +++ /dev/null @@ -1,43 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:21}} -{{DISPLAYTITLE:_PRINTMODE}} -The [[_PRINTMODE]] statement sets the text or [[_FONT]] printing mode on an image when using [[PRINT]] or [[_PRINTSTRING]]. - - -{{PageSyntax}} -: [[_PRINTMODE]] {''_KEEPBACKGROUND''|''_ONLYBACKGROUND''|''_FILLBACKGROUND''}[, {{Parameter|imageHandle&}}] - - -{{Parameters}} -* One of 3 mode keywords is mandatory when using this statement to deal with the text background. -**''_KEEPBACKGROUND'' (mode 1): Text background transparent. Only the text is displayed over anything behind it. -**''_ONLYBACKGROUND'' (mode 2): Text background only is displayed. Text is transparent to anything behind it. -**''_FILLBACKGROUND'' (mode 3): Text and background block anything behind them like a normal [[PRINT]]. '''Default setting.''' -* If the optional {{Parameter|imageHandle&}} is omitted or is 0 then the setting will be applied to the current [[_DEST|destination]] image. - - -{{PageDescription}} -* Use the [[_PRINTMODE (function)]] to find the current [[_PRINTMODE]] setting mode number for an image. -* '''The _PRINTMODE statement and function can only be used on graphic images, not text-based ones such as SCREEN 0''' - - -{{PageExamples}} -''Example:'' Using _PRINTMODE with [[PRINT]] in a graphic screen mode. The background used is CHR$(219) = â–ˆ -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -{{Cl|COLOR}} 8: {{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} {{Cl|STRING$}}(3, 219) 'background -{{Cl|_PRINTMODE}} _KEEPBACKGROUND -{{Cl|COLOR}} 15: {{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} {{Cl|_PRINTMODE}} -{{Cl|END}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_PRINTMODE (function)]] -* [[_PRINTSTRING]] -* [[_LOADFONT]] -* [[_NEWIMAGE]] -* [[PRINT]], [[_PRINT USING]] - - -{{PageNavigation}} diff --git a/internal/help/_PRINTSTRING__11111111111.txt b/internal/help/_PRINTSTRING__11111111111.txt deleted file mode 100644 index 716304e54..000000000 --- a/internal/help/_PRINTSTRING__11111111111.txt +++ /dev/null @@ -1,121 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:23}} -{{DISPLAYTITLE:_PRINTSTRING}} -The [[_PRINTSTRING]] statement prints text [[STRING|strings]] using graphic column and row coordinate positions. - - -{{PageSyntax}} -: [[_PRINTSTRING]]({{Parameter|column}}, {{Parameter|row}}), {{Parameter|textExpression$}}[, {{Parameter|imageHandle&}}] - - -{{Parameters}} -* {{Parameter|column}} and {{Parameter|row}} are [[INTEGER]] or [[LONG]] starting PIXEL (graphic) column and row coordinates to set text or custom fonts. -* {{Parameter|textExpression$}} is any literal or variable [[STRING|string]] value of text to be displayed. -* {{Parameter|imageHandle&}} is the optional image or destination to use. Zero designates current [[SCREEN (statement)|SCREEN]] page. - - -{{PageDescription}} -* The starting coordinate sets the top left corner of the text to be printed. Use [[_FONTHEIGHT]] to calculate that text or [[_FONT|font]] position -* The [[_FONT]] size can affect the [[SCREEN (statement)|screen]] and row heights. -** Custom fonts are not required. [[_PRINTSTRING]] can print all [[ASCII]] characters. -* [[_PRINTWIDTH]] can be used to determine how wide a text print will be so that the screen width is not exceeded. -* If the {{Parameter|imageHandle&}} is omitted, the current image, page or screen destination is used. -* Can use the current font alpha blending with a designated image background. See the [[_RGBA]] function example. -* Use the [[_PRINTMODE]] statement before printing to set how the background is rendered. -** Use the [[_PRINTMODE (function)]] to find the current _PRINTMODE setting. -* In SCREEN 0 (text only), [[_PRINTSTRING]] works as one-line replacement for '''LOCATE x, y: PRINT text$''', without changing the current cursor position. - - -==Availability== -* In versions of QB64 prior to 1.000 _PRINTSTRING can only be used in graphic, 256 color or 32 bit screen modes, not SCREEN 0.'' - - -{{PageExamples}} -''Example 1:'' Printing those unprintable [[ASCII]] control characters is no longer a problem! -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 256) - -{{Cl|FOR...NEXT|FOR}} code = 0 {{Cl|TO}} 31 - chrstr$ = chrstr$ + {{Cl|CHR$}}(code) + {{Cl|SPACE$}}(1) -{{Cl|NEXT}} - -{{Cl|_FONT}} {{Cl|_LOADFONT}}("C:\Windows\Fonts\Cour.ttf", 20, "MONOSPACE") 'select monospace font - -{{Cl|_PRINTSTRING}} (0, 16), chrstr$ - -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} - ☺ ☻ ♥ ♦ ♣ â™  • â—˜ â—‹ â—™ ♂ ♀ ♪ ♫ ☼ â–º â—„ ↕ ‼ ¶ § â–¬ ↨ ↑ ↓ → ↠∟ ↔ â–² â–¼ -{{OutputEnd}} - - -''Example 2:'' Making any '''QB64 program window''' larger using a SUB that easily converts PRINT to [[_PRINTSTRING]]. -{{CodeStart}} -Scr13& = {{Cl|_NEWIMAGE}}(320, 200, 13) 'this is the old SCREEN 13 image page to set the image -Big13& = {{Cl|_NEWIMAGE}}(640, 480, 256) 'use 4 X 3 aspect ratio that QBasic used when full screen - -{{Cl|SCREEN (statement)|SCREEN}} Big13& -{{Cl|_DEST}} Scr13& -image1& = {{Cl|_LOADIMAGE}}("Howie.BMP", 256) -image2& = {{Cl|_LOADIMAGE}}("Howie2.BMP", 256) -{{Cl|_PUTIMAGE}} (10, 20), image1&, Scr13& -{{Cl|_PUTIMAGE}} (160, 20), image2&, Scr13& -{{Cl|_COPYPALETTE}} image1&, Scr13& -{{Cl|COLOR}} 151: {{Cl|LOCATE}} 2, 4: PRINTS "Screen 13 Height Reduction to 83%" -{{Cl|LOCATE}} 22, 22: PRINTS {{Cl|CHR$}}(24) + " 4 X 3 Proportion" 'use {{Cl|concatenation}} -{{Cl|LOCATE}} 24, 21: PRINTS {{Cl|CHR$}}(27) + " Stretched at 100%" 'instead of a {{Cl|semicolon}}! -{{Cl|_COPYPALETTE}} Scr13&, Big13& 'required when imported image colors are used -{{Cl|_PUTIMAGE}} , Scr13&, Big13& 'stretches the screen to double the size -K$ = {{Cl|INPUT$}}(1) -{{Cl|END}} - -{{Cl|SUB}} PRINTS (Text$) -row% = ({{Cl|CSRLIN}} - 1) * {{Cl|_FONTHEIGHT}} 'finds current screen page text or font row height -col% = ({{Cl|POS}}(0) - 1) * {{Cl|_PRINTWIDTH}}("W") 'finds current page text or font column width -{{Cl|_PRINTSTRING}} (col%, row%), Text$ -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -: ''Explanation:'' The procedure above creates a larger version of a SCREEN 13 window by stretching it with [[_PUTIMAGE]]. It cannot stretch PRINTed text so [[_PRINTSTRING]] must be used instead. [[LOCATE]] sets the PRINT cursor position for [[CSRLIN]] and [[POS]](0) to read. The SUB then converts the coordinates to graphical ones. Then '''change''' [[PRINT]] to PRINTS using the IDE '''Search Menu'''. -
[https://www.dropbox.com/s/tcdik1ajegbeiz4/HOWIE.zip?dl=0 Download of Example 2 Bitmap images]
- - -''Example 3:'' Rotating a text string around a graphic object. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} 12 -{{Cl|DIM}} row {{Cl|AS}} {{Cl|INTEGER}}, cnt {{Cl|AS}} {{Cl|INTEGER}}, cstart {{Cl|AS}} {{Cl|SINGLE}}, cend {{Cl|AS}} {{Cl|SINGLE}} -{{Cl|DIM}} xrot {{Cl|AS}} {{Cl|INTEGER}}, yrot {{Cl|AS}} {{Cl|INTEGER}}, scale {{Cl|AS}} {{Cl|INTEGER}} -' {{Cl|_FULLSCREEN}} 'full screen optional -cstart = 0: cend = 8 * {{Cl|ATN}}(1) -xrot = 6: yrot = 60: scale = 4 -row = 1 -{{Cl|CIRCLE}} (320, 240), 15, 9: {{Cl|PAINT}} {{Cl|STEP}}(0, 0), 9 -{{Cl|DO}} - {{Cl|FOR...NEXT|FOR}} i = cstart {{Cl|TO}} cend {{Cl|STEP}} .04 - x = 300 + (scale * 40 - (row * xrot)) * {{Cl|COS}}(i) - y = 200 + (scale * 40 - (row * yrot)) * {{Cl|SIN}}(i) - cnt = cnt + 1 - {{Cl|COLOR}} 7: {{Cl|_PRINTSTRING}} (x, y), "HELLO WORLD!", 0 'display - {{Cl|IF}} cnt = {{Cl|LEN}}(text$) * 8 {{Cl|THEN}} cnt = 0: {{Cl|EXIT DO}} - {{Cl|_DISPLAY}} - {{Cl|COLOR}} 0: {{Cl|_PRINTSTRING}} (x, y), "HELLO WORLD!", 0 'erase - {{Cl|_DELAY}} 0.02 - {{Cl|NEXT}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit -{{Cl|COLOR}} 15 -{{Cl|END}} -{{CodeEnd}} -{{small|Adapted from code by Unseen Machine}} - - - -{{PageSeeAlso}} -* [[_NEWIMAGE]], [[_PRINTWIDTH]], [[_PRINTMODE]] -* [[_CONTROLCHR]] {{text|(turns [[ASCII]] control characters OFF or ON)}} -* [[_FONT]], [[_LOADFONT]], [[_FONTHEIGHT]], [[_FONTWIDTH]] -* [[_SCREENIMAGE]], [[_SCREENPRINT]] -* [[Text Using Graphics]] - - -{{PageNavigation}} diff --git a/internal/help/_PRINTWIDTH__1111111111.txt b/internal/help/_PRINTWIDTH__1111111111.txt deleted file mode 100644 index 6a9f8a809..000000000 --- a/internal/help/_PRINTWIDTH__1111111111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:24}} -{{DISPLAYTITLE:_PRINTWIDTH}} -The [[_PRINTWIDTH]] function returns the width in pixels of the text [[STRING|string]] specified. - - -{{PageSyntax}} -: {{Parameter|pixelWidth%}} = [[_PRINTWIDTH]]({{Parameter|textToPrint$}}[, {{Parameter|destinationHandle&}}]) - - -{{PageDescription}} -* {{Parameter|textToPrint$}} is any literal or variable [[STRING]] value. -* If the {{Parameter|destinationHandle&}} is omitted, the current destination image or screen page is used. -* Useful to find the width of the font print [[STRING|string]] before actually printing it. -* Can be used with variable-width fonts or built-in fonts, unlike [[_FONTWIDTH]] which requires a MONOSPACE font handle. -* In SCREEN 0, _PRINTWIDTH returns the character length of a text string, exactly as [[LEN]]({{Parameter|textToPrint$}}) ('''version 1.000 and up'''). - - -{{PageExamples}} -''Example:'' SUB returns font or screen mode's text block size using _PRINTWIDTH and [[_FONTHEIGHT]] without a handle parameter. -{{CodeStart}} -{{Cl|DO}} - {{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13: ", scr$ - mode% = {{Cl|VAL}}(scr$) -{{Cl|LOOP}} {{Cl|UNTIL}} mode% > 0 -{{Cl|SCREEN (statement)|SCREEN}} mode% -{{Cl|INPUT}} "Enter first name of TTF font to use or hit enter for text size: ", TTFont$ -{{Cl|IF}} {{Cl|LEN}}(TTFont$) {{Cl|THEN}} {{Cl|INPUT (file mode)|INPUT}} "Enter font height: ", hi$ -height& = {{Cl|VAL}}(hi$) -{{Cl|IF}} height& > 0 {{Cl|THEN}} {{Cl|_FONT}} {{Cl|_LOADFONT}}("C:\Windows\Fonts\" + TTFont$ + ".ttf", height&, style$) - -TextSize wide&, high& 'get the font or current screen mode's text block pixel size - -{{Cl|_PRINTSTRING}} (20, 100), {{Cl|CHR$}}(1) + {{Cl|STR$}}(wide&) + " X" + {{Cl|STR$}}(high&) + " " + {{Cl|CHR$}}(2) - -{{Cl|END}} - -{{Cl|SUB}} TextSize (TextWidth&, TextHeight&) -TextWidth& = {{Cl|_PRINTWIDTH}}("W") 'measure width of one font or text character -TextHeight& = {{Cl|_FONTHEIGHT}} 'can measure normal text block heights also -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by Ted Weissgerber}} -
'''Note:''' The SUB procedure does not need the font handle for font sizes after [[_FONT]] enables one.
- - -{{PageSeeAlso}} -* [[_FONTWIDTH]], [[_FONTHEIGHT]] -* [[_NEWIMAGE]], [[_LOADFONT]] -* [[_PRINTSTRING]], [[_FONT]] -* [[Text Using Graphics]] - - -{{PageNavigation}} diff --git a/internal/help/_PUTIMAGE__11111111.txt b/internal/help/_PUTIMAGE__11111111.txt deleted file mode 100644 index dbe289e95..000000000 --- a/internal/help/_PUTIMAGE__11111111.txt +++ /dev/null @@ -1,194 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:25}} -{{DISPLAYTITLE:_PUTIMAGE}} -[[_PUTIMAGE]] puts an area of a source image to an area of a destination image in one operation, like [[GET (graphics statement)|GET]] and [[PUT (graphics statement)|PUT]]. - - -{{PageSyntax}} -:[[_PUTIMAGE]] [STEP] [({{Parameter|dx1}}, {{Parameter|dy1}})-[STEP][({{Parameter|dx2}}, {{Parameter|dy2}})]][, {{Parameter|sourceHandle&}}][, {{Parameter|destHandle&}}][, ][STEP][({{Parameter|sx1}}, {{Parameter|sy1}})[-STEP][({{Parameter|sx2}}, {{Parameter|sy2}})]][''_SMOOTH''] - -===Sample usage=== - -::[[_PUTIMAGE]] {{text|'full source image to fit full destination area after [[_SOURCE]] and [[_DEST]] are set}} - -::[[_PUTIMAGE]] , {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}} {{text|'size full source to fit full destination area}} - -::[[_PUTIMAGE]] (''dx1'', ''dy1''), {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}} {{text|'full source to top-left corner destination position}} - -::[[_PUTIMAGE]] (''dx1'', ''dy1'')-(''dx2'', ''dy2''), {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}} {{text|'size full source to destination coordinate area}} - -::[[_PUTIMAGE]] (''dx1'', ''dy1''), {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}}, (''sx1'', ''sy1'')-(''sx2'', ''sy2'') {{text|'portion of source to the top-left corner of the destination page}} - -::[[_PUTIMAGE]] , {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}}, (''sx1'', ''sy1'')-(''sx2'', ''sy2'') {{text|'portion of source to full destination area}} - -::[[_PUTIMAGE]] (''dx1'', ''dy1'')-(''dx2'', ''dy2''), {{Parameter|sourceHandle&}}, {{Parameter|destHandle&}},(''sx1'', ''sy1'') {{text|'right side of source from top-left corner to destination}} - - -::Note: The top-left corner position designates the leftmost and topmost portion of the image to use. - - -{{Parameters}} -* Relative coordinates to a previous graphical object can be designated using [[STEP]] as opposed to literal surface coordinates (version '''1.000''' and up). -* Coordinates ''dx'' and ''dy'' map the box area of the [[_DEST|destination]] area to use. When omitted the entire desination area is used. If only one coordinate is used, the source is placed with its original dimensions. Coordinates can be set to flip or resize the image. -** {{Parameter|dx1}} = the column coordinate at which the insertion of the source will begin (leftmost); when larger than ''dx2'', reverses image. -** {{Parameter|dy1}} = the row coordinate at which the insertion of the source will begin (topmost); when larger than ''dy2'', inverts image. -** {{Parameter|dx2}} = the column coordinate at which the insertion of the source will end (rightmost); further apart, widens image. -** {{Parameter|dy2}} = the row coordinate at which the insertion of the source will end (bottommost); closer together, shrinks image -* {{Parameter|sourceHandle&}} = the [[LONG]] handle of the [[_SOURCE|source]] image created with [[_NEWIMAGE]], [[_LOADIMAGE]] or [[_COPYIMAGE]]. -* {{Parameter|destHandle&}} = the [[LONG]] handle of the [[_DEST|destination]] image may be created with [[_NEWIMAGE]], [[SCREEN]] or [[_DEST|destination]] 0. -* Coordinates ''sx'' and ''sy'' [[GET (graphics statement)|GET]] the box area of the [[_SOURCE|source]] image to transfer to the [[_DEST|destination]] image, page or [[SCREEN|screen]]: -** {{Parameter|sx1}} = the column coordinate of the left-most pixel to include of the source. When omitted, the entire image is used -** {{Parameter|sy1}} = the row coordinate of the upper-most pixel to include of the source. When omitted, the entire image is used -** {{Parameter|sx2}} = the column coordinate of the right-most pixel to include of the source. Can be omitted to get rest of image. -** {{Parameter|sy2}} = the row coordinate of the bottom-most pixel to include of the source. Can be omitted to get rest of image. -* ''_SMOOTH'' applies linear filtering ('''version 1.000 and up'''). - -
'''Note: The [[PUT (graphics statement)|PUT]] options PSET, PRESET, AND, OR and XOR are not available with _PUTIMAGE. QB64 can use [[_ALPHA|transparency]] of colors to achieve the same results.'''
- - -{{PageDescription}} -* _PUTIMAGE can be used without any handle parameters if the [[_SOURCE]] and/or [[_DEST]] are already defined. -* If the area of the source is bigger or smaller than the area of the destination then the image is adjusted to fit that area. -* Supports 32 bit alpha blending, color key transparency, true type fonts, stretching, mirroring/flipping, and a variety of graphics file formats including gif, png, bmp & jpg. '''32 bit screen surface backgrounds (black) have zero [[_ALPHA]] and are transparent when placed over other surfaces.''' Use [[CLS]] or [[_DONTBLEND]] to make a new surface background [[_ALPHA]] 255 or opaque. -* All graphical surfaces, including screen pages, can be acted upon in the same manner, and are referred to as "images". -* '''Hardware images''' (created using mode '''33''' via [[_LOADIMAGE]] or [[_COPYIMAGE]]) can be used as the source or destination. -* [[Handle]]s are used to identify graphical surfaces. Positive values are used to refer to screen pages. -1 (negative one) indicates an invalid surface. It is recommended to store image handles in [[LONG]] variables. Passing an invalid handle generates an [[ERROR Codes|"Invalid handle"]] error. -* When handles are not passed (or cannot be passed) to subs/functions then the default destination image or source image is referenced. These are set to the active page when the SCREEN statement is called, but can be changed to any image. So it is possible to read from one image using [[POINT]] and write to a different one with [[PSET]]. -* '''[[PRINT]]ed text cannot be transferred and positioned accurately.''' Use [[_PRINTSTRING]] for graphical text or font placement. -* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].''' -* '''It is important to free discarded or unused images with [[_FREEIMAGE]] to prevent CPU memory overflow errors.''' - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}} - {{Cl|SCREEN (statement)|SCREEN}} 13 - a& = {{Cl|_NEWIMAGE}}(640, 200, 13) ' creates a 640 * 200 image with the {{Cl|LONG}} handle a& - {{Cl|_DEST}} a& ' makes image a& the default drawing output. - {{Cl|LINE}} (10, 10)-(100, 100), 12, BF ' draws a filled box (BF) into destination - {{Cl|_PUTIMAGE}} (0, 0)-(320, 200), a&, 0, (0, 0)-(320, 200) -{{CodeEnd}} -:''Explanation:'' -: 1) A graphics mode is set by using [[SCREEN (statement)|SCREEN]] 13 which can use up to 256 colors. -: 2) A new image is created that is 640 X 200 and uses the palette compatible with SCREEN 13 (256 colors). -: 3) [[_DEST]] a& makes the image with handle 'a&' the default image to draw on instead of the screen (which is [[_DEST]] 0). -: 4) Next a filled box (BF) is drawn from 10, 10 to 100, 100 with red color (12) to the destination image (set by [[_DEST]] a&) -: 5) Now we put the image from 0, 0 to 320, 200 from the image with the handle 'a&' to the screen (always handle 0) and puts this image into the coordinates 0, 0 to 320, 200. If we want to stretch the image we can alter these coordinates. - -:'''Note:''' All arguments are optional. If you want to simply put the whole image of the source to the whole image of the destination then you omit the area (x, y)-(x2, y2) on both sides, the last line of the example can be replaced by [[_PUTIMAGE]] , a&, 0 which indeed will stretch the image since image a& is bigger than the screen (the screen is 320 * 200 and a& is 640 * 200) - - -''Example 2: ''You don't need to do anything special to use a .PNG image with alpha/transparency. Here's a simple example: - -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|CLS}} , {{Cl|_RGB}}(0, 255, 0) -i = {{Cl|_LOADIMAGE}}('''"QB64.PNG"''') 'any 32 bit image (ie. with alpha channel) -{{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. - - -''Example 3:'' Flipping and enlarging an image with _PUTIMAGE by swapping or increasing the desination coordinates. -{{CodeStart}} -{{Cl|DEFLNG}} A-Z -dest_handle = {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|SCREEN (statement)|SCREEN}} dest_handle '32 bit Screen 12 dimensions -source_handle = {{Cl|_LOADIMAGE}}('''"QB64.PNG"''', 32) 'any 32 bit image (ie. with alpha channel) -dx1 = 0: dy1 = 0 -dx2 = {{Cl|_WIDTH (function)|_WIDTH}}(source_handle) - 1: dy2 = {{Cl|_HEIGHT}}(source_handle) - 1 'image dimensions - 1 -{{Cl|LOCATE}} 29, 33: {{Cl|PRINT}} "Press any Key!"; -'normal image coordinate values based on the dimensions of the image: -{{Cl|_PUTIMAGE}} (dx1, dy1)-(dx2, dy2), source_handle, dest_handle -{{Cl|LOCATE}} 20, 34: {{Cl|PRINT}} "Normal layout" -{{Cl|LOCATE}} 24, 10: {{Cl|PRINT}} "_PUTIMAGE (dx1, dy1)-(dx2, dy2), source_handle, dest_handle" -K$ = {{Cl|INPUT$}}(1) -'to flip the image on the x axis, swap the dx coordinate values: -{{Cl|_PUTIMAGE}} (dx2, dy1)-(dx1, dy2), source_handle, dest_handle -{{Cl|LOCATE}} 20, 34: {{Cl|PRINT}} "Flip by X axis" -{{Cl|LOCATE}} 24, 10: {{Cl|PRINT}} "_PUTIMAGE (dx2, dy1)-(dx1, dy2), source_handle, dest_handle" -K$ = {{Cl|INPUT$}}(1) -'to flip image on y axis, swap the dy coordinate values: -{{Cl|_PUTIMAGE}} (dx1, dy2)-(dx2, dy1), source_handle, dest_handle -{{Cl|LOCATE}} 20, 34: {{Cl|PRINT}} "Flip by Y axis" -{{Cl|LOCATE}} 24, 10: {{Cl|PRINT}} "_PUTIMAGE (dx1, dy2)-(dx2, dy1), source_handle, dest_handle " -K$ = {{Cl|INPUT$}}(1) -'to flip both, swap both the dx and dy coordinate values: -{{Cl|_PUTIMAGE}} (dx2, dy2)-(dx1, dy1), source_handle, dest_handle -{{Cl|LOCATE}} 20, 34: {{Cl|PRINT}} "Flip on both axis" -{{Cl|LOCATE}} 24, 10: {{Cl|PRINT}} "_PUTIMAGE (dx2, dy2)-(dx1, dy1), source_handle, dest_handle" -K$ = {{Cl|INPUT$}}(1) -'to enlarge, double the second set of values plus any offset of the first coordinates: -{{Cl|_PUTIMAGE}} (dx1, dy1)-((2 * dx2) + dx1, (2 * dy2) + dy1), source_handle, dest_handle -{{Cl|LOCATE}} 20, 34: {{Cl|PRINT}} "Double image size" -{{Cl|LOCATE}} 24, 2: -{{Cl|PRINT}} "_PUTIMAGE (dx1, dy1)-((2 * dx2) + dx1, (2 * dy2) + dy1), s_handle, d_handle -{{Cl|END}} -{{CodeEnd}} -{{small|Adapted from code by Darth Who}} - - -''Example 4:'' Using _PUTIMAGE to scroll a larger image created on a separate [[_NEWIMAGE]] screen page with QB64. -{{CodeStart}} -{{Cl|RANDOMIZE}} {{Cl|TIMER}} -ws& = {{Cl|_NEWIMAGE}}(2560, 1440, 32) 'large image page -s& = {{Cl|_NEWIMAGE}}(1280, 720, 32)' program screen - -{{Cl|_DEST}} ws& 'create large image of random filled circles -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 50 - x = {{Cl|RND}}(1) * 2560 - y = {{Cl|RND}}(1) * 1440 - clr& = {{Cl|_RGB32}}({{Cl|RND}}(1) * 255, {{Cl|RND}}(1) * 255, {{Cl|RND}}(1) * 255) - {{Cl|CIRCLE}} (x, y), {{Cl|RND}}(1) * 300, clr& - {{Cl|PAINT}} (x, y), clr& -{{Cl|NEXT}} -{{Cl|PRINT}} "This is a demo of some screen scrolling. Use the number pad keys to scroll. 4 goes left, 6 goes right. 8 up, 2 down. ESC key will close this program." -x = 0: y = 0 -{{Cl|SCREEN}} s& - -DO - {{Cl|CLS}} - {{Cl|_PUTIMAGE}} (0, 0), ws&, 0, (x, y)-(x + 1279, y + 719) - a$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} a$ - {{Cl|CASE}} "4": x = x - 10: {{Cl|IF...THEN|IF}} x < 0 {{Cl|THEN}} x = 0 - {{Cl|CASE}} "6": x = x + 10: {{Cl|IF...THEN|IF}} x > 1280 {{Cl|THEN}} x = 1280 - {{Cl|CASE}} "8": y = y - 10: {{Cl|IF...THEN|IF}} y < 0 {{Cl|THEN}} y = 0 - {{Cl|CASE}} "2": y = y + 10: {{Cl|IF...THEN|IF}} y > 720 {{Cl|THEN}} y = 720 - {{Cl|CASE}} {{Cl|CHR$}}(32): {{Cl|SYSTEM}} - {{Cl|END SELECT}} - {{Cl|_DISPLAY}} -{{Cl|LOOP}} -{{CodeEnd}}{{small|Code example by SMcNeill}} - - -''Example 5:'' _PUTIMAGE can be used with no parameters at all if the [[_SOURCE]] and [[_DEST]] are already set. -{{CodeStart}} -{{Cl|SCREEN}} 13 -h& = {{Cl|_NEWIMAGE}}(640, 480, 256) -{{Cl|_DEST}} h& -{{Cl|_PRINTSTRING}} (10, 10), "This _PUTIMAGE used no parameters!" -{{Cl|_SOURCE}} h& -{{Cl|_DEST}} 0 -{{Cl|_PUTIMAGE}} -{{Cl|END}} -{{CodeEnd}} - - - -===More examples=== -* [[Bitmaps]] (Bitmap Screenshots) -* [[SAVEIMAGE]] (Converts Images to Bitmaps) - - -{{PageSeeAlso}} -* [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[_COPYIMAGE]], [[_SCREENIMAGE]] -* [[_MAPTRIANGLE]], [[STEP]] -* [[_DEST]], [[_SOURCE]], [[_FREEIMAGE]] -* [[Hardware images]] - - -{{PageNavigation}} diff --git a/internal/help/_R2D__121.txt b/internal/help/_R2D__121.txt deleted file mode 100644 index 960771171..000000000 --- a/internal/help/_R2D__121.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:27}} -{{DISPLAYTITLE:_R2D}} -The [[_R2D]] function converts a '''radian''' value into a '''degree''' value. - - -{{PageSyntax}} -: {{Parameter|result!}} = [[_R2D]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Radian into Degree. -{{CodeStart}} -INPUT "Give me an angle in Radians ", D -R = _R2D(D) -PRINT "That angle in Degrees is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Radians 0.5 -That angle in Degrees is 28.64789 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]], [[_D2R]] -* [[_G2D]], [[_G2R]] -* [[_R2G]] - - - -{{PageNavigation}} diff --git a/internal/help/_R2G__121.txt b/internal/help/_R2G__121.txt deleted file mode 100644 index d7086711c..000000000 --- a/internal/help/_R2G__121.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:30}} -{{DISPLAYTITLE:_R2G}} -The [[_R2G]] function converts a '''radian''' value into a '''gradient''' value. - - -{{PageSyntax}} -: {{Parameter|result!}} = [[_R2G]]({{Parameter|num}}) - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Coverting Radian into Gradient. -{{CodeStart}} -INPUT "Give me an angle in Radians ", D -R = _R2G(D) -PRINT "That angle in Gradient is "; R -{{CodeEnd}} -{{OutputStart}} -Give me an angle in Radians 0.5 -That angle in Gradient is 31.83099 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_D2G]], [[_D2R]] -* [[_G2D]], [[_G2R]] -* [[_R2D]] - - - -{{PageNavigation}} diff --git a/internal/help/_READBIT__1111111.txt b/internal/help/_READBIT__1111111.txt deleted file mode 100644 index 200055e1c..000000000 --- a/internal/help/_READBIT__1111111.txt +++ /dev/null @@ -1,59 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:33}} -{{DISPLAYTITLE:_READBIT}} -The [[_READBIT]] function is used to check the state of a specified bit of a integer value. - - -{{PageSyntax}} -:{{Parameter|result}} = [[_READBIT]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to read the state of a bit of and can be of the following types: [[_BYTE]], [[INTEGER]], [[LONG]], or [[_INTEGER64]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} the number of the bit to be read. - - -{{PageDescription}} -* Used to check the current state of a bit in an integer value. -* Returns -1 if the bit is set(1), otherwise returns 0 if the bit is not set(0) -* Bits start at 0 (so a [[_BYTE]] has bits 0 to 7, [[INTEGER]] 0 to 15, and so on) - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}} -A~%% = {{Cl|_SETBIT}}(A~%%,4) -{{Cl|PRINT}} "Bit 4 is currently "; -IF {{Cl|_READBIT}}(A~%%,4) = -1 THEN {{Cl|PRINT}} "ON" ELSE {{Cl|PRINT}} "OFF" -{{Cl|PRINT}} "And bit 2 is currently "; -IF {{Cl|_READBIT}}(A~%%,2) = -1 THEN {{Cl|PRINT}} "ON" ELSE {{Cl|PRINT}} "OFF" -{{CodeEnd}} -{{OutputStart}} -Bit 4 is currently ON -And bit 2 is currently OFF -{{OutputEnd}} - -''Example 2:'' -{{CodeStart}} -B& = 12589575 -{{Cl|PRINT}} "B& ="; B& -FOR I%% = 31 TO 0 STEP -1 '32 bits for a {{Cl|LONG}} value - Binary$ = Binary$ + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ABS}}({{Cl|_READBIT}}(B&, I%%)))) -NEXT I%% -{{Cl|PRINT}} "B& in binary is: "; Binary${{CodeEnd}} -{{OutputStart}} -B& = 12589575 -B& in binary is: 00000000110000000001101000000111 -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[_SHL]], [[_SHR]], [[INTEGER]], [[LONG]] -* [[_SETBIT]], [[_BYTE]], [[_INTEGER64]] -* [[_RESETBIT]], [[_TOGGLEBIT]] - -{{PageNavigation}} diff --git a/internal/help/_RED32__11132.txt b/internal/help/_RED32__11132.txt deleted file mode 100644 index 87bdd05a7..000000000 --- a/internal/help/_RED32__11132.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:32}} -{{DISPLAYTITLE:_RED32}} -The [[_RED32]] function returns the red component intensity of a 32-bit image or surface color. - - -{{PageSyntax}} -: {{Parameter|red32color&}} = [[_RED32]]({{Parameter|rgbaColor&}}) - - -{{PageDescription}} -* {{Parameter|rgbaColor&}} is the 32-bit ''RGBA'' color value to retrieve the red component intensity value from. -* ''RGBA'' color values are returned by the [[_PALETTECOLOR (function)|_PALETTECOLOR]], [[POINT]], [[_RGB]], [[_RGB32]], [[_RGBA]] or [[_RGBA32]] functions. -* [[LONG]] intensity values returned range from 0 (no intensity, not present) to 255 (full intensity). - - -{{PageExamples}} -* See the example in [[POINT]]. - - -{{PageSeeAlso}} -* [[_BLUE32]], [[_GREEN32]] -* [[_RGB32]], [[_RED]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_RED__111.txt b/internal/help/_RED__111.txt deleted file mode 100644 index cd93d253e..000000000 --- a/internal/help/_RED__111.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:31}} -{{DISPLAYTITLE:_RED}} -The [[_RED]] function returns the palette index or the red component intensity of a 32-bit image color. - - -{{PageSyntax}} -: {{Parameter|redIntensity&}} = [[_RED]]({{Parameter|rgbaColorIndex&}}[, {{Parameter|imageHandle&}}]) - - -{{PageDescription}} -* {{Parameter|rgbaColorIndex&}} is the ''RGBA'' color value or palette index of the color to retrieve the red component intensity from. -* The [[LONG]] intensity value returned ranges from 0 (no intensity, not present) to 255 (full intensity). -* {{Parameter|imageHandle&}} is optional. -* If {{Parameter|imageHandle&}} specifies a 32-bit color image, {{Parameter|rgbaColorIndex&}} is interpreted as a 32-bit ''RGBA'' color value. -* If {{Parameter|imageHandle&}} specifies an image that uses a palette, {{Parameter|rgbaColorIndex&}} is interpreted as a palette index. -* If {{Parameter|imageHandle&}} is not specified, it is assumed to be the current write page. -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|invalid handle]] error occurs. -* If {{Parameter|rgbaColorIndex&}} is outside the range of valid indexes for a given image mode, an [[ERROR Codes|illegal function call]] error occurs. -* Uses index parameters passed by the [[_RGB]], [[_RGBA]], [[_RGB32]] or [[_RGBA32]] functions. - - -{{PageExamples}} -* See the example in [[POINT]]. - - -{{PageSeeAlso}} -* [[_GREEN]], [[_BLUE]] -* [[_RGB]], [[RGB32]] -* [[_LOADIMAGE]] - - -{{PageNavigation}} diff --git a/internal/help/_RESETBIT__11111111.txt b/internal/help/_RESETBIT__11111111.txt deleted file mode 100644 index c5906120c..000000000 --- a/internal/help/_RESETBIT__11111111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:34}} -{{DISPLAYTITLE:_RESETBIT}} -The [[_RESETBIT]] function is used to set a specified bit of a numerical value to 0 (OFF state). - - -{{PageSyntax}} -:{{Parameter|result}} = [[_RESETBIT]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to set the bit of and can be of the following types: [[_BYTE]], [[INTEGER]], [[LONG]], or [[_INTEGER64]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} the number of the bit to be set. - - -{{PageDescription}} -* Can be used to manually manipulate individual bits of an integer value by setting them to 0 (OFF state). -* Resetting a bit that is already set to 0 will have no effect. -* Bits start at 0 (so a [[_BYTE]] has bits 0 to 7, [[INTEGER]] 0 to 15, and so on) - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}}A~%% = 0 '{{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|PRINT}} A~%% -A~%% = {{Cl|_SETBIT}}(A~%%,6) 'set the seventh bit of A~%% -{{Cl|PRINT}} A~%% -A~%% = {{Cl|_RESETBIT}}(A~%%,6) 'Reset the seventh bit of A~%% -{{Cl|PRINT}} A~%% -{{CodeEnd}} -{{OutputStart}} - 0 - 64 - 0 -{{OutputEnd}} - - - -{{PageSeeAlso}} -* [[_SHL]], [[_SHR]], [[INTEGER]], [[LONG]] -* [[_SETBIT]], [[_BYTE]], [[_INTEGER64]] -* [[_READBIT]], [[_TOGGLEBIT]] - -{{PageNavigation}} diff --git a/internal/help/_RESIZEHEIGHT__111111111111.txt b/internal/help/_RESIZEHEIGHT__111111111111.txt deleted file mode 100644 index bb4bfc37c..000000000 --- a/internal/help/_RESIZEHEIGHT__111111111111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:39}} -{{DISPLAYTITLE:_RESIZEHEIGHT}} -The [[_RESIZEHEIGHT]] function returns the user resized screen pixel height if [[$RESIZE]]:ON allows it and [[_RESIZE (function)|_RESIZE]] returns -1 - - -{{PageSyntax}} -: {{Parameter|newHeight&}} = [[_RESIZEHEIGHT]] - - -{{Parameter|Details:}} -* [[_RESIZE (function)|_RESIZE]] function must return true (-1) before the requested screen dimensions can be returned by the function. -* The program should decide if the request is allowable for proper program interaction. - - -==Availability== -* '''Version 1.000 and up'''. - - -{{PageExamples}} -''Example:'' Resize the current screen image according to user's request. -{{CodeStart}} -{{Cl|$RESIZE}}:ON - -s& = {{Cl|_NEWIMAGE}}(300, 300, 32) -{{Cl|SCREEN}} s& - -bee& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'any image - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_RESIZE (function)|_RESIZE}} THEN - oldimage& = s& - s& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32) - SCREEN s& - {{Cl|_FREEIMAGE}} oldimage& - END IF - - {{Cl|CLS}} - - 'Center the QB64 bee image: - x = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - _WIDTH(bee&) / 2 - y = {{Cl|_HEIGHT}} / 2 - _HEIGHT(bee&) / 2 - {{Cl|_PUTIMAGE}} (x, y), bee& - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$RESIZE]] -* [[_RESIZE (function)]] -* [[_RESIZEWIDTH]] - - -{{PageNavigation}} diff --git a/internal/help/_RESIZEWIDTH__11111111111.txt b/internal/help/_RESIZEWIDTH__11111111111.txt deleted file mode 100644 index 2135ff954..000000000 --- a/internal/help/_RESIZEWIDTH__11111111111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:40}} -{{DISPLAYTITLE:_RESIZEWIDTH}} -The [[_RESIZEWIDTH]] function returns the user resized screen pixel width if [[$RESIZE]]:ON allows it and [[_RESIZE (function)|_RESIZE]] returns -1 - - -{{PageSyntax}} -: {{Parameter|newWidth&}} = [[_RESIZEWIDTH]] - - -{{PageDescription}} -* [[_RESIZE (function)|_RESIZE]] function must return true (-1) before the requested screen dimensions can be returned by the function. -* The program should decide if the request is allowable for proper program interaction. - - -==Availability== -* '''Version 1.000 and up'''. - - -{{PageExamples}} -''Example:'' Resize the current screen image according to user's request. -{{CodeStart}} -{{Cl|$RESIZE}}:ON - -s& = {{Cl|_NEWIMAGE}}(300, 300, 32) -{{Cl|SCREEN}} s& - -bee& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'any image - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_RESIZE (function)|_RESIZE}} THEN - oldimage& = s& - s& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32) - SCREEN s& - {{Cl|_FREEIMAGE}} oldimage& - END IF - - {{Cl|CLS}} - - 'Center the QB64 bee image: - x = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - _WIDTH(bee&) / 2 - y = {{Cl|_HEIGHT}} / 2 - _HEIGHT(bee&) / 2 - {{Cl|_PUTIMAGE}} (x, y), bee& - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$RESIZE]] -* [[_RESIZE (function)]] -* [[_RESIZEHEIGHT]] - - -{{PageNavigation}} diff --git a/internal/help/_RESIZE_(function)__111111_(00000000).txt b/internal/help/_RESIZE_(function)__111111_(00000000).txt deleted file mode 100644 index f753e1888..000000000 --- a/internal/help/_RESIZE_(function)__111111_(00000000).txt +++ /dev/null @@ -1,57 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:38}} -{{DISPLAYTITLE:_RESIZE (function)}} -The [[_RESIZE]] function returns true (-1) when a user has attempted to resize the program window and [[$RESIZE]]:ON has allowed it. - - -{{PageSyntax}} -: IF '''_RESIZE''' THEN rx& = [[_RESIZEWIDTH]]: ry& = [[_RESIZEHEIGHT]] - - -{{PageDescription}} -* The function returns -1 if a program screen resize was attempted by the user. -* After the function returns -1, [[_RESIZEWIDTH]] and [[_RESIZEHEIGHT]] can return the new requested dimensions in pixels. -* The [[$RESIZE]]:ON [[metacommand]] must be used so the program is created with a user resizable window. - - -==Availability== -* '''Version 1.000 and up'''. - - -{{PageExamples}} -''Example:'' Resize the current screen image according to user's request. -{{CodeStart}} -{{Cl|$RESIZE}}:ON - -s& = {{Cl|_NEWIMAGE}}(300, 300, 32) -{{Cl|SCREEN}} s& - -bee& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'any image - -{{Cl|DO}} - {{Cl|IF}} {{Cl|_RESIZE (function)|_RESIZE}} THEN - oldimage& = s& - s& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32) - SCREEN s& - {{Cl|_FREEIMAGE}} oldimage& - END IF - - {{Cl|CLS}} - - 'Center the QB64 bee image: - x = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - _WIDTH(bee&) / 2 - y = {{Cl|_HEIGHT}} / 2 - _HEIGHT(bee&) / 2 - {{Cl|_PUTIMAGE}} (x, y), bee& - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[$RESIZE]] {{text|(metacommand)}} -* [[_RESIZE]] -* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(requested pixel dimensions)}} - - -{{PageNavigation}} diff --git a/internal/help/_RESIZE__111111.txt b/internal/help/_RESIZE__111111.txt deleted file mode 100644 index 53ec76237..000000000 --- a/internal/help/_RESIZE__111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:37}} -{{DISPLAYTITLE:_RESIZE}} -The [[_RESIZE]] statement sets resizing of the window ON or OFF and sets the method as _STRETCH or _SMOOTH. - - -{{PageSyntax}} -: [[_RESIZE]] [{ON|OFF}][, {_STRETCH|_SMOOTH}] - - -{{Parameters}} -* When resizing is turned OFF no method is listed. -* When resizing is turned ON or left empty, a ''_STRETCH'' or ''_SMOOTH'' method can be used. - - -{{PageDescription}} -* Before this statement can be used, you must add the [[$RESIZE]]''':ON''' metacommand to your program. - - -{{PageSeeAlso}} -* [[$RESIZE]] -* [[_RESIZE (function)]] -* [[_RESIZEHEIGHT]] -* [[_RESIZEWIDTH]] - - - -{{PageNavigation}} diff --git a/internal/help/_RGB32__11132.txt b/internal/help/_RGB32__11132.txt deleted file mode 100644 index 93ddb5e4e..000000000 --- a/internal/help/_RGB32__11132.txt +++ /dev/null @@ -1,144 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:43}} -{{DISPLAYTITLE:_RGB32}} -The [[_RGB32]] function returns the 32-bit ''RGBA'' color value with specified red, green and blue component intensities and optional alpha. - - -{{PageSyntax}} -''Original syntax'': -:{{Parameter|color32value~&}} = [[_RGB32]]({{Parameter|red&}}, {{Parameter|green&}}, {{Parameter|blue&}}) - -''Alternative Syntax 2'': -:{{Parameter|color32value~&}} = [[_RGB32]]({{Parameter|red&}}, {{Parameter|green&}}, {{Parameter|blue&}}, {{Parameter|alpha&}}) - -''Alternative Syntax 3'': -:{{Parameter|color32value~&}} = [[_RGB32]]({{Parameter|intensity&}}, {{Parameter|alpha&}}) - -''Alternative Syntax 4'': -:{{Parameter|color32value~&}} = [[_RGB32]]({{Parameter|intensity&}}) - - -{{Parameters}} -* {{Parameter|red&}} specifies the red [[LONG]] component intensity from 0 to 255. -* {{Parameter|green&}} specifies the green [[LONG]] component intensity from 0 to 255. -* {{Parameter|blue&}} specifies the blue [[LONG]] component intensity from 0 to 255. -* {{Parameter|alpha&}} specifies the alpha [[LONG]] component from 0 to 255. -* {{Parameter|intensity&}} specifies the red, green and blue [[LONG]] components intensity from 0 to 255 simultaneously, to generate a shade of gray. - -{{PageDescription}} -* The value returned is always a 32-bit [[_UNSIGNED]] [[LONG]] color value, as is the [[POINT]] value. -* '''Return variable types must be [[_UNSIGNED]] [[LONG]] or [[LONG]], otherwise resulting color may lose the [[_BLUE]] value.''' -* Parameter values outside of the 0 to 255 range are clipped. -* Returns [[LONG]] 32 bit hexadecimal values from '''&H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}'''. -* When [[LONG]] values are [[PUT]] to file, the ARGB values become BGRA. Use [[LEFT$]]([[MKL$]]({{Parameter|color32value~&}}), 3) to place 3 colors. -* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGB32]](0, 0). Use [[CLS]] to make the black opaque.''' - - -==Availability== -* Alternative syntaxes available with '''version 1.3 and up'''. - - -{{PageExamples}} -''Example 1:'' Converting the color port RGB intensity palette values 0 to 63 to 32 bit hexadecimal values. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DIM}} hex32$(15) -{{Cl|FOR...NEXT|FOR}} attribute = 1 {{Cl|TO}} 15 - {{Cl|OUT}} {{Cl|&H}}3C7, attribute 'set color attribute to read - red = {{Cl|INP}}({{Cl|&H}}3C9) * 4 'multiply by 4 to convert intensity to 0 to 255 RGB values - grn = {{Cl|INP}}({{Cl|&H}}3C9) * 4 - blu = {{Cl|INP}}({{Cl|&H}}3C9) * 4 - hex32$(attribute) = "{{Cl|&H}}" + {{Cl|HEX$}}({{Cl|_RGB32}}(red, grn, blu)) 'always returns the 32 bit value - {{Cl|COLOR}} attribute - {{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}({{Cl|_RGB}}(red, grn, blu)) + " = " + hex32$(attribute) 'closest attribute -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}{{text|COLOR 1 = &HFF0000A8|#0000A8}} -{{text|COLOR 2 = &HFF00A800|#00A800}} -{{text|COLOR 3 = &HFF00A8A8|#00A8A8}} -{{text|COLOR 4 = &HFFA80000|#A80000}} -{{text|COLOR 5 = &HFFA800A8|#A800A8}} -{{text|COLOR 6 = &HFFA85400|#A85400}} -{{text|COLOR 7 = &HFFA8A8A8|#A8A8A8}} -{{text|COLOR 8 = &HFF545454|#545454}} -{{text|COLOR 9 = &HFF5454FC|#5454FC}} -{{text|COLOR 10 = &HFF54FC54|#54FC54}} -{{text|COLOR 11 = &HFF54FCFC|#54FCFC}} -{{text|COLOR 12 = &HFFFC5454|#FC5454}} -{{text|COLOR 13 = &HFFFC54FC|#FC54FC}} -{{text|COLOR 14 = &HFFFCFC54|#FCFC54}} -{{text|COLOR 15 = &HFFFCFCFC|#FCFCFC}} -{{OutputEnd}} -:''Note:'' This procedure also shows how the returns from [[_RGB]] and [[_RGB32]] differ in a non-32 bit screen mode. - - -''Example 2:'' Working with 32 bit colors. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) - -{{Cl|CLS}} , {{Cl|_RGB32}}(0, 0, 128) 'deep blue background - -{{Cl|LINE}} (100, 100)-(540, 380), {{Cl|_RGB}}(255, 0, 0), BF ' a red box -{{Cl|LINE}} (200, 200)-(440, 280), {{Cl|_RGB}}(0, 255, 0), BF ' a green box - - -{{Cl|SLEEP}} 'Just so we can see our pretty background before we print anything on it. - - -{{Cl|COLOR}} {{Cl|_RGB32}}(255, 255, 255), 0 'White on NO BACKGROUND - -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10 - {{Cl|PRINT}} "This is just a whole bunch of happy nothing! Happy World!!" -{{Cl|NEXT}} -{{Cl|PRINT}}: {{Cl|PRINT}}: {{Cl|PRINT}}: - -{{Cl|COLOR}} 0, {{Cl|_RGB32}}(0, 0, 0) 'And here, we're going with NO {{Cl|COLOR}} text, with a BLACK background. -'Notice how this doesn't change the color on the screen at all, where the text is, but does toss a black background to it. - -{{Cl|LOCATE}} , 15: {{Cl|PRINT}} "NOTICE HOW OUR 0 {{Cl|COLOR}} WORKS?" -{{Cl|PRINT}} -{{Cl|LOCATE}} , 15: {{Cl|PRINT}} "NEAT, HUH?" -{{Cl|SLEEP}} -SYSTEM -{{CodeEnd}}{{small|Code by Steve McNeill}} - - -''Example 3:'' Comparing the output of the new _RGB32 syntaxes (starting with version 1.3) and their equivalents in previous versions. -{{CodeStart}} -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(400, 400, 32) - -{{Cl|COLOR}} {{Cl|_RGB32}}(255, 255, 255) -{{Cl|PRINT}} "White" -{{Cl|COLOR}} {{Cl|_RGB32}}(255) -{{Cl|PRINT}} "White, too, but with less typing" -{{Cl|PRINT}} - -{{Cl|COLOR}} {{Cl|_RGB32}}(80, 80, 80) -{{Cl|PRINT}} "Dark gray" -{{Cl|COLOR}} {{Cl|_RGB32}}(80) -{{Cl|PRINT}} "Same gray, but with less typing" -{{Cl|PRINT}} - -{{Cl|COLOR}} {{Cl|_RGBA32}}(255, 255, 255, 120) -{{Cl|PRINT}} "White with alpha of 120 (out of 255)" -{{Cl|COLOR}} {{Cl|_RGB32}}(255, 120) -{{Cl|PRINT}} "White with alpha of 120 - but with less typing" -{{Cl|PRINT}} - -{{Cl|COLOR}} {{Cl|_RGBA32}}(255, 0, 255, 110) -{{Cl|PRINT}} "Magenta, 110 alpha" -{{Cl|COLOR}} {{Cl|_RGB32}}(255, 0, 255, 110) -{{Cl|PRINT}} "Magenta too, 110 alpha - but with less typing" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_RGBA32]], [[_RGB]], [[_RGBA]] -* [[_RED32]], [[_GREEN32]], [[_BLUE32]] -* [[_PALETTECOLOR]] -* [[HEX$ 32 Bit Values]] -* [[SAVEIMAGE]] -* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values] - - -{{PageNavigation}} diff --git a/internal/help/_RGBA32__111132.txt b/internal/help/_RGBA32__111132.txt deleted file mode 100644 index 92350f010..000000000 --- a/internal/help/_RGBA32__111132.txt +++ /dev/null @@ -1,61 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:45}} -{{DISPLAYTITLE:_RGBA32}} -The [[_RGBA32]] function returns the 32-bit ''RGBA'' color value with the specified red, green, blue and alpha component intensities. - - -{{PageSyntax}} -: {{Parameter|color32value~&}} = [[_RGBA32]]({{Parameter|red&}}, {{Parameter|green&}}, {{Parameter|blue&}}, {{Parameter|alpha&}}) - - -{{PageDescription}} -* The value returned is a 32-bit [[_UNSIGNED]] [[LONG]] color value. -* '''Return variable types must be [[_UNSIGNED]] [[LONG]] or resulting color may lose the [[_BLUE]] value.''' -* {{Parameter|red&}} specifies the red component intensity from 0 to 255. -* {{Parameter|green&}} specifies the green component intensity from 0 to 255. -* {{Parameter|blue&}} specifies the blue component intensity from 0 to 255. -* {{Parameter|alpha&}} specifies the [[_ALPHA|''alpha'']] component transparency value from 0 (fully transparent) to 255 (opaque). -* Alpha or intensity values outside of the valid range of 0 to 255 are clipped. -* Returns [[LONG]] 32-bit hexadecimal values from '''&H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with varying [[_ALPHA]] transparency. -* When [[LONG]] values are [[PUT]] to file, the ARGB values become BGRA. Use [[LEFT$]]([[MKL$]]({{Parameter|color32value~&}}), 3) to place 3 colors. -* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.''' - - -{{PageExamples}} -''Example:'' Changing the [[ALPHA]] value to fade an image in and out using a 32 bit PNG image. -{{CodeStart}} -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(600, 400, 32) - -img& = {{Cl|_LOADIMAGE}}("qb64_trans.png") 'use any 24/32 bit image -'Turn off auto display -{{Cl|_DISPLAY}} - -' Fade in -{{Cl|FOR...NEXT|FOR}} i% = 255 {{Cl|TO}} 0 {{Cl|STEP}} -5 - {{Cl|_LIMIT}} 20 'control fade speed - {{Cl|_PUTIMAGE}} (0, 0)-(600, 400), img& - {{Cl|LINE}} (0, 0)-(600, 400), {{Cl|_RGBA}}(0, 0, 0, i%), BF 'decrease black box transparency - {{Cl|_DISPLAY}} -{{Cl|NEXT}} - -' Fade out -{{Cl|FOR...NEXT|FOR}} i% = 0 {{Cl|TO}} 255 {{Cl|STEP}} 5 - {{Cl|_LIMIT}} 20 'control fade speed - {{Cl|_PUTIMAGE}} (0, 0)-(600, 400), img& - {{Cl|LINE}} (0, 0)-(600, 400), {{Cl|_RGBA}}(0, 0, 0, i%), BF 'increase black box transparency - {{Cl|_DISPLAY}} -{{Cl|NEXT}} -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Unseen Machine}} - - -{{PageSeeAlso}} -* [[_RGB32]], [[_RGBA]], [[_RGB]] -* [[_RED32]], [[_GREEN32]], [[_BLUE32]] -* [[HEX$ 32 Bit Values]], [[POINT]] -* [[SAVEIMAGE]] -* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values] - - -{{PageNavigation}} diff --git a/internal/help/_RGBA__1111.txt b/internal/help/_RGBA__1111.txt deleted file mode 100644 index ce33b6285..000000000 --- a/internal/help/_RGBA__1111.txt +++ /dev/null @@ -1,56 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:44}} -{{DISPLAYTITLE:_RGBA}} -The [[_RGBA]] function returns the closest palette index (legacy SCREEN modes) OR the 32-bit [[LONG]] color value (32-bit screens). - - -{{PageSyntax}} -: {{Parameter|colorIndex~&}} = [[_RGBA]]({{Parameter|red&}}, {{Parameter|green&}}, {{Parameter|blue&}}, {{Parameter|alpha&}}[, {{Parameter|imageHandle&}}]''')''' - - -* The value returned is either the closest color attribute number or a 32-bit [[_UNSIGNED]] [[LONG]] color value. -* '''Return variable types must be [[LONG]] or the resulting color may lose the [[_BLUE]] value.''' -* {{Parameter|red&}} specifies the red component intensity from 0 to 255. -* {{Parameter|green&}} specifies the green component intensity from 0 to 255. -* {{Parameter|blue&}} specifies the blue component intensity from 0 to 255. -* The [[_ALPHA|''alpha&'']] value can be set to make the color transparent (0), opaque (255) or somewhere in between. -* Parameter values outside of the 0 to 255 range are clipped. -* Returns [[LONG]] 32-bit hexadecimal values from '''&H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with varying [[_ALPHA]] transparency. -* When [[LONG]] values are [[PUT]] to file, the ARGB values become BGRA. Use [[LEFT$]]([[MKL$]]({{Parameter|colorIndex~&}}), 3) to place 3 colors. -* If {{Parameter|imageHandle&}} is omitted, the image is assumed to be the current [[_DEST|destination]] or [[SCREEN]] page. -* Allows the blending of pixel colors red, green and blue to create any of 16 million colors. -* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.''' - - -{{PageExamples}} -''Example:'' Setting a font's background color alpha to clear to overlay a second text color. -{{CodeStart}} -scrn& = {{Cl|_NEWIMAGE}}(400, 400, 32) -{{Cl|SCREEN (statement)|SCREEN}} scrn& -fnt& = {{Cl|_LOADFONT}}("C:\WINDOWS\FONTS\ARIAL.TTF", 26) -{{Cl|_FONT}} fnt& -X% = 20 -Y% = 20 -{{Cl|COLOR}} {{Cl|_RGB}}(255, 255, 255), {{Cl|_RGB}}(0, 0, 0) 'Foreground set to WHITE background to BLACK -{{Cl|_PRINTSTRING}} (X%, Y%), "Hello World" -{{Cl|COLOR}} {{Cl|_RGB}}(255, 0, 0), {{Cl|_RGBA}}(0, 0, 0, 0) 'Foreground set to RED background to TRANSPARENT BLACK -{{Cl|_PRINTSTRING}} (X% + 2, Y% + 2), "Hello World" -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Unseen Machine}} -''Explanation:'' [[_PRINTSTRING]] allows text or font colors to be alpha blended in 32 bit screens. - - -{{PageSeeAlso}} -* [[_RGB]], [[_RGB32]], [[_RGBA32]] -* [[_RED]], [[_GREEN]], [[_BLUE]] -* [[_LOADIMAGE]] -* [[_PRINTSTRING]] -* [[HEX$ 32 Bit Values]], [[POINT]] -* [[SAVEIMAGE]] -* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_RGB__111.txt b/internal/help/_RGB__111.txt deleted file mode 100644 index f111df467..000000000 --- a/internal/help/_RGB__111.txt +++ /dev/null @@ -1,70 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:41}} -{{DISPLAYTITLE:_RGB}} -The [[_RGB]] function returns the closest palette attribute index (legacy SCREEN modes) OR the [[LONG]] 32-bit color value (32-bit screens). - - -{{PageSyntax}} -: {{Parameter|colorIndex~&}} = [[_RGB]]({{Parameter|red&}}, {{Parameter|green&}}, {{Parameter|blue&}}[, {{Parameter|imageHandle&}}]) - - -{{PageDescription}} -* The value returned is either the closest color attribute number or a 32-bit [[_UNSIGNED]] [[LONG]] color value. -* '''Return variable types must be [[LONG]] or resulting color may lose the [[_BLUE]] value.''' -* {{Parameter|red&}} specifies the red component intensity from 0 to 255. -* {{Parameter|green&}} specifies the green component intensity from 0 to 255. -* {{Parameter|blue&}} specifies the blue component intensity from 0 to 255. -* Intensity values outside the valid range are clipped. -* Returns [[LONG]] 32-bit hexadecimal values from '''&HFF{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''', always with full [[_ALPHA]]. -* When [[LONG]] values are [[PUT]] to file, the ARGB values become BGRA. Use [[LEFT$]]([[MKL$]]({{Parameter|colorIndex~&}}), 3) to place 3 colors. -* If the {{Parameter|imageHandle&}} is omitted the image is assumed to be the current [[_DEST|destination]] or [[SCREEN]] page. -* Colors returned are always opaque as the transparency value is always 255. Use [[_ALPHA]] or [[_CLEARCOLOR]] to change it. -* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.''' - - -{{PageExamples}} -''Example:'' Converting the color port RGB intensity palette values 0 to 63 to 32 bit hexadecimal values. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DIM}} hex32$(15) -{{Cl|FOR...NEXT|FOR}} attribute = 1 {{Cl|TO}} 15 - {{Cl|OUT}} {{Cl|&H}}3C7, attribute 'set color attribute to read - red = {{Cl|INP}}({{Cl|&H}}3C9) * 4 'multiply by 4 to convert intensity to 0 to 255 RGB values - grn = {{Cl|INP}}({{Cl|&H}}3C9) * 4 - blu = {{Cl|INP}}({{Cl|&H}}3C9) * 4 - hex32$(attribute) = "{{Cl|&H}}" + {{Cl|HEX$}}({{Cl|_RGB32}}(red, grn, blu)) 'always returns the 32 bit value - {{Cl|COLOR}} attribute - {{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}({{Cl|_RGB}}(red, grn, blu)) + " = " + hex32$(attribute) 'closest attribute -{{Cl|NEXT}} -{{CodeEnd}} -{{OutputStart}}{{text|COLOR 1 = &HFF0000A8|#0000A8}} -{{text|COLOR 2 = &HFF00A800|#00A800}} -{{text|COLOR 3 = &HFF00A8A8|#00A8A8}} -{{text|COLOR 4 = &HFFA80000|#A80000}} -{{text|COLOR 5 = &HFFA800A8|#A800A8}} -{{text|COLOR 6 = &HFFA85400|#A85400}} -{{text|COLOR 7 = &HFFA8A8A8|#A8A8A8}} -{{text|COLOR 8 = &HFF545454|#545454}} -{{text|COLOR 9 = &HFF5454FC|#5454FC}} -{{text|COLOR 10 = &HFF54FC54|#54FC54}} -{{text|COLOR 11 = &HFF54FCFC|#54FCFC}} -{{text|COLOR 12 = &HFFFC5454|#FC5454}} -{{text|COLOR 13 = &HFFFC54FC|#FC54FC}} -{{text|COLOR 14 = &HFFFCFC54|#FCFC54}} -{{text|COLOR 15 = &HFFFCFCFC|#FCFCFC}} -{{OutputEnd}} -:''Note:'' This procedure also shows how the returns from [[_RGB]] and [[_RGB32]] differ in a non-32 bit screen mode. - - -{{PageSeeAlso}} -* [[_RGBA]], [[_RGB32]], [[_RGBA32]] -* [[_RED]], [[_GREEN]], [[_BLUE]] -* [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[HEX$ 32 Bit Values]], [[POINT]] -* [[SAVEIMAGE]] -* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_ROUND__11111.txt b/internal/help/_ROUND__11111.txt deleted file mode 100644 index eae5b954a..000000000 --- a/internal/help/_ROUND__11111.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:46}} -{{DISPLAYTITLE:_ROUND}} -The [[_ROUND]] function rounds to the closest even [[INTEGER]], [[LONG]] or [[_INTEGER64]] numerical value. - - -{{PageSyntax}} -: {{Parameter|value}} = [[_ROUND]]({{Parameter|number}}) - - -{{PageDescription}} -* Can round [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] floating decimal point parameter values. -* Can be used when numerical values exceed the limits of [[CINT]] or [[CLNG]]. -* Rounding is done to the closest even [[INTEGER|integer]] value. The same as QBasic does with [[\|integer division]]. - - -''Example:'' Displays how QB64 rounds to the closest even integer value. -{{CodeStart}} -{{Cl|PRINT}} {{Cl|_ROUND}}(0.5) -{{Cl|PRINT}} {{Cl|_ROUND}}(1.5) -{{Cl|PRINT}} {{Cl|_ROUND}}(2.5) -{{Cl|PRINT}} {{Cl|_ROUND}}(3.5) -{{Cl|PRINT}} {{Cl|_ROUND}}(4.5) -{{Cl|PRINT}} {{Cl|_ROUND}}(5.5) -{{CodeEnd}} -{{OutputStart}}0 -2 -2 -4 -4 -6 -{{OutputEnd}} - - -''See also:'' -* [[INT]], [[CINT]] -* [[FIX]], [[CLNG]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCREENCLICK__11111111111.txt b/internal/help/_SCREENCLICK__11111111111.txt deleted file mode 100644 index 1e0c5b94c..000000000 --- a/internal/help/_SCREENCLICK__11111111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:47}} -{{DISPLAYTITLE:_SCREENCLICK}} -The [[_SCREENCLICK]] statement simulates clicking on a pixel coordinate on the desktop screen with the left mouse button. - - -{{PageSyntax}} -: [[_SCREENCLICK]] {{Parameter|column%}}, {{Parameter|row%}}[, {{Parameter|button%}}] - - -{{PageDescription}} -* {{Parameter|column%}} is the horizontal pixel coordinate position on the screen. -* {{Parameter|row%}} is the vertical pixel coordinate position on the screen. -* Optional {{Parameter|button%}} can be used to specify left button (1, default), right button (2) or middle button (3) (available with '''build 20170924/68'''). -* Coordinates can range from 0 to the [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]]. The desktop image acquired by [[_SCREENIMAGE]] can be used to map the coordinates required. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]] - - -{{PageSeeAlso}} -* [[_SCREENIMAGE]], [[_SCREENPRINT]] -* [[_SCREENMOVE]], [[_SCREENX]], [[_SCREENY]] -* [[_DESKTOPWIDTH]], [[_DESKTOPHEIGHT]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCREENEXISTS__111111111111.txt b/internal/help/_SCREENEXISTS__111111111111.txt deleted file mode 100644 index 2b1418e49..000000000 --- a/internal/help/_SCREENEXISTS__111111111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:48}} -{{DISPLAYTITLE:_SCREENEXISTS}} -The [[_SCREENEXISTS]] function returns true (-1) once a screen has been created. - - -{{PageSyntax}} -: {{Parameter|screenReady%%}} = [[_SCREENEXISTS]] - - -{{PageDescription}} -* Function returns true (-1) once a program screen is available to use or change. -* Can be used to avoid program errors because a screen was not ready for input or alterations. -** Use before [[_TITLE]], [[_SCREENMOVE]] and other functions that require the output window to have been created. - - -{{PageExamples}} -;Example:Waiting in a loop until the screen exists to add the title. The [[_LIMIT]] prevents the loop from using all CPU time while waiting. -{{CodeStart}} -{{Cl|SCREEN}} 12 -{{Cl|DO}}: {{Cl|_LIMIT}} 10: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_SCREENEXISTS}} -{{Cl|_TITLE}} "My Title" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_FULLSCREEN]] -* [[_SCREENIMAGE]] -* [[$CONSOLE]] -* [[$RESIZE]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_SCREENHIDE__1111111111.txt b/internal/help/_SCREENHIDE__1111111111.txt deleted file mode 100644 index 99aa330bc..000000000 --- a/internal/help/_SCREENHIDE__1111111111.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:50}} -{{DISPLAYTITLE:_SCREENHIDE}} -The [[_SCREENHIDE]] statement can be used to hide the main program window in a section of code. - - -{{PageSyntax}} -: [[_SCREENHIDE]] - - -{{PageDescription}} -* Use [[_SCREENHIDE]] to get rid of the main program window until later in the program. -* Use the respective [[Metacommand]] to get rid of the program window throughout a program or when using [[$CONSOLE]]. - - -{{PageSeeAlso}} -* [[$SCREENHIDE]], [[$SCREENSHOW]], [[$CONSOLE]] ([[Metacommand#QB64 Metacommands|QB64 Metacommands]]) -* [[_SCREENSHOW]], [[_CONSOLE]] -* [[_SCREENICON]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_SCREENICON_(function)__1111111111_(00000000).txt b/internal/help/_SCREENICON_(function)__1111111111_(00000000).txt deleted file mode 100644 index 0d24e46d0..000000000 --- a/internal/help/_SCREENICON_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:52}} -{{DISPLAYTITLE:_SCREENICON (function)}} -The [[_SCREENICON (function)|_SCREENICON]] function returns true (-1) or false (0) to indicate whether the window has been minimized to an icon on the taskbar. - - -{{PageSyntax}} -: {{Parameter|isMinimized%%}} = [[_SCREENICON (function)|_SCREENICON]] - - -{{PageDescription}} -* The function returns true (-1) when the program is minimized to the task bar and false (0) when not. - - -{{PageSeeAlso}} -* [[_SCREENICON]] -* [[_SCREENHIDE]] -* [[_SCREENSHOW]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_SCREENICON__1111111111.txt b/internal/help/_SCREENICON__1111111111.txt deleted file mode 100644 index de5a0cc7f..000000000 --- a/internal/help/_SCREENICON__1111111111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:53}} -{{DISPLAYTITLE:_SCREENICON}} -The [[_SCREENICON]] statement can be used to minimize the main program window to the taskbar. - - -{{PageSyntax}} -: [[_SCREENICON]] - - -{{PageDescription}} -* Use [[_SCREENICON]] to minimize the main program window to the taskbar. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[$SCREENHIDE]], [[$SCREENSHOW]], [[$CONSOLE]] (QB64 [[Metacommand]]s) -* [[_SCREENHIDE]], [[_SCREENSHOW]], [[_CONSOLE]] -* [[_SCREENICON (function)]] - - -{{PageNavigation}} diff --git a/internal/help/_SCREENIMAGE__11111111111.txt b/internal/help/_SCREENIMAGE__11111111111.txt deleted file mode 100644 index 6a15e0050..000000000 --- a/internal/help/_SCREENIMAGE__11111111111.txt +++ /dev/null @@ -1,54 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:54}} -{{DISPLAYTITLE:_SCREENIMAGE}} -The [[_SCREENIMAGE]] function stores the current desktop image or a portion of it and returns an image handle. - - -{{PageSyntax}} -: {{Parameter|imageHandle&}} = [[_SCREENIMAGE]]({{Parameter|column1}}, {{Parameter|row1}}, {{Parameter|column2}}, {{Parameter|row2}})] - - -{{PageDescription}} -* {{Parameter|imageHandle&}} is the handle to the new image in memory that will contain the desktop screenshot. -* The optional screen {{Parameter|column}} and {{Parameter|row}} positions can be used to get only a portion of the desktop image. -* The desktop image or partial image is always a 32-bit image. -* The current screen resolution or width-to-height aspect ratio can be obtained with [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]]. -* Can be used to take screenshots of the desktop or used with [[_PRINTIMAGE]] to print them. -* It is important to free unused or uneeded image handles with [[_FREEIMAGE]] to prevent memory overflow errors. -* [[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:'' Determining the present screen resolution of user's PC for a screensaver program. -{{CodeStart}} - desktop& = {{Cl|_SCREENIMAGE}} - MaxScreenX& = {{Cl|_WIDTH (function)|_WIDTH}}(desktop&) - MaxScreenY& = {{Cl|_HEIGHT}}(desktop&) - {{Cl|_FREEIMAGE}} desktop& 'free image after measuring screen(it is not displayed) - {{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(MaxScreenX&, MaxScreenY&, 256) 'program window is sized to fit - {{Cl|_SCREENMOVE}} _MIDDLE -{{CodeEnd}} - - -===Sample code to save images to disk=== -*[[SAVEIMAGE]] -*[[Program ScreenShots]] (member-contributed program for legacy screen modes) -* [[ThirtyTwoBit SUB]] -* [[SaveIcon32]] - - - -{{PageSeeAlso}} -* [[_SCREENCLICK]], [[_SCREENPRINT]] -* [[_SCREENMOVE]], [[_SCREENX]], [[_SCREENY]] -* [[_WIDTH (function)|_WIDTH]], [[_HEIGHT]] -* [[_DESKTOPWIDTH]], [[_DESKTOPHEIGHT]] -* [[_FULLSCREEN]], [[_PRINTIMAGE]] -* [[Screen Saver Programs]] -* [[Bitmaps]], [[Icons and Cursors]] -* [[Hardware images]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCREENMOVE__1111111111.txt b/internal/help/_SCREENMOVE__1111111111.txt deleted file mode 100644 index 5e088f6b4..000000000 --- a/internal/help/_SCREENMOVE__1111111111.txt +++ /dev/null @@ -1,71 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:38:45}} -{{DISPLAYTITLE:_SCREENMOVE}} -The [[_SCREENMOVE]] statement positions the program window on the desktop using designated coordinates. - - -{{PageSyntax}} -: [[_SCREENMOVE]] {{{Parameter|column&}}, {{Parameter|row&}}|_MIDDLE} - - -{{Parameters}} -* Positions the program window on the desktop using the {{Parameter|column&}} and {{Parameter|row&}} pixel coordinates for the upper left corner. -* '''_MIDDLE''' can be used instead to automatically center the program window on the desktop, in any screen resolution. - - -{{PageDescription}} -* The program's [[SCREEN]] dimensions may influence the desktop position that can be used to keep the entire window on the screen. -* Use [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]] to find the current desktop resolution to place the program's window. -* On dual monitors a negative {{Parameter|column&}} position or a value greater than the main screen width can be used to position a window in another monitor. -* '''A small delay may be necessary when a program first starts up to properly orient the screen on the desktop properly.''' See [[_SCREENEXISTS]]. -* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not supported in Linux versions]]''' - - -{{PageExamples}} -''Example 1:'' Calculating the border and header offsets by comparing a coordinate move with _MIDDLE by using trial and error. -{{CodeStart}} -userwidth& = {{Cl|_DESKTOPWIDTH}}: userheight& = {{Cl|_DESKTOPHEIGHT}} 'get current screen resolution -{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 256) -scrnwidth& = {{Cl|_WIDTH}}: scrnheight& = {{Cl|_HEIGHT}} 'get the dimensions of the program screen - -{{Cl|_SCREENMOVE}} (userwidth& \ 2 - scrnwidth& \ 2) - 3, (userheight& \ 2 - scrnheight& \ 2) - 29 -{{Cl|_DELAY}} 4 -{{Cl|_SCREENMOVE}} _MIDDLE 'check centering - -{{Cl|END}} -{{CodeEnd}} -: When positioning the window, offset the position by -3 columns and - 29 rows to calculate the top left corner coordinate. - - -''Example 2:'' Moving a program window to a second monitor positioned to the right of the main desktop. -{{CodeStart}} -wide& = {{Cl|_DESKTOPWIDTH}} -high& = {{Cl|_DESKTOPHEIGHT}} - -{{Cl|PRINT}} wide&; "X"; high& - -{{Cl|_DELAY}} 4 -{{Cl|_SCREENMOVE}} wide& + 200, 200 'positive value for right monitor 2 - -img2& = {{Cl|_SCREENIMAGE}} -wide2& = {{Cl|_WIDTH (function)|_WIDTH}}(img2&) -high2& = {{Cl|_HEIGHT}}(img2&) -{{Cl|PRINT}} wide2&; "X"; high2& -{{Cl|_DELAY}} 4 -{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} 'moves program back to main monitor 1 -{{CodeEnd}} -: ''Notes:'' Change the [[_SCREENMOVE]] column to negative for a left monitor. - -
'''[[_FULLSCREEN]] works in the primary monitor and may push all running programs to a monitor on the right.'''
- - -{{PageSeeAlso}} -* [[_SCREENX]], [[_SCREENY]] -* [[_SCREENIMAGE]], [[_DESKTOPWIDTH]], [[_DESKTOPHEIGHT]] -* [[_SCREENPRINT]] -* [[_SCREENEXISTS]] -* [[_NEWIMAGE]], [[SCREEN (statement)]] - - - -{{PageNavigation}} diff --git a/internal/help/_SCREENPRINT__11111111111.txt b/internal/help/_SCREENPRINT__11111111111.txt deleted file mode 100644 index 60ae38191..000000000 --- a/internal/help/_SCREENPRINT__11111111111.txt +++ /dev/null @@ -1,90 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:55}} -{{DISPLAYTITLE:_SCREENPRINT}} -The [[_SCREENPRINT]] statement simulates typing text into a Windows focused program. - - -{{PageSyntax}} -: [[_SCREENPRINT]] {{Parameter|text$}} - - -{{PageDescription}} -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not supported in Linux or MAC versions]] -* {{Parameter|text$}} is the text to be typed into a focused program's text entry area, one character at a time. -* Set the focus to a desktop program by using the [[_SCREENIMAGE]] handle as the [[_SOURCE]]. Use the image to map the desired area. -* [[_SCREENCLICK]] can also be used to set the focus to a program's text entry area on the desktop. -*'''Note: If the focus is not set correctly, the text may be printed to the QB64 IDE, if open, or not printed at all.''' -* Ctrl + letter key shortcuts can be simulated using the appropriate [[ASCII]] Control character codes 1 to 26 shown below: -{{WhiteStart}} CTRL + A = CHR$(1) ☺ StartHeader (SOH) CTRL + B = CHR$(2) ☻ StartText (STX) - CTRL + C = CHR$(3) ♥ EndText (ETX) CTRL + D = CHR$(4) ♦ EndOfTransmit (EOT) - CTRL + E = CHR$(5) ♣ Enquiry (ENQ) CTRL + F = CHR$(6) ♠ Acknowledge (ACK) - CTRL + G = CHR$(7) • [[BEEP]] (BEL) CTRL + H = CHR$(8) ◘ '''[Backspace]''' (BS) - CTRL + I = CHR$(9) ○ Horiz.Tab '''[Tab]''' CTRL + J = CHR$(10) ◙ LineFeed(printer) (LF) - CTRL + K = CHR$(11) ♂ Vert. Tab (VT) CTRL + L = CHR$(12) ♀ FormFeed(printer) (FF) - CTRL + M = CHR$(13) ♪ '''[Enter]''' (CR) CTRL + N = CHR$(14) ♫ ShiftOut (SO) - CTRL + O = CHR$(15) ☼ ShiftIn (SI) CTRL + P = CHR$(16) ► DataLinkEscape (DLE) - CTRL + Q = CHR$(17) ◄ DevControl1 (DC1) CTRL + R = CHR$(18) ↕ DeviceControl2 (DC2) - CTRL + S = CHR$(19) ‼ DevControl3 (DC3) CTRL + T = CHR$(20) ¶ DeviceControl4 (DC4) - CTRL + U = CHR$(21) § NegativeACK (NAK) CTRL + V = CHR$(22) ▬ Synchronous Idle (SYN) - CTRL + W = CHR$(23) ↨ EndTXBlock (ETB) CTRL + X = CHR$(24) ↑ Cancel (CAN) - CTRL + Y = CHR$(25) ↓ EndMedium (EM) CTRL + Z = CHR$(26) → End Of File(SUB) (EOF) -{{WhiteEnd}} - - -{{PageExamples}} -''Example:'' Printing text into a Windows text editor (Notepad) and copying to the clipboard. May not work on all systems. -{{CodeStart}} -{{Cl|DEFLNG}} A-Z -{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|PRINT}} "OPENing and MAXIMIZING Notepad in 5 seconds..."; : {{Cl|_DELAY}} 5 -{{Cl|SHELL}} {{Cl|_DONTWAIT}} "START /MAX NotePad.exe" 'opens Notepad file "untitled.txt" -'detect notepad open and maximized -'condition: 80% or more of the screen is white -{{Cl|DO}} 'read the desktop screen image for maximized window - s = {{Cl|_SCREENIMAGE}} - {{Cl|_SOURCE}} s - z = 0 - {{Cl|FOR...NEXT|FOR}} y = 0 {{Cl|TO}} {{Cl|_HEIGHT}}(s) - 1 'scan for large white area - {{Cl|FOR...NEXT|FOR}} x = 0 {{Cl|TO}} _{{Cl|WIDTH}}(s) - 1 - c = {{Cl|POINT}}(x, y) - {{Cl|IF}} c = {{Cl|_RGB32}}(255, 255, 255) {{Cl|THEN}} z = z + 1 - {{Cl|NEXT}} - {{Cl|NEXT}} - {{Cl|IF}} z / ({{Cl|_HEIGHT}}(s) * _{{Cl|WIDTH}}(s)) > 0.8 {{Cl|THEN}} {{Cl|EXIT DO}} 'when 80% of screen is white - {{Cl|_FREEIMAGE}} s 'free desktop image - {{Cl|_LIMIT}} 1 'scans 1 loop per second -{{Cl|PRINT}} "."; -{{Cl|LOOP}} -{{Cl|PRINT}} -{{Cl|PRINT}} "NOTEPAD detected as OPEN and MAXIMIZED" - - -{{Cl|_SCREENPRINT}} "HELLO WORLD" -{{Cl|SLEEP}} 2 -{{Cl|_SCREENPRINT}} {{Cl|CHR$}}(8) + {{Cl|CHR$}}(8) + {{Cl|CHR$}}(8) + {{Cl|CHR$}}(8) + {{Cl|CHR$}}(8) 'backspace 5 characters -{{Cl|SLEEP}} 3 -{{Cl|_SCREENPRINT}} "QB64!" -{{Cl|SLEEP}} 2 -{{Cl|_SCREENPRINT}} {{Cl|CHR$}}(1) 'CTRL + A select all -{{Cl|SLEEP}} 2 -{{Cl|_SCREENPRINT}} {{Cl|CHR$}}(3) 'CTRL + C copy to clipboard -{{Cl|SLEEP}} 2 -{{Cl|PRINT}} {{Cl|_CLIPBOARD$}} -{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "QB64 ROCKS!" -{{Cl|SLEEP}} 2 -{{Cl|_SCREENPRINT}} {{Cl|CHR$}}(22) 'CTRL + V paste from clipboard -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Galleon}} -:''Explanation:'' If the Windows shortcuts are set up properly, printing ASCII Control characters acts like the user selected the control + letter combinations to ''Select all'' (CHR$(1)), ''Copy'' (CHR$(3)) and ''Paste'' (CHR$(22)) the text with the Windows Clipboard. If the editor program's CTRL key combinations are different, use the matching letter [[ASCII]] code from A = 1 to Z = 26 in the text editor. - - -{{PageSeeAlso}} -* [[_SCREENIMAGE]], [[_SCREENCLICK]] -* [[_SCREENMOVE]], [[_SCREENX]], [[_SCREENY]] -* [[ASCII]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCREENSHOW__1111111111.txt b/internal/help/_SCREENSHOW__1111111111.txt deleted file mode 100644 index 6fd3b1b65..000000000 --- a/internal/help/_SCREENSHOW__1111111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:57}} -{{DISPLAYTITLE:_SCREENSHOW}} -The [[_SCREENSHOW]] statement can be used to display the main program window in a section of code. - - -{{PageSyntax}} -: [[_SCREENSHOW]] - - -{{PageDescription}} -* Use [[_SCREENSHOW]] to display the main program window after it was hidden by [[_SCREENHIDE]]. - - -{{PageSeeAlso}} -* [[$SCREENHIDE]], [[$SCREENSHOW]], [[$CONSOLE]] ([[Metacommand#QB64 Metacommands|QB64 Metacommands]]) -* [[_SCREENHIDE]], [[_CONSOLE]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_SCREENX__1111111.txt b/internal/help/_SCREENX__1111111.txt deleted file mode 100644 index b836b25e0..000000000 --- a/internal/help/_SCREENX__1111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:58}} -{{DISPLAYTITLE:_SCREENX}} -The [[_SCREENX]] function returns the current column pixel coordinate of the program window on the desktop. - - -{{PageSyntax}} -: {{Parameter|positionX&}} = [[_SCREENX]] - - -{{PageDescription}} -* Function returns the current program window's upper left corner column position on the desktop. -* Use [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]] to find the current Windows desktop resolution to adjust the position with [[_SCREENMOVE]]. -* [[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:'' Clicks and opens program window header menu: -{{CodeStart}}{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} -{{Cl|_SCREENCLICK}} {{Cl|_SCREENX}} + 10, {{Cl|_SCREENY}} + 10 -{{Cl|PRINT}} "Hello window!" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SCREENY]] -* [[_SCREENIMAGE]] -* [[_SCREENCLICK]] -* [[_SCREENPRINT]] -* [[_SCREENMOVE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCREENY__1111111.txt b/internal/help/_SCREENY__1111111.txt deleted file mode 100644 index 6d93f2279..000000000 --- a/internal/help/_SCREENY__1111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:39:59}} -{{DISPLAYTITLE:_SCREENY}} -The [[_SCREENY]] function returns the current row pixel coordinate of the program window on the desktop. - - -{{PageSyntax}} -: {{Parameter|positionY&}} = [[_SCREENY]] - - -{{PageDescription}} -* Function returns the current program window's upper left corner row position on the desktop. -* Use [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]] to find the current user's Windows desktop resolution to adjust the position with [[_SCREENMOVE]]. -* [[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:'' Clicks and opens program window header menu: -{{CodeStart}}{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} -{{Cl|_SCREENCLICK}} {{Cl|_SCREENX}} + 10, {{Cl|_SCREENY}} + 10 -{{Cl|PRINT}} "Hello window!" -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SCREENX]] -* [[_SCREENIMAGE]] -* [[_SCREENCLICK]] -* [[_SCREENPRINT]] -* [[_SCREENMOVE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SCROLLLOCK_(function)__1111111111_(00000000).txt b/internal/help/_SCROLLLOCK_(function)__1111111111_(00000000).txt deleted file mode 100644 index e95fed17f..000000000 --- a/internal/help/_SCROLLLOCK_(function)__1111111111_(00000000).txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:01}} -{{DISPLAYTITLE: _SCROLLLOCK (function)}} -The [[_SCROLLLOCK (function)| _SCROLLLOCK]] function returns the current state of the Scroll Lock key as on (-1) or off (0). - - -{{PageSyntax}} -: {{Parameter|keyStatus%%}} = [[_SCROLLLOCK (function)| _SCROLLLOCK]] - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_CAPSLOCK (function)]], [[_NUMLOCK (function)]] -* [[_CAPSLOCK]] (statement), [[_NUMLOCK]] (statement), [[_SCROLLLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_SCROLLLOCK__1111111111.txt b/internal/help/_SCROLLLOCK__1111111111.txt deleted file mode 100644 index 19adededc..000000000 --- a/internal/help/_SCROLLLOCK__1111111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:02}} -{{DISPLAYTITLE: _SCROLLLOCK}} -The [[_SCROLLLOCK]] statement sets the state of the Scroll Lock key. - - -{{PageSyntax}} -: [[_SCROLLLOCK]] {ON|OFF|_TOGGLE} - - -{{PageAvailability}} -* '''QB64 1.4 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -{{PageSeeAlso}} -* [[_CAPSLOCK (function)]], [[_NUMLOCK (function)]], [[_SCROLLLOCK (function)]] -* [[_CAPSLOCK]] (statement), [[_NUMLOCK]] (statement) - - -{{PageNavigation}} diff --git a/internal/help/_SETALPHA__11111111.txt b/internal/help/_SETALPHA__11111111.txt deleted file mode 100644 index 60498b7f1..000000000 --- a/internal/help/_SETALPHA__11111111.txt +++ /dev/null @@ -1,69 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:03}} -{{DISPLAYTITLE:_SETALPHA}} -The [[_SETALPHA]] statement sets the alpha channel transparency level of some or all of the pixels of an image. - - -{{PageSyntax}} -: [[_SETALPHA]] {{Parameter|alpha&}}[, {{Parameter|color1&}}][ [[TO]] {{Parameter|colour2&}}] [, {{Parameter|imageHandle&}}] - - -{{Parameters}} -* {{Parameter|alpha&}} is the new alpha level to set, ranging from 0 (transparent) to 255 (opaque). -* {{Parameter|color1&}} designates the 32-bit [[LONG]] color value or range of color values {{Parameter|color1&}} TO {{Parameter|colour2&}} to set the transparency. -* If no color value or range of colors is given, the entire image's alpha is changed, including any [[_CLEARCOLOR]] settings. -* If {{Parameter|imageHandle&}} is omitted, it is assumed to be the current write page or [[_DEST|destination]] image. - - -{{PageDescription}} -* In the first syntax, the alpha level of all pixels is set to {{Parameter|alpha&}}. -* In the second syntax, the alpha level of all pixels matching the color {{Parameter|color1&}} is set to {{Parameter|alpha&}}. -* In the third syntax, the alpha level of all pixels with red, green, blue and alpha channels in the range [{{Parameter|color1&}} TO {{Parameter|color2&}}] are set. -* The [[_ALPHA]] setting makes a 32-bit color transparent, opaque or something in between. Zero is clear and 255 totally blocks underlying images. Use it to see through backgrounds or image colors. -* If {{Parameter|alpha&}} is outside that range, an [[ERROR Codes|illegal function call]] error will occur. -* If the image specified by {{Parameter|imageHandle&}} uses a palette, an [[ERROR Codes|invalid handle]] error will occur. -* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|illegal function call]] error will occur. -* '''NOTE: 32-bit [[_NEWIMAGE]] screen page backgrounds are transparent black or [[_ALPHA]] 0. Use [[_DONTBLEND]] or [[CLS]] for opaque.''' - - -{{PageExamples}} -''Example:'' Using a _SETALPHA color range to fade an image in and out while not affecting the transparent white background. -{{CodeStart}} -main = {{Cl|_NEWIMAGE}}(640, 480, 32) -{{Cl|SCREEN}} main -{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} - -Image1& = {{Cl|_LOADIMAGE}}("qb64_trans.png") '<<< PNG file with white background to hide -{{Cl|_SOURCE}} Image1& -clr~& = {{Cl|POINT}}(0, 0) 'find background color of image -{{Cl|_CLEARCOLOR}} clr~&, Image1& 'set background color as transparent - -topclr~& = clr~& - {{Cl|_RGBA}}(1, 1, 1, 0) 'get topmost color range just below full white -{{Cl|_DEST}} main - -a& = 0 -d = 1 -DO - {{Cl|_LIMIT}} 10 'regulate speed of fade in and out - {{Cl|CLS}} ', {{Cl|_RGB}}(255, 0, 0) - a& = a& + d - {{Cl|IF...THEN|IF}} a& = 255 {{Cl|THEN}} d = -d - {{Cl|_SETALPHA}} a&, 0 {{Cl|TO}} topclr~&, Image1& 'affects all colors below bright white - {{Cl|_PUTIMAGE}} (0, 342), Image1& - {{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} "Alpha: "; a& - {{Cl|_DISPLAY}} -{{Cl|LOOP}} {{Cl|UNTIL}} a& = 0 -{{CodeEnd}} -: ''Explanation:'' The [[POINT]] value minus [[_RGBA]](1, 1, 1, 0) subtracts a small amount from the bright white color value so that the top [[_SETALPHA]] color range will not affect the [[_CLEARCOLOR]] transparency of the bright white PNG background. - - -{{PageSeeAlso}} -* [[_ALPHA]], [[_ALPHA32]] -* [[_RGBA]], [[_RGBA32]] -* [[_CLEARCOLOR]] -* [[_CLEARCOLOR (function)]] -* [[_BLEND]], [[_DONTBLEND]] -* [[COLOR]], [[Images]] - - -{{PageNavigation}} diff --git a/internal/help/_SETBIT__111111.txt b/internal/help/_SETBIT__111111.txt deleted file mode 100644 index 9dad7817a..000000000 --- a/internal/help/_SETBIT__111111.txt +++ /dev/null @@ -1,45 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:04}} -{{DISPLAYTITLE:_SETBIT}} -The [[_SETBIT]] function is used to set a specified bit of a numerical value to 1 (on state). - - -{{PageSyntax}} -:{{Parameter|result}} = [[_SETBIT]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to set the bit of and can be of the following types: [[_BYTE]], [[INTEGER]], [[LONG]], or [[_INTEGER64]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} the number of the bit to be set. - - -{{PageDescription}} -* Can be used to manually manipulate individual bits of an integer value by setting them to 1 (on state). -* Setting a bit that is already set to 1 will have no effect. -* Bits start at 0 (so a [[_BYTE]] has bits 0 to 7, [[INTEGER]] 0 to 15, and so on) - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}}A~%% = 0 '{{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|PRINT}} A~%% -A~%% = {{Cl|_SETBIT}}(A~%%,6) 'set the seventh bit of A~%% -{{Cl|PRINT}} A~%% -{{CodeEnd}} -{{OutputStart}} - 0 - 64 -{{OutputEnd}} - - - -{{PageSeeAlso}} -* [[_SHL]], [[_SHR]], [[INTEGER]], [[LONG]] -* [[_READBIT]], [[_BYTE]], [[_INTEGER64]] -* [[_RESETBIT]], [[_TOGGLEBIT]] - -{{PageNavigation}} diff --git a/internal/help/_SHELLHIDE__111111111.txt b/internal/help/_SHELLHIDE__111111111.txt deleted file mode 100644 index e2905a7dc..000000000 --- a/internal/help/_SHELLHIDE__111111111.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:05}} -{{DISPLAYTITLE:_SHELLHIDE}} -The [[_SHELLHIDE]] function hides the console window and returns any [[INTEGER]] code sent when a program exits. - - -{{PageSyntax}} -: {{Parameter|returnCode%}} = [[_SHELLHIDE]]({{Parameter|externalCommand$}}) - - -{{Parameters}} -* The literal or variable [[STRING]] {{Parameter|externalCommand$}} parameter can be any external command or call to another program. - - -{{PageDescription}} -* A QB64 program can return codes specified after [[END]] or [[SYSTEM]] calls. -* The {{Parameter|returnCode%}} is usually 0 when the external program ends with no errors. - - -{{PageExamples}} -''Example:'' Shelling to another QB64 program will return the exit code when one is set in the program that is run. -{{CodeStart}} -returncode% = {{Cl|_SHELLHIDE}}("DesktopSize") 'replace call with your program EXE - -{{Cl|PRINT}} returncode% - -{{Cl|END}} -{{CodeEnd}} -: ''Explanation:'' To set a program exit code use an [[INTEGER]] parameter value after [[END]] or [[SYSTEM]] in the called program. - - -{{PageSeeAlso}} -* [[SHELL (function)]] -* [[SHELL]], [[_HIDE]] -* [[_CONSOLE]], [[$CONSOLE]] -* [[SYSTEM]], [[END]] - - -{{PageNavigation}} diff --git a/internal/help/_SHL__111.txt b/internal/help/_SHL__111.txt deleted file mode 100644 index e77b0fe0d..000000000 --- a/internal/help/_SHL__111.txt +++ /dev/null @@ -1,69 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:06}} -{{DISPLAYTITLE:_SHL}} -The [[_SHL]] function is used to shift the bits of a numerical value to the left. - - -{{PageSyntax}} -:{{Parameter|result}} = [[_SHL]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to shift the bits of and can be of the following types: [[INTEGER]], [[LONG]],[[_INTEGER64]], or [[_BYTE]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} is the number of places to shift the bits. -* While 0 is a valid value it will have no affect on the variable being shifted. - - -{{PageDescription}} -* Allows for multiplication of a value by 2 faster than normal multiplication (see example 2 below). -* Bits that reach the end of a variable's bit count are dropped (when using a variable of the same type - otherwise they will carry over). -* The type of variable used to store the results should match the type of the variable being shifted. - - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}}A~%% = 1 'set right most bit of an{{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|PRINT}} A~%% -{{Cl|PRINT}} {{Cl|_SHL}}(A~%%,7) -B~%% = {{Cl|_SHL}}(A~%%,8) 'shift the bit off the left 'edge' -{{Cl|PRINT}} B~%% -{{CodeEnd}} -{{OutputStart}} - 1 - 128 - 0 -{{OutputEnd}} - - -''Example 2:'' -{{CodeStart}} -A~%% = 1 -{{Cl|FOR}} I%% = 0 {{Cl|TO}} 8 - {{Cl|PRINT}} {{Cl|_SHL}}(A~%%, I%%) -{{Cl|FOR...NEXT|NEXT}} I%% -{{CodeEnd}} -{{OutputStart}} - 1 - 2 - 4 - 8 - 16 - 32 - 64 - 128 - 256 -{{OutputEnd}} -* Note: When directly [[PRINT]]ing to screen, the result is calculated internally using a larger variable type so the left most bit is carried to the next value. -** To avoid this store the result in a variable of the same type before printing. - -{{PageSeeAlso}} -* [[_SHR]], [[INTEGER]], [[LONG]] -* [[_BYTE]], [[_INTEGER64]] - - -{{PageNavigation}} diff --git a/internal/help/_SHR__111.txt b/internal/help/_SHR__111.txt deleted file mode 100644 index af1fb9422..000000000 --- a/internal/help/_SHR__111.txt +++ /dev/null @@ -1,66 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:08}} -{{DISPLAYTITLE:_SHR}} -The [[_SHR]] function is used to shift the bits of a numerical value to the right. - - -{{PageSyntax}} -:{{Parameter|result}} = [[_SHR]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to shift the bits of and can be of the following types: [[INTEGER]], [[LONG]], [[_INTEGER64]], or [[_BYTE]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} the number of places to shift the bits. -* While 0 is a valid value it will have no affect on the variable being shifted. - - -{{PageDescription}} -* Allows for division of a value by 2 faster than normal division (see example 2 below). -* Bits that reach the end of a variables bit count are dropped. -* The type of variable used to store the results should match the type of the variable being shifted. -* NOTE: When dealing with SIGNED variables, shifting the bits right will leave the sign bit set. This is due to how C++ deals with bit shifting under the hood. - -==Availability== -* '''Version 1.3 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}}A~%% = 128 'set left most bit of an{{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|PRINT}} A~%% -{{Cl|PRINT}} {{Cl|_SHR}}(A~%%,7) -{{Cl|PRINT}} {{Cl|_SHR}}(A~%%,8) 'shift the bit off the right 'edge' -{{CodeEnd}} -{{OutputStart}} - 128 - 1 - 0 -{{OutputEnd}} - - -''Example 2:'' -{{CodeStart}} -A~%% = 128 -{{Cl|FOR}} I%% = 0 {{Cl|TO}} 8 - {{Cl|PRINT}} {{Cl|_SHR}}(A~%%, I%%) -{{Cl|FOR...NEXT|NEXT}} I%% -{{CodeEnd}} -{{OutputStart}} - 128 - 64 - 32 - 16 - 8 - 4 - 2 - 1 - 0 -{{OutputEnd}} - -{{PageSeeAlso}} -* [[_SHL]], [[INTEGER]], [[LONG]] -* [[_BYTE]], [[_INTEGER64]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDBAL__111111.txt b/internal/help/_SNDBAL__111111.txt deleted file mode 100644 index 25e399e8b..000000000 --- a/internal/help/_SNDBAL__111111.txt +++ /dev/null @@ -1,103 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:09}} -{{DISPLAYTITLE:_SNDBAL}} -The [[_SNDBAL]] statement attempts to set the balance or 3D position of a sound. - - -{{PageSyntax}} -: [[_SNDBAL]] {{Parameter|handle&}}[, {{Parameter|x!}}][, {{Parameter|y!}}][, {{Parameter|z!}}][, {{Parameter|channel&}}]] - - -{{Parameters}} -* ''handle&'' is a valid sound handle created by the [[_SNDOPEN]] function. -* {{Parameter|x!}} distance values go from left (negative) to right (positive). -* {{Parameter|y!}} distance values go from below (negative) to above (positive). -* {{Parameter|z!}} distance values go from behind (negative) to in front (positive). -* {{Parameter|channel&}} value 1 denotes left (mono) and 2 denotes right (stereo) channel (beginning with '''build 20170811/60''') - - -{{PageDescription}} -*Attempts to position a sound in 3D space, or as close to it as the underlying software libraries allow. In some cases, this will be true 3D positioning, in others, a mere volume adjustment based on distance alone. -*Omitted x!, y! or z! [[SINGLE]] values are set to 0 or not changed in '''build 20170811/60 onward'''. -*By setting the x! value to -1 or 1 it plays the sound at full volume from the appropriate speaker. -*Sounds at a distance of 1 or -1 are played at full volume. Sounds further than a distance of 1000 cannot be heard. -*The volume decreases linearly (at a constant gradient) over distance. Half volume = 500. -* An "'''Illegal Function Call'''" error can occur if another sound is using the primary or same channel position. -* Opened sound files must have the [[_SNDOPEN|"VOL"]] capability to use this statement in versions '''before build 20170811/60.''' - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}} -h& = {{Cl|_SNDOPEN}}("LOL.wav", "SYNC,VOL") -{{Cl|_SNDBAL}} h&, 1 -{{Cl|_SNDPLAY}} h& -{{CodeEnd}} - - -''Example:'' Loading a sound after '''build 20170811/60''' - no need to specify "sound capabilities" in [[_SNDOPEN]]. -{{CodeStart}} -s& = {{Cl|_SNDOPEN}}("song.ogg") -{{Cl|PRINT}} "{{Cl|READ}}Y"; s& -{{Cl|_SNDPLAY}} s& -{{Cl|_SNDLOOP}} s& - - -xleft = -1 -xright = 1 -DO - k$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} k$ - {{Cl|CASE}} "f" - xleft = xleft - 0.1 - {{Cl|_SNDBAL}} s&, xleft, , , 1 - {{Cl|CASE}} "g" - xleft = xleft + 0.1 - {{Cl|_SNDBAL}} s&, xleft, , , 1 - {{Cl|CASE}} "h" - xright = xright - 0.1 - {{Cl|_SNDBAL}} s&, xright, , , 2 - {{Cl|CASE}} "j" - xright = xright + 0.1 - {{Cl|_SNDBAL}} s&, xright, , , 2 - {{Cl|CASE}} "n" - volume = volume - 0.1 - {{Cl|_SNDVOL}} s&, volume - {{Cl|CASE}} "m" - volume = volume + 0.1 - {{Cl|_SNDVOL}} s&, volume - {{Cl|CASE}} "p" - {{Cl|_SNDPAUSE}} s& - {{Cl|CASE}} " " - {{Cl|_SNDPLAY}} s& - {{Cl|CASE}} "i" - {{Cl|PRINT}} {{Cl|_SNDPLAYING}}(s&) - {{Cl|PRINT}} {{Cl|_SNDPAUSED}}(s&) - {{Cl|SLEEP}} - {{Cl|CASE}} "b" - {{Cl|_SNDSETPOS}} s&, 110 - {{Cl|CASE}} "l" - {{Cl|_SNDLIMIT}} s&, 10 - {{Cl|PRINT}} "LIM" - {{Cl|SLEEP}} - {{Cl|CASE}} "k" - {{Cl|_SNDSTOP}} s& - {{Cl|CASE}} "c" - {{Cl|_SNDCLOSE}} s& - {{Cl|SLEEP}} - s2& = {{Cl|_SNDOPEN}}("song.ogg") - {{Cl|CASE}} "d" - s2& = {{Cl|_SNDCOPY}}(s&) - {{Cl|_SNDPLAY}} s2& - {{Cl|END SELECT}} - {{Cl|LOCATE}} 1, 1 - {{Cl|PRINT}} xleft, xright, volume, {{Cl|_SNDGETPOS}}(s&); " " -LOOP -{{CodeEnd}}{{small|Code by Johny B}} - - -{{PageSeeAlso}} -*[[_SNDOPEN]], [[_SNDVOL]], [[_SNDLIMIT]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDCLOSE__11111111.txt b/internal/help/_SNDCLOSE__11111111.txt deleted file mode 100644 index 37578c321..000000000 --- a/internal/help/_SNDCLOSE__11111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:10}} -{{DISPLAYTITLE:_SNDCLOSE}} -The [[_SNDCLOSE]] statement frees and unloads an open sound using a [[_SNDOPEN]] or [[_SNDCOPY]] handle. - - -{{PageSyntax}} -: [[_SNDCLOSE]] {{Parameter|handle&}} - - -{{PageDescription}} -* If the sound is still playing, it will be freed automatically after it finishes. -** Closing a looping/paused/etc. sound means it is never freed until the QB64 program terminates. -* When your QB64 program terminates, all sounds are automatically freed. - - -{{PageSeeAlso}} -*[[_SNDSTOP]], [[_SNDPAUSE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDCOPY__1111111.txt b/internal/help/_SNDCOPY__1111111.txt deleted file mode 100644 index 7433c2724..000000000 --- a/internal/help/_SNDCOPY__1111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:11}} -{{DISPLAYTITLE:_SNDCOPY}} -The [[_SNDCOPY]] function copies a sound to a new handle so that two or more of the same sound can be played at once. The passed handle parameter is from the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: {{Parameter|copyHandle&}} = [[_SNDCOPY]]({{Parameter|handle&}}) - - -{{PageDescription}} -* Returns a new handle to the a copy in memory of the sound data referred to by the source handle. -* No changes to the source handle (such as a volume change) are inherited. -* The sound data referred to by the handle and its copies are not freed until all of them are closed. -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"SYNC" capability]] to use this function. - - -{{PageSeeAlso}} -* [[_SNDPLAYCOPY]] -* [[_SNDOPEN]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDGETPOS__111111111.txt b/internal/help/_SNDGETPOS__111111111.txt deleted file mode 100644 index 0f576ed3d..000000000 --- a/internal/help/_SNDGETPOS__111111111.txt +++ /dev/null @@ -1,38 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:12}} -{{DISPLAYTITLE:_SNDGETPOS}} -The [[_SNDGETPOS]] function returns the current playing position in seconds using a handle from [[_SNDOPEN]]. - - -{{PageSyntax}} -:{{Parameter|position}} = [[_SNDGETPOS]]({{Parameter|handle&}}) - - -{{PageDescription}} -*Returns the current playing position in seconds from an open sound file. -*If a sound isn't playing, it returns 0. -*If a sound is paused, it returns the paused position. -*For a looping sound, the value returned continues to increment and does not reset to 0 when the sound loops. -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"SETPOS" capability]] to use this function. - - -{{PageExamples}} -''Example:'' To check the current playing position in an MP3 file, use [[_SNDPLAY]] with [[_SNDGETPOS]] printed in a loop: -{{CodeStart}} -SoundFile& = {{Cl|_SNDOPEN}}("YourSoundFile.mp3") '<<< your MP3 sound file here! -{{Cl|_SNDSETPOS}} SoundFile&, 5.5 'set to play sound 5 1/2 seconds into music -{{Cl|_SNDPLAY}} SoundFile& 'play sound -Do: {{Cl|_LIMIT}} 60 - LOCATE 5, 2: PRINT "Current play position> "; {{Cl|_SNDGETPOS}}(SoundFile&) -LOOP UNTIL {{Cl|_KEYDOWN}}(27) OR {{Cl|NOT}} {{Cl|_SNDPLAYING}}(SoundFile&) 'ESC or end of sound exit -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDSETPOS]] -* [[_SNDOPEN]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDLEN__111111.txt b/internal/help/_SNDLEN__111111.txt deleted file mode 100644 index 5259198d4..000000000 --- a/internal/help/_SNDLEN__111111.txt +++ /dev/null @@ -1,22 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:13}} -{{DISPLAYTITLE:_SNDLEN}} -The [[_SNDLEN]] function returns the length in seconds of a loaded sound using a handle from the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: {{Parameter|soundLength}} = [[_SNDLEN]]({{Parameter|handle&}}) - - -{{PageDescription}} -* Returns the length of a sound in seconds. -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"LEN" capability]] to use this function. - - -{{PageSeeAlso}} -* [[_SNDCOPY]], [[_SNDLIMIT]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDLIMIT__11111111.txt b/internal/help/_SNDLIMIT__11111111.txt deleted file mode 100644 index 5bee1d150..000000000 --- a/internal/help/_SNDLIMIT__11111111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:14}} -{{DISPLAYTITLE:_SNDLIMIT}} -The [[_SNDLIMIT]] statement stops playing a sound after it has been playing for a set number of seconds. - - -{{PageSyntax}} -: [[_SNDLIMIT]] {{Parameter|handle&}}, {{Parameter|numberOfSeconds!}} - - -{{Parameters}} -* The {{Parameter|handle&}} variable name is created using the [[_SNDOPEN]] function from a loaded sound file. -* {{Parameter|numberOfSeconds!}} is a [[SINGLE]] value of seconds that the sound will play. - - -{{PageDescription}} -*Sets how long a sound will be played in seconds. If the limit is set after the sound is started, the timer starts counting down from when the limit is applied, not from the start of playing. -*Set {{Parameter|numberOfSeconds!}} to 0 seconds to remove the limit. -*Pausing or stopping the sound will also remove the limit. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|_SNDLIMIT}} h&, 5.5 -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDOPEN]], [[_SNDLEN]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDLOOP__1111111.txt b/internal/help/_SNDLOOP__1111111.txt deleted file mode 100644 index c476637d4..000000000 --- a/internal/help/_SNDLOOP__1111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:15}} -{{DISPLAYTITLE:_SNDLOOP}} -The [[_SNDLOOP]] statement is like [[_SNDPLAY]] but the sound is looped. Uses a handle from the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: [[_SNDLOOP]] {{Parameter|handle&}} - - -{{PageDescription}} -*Plays the sound identified by {{Parameter|handle&}} in a loop. - - -{{PageExamples}} -''Example:'' Loading a sound or music file and playing it in a loop until a key is pressed. -{{CodeStart}} -bg = {{Cl|_SNDOPEN}}("back.ogg") '<<<<<<<<<< change to your sound file name -{{Cl|_SNDLOOP}} bg - -DO - {{Cl|_LIMIT}} 10 'keep CPU resources used low -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'key press program exit -{{Cl|_SNDSTOP}} bg -{{Cl|_SNDCLOSE}} bg -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDOPEN]], [[_SNDSTOP]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDOPENRAW__1111111111.txt b/internal/help/_SNDOPENRAW__1111111111.txt deleted file mode 100644 index df659188c..000000000 --- a/internal/help/_SNDOPENRAW__1111111111.txt +++ /dev/null @@ -1,40 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:18}} -{{DISPLAYTITLE:_SNDOPENRAW}} -The [[_SNDOPENRAW]] function opens a new channel to fill with _SNDRAW content to manage multiple dynamically generated sounds. - - -{{PageSyntax}} -: {{Parameter|pipeHandle&}} = [[_SNDOPENRAW]] - - -{{PageDescription}} -* You can manage multiple dynamically generated sounds at once without having to worry about mixing. -* Use [[_SNDCLOSE]] to remove the pipe sound handles from memory. - - -{{PageExamples}} -''Example:'' Combining 2 sounds without worrying about mixing: -{{CodeStart}} -a = {{Cl|_SNDOPENRAW}} -b = {{Cl|_SNDOPENRAW}} - -{{Cl|FOR...NEXT|FOR}} x = 1 {{Cl|TO}} 100000 - {{Cl|_SNDRAW}} {{Cl|SIN}}(x / 10), , a 'fill with a tone - {{Cl|_SNDRAW}} {{Cl|RND}} * 1 - 0.5, , b 'fill with static -{{Cl|NEXT}} - -{{Cl|_SNDCLOSE}} a -{{Cl|_SNDCLOSE}} b -{{CodeEnd}}{{small|Code by Galleon}} - - -{{PageSeeAlso}} -* [[_SNDRAWDONE]] -* [[_SNDRAW]] -* [[_SNDCLOSE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDOPEN__1111111.txt b/internal/help/_SNDOPEN__1111111.txt deleted file mode 100644 index 4e9a2bcda..000000000 --- a/internal/help/_SNDOPEN__1111111.txt +++ /dev/null @@ -1,112 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:17}} -{{DISPLAYTITLE:_SNDOPEN}} -The [[_SNDOPEN]] function loads a sound file into memory and returns a [[LONG]] handle value above 0. - - -{{PageSyntax}} -: {{Parameter|soundHandle&}} = [[_SNDOPEN]]({{Parameter|fileName$}}) - - -{{PageDescription}} -* Returns a [[LONG]] {{Parameter|soundHandle&}} value to the sound file in memory. '''A zero value means the sound could not be loaded.''' -* The literal or variable [[STRING]] sound {{Parameter|fileName$}} can be '''WAV, OGG or MP3''' file types. -* '''Always check the handle value returned is greater than zero before attempting to play the sound.''' -* The handle can be used by most of the _SND sound playing functions and statements in QB64 except [[_SNDPLAYFILE]] which plays a sound file directly from the disk and does not use a handle value. -* Handles can be closed with [[_SNDCLOSE]] when the sound is no longer necessary. -* If a WAV sound file won't play, try it using the Windows [[Windows_Libraries#Play_WAV_Sounds|Play WAV sounds library]] to check it or convert the sound file to OGG. - - -{{PageExamples}} -''Snippet 1:'' Loading a sound file to use in the program later. Only load it once and use the handle any time you want. -{{CodeStart}} -h& = {{Cl|_SNDOPEN}}("dog.wav") -IF h& = 0 THEN BEEP ELSE {{Cl|_SNDPLAY}} h& 'check for valid handle before using! -{{CodeEnd}} - - -''Snippet 2:'' Playing a sound from 2 different speakers based on program results. -{{CodeStart}} -Laff& = {{Cl|_SNDOPEN}}("KONGlaff.ogg") 'load sound file and get LONG handle value -{{Cl|IF}} LaffX! < -1 {{Cl|THEN}} LaffX! = -1 'set full volume to left speaker -{{Cl|IF}} LaffX! > 1 {{Cl|THEN}} LaffX! = 1 'set full volume to right speaker - -{{Cl|_SNDBAL}} Laff&, LaffX! 'balance sound to left or right speaker -{{Cl|_SNDPLAY}} Laff& 'play sound -{{CodeEnd}} - - -''Example:'' Playing a file and controlling playback: -{{CodeStart}} -s& = {{Cl|_SNDOPEN}}("song.ogg") -{{Cl|PRINT}} "{{Cl|READ}}Y"; s& -{{Cl|_SNDPLAY}} s& -{{Cl|_SNDLOOP}} s& - - -xleft = -1 -xright = 1 -DO - k$ = {{Cl|INKEY$}} - {{Cl|SELECT CASE}} k$ - {{Cl|CASE}} "f" - xleft = xleft - 0.1 - {{Cl|_SNDBAL}} s&, xleft, , , 1 - {{Cl|CASE}} "g" - xleft = xleft + 0.1 - {{Cl|_SNDBAL}} s&, xleft, , , 1 - {{Cl|CASE}} "h" - xright = xright - 0.1 - {{Cl|_SNDBAL}} s&, xright, , , 2 - {{Cl|CASE}} "j" - xright = xright + 0.1 - {{Cl|_SNDBAL}} s&, xright, , , 2 - {{Cl|CASE}} "n" - volume = volume - 0.1 - {{Cl|_SNDVOL}} s&, volume - {{Cl|CASE}} "m" - volume = volume + 0.1 - {{Cl|_SNDVOL}} s&, volume - {{Cl|CASE}} "p" - {{Cl|_SNDPAUSE}} s& - {{Cl|CASE}} " " - {{Cl|_SNDPLAY}} s& - {{Cl|CASE}} "i" - {{Cl|PRINT}} {{Cl|_SNDPLAYING}}(s&) - {{Cl|PRINT}} {{Cl|_SNDPAUSED}}(s&) - {{Cl|SLEEP}} - {{Cl|CASE}} "b" - {{Cl|_SNDSETPOS}} s&, 110 - {{Cl|CASE}} "l" - {{Cl|_SNDLIMIT}} s&, 10 - {{Cl|PRINT}} "LIM" - {{Cl|SLEEP}} - {{Cl|CASE}} "k" - {{Cl|_SNDSTOP}} s& - {{Cl|CASE}} "c" - {{Cl|_SNDCLOSE}} s& - {{Cl|SLEEP}} - s2& = {{Cl|_SNDOPEN}}("song.ogg") - {{Cl|CASE}} "d" - s2& = {{Cl|_SNDCOPY}}(s&) - {{Cl|_SNDPLAY}} s2& - {{Cl|END SELECT}} - {{Cl|LOCATE}} 1, 1 - {{Cl|PRINT}} xleft, xright, volume, {{Cl|_SNDGETPOS}}(s&); " " -LOOP -{{CodeEnd}}{{small|Code by Johny B}} - - - -{{PageSeeAlso}} -* [[_SNDCLOSE]], [[_SNDPLAY]], [[_SNDSTOP]] -* [[_SNDPAUSE]], [[_SNDLOOP]], [[_SNDLIMIT]] -* [[_SNDSETPOS]], [[_SNDGETPOS]] -* [[_SNDPLAYING]], [[_SNDPAUSED]] -* [[_SNDCOPY]], [[_SNDPLAYCOPY]] -* [[_SNDBAL]], [[_SNDLEN]], [[_SNDVOL]] -* [[_SNDPLAYFILE]] {{text|(plays a named sound file directly and closes)}} -* [[_SNDRAW]], [[_SNDRATE]], [[_SNDRAWLEN]] {{text|(raw sounds without files)}} - - -{{PageNavigation}} diff --git a/internal/help/_SNDPAUSED__111111111.txt b/internal/help/_SNDPAUSED__111111111.txt deleted file mode 100644 index 627fccbc0..000000000 --- a/internal/help/_SNDPAUSED__111111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:20}} -{{DISPLAYTITLE:_SNDPAUSED}} -The [[_SNDPAUSED]] function checks if a sound is paused. Uses a handle parameter passed from [[_SNDOPEN]]. - - -{{PageSyntax}} -: {{Parameter|isPaused%%}} = [[_SNDPAUSED]]({{Parameter|handle&}}) - - -{{PageDescription}} -*Returns true (-1) if the sound is paused. False (0) if not paused. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|PRINT}} {{Cl|_SNDPAUSED}}(h&) -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDPAUSE]], [[_SNDPLAY]], -* [[_SNDSTOP]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDPAUSE__11111111.txt b/internal/help/_SNDPAUSE__11111111.txt deleted file mode 100644 index a9f5c1c27..000000000 --- a/internal/help/_SNDPAUSE__11111111.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:19}} -{{DISPLAYTITLE:_SNDPAUSE}} -The [[_SNDPAUSE]] statement pauses a sound using a handle from the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: [[_SNDPAUSE]] {{Parameter|handle&}} - - -{{PageDescription}} -* Continue playing by calling [[_SNDPLAY]] {{Parameter|handle&}} -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"PAUSE" capability]] to use this function. - - -{{PageSeeAlso}} -* [[_SNDPLAY]], [[_SNDSTOP]] -* [[_SNDPAUSED]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDPLAYCOPY__11111111111.txt b/internal/help/_SNDPLAYCOPY__11111111111.txt deleted file mode 100644 index 8da662f25..000000000 --- a/internal/help/_SNDPLAYCOPY__11111111111.txt +++ /dev/null @@ -1,46 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:22}} -{{DISPLAYTITLE:_SNDPLAYCOPY}} -The [[_SNDPLAYCOPY]] statement copies a sound, plays it, and automatically closes the copy using a handle parameter passed from [[_SNDOPEN]] or [[_SNDCOPY]] - - -{{PageSyntax}} -: [[_SNDPLAYCOPY]] {{Parameter|handle&}}[, {{Parameter|volume!}}] - - -{{Parameters}} -* The [[LONG]] {{Parameter|handle&}} value is returned by [[_SNDOPEN]] using a specific sound file. -* The {{Parameter|volume!}} parameter can be any [[SINGLE]] value from 0 (no volume) to 1 (full volume). - - -{{PageDescription}} -*Makes coding easier by doing all of the following automatically: -:#Copies/duplicates the source handle (see [[_SNDCOPY]]). -:#Changes the volume of the copy if volume is passed. -:#Plays the copy. -:#Closes the copy. -* This statement is a better choice than [[_SNDPLAYFILE]] if the sound will be played often, reducing the burden on the computer. - - -{{PageExamples}} -''Example 1:'' Playing a previously opened sound at half volume. -{{CodeStart}} -{{Cl|_SNDPLAYCOPY}} applause&, 0.5 -{{CodeEnd}} - - -''Example 2:'' Playing a song at random volumes. -{{CodeStart}} -chomp& = _SNDOPEN("chomp.wav") -_SNDPLAYCOPY chomp&, 0.5 + RND * 0.49 -{{CodeEnd}} - - - -{{PageSeeAlso}} -* [[_SNDOPEN]] -* [[_SNDCOPY]] -* [[_SNDPLAYFILE]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDPLAYFILE__11111111111.txt b/internal/help/_SNDPLAYFILE__11111111111.txt deleted file mode 100644 index 919382879..000000000 --- a/internal/help/_SNDPLAYFILE__11111111111.txt +++ /dev/null @@ -1,35 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:23}} -{{DISPLAYTITLE:_SNDPLAYFILE}} -The [[_SNDPLAYFILE]] statement is used to play a sound file without generating a handle, automatically closing it after playback finishes. - - -{{PageSyntax}} -:[[_SNDPLAYFILE]] {{Parameter|filename$}}[, {{Parameter|ignored%}}][, {{Parameter|volume!}}] - - -{{PageDescription}} -* Supported file formats are '''WAV, OGG and MP3'''. See [[_SNDOPEN]]. -* {{Parameter|ignored%}} is an optional parameter , accepted for historical reasons. -** In versions prior to '''build 20170811/60''', {{Parameter|ignored%}} identified if a sound was to be loaded with [[_SNDOPEN|"SYNC" capabilities]], (-1 for true, 0 for false). This is true for all sound files in the latest versions, making this parameter safe to be ignored. -* {{Parameter|volume!}} is a [[SINGLE]] value from 0 (silence) to 1 (full volume). If not used or outside this range, the sound will be played at full volume. -* [[_SNDPLAYFILE]] never creates an error. If the sound cannot be played it takes no further action. -* The sound is closed automatically after it finishes playing. -* When a sound will be used often, open the file with [[_SNDOPEN]] and use [[_SNDPLAYCOPY]] to play the handle instead to reduce the burden on the computer. - - -{{PageExamples}} -''Example:'' Playing a sound file at half volume. -{{CodeStart}} -{{Cl|_SNDPLAYFILE}} "dog.wav", , .5 -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDOPEN]], [[_SNDPLAY]] -* [[_SNDPLAYCOPY]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDPLAYING__1111111111.txt b/internal/help/_SNDPLAYING__1111111111.txt deleted file mode 100644 index 3872bd5e7..000000000 --- a/internal/help/_SNDPLAYING__1111111111.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:25}} -{{DISPLAYTITLE:_SNDPLAYING}} -The [[_SNDPLAYING]] function returns whether a sound is being played. Uses a handle from the [[_SNDOPEN]] or [[_SNDCOPY]] functions. - - -{{PageSyntax}} -:{{Parameter|isPlaying%}} = [[_SNDPLAYING]]({{Parameter|handle&}}) - - -{{PageDescription}} -*Returns false (0) if a sound is not playing or true (-1) if it is. -*If a sound is paused, [[_SNDPLAYING]] returns 0. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|PRINT}} {{Cl|_SNDPLAYING}}(h&) -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDPLAY]], [[_SNDPAUSE]], [[_SNDSTOP]] -* [[_SNDPAUSED]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDPLAY__1111111.txt b/internal/help/_SNDPLAY__1111111.txt deleted file mode 100644 index 4cfcd6835..000000000 --- a/internal/help/_SNDPLAY__1111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:21}} -{{DISPLAYTITLE:_SNDPLAY}} -The [[_SNDPLAY]] statement plays a sound designated by a file handle created by [[_SNDOPEN]]. - - -{{PageSyntax}} -: [[_SNDPLAY]] {{Parameter|handle&}} - - -{{PageDescription}} -* Make sure that the {{Parameter|handle&}} value is not 0 before attempting to play it. - - -{{PageExamples}} -''Example:'' Checking a handle value before playing -{{CodeStart}} - {{Cl|IF...THEN|IF}} h& {{Cl|THEN}} {{Cl|_SNDPLAY}} h& -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDOPEN]], [[_SNDPAUSE]], [[_SNDPLAYING]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDRATE__1111111.txt b/internal/help/_SNDRATE__1111111.txt deleted file mode 100644 index 5fa70152a..000000000 --- a/internal/help/_SNDRATE__1111111.txt +++ /dev/null @@ -1,27 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:26}} -{{DISPLAYTITLE:_SNDRATE}} -The [[_SNDRATE]] function returns the sample rate frequency per second of the current computer's sound card. - - -{{PageSyntax}} -: {{Parameter|sampleRate&}} = [[_SNDRATE]] - - -{{PageDescription}} -* The sample rate frequency per second value returned can be any [[LONG]] value. Common values are 22050 or 44100. -* '''The sound card sample rate is determined by the sound card and it cannot be changed.''' - - -{{PageExamples}} -* See the example in [[_SNDRAW]]. - - -{{PageSeeAlso}} -* [[_SNDRAW]] -* [[_SNDRAWLEN]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDRAWDONE__1111111111.txt b/internal/help/_SNDRAWDONE__1111111111.txt deleted file mode 100644 index 912924848..000000000 --- a/internal/help/_SNDRAWDONE__1111111111.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:28}} -{{DISPLAYTITLE:_SNDRAWDONE}} -[[_SNDRAWDONE]] ensures that the final buffer portion is played in short sound effects even if it is incomplete. - - -{{PageSyntax}} -: [[_SNDRAWDONE]] [{{Parameter|pipeHandle&}}] - - -{{PageParameters}} -* The optional {{Parameter|pipeHandle&}} parameter refers to the sound pipe opened using [[_SNDOPENRAW]]. - - -{{PageDescription}} -* Use to force playing small buffers of [[_SNDRAW]] data. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[_SNDOPENRAW]] -* [[_SNDRAW]] -* [[_SNDRAWLEN]] -* [[_SNDRATE]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDRAWLEN__111111111.txt b/internal/help/_SNDRAWLEN__111111111.txt deleted file mode 100644 index 917ba8593..000000000 --- a/internal/help/_SNDRAWLEN__111111111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:29}} -{{DISPLAYTITLE:_SNDRAWLEN}} -The [[_SNDRAWLEN]] function returns the length, in seconds, of a [[_SNDRAW]] sound currently queued. - - -{{PageSyntax}} -: {{Parameter|length#}} = [[_SNDRAWLEN]] [{{Parameter|pipeHandle&}}] - - -{{PageParameters}} -* The optional {{Parameter|pipeHandle&}} parameter refers to the sound pipe opened using [[_SNDOPENRAW]]. - - -{{PageDescription}} -* Use [[_SNDRAWLEN]] to determine the length of a sound queue during creation and when to stop playing the sound. -* Ensure that [[_SNDRAWLEN]] is comfortably above 0 (until you've actually finished playing sound). -* If you are getting occasional random clicks, this generally means that [[_SNDRAWLEN]] has dropped to 0. -* The [[_SNDRATE]] determines how many samples are played per second. However, the timing is achieved by the sound card and [[_SNDRAWLEN]], not your program. -* '''Do not attempt to use [[_TIMER]] or [[_DELAY]] or [[_LIMIT]] to control the timing of [[_SNDRAW]] sounds. You may use them as usual for delays or to limit your program's CPU usage, but the decision of how much sound to queue should only be based on the remaining _SNDRAWLEN'''. - - -{{PageExamples}} -* See the example in [[_SNDRAW]] - - -{{PageSeeAlso}} -* [[_SNDRAW]] -* [[_SNDRATE]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDRAW__111111.txt b/internal/help/_SNDRAW__111111.txt deleted file mode 100644 index 290709388..000000000 --- a/internal/help/_SNDRAW__111111.txt +++ /dev/null @@ -1,116 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:27}} -{{DISPLAYTITLE:_SNDRAW}} -The [[_SNDRAW]] statement plays sound wave sample frequencies created by a program. - - -{{PageSyntax}} -: [[_SNDRAW]] {{Parameter|leftSample}}[, {{Parameter|rightSample}}][, {{Parameter|pipeHandle&}}] - - -{{Parameters}} -* The {{Parameter|leftSample}} and {{Parameter|rightSample}} value(s) can be any [[SINGLE]] or [[DOUBLE]] literal or variable frequency value from -1.0 to 1.0. -* The {{Parameter|pipeHandle&}} parameter refers to the sound pipe opened using [[_SNDOPENRAW]]. - - -{{PageDescription}} -* Specifying {{Parameter|pipeHandle&}} allows sound to be played through two or more channels at the same time ('''version 1.000 and up'''). -* If only {{Parameter|leftSample}} value is used, the sound will come out of both speakers. -* Using _SNDRAW will pause any currently playing music. -* _SNDRAW is designed for continuous play. It will not produce any sound until a significant number of samples have been queued. No sound is played if only a few samples are queued. -* Ensure that [[_SNDRAWLEN]] is comfortably above 0 (until you've actually finished playing sound). If you are getting occasional unintended random clicks, this generally means that [[_SNDRAWLEN]] has dropped to 0. -* _SNDRAW is not intended to queue up many minutes worth of sound. It will probably work but will chew up a lot of memory (and if it gets swapped to disk, your sound could be interrupted abruptly). -* [[_SNDRATE]] determines how many samples are played per second, but timing is done by the sound card, not your program. -* '''Do not attempt to use [[_TIMER]] or [[_DELAY]] or [[_LIMIT]] to control the timing of _SNDRAW. You may use them for delays or to limit your program's CPU usage, but how much to queue should only be based on the [[_SNDRAWLEN]].''' - - -{{PageExamples}} -''Example 1:'' Sound using a sine wave with _SNDRAW Amplitude * SIN(8 * ATN(1) * Duration * (Frequency / _SNDRATE)) -{{CodeStart}} -FREQ = 400 'any frequency desired from 36 to 10,000 -Pi2 = 8 * {{Cl|ATN}}(1) '2 * pi -Amplitude = .3 'amplitude of the signal from -1.0 to 1.0 -SampleRate = {{Cl|_SNDRATE}} 'sets the sample rate -FRate = FREQ / SampleRate' -{{Cl|FOR...NEXT|FOR}} Duration = 0 {{Cl|TO}} 5 * SampleRate 'play 5 seconds - {{Cl|_SNDRAW}} Amplitude * {{Cl|SIN}}(Pi2 * Duration * FRate) 'sine wave - '{{Cl|_SNDRAW}} Amplitude * {{Cl|SGN}}({{Cl|SIN}}(Pi2 * Duration * FRate)) 'square wave -{{Cl|NEXT}} -{{Cl|DO}}: LOOP {{Cl|WHILE}} {{Cl|_SNDRAWLEN}} -{{Cl|END}} -{{CodeEnd}} -{{small|Code by DarthWho}} -:''Explanation:'' The loop Duration is determined by the number of seconds times the [[_SNDRATE]] number of samples per second. Square waves can use the same formula with Amplitude * [[SGN]](SIN(8 * ATN(1) * Duration * (Frequency/_SNDRATE))). - - -''Example 2:'' A simple ringing bell tone that tapers off. -{{CodeStart}}t = 0 -tmp$ = "Sample = ##.##### Time = ##.#####" -LOCATE 1, 60: PRINT "Rate:"; {{Cl|_SNDRATE}} -DO - 'queue some sound - DO WHILE {{Cl|_SNDRAWLEN}} < 0.1 'you may wish to adjust this - sample = {{Cl|SIN}}(t * 440 * {{Cl|ATN}}(1) * 8) '440Hz sine wave (t * 440 * 2π) - sample = sample * {{Cl|EXP}}(-t * 3) 'fade out eliminates clicks after sound - {{Cl|_SNDRAW}} sample - t = t + 1 / {{Cl|_SNDRATE}} 'sound card sample frequency determines time - LOOP - - 'do other stuff, but it may interrupt sound - LOCATE 1, 1: PRINT USING tmp$; sample; t -LOOP WHILE t < 3.0 'play for 3 seconds - -DO WHILE {{Cl|_SNDRAWLEN}} > 0 'Finish any left over queued sound! -LOOP -{{Cl|END}} -{{CodeEnd}} -{{small|Code by Artelius (responsible for the implementation of _SNDRAW)}} - - -''Example 3:'' Routine uses _SNDRAW to display and play 12 notes from octaves 1 through 9. -{{CodeStart}} -{{Cl|DIM}} {{Cl|SHARED}} rate& -rate& = {{Cl|_SNDRATE}} -DO - {{Cl|PRINT}} "Enter the octave 1 to 8 (0 quits!):"; - oct% = {{Cl|VAL}}({{Cl|INPUT$}}(1)): {{Cl|PRINT}} oct% - {{Cl|IF...THEN|IF}} oct% = 0 {{Cl|THEN}} {{Cl|EXIT DO}} - octave = oct% - 4 '440 is in the 4th octave, 9th note - {{Cl|COLOR}} oct% + 1 - {{Cl|PRINT USING}} "Octave: ##"; oct% - {{Cl|FOR...NEXT|FOR}} Note = 0 {{Cl|TO}} 11 'notes C to B - fq = FreQ(octave, Note, note$) - {{Cl|PRINT USING}} "#####.## \\"; fq, note$ - PlaySound fq - {{Cl|IF...THEN|IF}} {{Cl|INKEY$}} > "" {{Cl|THEN}} {{Cl|EXIT DO}} - {{Cl|NEXT}} -{{Cl|LOOP}} -{{Cl|END}} - -{{Cl|FUNCTION}} FreQ (octave, note, note$) -FreQ = 440 * 2 ^ (octave + (note + 3) / 12 - 1) '* 12 note octave starts at C (3 notes up) -note$ = {{Cl|MID$}}("C C#D D#E F F#G G#A A#B ", note * 2 + 1, 2) -{{Cl|END FUNCTION}} - -{{Cl|SUB}} PlaySound (frq!) ' plays sine wave fading in and out -SndLoop! = 0 -{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} SndLoop! < rate& - {{Cl|_SNDRAW}} {{Cl|SIN}}((2 * 4 * {{Cl|ATN}}(1) * SndLoop! / rate&) * frq!) * {{Cl|EXP}}(-(SndLoop! / rate&) * 3) - SndLoop! = SndLoop! + 1 -{{Cl|LOOP}} -{{Cl|DO}}: {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|_SNDRAWLEN}} 'flush the sound playing buffer -{{Cl|END SUB}} -{{CodeEnd}} -{{small|Code by CodeGuy}} - - -{{PageSeeAlso}} -* [[_SNDRATE]], [[_SNDRAWLEN]] -* [[_SNDOPENRAW]], [[_SNDRAWDONE]] -* [[_SNDOPEN]] -* [[PLAY]], [[BEEP]] -* Music Frequency table in [[SOUND]]. -* [[DTMF Phone Demo]] - - -{{PageNavigation}} diff --git a/internal/help/_SNDSETPOS__111111111.txt b/internal/help/_SNDSETPOS__111111111.txt deleted file mode 100644 index beba38cfa..000000000 --- a/internal/help/_SNDSETPOS__111111111.txt +++ /dev/null @@ -1,37 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:30}} -{{DISPLAYTITLE:_SNDSETPOS}} -The [[_SNDSETPOS]] statement changes the current/starting playing position in seconds of a sound. - - -{{PageSyntax}} -: [[_SNDSETPOS]] {{Parameter|handle&}}, {{Parameter|position!}} - - -{{PageDescription}} -*Changes the current/starting playing position in seconds (a [[SINGLE]] value) of a sound in memory. -*If {{Parameter|position!}} is past the length of the sound, playback will be interrupted. -*Function cannot be called while a looping sound is being played (see [[_SNDLOOP]]). -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"SETPOS" capability]] to use this statement. - - -{{PageExamples}} -''Example:'' To check the current playing position in an MP3 file, use [[_SNDPLAY]] with [[_SNDGETPOS]] printed in a loop -{{CodeStart}} -SoundFile& = {{Cl|_SNDOPEN}}("YourSoundFile.mp3") '<<< your MP3 sound file here! -{{Cl|_SNDSETPOS}} SoundFile&, 5.5 'set to play sound 5 1/2 seconds into music -{{Cl|_SNDPLAY}} SoundFile& 'play sound -Do: {{Cl|_LIMIT}} 60 - LOCATE 5, 2: PRINT "Current play position> "; {{Cl|_SNDGETPOS}}(SoundFile&) -LOOP UNTIL {{Cl|_KEYDOWN}}(27) OR {{Cl|NOT}} {{Cl|_SNDPLAYING}}(SoundFile&) 'ESC or end of sound exit -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDGETPOS]], [[_SNDLEN]] -* [[_SNDOPEN]], [[_SNDLIMIT]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDSTOP__1111111.txt b/internal/help/_SNDSTOP__1111111.txt deleted file mode 100644 index 478f9de34..000000000 --- a/internal/help/_SNDSTOP__1111111.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:31}} -{{DISPLAYTITLE:_SNDSTOP}} -The [[_SNDSTOP]] statement stops a playing or paused sound using a handle from the [[_SNDOPEN]] or [[_SNDCOPY]] functions. - - -{{PageSyntax}} -: [[_SNDSTOP]] {{Parameter|handle&}} - - -{{PageDescription}} -* Sounds can be resumed using [[_SNDPLAY]] with the correct handle. - - -{{PageExamples}} -''Example:'' -{{CodeStart}} -{{Cl|_SNDSTOP}} h& -{{CodeEnd}} - - -{{PageSeeAlso}} -* [[_SNDPAUSE]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SNDVOL__111111.txt b/internal/help/_SNDVOL__111111.txt deleted file mode 100644 index b5a37f908..000000000 --- a/internal/help/_SNDVOL__111111.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:33}} -{{DISPLAYTITLE:_SNDVOL}} -The [[_SNDVOL]] statement sets the volume of a sound loaded in memory using a handle from the [[_SNDOPEN]] function. - - -{{PageSyntax}} -: [[_SNDVOL]] {{Parameter|handle&}}, {{Parameter|volume!}} - - -{{PageDescription}} -* {{Parameter|volume!}} is a value from 0 (silence) to 1 (full volume). -* In versions '''prior to build 20170811/60''', the sound identified by {{Parameter|handle&}} must have been opened using the [[_SNDOPEN|"VOL" capability]] to use this function. - - -{{PageExamples}} -{{CodeStart}} -h& = {{Cl|_SNDOPEN}}("bell.wav") -{{Cl|_SNDVOL}} h&, 0.5 -{{Cl|_SNDPLAY}} h& -{{CodeEnd}} - - -{{PageSeeAlso}} -*[[_SNDOPEN]], [[_SNDBAL]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SOURCE_(function)__111111_(00000000).txt b/internal/help/_SOURCE_(function)__111111_(00000000).txt deleted file mode 100644 index ea8b9d051..000000000 --- a/internal/help/_SOURCE_(function)__111111_(00000000).txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:35}} -{{DISPLAYTITLE:_SOURCE (function)}} -The [[_SOURCE (function)|_SOURCE]] function returns the present image source handle value. - - -{{PageSyntax}} -: {{Parameter|currentSource&}} = [[_SOURCE (function)|_SOURCE]] - - -{{PageDescription}} -* Returns a handle value that is a [[LONG]] integer type. -* Save the source handle to a [[LONG]] variable for later restoration using the [[_SOURCE]] statement. - - -{{PageExamples}} -See the examples in: -* [[Bitmaps]] -* [[SAVEIMAGE]] -* [[SaveIcon32]] - - -{{PageSeeAlso}} -* [[_DEST (function)]] -* [[_SOURCE]], [[_DEST]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_SOURCE__111111.txt b/internal/help/_SOURCE__111111.txt deleted file mode 100644 index 36e9e5cba..000000000 --- a/internal/help/_SOURCE__111111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:34}} -{{DISPLAYTITLE:_SOURCE}} -The [[_SOURCE]] statement establishes the image SOURCE using a handle created by [[_LOADIMAGE]], [[_NEWIMAGE]] or [[_COPYIMAGE]]. - - -{{PageSyntax}} -: [[_SOURCE]] {{Parameter|handle&}} - - -{{PageDescription}} -* The handle is a [[LONG]] integer value from the [[_SOURCE (function)|_SOURCE]] function or a handle created by [[_NEWIMAGE]]. -* If the handle is designated as 0, it refers to the current [[SCREEN]] image. -* A source image can only supply information to a program. [[POINT]] and [[GET (graphics statement)|GET]] might require a source other than the one currently active. - - -{{PageExamples}} -{{CodeStart}} -{{Cl|SCREEN}} 13 -a = {{Cl|_NEWIMAGE}}(320,200,13) -{{Cl|_DEST}} a -{{Cl|PSET}} (100, 100), 15 -{{Cl|_SOURCE}} a -{{Cl|_DEST}} 0 -{{Cl|PRINT}} {{Cl|POINT}}(100, 100) -{{CodeEnd}} -{{OutputStart}} - 15 -{{OutputEnd}} -: ''Explanation:'' Create a new image with handle 'a', then use [[_DEST]] to define the image to draw on. Draw a pixel then set the source to 'a' and use [[POINT]] to show what color is in that position. White (15) and is the color set with [[PSET]]. Use [[_DEST]] 0 for the screen to display the results. - - -===More examples=== -See the examples in: -* [[Bitmaps]] -* [[SAVEIMAGE]] -* [[SaveIcon32]] - - -{{PageSeeAlso}} -* [[_DEST]] -* [[_SOURCE (function)]] -* [[POINT]], [[GET (graphics statement)]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_STARTDIR$__11111111$.txt b/internal/help/_STARTDIR$__11111111$.txt deleted file mode 100644 index 2627c2a6b..000000000 --- a/internal/help/_STARTDIR$__11111111$.txt +++ /dev/null @@ -1,36 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:36}} -{{DISPLAYTITLE:_STARTDIR$}} -The [[_STARTDIR$]] function returns the path a user called a QB64 program from. - -{{PageSyntax}} -: {{Parameter|callPath$}} = [[_STARTDIR$]] - - -{{PageDescription}} -* Returns a [[STRING]] representing the user's program calling path. - - -{{PageAvailability}} -* '''QB64 1.0 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -''Example:'' Showcasing QB64 path functions: -{{CodeStart}} -{{Cl|$CONSOLE}}:ONLY -{{Cl|_DEST}} {{Cl|_CONSOLE}} -{{Cl|SHELL}} "cd" -{{Cl|PRINT}} {{Cl|_CWD$}} -{{Cl|PRINT}} {{Cl|_STARTDIR$}} -{{Cl|SYSTEM}} -{{CodeEnd}}{{small|Code by Galleon}} - - -{{PageSeeAlso}} -* [[_CWD$]] -* [[SHELL]] - - -{{PageNavigation}} diff --git a/internal/help/_STRCMP__111111.txt b/internal/help/_STRCMP__111111.txt deleted file mode 100644 index e2964ef81..000000000 --- a/internal/help/_STRCMP__111111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:37}} -{{DISPLAYTITLE:_STRCMP}} - -The [[_STRCMP]] function compares the relationship between two strings, comparing upper or lower case. - - -{{PageSyntax}} -: {{Parameter|comparison%}} = [[_STRCMP]]({{Parameter|string1$}}, {{Parameter|string2$}}) - - -{{PageDescription}} -* Function returns -1 when {{Parameter|string1$}} is less than {{Parameter|string2$}}, 0 when equal or 1 when {{Parameter|string1$}} is greater than {{Parameter|string2$}}. -* Upper case letters are valued less than lower case letters in the [[ASCII]] evaluation. - - -{{PageSeeAlso}} -* [[_STRICMP]] -* [[STR$]] -* [[STRING]] -* [[ASCII]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_STRICMP__1111111.txt b/internal/help/_STRICMP__1111111.txt deleted file mode 100644 index d6ef7c585..000000000 --- a/internal/help/_STRICMP__1111111.txt +++ /dev/null @@ -1,26 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:38}} -{{DISPLAYTITLE:_STRICMP}} - -The [[_STRICMP]] function compares the relationship between two strings, ignoring upper or lower case letters. - - -{{PageSyntax}} -: {{Parameter|comparison%}} = [[_STRICMP]]({{Parameter|string1$}}, {{Parameter|string2$}}) - - -{{PageDescription}} -* Function returns -1 when {{Parameter|string1$}} is less than {{Parameter|string2$}}, 0 when equal or 1 when {{Parameter|string1$}} is greater than {{Parameter|string2$}}. -* Alphabet comparisons will be evaluated without regard to the letter case in the 2 strings. - - -{{PageSeeAlso}} -* [[_STRCMP]] -* [[STR$]] -* [[STRING]] -* [[ASCII]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_TITLE$__11111$.txt b/internal/help/_TITLE$__11111$.txt deleted file mode 100644 index b61e7f585..000000000 --- a/internal/help/_TITLE$__11111$.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:40}} -{{DISPLAYTITLE:_TITLE$}} -The [[_TITLE$]] function returns the program title last set by the [[_TITLE]] statement. - - -{{PageSyntax}} -: {{Parameter|currentTitle$}} = [[_TITLE$]] - - -{{PageDescription}} -* If no title has been set, the title bar will say "Untitled" and this function will return an empty [[STRING|string]] (""). - - -{{PageAvailability}} -* '''QB64 1.2 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageSeeAlso}} -* [[_TITLE]] -* [[_CONSOLETITLE]] - - -{{PageNavigation}} diff --git a/internal/help/_TITLE__11111.txt b/internal/help/_TITLE__11111.txt deleted file mode 100644 index 283eb7dd8..000000000 --- a/internal/help/_TITLE__11111.txt +++ /dev/null @@ -1,73 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:39}} -{{DISPLAYTITLE:_TITLE}} -The [[_TITLE]] statement provides the program name in the title bar of the program window. - - -{{PageSyntax}} -: [[_TITLE]] {{Parameter|text$}} - - -{{Parameters}} -* {{Parameter|text$}} can be any literal or variable [[STRING]] or [[ASCII]] character value. - - -{{PageDescription}} -* The title can be changed anywhere in a program procedure. -* The title bar will say "Untitled" if a title is not set. -* Change the title of the [[$CONSOLE]] windows created using [[_CONSOLETITLE]] -* '''Note: A [[_DELAY|delay]] may be required before the title can be set.''' See [[_SCREENEXISTS]]. - - -{{PageExamples}} -''Example 1:'' How to create the window title bar. -{{CodeStart}} -{{Cl|_TITLE}} "My New Program" -{{CodeEnd}} - - -''Example 2:'' How to find the currently running program module name and current path using a Windows API Library. -{{CodeStart}} -{{Cl|_TITLE}} "My program" -{{Cl|_DELAY}} 5 '5 second delay - -{{Cl|_TITLE}} {{Cl|MID$}}(TITLE$, 1, {{Cl|INSTR}}(TITLE$, ".") - 1) - -{{Cl|PRINT}} PATH$ - - -{{Cl|FUNCTION}} TITLE$ '=== SHOW CURRENT PROGRAM -{{Cl|SHARED}} PATH$ -{{Cl|DECLARE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav - {{Cl|FUNCTION}} GetModuleFileNameA ({{Cl|BYVAL}} Module {{Cl|AS}} {{Cl|LONG}}, FileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -FileName$ = {{Cl|SPACE$}}(256) -Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) -{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} - PATH$ = {{Cl|LEFT$}}(FileName$, Result) - start = 1 - DO - posit = {{Cl|INSTR}}(start, PATH$, "\") - {{Cl|IF...THEN|IF}} posit {{Cl|THEN}} last = posit - start = posit + 1 - {{Cl|LOOP}} {{Cl|UNTIL}} posit = 0 - TITLE$ = {{Cl|MID$}}(PATH$, last + 1) - PATH$ = {{Cl|LEFT$}}(PATH$, last) -{{Cl|ELSE}} TITLE$ = "": PATH$ = "" -{{Cl|END IF}} -{{Cl|END FUNCTION}} -{{CodeEnd}} -: ''Note:'' The actual module file name is returned. Not necessarily the Title value. The value returned can be used however. - - -{{PageSeeAlso}} -* [[_TITLE$]] (function) -* [[_ICON]] -* [[_DELAY]] -* [[ASCII]] -* [[_CONSOLETITLE]] -* [[_SCREENEXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_TOGGLEBIT__111111111.txt b/internal/help/_TOGGLEBIT__111111111.txt deleted file mode 100644 index 60e329c80..000000000 --- a/internal/help/_TOGGLEBIT__111111111.txt +++ /dev/null @@ -1,48 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:42}} -{{DISPLAYTITLE:_TOGGLEBIT}} -The [[_TOGGLEBIT]] function is used to toggle a specified bit of a numerical value. - - -{{PageSyntax}} -:{{Parameter|result}} = [[_TOGGLEBIT]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}}) - - -{{Parameters}} -* {{Parameter|numericalVariable}} is the variable to toggle the bit of and can be of the following types: [[_BYTE]], [[INTEGER]], [[LONG]], or [[_INTEGER64]]. -* Integer values can be signed or [[_UNSIGNED]]. -* {{Parameter|numericalValue}} the number of the bit to be set. - - -{{PageDescription}} -* Can be used to manually manipulate individual bits of an integer value by toggling their state. -* A bit set to 1 is changed to 0 and a bit set to 0 is changed to 1. -* Bits start at 0 (so a [[_BYTE]] has bits 0 to 7, [[INTEGER]] 0 to 15, and so on) - -==Availability== -* '''Version 1.4 and up'''. - - -{{PageExamples}} -''Example 1:'' -{{CodeStart}}A~%% = 0 '{{Cl|_UNSIGNED}} {{Cl|_BYTE}} -{{Cl|PRINT}} A~%% -A~%% = {{Cl|_TOGGLEBIT}}(A~%%,4) 'toggle the fourth bit of A~%% -{{Cl|PRINT}} A~%% -A~%% = {{Cl|_TOGGLEBIT}}(A~%%,4) 'toggle the fourth bit of A~%% -{{Cl|PRINT}} A~%% -{{CodeEnd}} -{{OutputStart}} - 0 - 16 - 0 -{{OutputEnd}} - - - -{{PageSeeAlso}} -* [[_SHL]], [[_SHR]], [[INTEGER]], [[LONG]] -* [[_SETBIT]], [[_BYTE]], [[_INTEGER64]] -* [[_RESETBIT]], [[_READBIT]] - -{{PageNavigation}} diff --git a/internal/help/_TOTALDROPPEDFILES__11111111111111111.txt b/internal/help/_TOTALDROPPEDFILES__11111111111111111.txt deleted file mode 100644 index eb4271281..000000000 --- a/internal/help/_TOTALDROPPEDFILES__11111111111111111.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:43}} -{{DISPLAYTITLE:_TOTALDROPPEDFILES}} -The [[_TOTALDROPPEDFILES]] function returns the number of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled. - - -{{PageSyntax}} -: {{Parameter|totalFilesReceived&}} = [[_TOTALDROPPEDFILES]] - - -{{PageDescription}} -* After [[_ACCEPTFILEDROP]] is enabled, [[_TOTALDROPPEDFILES]] will return 0 until the user drops files or folders into the program's window. -* When using [[_DROPPEDFILE]] to read the list sequentially, [[_TOTALDROPPEDFILES]] will be reset to 0 after the last item is retrieved (after [[_DROPPEDFILE]] returns an empty string ""). -* If using [[_DROPPEDFILE]] with an index, you must call [[_FINISHDROP]] after you finish working with the list. -* When using [[_DROPPEDFILE]] to read the list with an index, [[_TOTALDROPPEDFILES]] will '''not''' be reset (and the list of items won't be cleared) until [[_FINISHDROP]] is called. -* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''. - - -{{PageAvailability}} -* '''QB64 1.3 and up''' (QB64 Team) -* '''QBPE 0.5 and up''' (QB64 Phoenix Edition) - - -{{PageExamples}} -* See example for [[_ACCEPTFILEDROP]] - -{{PageSeeAlso}} -* [[_ACCEPTFILEDROP]], [[_DROPPEDFILE]], [[_FINISHDROP]] -* [[_FILEEXISTS]], [[_DIREXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_TRIM$__1111$.txt b/internal/help/_TRIM$__1111$.txt deleted file mode 100644 index e314b737f..000000000 --- a/internal/help/_TRIM$__1111$.txt +++ /dev/null @@ -1,42 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:44}} -{{DISPLAYTITLE:_TRIM$}} -The [[_TRIM$]] function removes both leading and trailing space characters from a [[STRING]] value. - - -{{PageSyntax}} -:{{Parameter|return$}} = [[_TRIM$]]({{Parameter|text$}}) - - -{{PageDescription}} -* Shorthand to using [[LTRIM$]]([[RTRIM$]]("text")) -* {{Parameter|text$}} is the [[STRING]] value to trim. -* If {{Parameter|text$}} contains no leading or trailing space characters, it is returned unchanged. -* Convert fixed length [[STRING]] values by using a different {{parameter|return$}} variable. - - -{{PageExamples}} -''Example: Demonstrating how _TRIM$(text$) can replace LTRIM$(RTRIM$(text$)): -{{CodeStart}} -text$ = {{Cl|SPACE$}}(10) + "some text" + {{Cl|SPACE$}}(10) -{{Cl|PRINT}} "[" + text$ + "]" -{{Cl|PRINT}} "[" + {{Cl|RTRIM$}}(text$) + "]" -{{Cl|PRINT}} "[" + {{Cl|LTRIM$}}(text$) + "]" -{{Cl|PRINT}} "[" + {{Cl|LTRIM$}}({{Cl|RTRIM$}}(text$)) + "]" -{{Cl|PRINT}} "[" + {{Cl|_TRIM$}}(text$) + "]" -{{CodeEnd}} -{{OutputStart}}[ some text ] -[ some text] -[some text ] -[some text] -[some text] -{{OutputEnd}} - - -{{PageSeeAlso}} -* [[RTRIM$]], [[LTRIM$]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_UNSIGNED__11111111.txt b/internal/help/_UNSIGNED__11111111.txt deleted file mode 100644 index bb41dab5b..000000000 --- a/internal/help/_UNSIGNED__11111111.txt +++ /dev/null @@ -1,91 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:45}} -{{DISPLAYTITLE:_UNSIGNED}} -[[_UNSIGNED]] defines a numerical value as being only positive. - - -{{PageSyntax}} -: [[DIM]] {{Parameter|variable}} [[AS]] [{{KW|_UNSIGNED}}] {{Parameter|datatype}} - -: [[_DEFINE]] {{Parameter|letterRange}} [[AS]] [{{KW|_UNSIGNED}}] {{Parameter|datatype}} - - -{{PageDescription}} -* Datatype can be any of the following: [[INTEGER]], [[LONG]], [[_BIT]], [[_BYTE]], [[_INTEGER64]], [[_OFFSET]] -*'''[[SINGLE]], [[DOUBLE]] and [[_FLOAT]] variable types cannot be _UNSIGNED.''' -* [[_UNSIGNED]] can be used in a [[_DEFINE]] statement to set undefined variable name first letters as all positive-only values. -* Can also be used in [[DIM]] statements or subprocedure parameter definitions following [[AS]]. -* [[_UNSIGNED]] allows larger positive numerical variable value limits than signed ones. -* The unsigned variable type suffix used is the '''tilde (~)''', right before the number's own type suffix: {{Parameter|variableName~&}} - - -
How negative values affect the [[_UNSIGNED]] value returned by a [[_BYTE]] (8 bits).
-{{WhiteStart}} - 00000001 - unsigned & signed are both 1 - 01111111 - unsigned & signed are both 127 - 11111111 - unsigned is 255 but signed is -1 - 11111110 - unsigned is 254 but signed is -2 - 11111101 - unsigned is 253 but signed is -3 -{{WhiteEnd}} - - -{{PageExamples}} -''Example 1:'' In '''QB64''', when a signed [[INTEGER]] value exceeds 32767, the value may become a negative value: -{{CodeStart}} -i% = 38000 -{{Cl|PRINT}} i% -{{CodeEnd}}{{OutputStart}}-27536 -{{OutputEnd}} -:''Explanation:'' Use an [[_UNSIGNED]] [[INTEGER]] or a ~% variable type suffix for only positive integer values up to 65535. - - -''Example 2:'' In '''QB64''', [[_UNSIGNED]] [[INTEGER]] values greater than 65535 cycle over again from zero: -{{CodeStart}} -i~% = 70000 -{{Cl|PRINT}} i~% -{{CodeEnd}}{{OutputStart}} 4464 -{{OutputEnd}} -:''Explanation:'' In QB64 an unsigned integer value of 65536 would be 0 with values increasing by the value minus 65536. - - -''Example 3:'' Demonstrating how _UNSIGNED variables expand the [[INTEGER]] range. -{{CodeStart}} -{{Cl|DIM}} n {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|INTEGER}} -{{Cl|DIM}} pn {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|INTEGER}} -{{Cl|LOCATE}} 3, 6: {{Cl|PRINT}} "Press Esc to exit loop" -{{Cl|FOR...NEXT|FOR}} n = 1 {{Cl|TO}} 80000 - {{Cl|_LIMIT}} 10000 ' 6.5 second loop - {{Cl|LOCATE}} 12, 37: {{Cl|PRINT}} n ' display current value - {{Cl|IF...THEN|IF}} n > 0 {{Cl|THEN}} pn = n ' find highest value - {{Cl|IF...THEN|IF}} n = 0 {{Cl|THEN}} Count = Count + 1: {{Cl|LOCATE}} 14, 37: {{Cl|PRINT}} "Count:"; Count; "Max:"; pn - {{Cl|IF...THEN|IF}} {{Cl|INP}}(&H60) = 1 {{Cl|THEN}} {{Cl|EXIT|EXIT FOR}} ' escape key exit -{{Cl|NEXT}} n -{{Cl|END}} -{{CodeEnd}} -{{OutputStart}} - - Press Esc to exit loop - - - - - 65462 - - Count: 13 Max: 65535 - - -{{OutputEnd}} -''Explanation:'' The maximum value can only be 65535 (32767 + 32768) so the FOR loop repeats itself. Remove the [[_UNSIGNED]] parts and run it again. - - - -{{PageSeeAlso}} -* DECLARE, [[SUB]], [[FUNCTION]] -* [[DIM]], [[_DEFINE]] -* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]] -* [[INTEGER]], [[LONG]], [[_INTEGER64]] -* [[ABS]], [[SGN]] -* [[Variable Types]] - - -{{PageNavigation}} diff --git a/internal/help/_WHEEL__11111.txt b/internal/help/_WHEEL__11111.txt deleted file mode 100644 index 8fb5a81e8..000000000 --- a/internal/help/_WHEEL__11111.txt +++ /dev/null @@ -1,74 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:49}} -{{DISPLAYTITLE:_WHEEL}} -The [[_WHEEL]] function returns the relative position of a specified wheel number on a controller device. - - -{{PageSyntax}} -: {{Parameter|move}} = [[_WHEEL]]({{Parameter|wheelNumber%}}) - - -* Returns -1 when scrolling up and 1 when scrolling down with 0 indicating no movement since last read. -* Add consecutive wheel values to determine a cumulative value over time for scrolling or moving objects. -* {{Parameter|wheelNumber%}} must be a number which does not exceed the number of wheels found by the [[_LASTWHEEL]] function. -* When a mouse indicates it has 3 wheels, the first two are for relative movement reads. The third wheel is for scrolling. -* '''The number of [[_DEVICES]] must be read before using [[_DEVICE$]], [[_DEVICEINPUT]] or [[_LASTWHEEL]].''' - - -{{PageExamples}} -''Example 1:'' Reading multiple controller device buttons, axis and wheels. -{{CodeStart}} -{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}} - {{Cl|PRINT}} {{Cl|STR$}}(i) + ") " + {{Cl|_DEVICE$}}(i) + " Buttons:"; {{Cl|_LASTBUTTON}}(i); ",Axis:"; {{Cl|_LASTAXIS}}(i); ",Wheel:"; {{Cl|_LASTWHEEL}}(i) -{{Cl|NEXT}} - -{{Cl|DO...LOOP|DO}} - d& = {{Cl|_DEVICEINPUT}} - {{Cl|IF...THEN|IF}} d& {{Cl|THEN}} ' the device number cannot be zero! - {{Cl|PRINT}} "Found"; d&; - {{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} {{Cl|_LASTBUTTON}}(d&) - {{Cl|PRINT}} {{Cl|_BUTTONCHANGE}}(b); {{Cl|_BUTTON}}(b); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} {{Cl|_LASTAXIS}}(d&) - {{Cl|PRINT}} {{Cl|_AXIS}}(a); - {{Cl|NEXT}} - {{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} {{Cl|_LASTWHEEL}}(d&) - {{Cl|PRINT}} {{Cl|_WHEEL}}(w); - {{Cl|NEXT}} - {{Cl|PRINT}} - {{Cl|END IF}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit - -{{Cl|END}} -{{CodeEnd}} -: ''Note:'' When there is no device control to read, a [[FOR...NEXT|FOR]] n = 1 TO 0 loop will not run thus avoiding a control function read error. - - -''Example 2:'' Why does a mouse have 3 wheels? Relative x and y movements can be read using the first 2 _WHEEL reads. -{{CodeStart}} -ignore = {{Cl|_MOUSEMOVEMENTX}} 'dummy call to put mouse into relative movement mode - -{{Cl|PRINT}} "Move your mouse and/or your mouse wheel (ESC to exit)" - -d = {{Cl|_DEVICES}} ' always read number of devices to enable device input -DO: {{Cl|_LIMIT}} 30 'main loop - {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_DEVICEINPUT}}(2) 'loop only runs during a device 2 mouse event - {{Cl|PRINT}} {{Cl|_WHEEL}}(1), {{Cl|_WHEEL}}(2), {{Cl|_WHEEL}}(3) - {{Cl|LOOP}} -{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) -{{CodeEnd}} -: ''Explanation:'' Referencing the [[_MOUSEMOVEMENTX]] function hides the mouse and sets the mouse to a relative movement mode which can be read by [[_WHEEL]]. [[_DEVICEINPUT]](2) returns -1 (true) only when the mouse is moved, scrolled or clicked. - - -{{PageSeeAlso}} -* [[_MOUSEWHEEL]] -* [[_LASTWHEEL]], [[_LASTBUTTON]], [[_LASTAXIS]] -* [[_AXIS]], [[_BUTTON]], [[_BUTTONCHANGE]] -* [[_DEVICES]], [[_DEVICE$]], [[_DEVICEINPUT]] -* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] -* [[Controller Devices]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_WIDTH_(function)__11111_(00000000).txt b/internal/help/_WIDTH_(function)__11111_(00000000).txt deleted file mode 100644 index 8f276d77e..000000000 --- a/internal/help/_WIDTH_(function)__11111_(00000000).txt +++ /dev/null @@ -1,53 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:50}} -{{DISPLAYTITLE:_WIDTH (function)}} -The [[_WIDTH (function)|_WIDTH]] function returns the width of an image handle or of the current write page. - - -{{PageSyntax}} -: {{Parameter|columns&}} = [[_WIDTH (function)|_WIDTH]][({{Parameter|imageHandle&}})] - - -{{PageDescription}} -* If {{Parameter|imageHandle&}} is omitted, it's assumed to be the handle of the current [[SCREEN]] or write page. -* To get the width of the current program [[SCREEN|screen]] window use zero for the handle value or nothing: {{Parameter|columns&}} = [[_WIDTH (function)|_WIDTH]](0) ''or'' {{Parameter|columns&}} = [[_WIDTH (function)|_WIDTH]] -* If the image specified by {{Parameter|imageHandle&}} is in text only([[SCREEN]] 0) mode, the number of characters per row is returned. -* If the image specified by {{Parameter|imageHandle&}} is in graphics mode, the number of pixels per row is returned. -* If {{Parameter|imageHandle&}} is an invalid handle, then an [[ERROR Codes|invalid handle error]] is returned. -* The last visible pixel coordinate of a program [[SCREEN|screen]] is '''[[_WIDTH (function)|_WIDTH]] - 1'''. - - -{{PageExamples}} -''Example:'' A SUB program that centers text in any graphic screen mode except text mode [[SCREEN (statement)|SCREEN]] 0. - -{{CodeStart}} - - s& = {{Cl|_NEWIMAGE}}(800, 600, 256) - SCREEN s& - Align 15, 5, s&, "This text is centered on the screen!" - - SUB Align (Tcolor, Trow, mode&, txt$) - center& = {{Cl|_WIDTH (function)|_WIDTH}} (mode&) \ 2 'returns pixels in graphic modes - MaxCol = (center& \ 8) + 1 'screen text width = 8 pixels - Tcol = MaxCol - ({{Cl|LEN}}(txt$) \ 2) - {{Cl|COLOR}} Tcolor: {{Cl|LOCATE}} Trow, Tcol: {{Cl|PRINT}} txt$; - END SUB - -{{CodeEnd}} - -: ''Explanation:'' [[_NEWIMAGE]] enlarges a screen to 800 pixels wide which is what [[_WIDTH (function)|_WIDTH]] function will return. The center is 800 \ 2 or 400. Since the text width is 8 pixels, that is divided by 8 to get 50 as the center text column. Then half of the text length is subtracted to find the starting text print [[LOCATE]] column. - - -: ''Note:'' The screen handle parameter is required because using no handle could assume other page handles created by functions like [[_NEWIMAGE]] or [[_PUTIMAGE]]. Use the correct handle in the SUB call! When using SCREEN 0, the MaxCol variable is not needed because _WIDTH returns the number of text columns, not pixels. Use the center value and add 1. '''Tcol = (center& + 1) - LEN(txt$) \ 2''' - - - -{{PageSeeAlso}} -* [[_HEIGHT]], [[_LOADIMAGE]], [[_NEWIMAGE]] -* [[WIDTH]] -* [[Bitmaps]] - - -{{PageNavigation}} - -[[Category:Latest]] diff --git a/internal/help/_WINDOWHANDLE__111111111111.txt b/internal/help/_WINDOWHANDLE__111111111111.txt deleted file mode 100644 index 82f917454..000000000 --- a/internal/help/_WINDOWHANDLE__111111111111.txt +++ /dev/null @@ -1,98 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:51}} -{{DISPLAYTITLE:_WINDOWHANDLE}} -The [[_WINDOWHANDLE]] function returns the window handle assigned to the current program by the OS. Windows-only. - - -{{PageSyntax}} -: {{Parameter|hwnd&&}} = [[_WINDOWHANDLE]] - - -{{PageDescription}} -* The result is an [[_INTEGER64]] number assigned by Windows to your running program. -* Use it to make [[Windows Libraries|API calls]] that require a window handle to be passed. -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]. - - -==Availability== -* '''Build 20170924/68'''. - - -{{PageExamples}} -''Example:'' Showing the system-default message box in Windows. -{{CodeStart}} -'Message Box Constant values as defined by Microsoft (MBType) -{{Cl|CONST}} MB_OK& = 0 'OK button only -{{Cl|CONST}} MB_OKCANCEL& = 1 'OK & Cancel -{{Cl|CONST}} MB_ABORTRETRYIGNORE& = 2 'Abort, Retry & Ignore -{{Cl|CONST}} MB_YESNOCANCEL& = 3 'Yes, No & Cancel -{{Cl|CONST}} MB_YESNO& = 4 'Yes & No -{{Cl|CONST}} MB_RETRYCANCEL& = 5 'Retry & Cancel -{{Cl|CONST}} MB_CANCELTRYCONTINUE& = 6 'Cancel, Try Again & Continue -{{Cl|CONST}} MB_ICONSTOP& = 16 'Error stop sign icon -{{Cl|CONST}} MB_ICONQUESTION& = 32 'Question-mark icon -{{Cl|CONST}} MB_ICONEXCLAMATION& = 48 'Exclamation-point icon -{{Cl|CONST}} MB_ICONINFORMATION& = 64 'Letter i in a circle icon -{{Cl|CONST}} MB_DEFBUTTON1& = 0 '1st button default(left) -{{Cl|CONST}} MB_DEFBUTTON2& = 256 '2nd button default -{{Cl|CONST}} MB_DEFBUTTON3& = 512 '3rd button default(right) -{{Cl|CONST}} MB_APPLMODAL& = 0 'Message box applies to application only -{{Cl|CONST}} MB_SYSTEMMODAL& = 4096 'Message box on top of all other windows -{{Cl|CONST}} MB_SETFOCUS& = 65536 'Set message box as focus -{{Cl|CONST}} IDOK& = 1 'OK button pressed -{{Cl|CONST}} IDCANCEL& = 2 'Cancel button pressed -{{Cl|CONST}} IDABORT& = 3 'Abort button pressed -{{Cl|CONST}} IDRETRY& = 4 'Retry button pressed -{{Cl|CONST}} IDIGNORE& = 5 'Ignore button pressed -{{Cl|CONST}} IDYES& = 6 'Yes button pressed -{{Cl|CONST}} IDNO& = 7 'No button pressed -{{Cl|CONST}} IDTRYAGAIN& = 10 'Try again button pressed -{{Cl|CONST}} IDCONTINUE& = 1 'Continue button pressed -'---------------------------------------------------------------------------------------- - -{{Cl|DECLARE LIBRARY|DECLARE DYNAMIC LIBRARY}} "user32" -{{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hwnd {{Cl|AS}} {{Cl|LONG}}, Message {{Cl|AS}} {{Cl|STRING}}, Title {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} MBType {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}}) -{{Cl|DECLARE LIBRARY|END DECLARE}} - -DO - msg& = 0: icon& = 0: DB& = 0 - {{Cl|INPUT}} "Enter Message Box type(0 to 6 other Quits): ", BOX& - {{Cl|IF...THEN|IF}} BOX& < 0 {{Cl|OR (boolean)|OR}} BOX& > 6 {{Cl|THEN}} {{Cl|EXIT DO}} - - {{Cl|INPUT}} "Enter Icon&(0=none, 1=stop, 2=?, 3=!, 4=info): ", Icon& - - {{Cl|IF...THEN|IF}} BOX& {{Cl|THEN}} {{Cl|INPUT (file mode)|INPUT}} "Enter Default Button(1st, 2nd or 3rd): ", DB& - {{Cl|IF...THEN|IF}} DB& {{Cl|THEN}} DB& = DB& - 1 'adjust value to 0, 1, or 2 - msg& = MsgBox&("Box Title", "Box text message", BOX&, Icon&, DB&, 4096) 'on top of all windows - - {{Cl|PRINT}} "Button ="; msg& -{{Cl|LOOP}} -{{Cl|END}} - -{{Cl|FUNCTION}} MsgBox& (Title$, Message$, BoxType&, Icon&, DBtn&, Mode&) -{{Cl|SELECT CASE}} Icon& - {{Cl|CASE}} 1: Icon& = MB_ICONSTOP& 'warning X-sign icon - {{Cl|CASE}} 2: Icon& = MB_ICONQUESTION& 'question-mark icon - {{Cl|CASE}} 3: Icon& = MB_ICONEXCLAMATION& 'exclamation-point icon - {{Cl|CASE}} 4: Icon& = MB_ICONINFORMATION& 'lowercase letter i in circle - {{Cl|CASE ELSE}}: Icon& = 0 'no icon -{{Cl|END SELECT}} -{{Cl|IF...THEN|IF}} BoxType& > 0 {{Cl|AND (boolean)|AND}} DBtn& > 0 {{Cl|THEN}} 'set default button as 2nd(256) or 3rd(512) - {{Cl|SELECT CASE}} BoxType& - {{Cl|CASE}} 2, 3, 6 - {{Cl|IF...THEN|IF}} DBtn& = 2 {{Cl|THEN}} Icon& = Icon& + MB_DEFBUTTON3& {{Cl|ELSE}} Icon& = Icon& + MB_DEFBUTTON2& '3 button - {{Cl|CASE ELSE}}: Icon& = Icon& + MB_DEFBUTTON2& '2nd button default - {{Cl|END SELECT}} -{{Cl|END IF}} -Focus& = MB_SetFocus& -MsgBox& = MessageBoxA&({{Cl|_WINDOWHANDLE}}, Message$, Title$, BoxType& + Icon& + Mode& + Focus&) 'focus on button -{{Cl|END FUNCTION}} -{{CodeEnd}} -:''Explanation:'' Notice how the call to the external dynamic library function MessageBoxA& passes _WINDOWHANDLE to the API and how the message box shown is created as a child of your program's window, not allowing the main window to be manipulated while the message box is open. - -{{PageSeeAlso}} -* [[_WINDOWHASFOCUS]] -* [[Windows Libraries]] - - -{{PageNavigation}} diff --git a/internal/help/_WINDOWHASFOCUS__11111111111111.txt b/internal/help/_WINDOWHASFOCUS__11111111111111.txt deleted file mode 100644 index ce04e0632..000000000 --- a/internal/help/_WINDOWHASFOCUS__11111111111111.txt +++ /dev/null @@ -1,44 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:40:52}} -{{DISPLAYTITLE:_WINDOWHASFOCUS}} -The [[_WINDOWHASFOCUS]] function returns true (-1) if the current program's window has focus. Windows-only. - - -{{PageSyntax}} -: {{Parameter|hasFocus%%}} = [[_WINDOWHASFOCUS]] - - -{{PageDescription}} -* The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0). -* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in macOS]]. - - -==Availability== -* '''Build 20170924/68'''. - - -{{PageExamples}} -''Example:'' Detecting if the current program has focus. Windows and Linux-only. -{{CodeStart}} -DO - {{Cl|IF}} {{Cl|_WINDOWHASFOCUS}} THEN - {{Cl|COLOR}} 15, 6 - {{Cl|CLS}} - {{Cl|PRINT}} "*** Hi there! ***" - {{Cl|ELSE}} - {{Cl|COLOR}} 0, 7 - CLS - PRINT "(ain't nobody looking...)" - {{Cl|END IF}} - {{Cl|_DISPLAY}} - {{Cl|_LIMIT}} 30 -{{Cl|LOOP}} -{{CodeEnd}} -: ''Explanation:'' The program will display ''"*** Hi There! ***"'' while the window is the topmost and is being manipulated by the user. If another window, the taskbar or the desktop are clicked, the program window loses focus and the message ''"(ain't nobody looking...)"'' is displayed. - - -{{PageSeeAlso}} -* [[_SCREENEXISTS]] - - -{{PageNavigation}} diff --git a/internal/help/_glAccum__0010000.txt b/internal/help/_glAccum__0010000.txt deleted file mode 100644 index dacdd2192..000000000 --- a/internal/help/_glAccum__0010000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:49}} -{{DISPLAYTITLE:_glAccum}} -The '''_glAccum''' statement operates on the accumulation buffer. - - -{{PageSyntax}} -: '''_glAccum''' GLenum {{Parameter|op}}, GLfloat {{Parameter|value}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glaccum Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBlendFunc]], [[_glClear]], [[_glClearAccum]] -* [[_glCopyPixels]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glLogicOp]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [[_glReadBuffer]], [[_glReadPixels]] -* [[_glScissor]], [[_glStencilOp]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glAlphaFunc__00100001000.txt b/internal/help/_glAlphaFunc__00100001000.txt deleted file mode 100644 index b9ccc58b6..000000000 --- a/internal/help/_glAlphaFunc__00100001000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:51}} -{{DISPLAYTITLE:_glAlphaFunc}} -The '''_glAlphaFunc''' statement enables your application to set the alpha test function. - - -{{PageSyntax}} -: '''_glAlphaFunc''' GLenum {{Parameter|func}}, GLclampf {{Parameter|ref}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glalphafunc Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBlendFunc]], [[_glClear]], [[_glDepthFunc]] -* [[_glEnable]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsEnabled]] -* [[_glStencilFunc]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glAreTexturesResident__001001000000010000000.txt b/internal/help/_glAreTexturesResident__001001000000010000000.txt deleted file mode 100644 index 4fc8f1c75..000000000 --- a/internal/help/_glAreTexturesResident__001001000000010000000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:54}} -{{DISPLAYTITLE:_glAreTexturesResident}} -The '''_glAreTexturesResident''' function determines whether specified texture objects are resident in texture memory. - - -{{PageSyntax}} -: GLboolean {{Parameter|result}} = '''_glAreTexturesResident''' (GLsizei {{Parameter|n}}, const GLuint {{Parameter|*textures}}, GLboolean {{Parameter|*residences}}) - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glaretexturesresident Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBindTexture]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexparameter _glGetTexParameter] -* [[_glPrioritizeTextures]], [[_glTexImage1D]], [[_glTexImage2D]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glArrayElement__00100001000000.txt b/internal/help/_glArrayElement__00100001000000.txt deleted file mode 100644 index 56e0bffe7..000000000 --- a/internal/help/_glArrayElement__00100001000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:56}} -{{DISPLAYTITLE:_glArrayElement}} -The '''_glArrayElement''' statement specifies the array elements used to render a vertex. - - -{{PageSyntax}} -: '''_glArrayElement''' GLint {{Parameter|index}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glarrayelement Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glColorPointer]], [[_glDrawArrays]], [[_glEdgeFlagPointer]] -* [[_glEnableClientState]], [[_glEnd]], [[_glGetPointerv]], [[_glGetString]] -* [[_glIndexPointer]], [[_glNormalPointer]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glBegin__0010000.txt b/internal/help/_glBegin__0010000.txt deleted file mode 100644 index daac04017..000000000 --- a/internal/help/_glBegin__0010000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:45:58}} -{{DISPLAYTITLE:_glBegin}} -The '''_glBegin''' and '''_glEnd''' statements delimit the vertices of a primitive or a group of like primitives. - - -{{PageSyntax}} -: '''_glBegin''' GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glbegin Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glCallList]], [[_glCallLists]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor-functions _glColor], [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflag-functions _glEdgeFlag] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalcoord-functions _glEvalCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalpoint _glEvalPoint], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial], [https://docs.microsoft.com/en-us/windows/win32/opengl/glnormal-functions _glNormal], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexcoord-functions _glTexCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glvertex-functions _glVertex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glBindTexture__0010001000000.txt b/internal/help/_glBindTexture__0010001000000.txt deleted file mode 100644 index 8449197d4..000000000 --- a/internal/help/_glBindTexture__0010001000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:00}} -{{DISPLAYTITLE:_glBindTexture}} -The '''_glBindTexture''' statement enables the creation of a named texture that is bound to a texture target. - - -{{PageSyntax}} -: '''_glBindTexture''' GLenum {{Parameter|target}}, GLuint {{Parameter|texture}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glbindtexture Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAreTexturesResident]], [[_glDeleteTextures]], [[_glGenTextures]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexparameter _glGetTexParameter], [[_glIsTexture]], [[_glPrioritizeTextures]], [[_glTexImage1D]] -* [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glBitmap__00100000.txt b/internal/help/_glBitmap__00100000.txt deleted file mode 100644 index 38ace6922..000000000 --- a/internal/help/_glBitmap__00100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:02}} -{{DISPLAYTITLE:_glBitmap}} -The '''_glBitmap''' statement draws a bitmap. - - -{{PageSyntax}} -: '''_glBitmap''' GLSizei {{Parameter|width}}, GLSizei {{Parameter|height}}, GLfloat {{Parameter|xorig}}, GLfloat {{Parameter|yorig}}, GLfloat {{Parameter|xmove}}, GLfloat {{Parameter|ymove}}, const GLubyte {{Parameter|*bitmap}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glbitmap Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDrawPixels]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/glrasterpos-functions _glRasterPos] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glBlendFunc__00100001000.txt b/internal/help/_glBlendFunc__00100001000.txt deleted file mode 100644 index f771abe34..000000000 --- a/internal/help/_glBlendFunc__00100001000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:05}} -{{DISPLAYTITLE:_glBlendFunc}} -The '''_glBlendFunc''' statement specifies pixel arithmetic. - - -{{PageSyntax}} -: '''_glBlendFunc''' GLenum {{Parameter|sfactor}}, GLenum {{Parameter|dfactor}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glblendfunc Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glBegin]], [[_glClear]], [[_glDisable]] -* [[_glDrawBuffer]], [[_glEnable]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsEnabled]] -* [[_glLogicOp]], [[_glStencilFunc]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCallList__0010001000.txt b/internal/help/_glCallList__0010001000.txt deleted file mode 100644 index 07ac6d872..000000000 --- a/internal/help/_glCallList__0010001000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:07}} -{{DISPLAYTITLE:_glCallList}} -The '''_glCallList''' statement executes a display list. - - -{{PageSyntax}} -: '''_glCallList''' GLuint {{Parameter|list}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcalllist Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCallLists]], [[_glDeleteLists]], [[_glEnd]] -* [[_glGenLists]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsList]], [[_glNewList]] -* [[_glPopAttrib]], [[_glPopMatrix]], [[_glPushAttrib]], [[_glPushMatrix]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCallLists__00100010000.txt b/internal/help/_glCallLists__00100010000.txt deleted file mode 100644 index 361ed0f0f..000000000 --- a/internal/help/_glCallLists__00100010000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:09}} -{{DISPLAYTITLE:_glCallLists}} -The '''_glCallLists''' statement executes a list of display lists. - - -{{PageSyntax}} -: '''_glCallLists''' GLsizei {{Parameter|n}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*lists}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcalllists Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCallList]], [[_glDeleteLists]], [[_glEnd]] -* [[_glGenLists]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsList]], [[_glListBase]] -* [[_glNewList]], [[_glPopAttrib]], [[_glPopMatrix]], [[_glPushAttrib]] -* [[_glPushMatrix]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClearAccum__001000010000.txt b/internal/help/_glClearAccum__001000010000.txt deleted file mode 100644 index 28a3b6be6..000000000 --- a/internal/help/_glClearAccum__001000010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:14}} -{{DISPLAYTITLE:_glClearAccum}} -The '''_glClearAccum''' statement specifies the clear values for the accumulation buffer. - - -{{PageSyntax}} -: '''_glClearAccum''' GLfloat {{Parameter|red}}, GLfloat {{Parameter|green}}, GLfloat {{Parameter|blue}}, GLfloat {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclearaccum Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glClear]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClearColor__001000010000.txt b/internal/help/_glClearColor__001000010000.txt deleted file mode 100644 index 404a7957d..000000000 --- a/internal/help/_glClearColor__001000010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:16}} -{{DISPLAYTITLE:_glClearColor}} -The '''_glClearColor''' statement specifies clear values for the color buffers. - - -{{PageSyntax}} -: '''_glClearColor''' GLclampf {{Parameter|red}}, GLclampf {{Parameter|green}}, GLclampf {{Parameter|blue}}, GLclampf {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclearcolor Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glClear]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClearDepth__001000010000.txt b/internal/help/_glClearDepth__001000010000.txt deleted file mode 100644 index 7a0907116..000000000 --- a/internal/help/_glClearDepth__001000010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:18}} -{{DISPLAYTITLE:_glClearDepth}} -The '''_glClearDepth''' statement specifies the clear value for the depth buffer. - - -{{PageSyntax}} -: '''_glClearDepth''' GLclampd {{Parameter|depth}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcleardepth Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glClear]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClearIndex__001000010000.txt b/internal/help/_glClearIndex__001000010000.txt deleted file mode 100644 index 0ba9ee37e..000000000 --- a/internal/help/_glClearIndex__001000010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:20}} -{{DISPLAYTITLE:_glClearIndex}} -The '''_glClearIndex''' statement specifies the clear value for the color-index buffers. - - -{{PageSyntax}} -: '''_glClearIndex''' GLfloat {{Parameter|c}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclearindex Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glClear]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClearStencil__00100001000000.txt b/internal/help/_glClearStencil__00100001000000.txt deleted file mode 100644 index c8b8be694..000000000 --- a/internal/help/_glClearStencil__00100001000000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:22}} -{{DISPLAYTITLE:_glClearStencil}} -The '''_glClearStencil''' statement specifies the clear value for the stencil buffer. - - -{{PageSyntax}} -: '''_glClearStencil''' GLint {{Parameter|s}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclearstencil Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glClear]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClear__0010000.txt b/internal/help/_glClear__0010000.txt deleted file mode 100644 index c2af71799..000000000 --- a/internal/help/_glClear__0010000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:11}} -{{DISPLAYTITLE:_glClear}} -The '''_glClear''' statement clears buffers to preset values. - - -{{PageSyntax}} -: '''_glClear''' GLbitfield {{Parameter|mask}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclear Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glClearAccum]], [[_glClearColor]], [[_glClearDepth]], [[_glClearIndex]] -* [[_glClearStencil]], [[_glDrawBuffer]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glScissor]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glClipPlane__00100010000.txt b/internal/help/_glClipPlane__00100010000.txt deleted file mode 100644 index 7b9c58b58..000000000 --- a/internal/help/_glClipPlane__00100010000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:24}} -{{DISPLAYTITLE:_glClipPlane}} -The '''_glClipPlane''' statement specifies a plane against which all geometry is clipped. - - -{{PageSyntax}} -: '''_glClipPlane''' GLenum {{Parameter|plane}}, const GLdouble {{Parameter|*equation}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glclipplane Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDisable]], [[_glEnable]], [[_glEnd]] -* [[_glGetClipPlane]], [[_glIsEnabled]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3b__001000030.txt b/internal/help/_glColor3b__001000030.txt deleted file mode 100644 index 7fb335c59..000000000 --- a/internal/help/_glColor3b__001000030.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:27}} -{{DISPLAYTITLE:_glColor3b}} -The '''_glColor3b''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3b''' GLbyte {{Parameter|red}}, GLbyte {{Parameter|green}}, GLbyte {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3b Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3bv__0010000300.txt b/internal/help/_glColor3bv__0010000300.txt deleted file mode 100644 index 8e7b283cf..000000000 --- a/internal/help/_glColor3bv__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:29}} -{{DISPLAYTITLE:_glColor3bv}} -The '''_glColor3bv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3bv''' const GLbyte {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3bv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3d__001000030.txt b/internal/help/_glColor3d__001000030.txt deleted file mode 100644 index e4117e1c6..000000000 --- a/internal/help/_glColor3d__001000030.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:31}} -{{DISPLAYTITLE:_glColor3d}} -The '''_glColor3d''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3d''' GLdouble {{Parameter|red}}, GLdouble {{Parameter|green}}, GLdouble {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3dv__0010000300.txt b/internal/help/_glColor3dv__0010000300.txt deleted file mode 100644 index 07a141e07..000000000 --- a/internal/help/_glColor3dv__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:33}} -{{DISPLAYTITLE:_glColor3dv}} -The '''_glColor3dv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3dv''' const GLdouble {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3dv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3f__001000030.txt b/internal/help/_glColor3f__001000030.txt deleted file mode 100644 index 27813ca64..000000000 --- a/internal/help/_glColor3f__001000030.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:35}} -{{DISPLAYTITLE:_glColor3f}} -The '''_glColor3f''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3f''' GLfloat {{Parameter|red}}, GLfloat {{Parameter|green}}, GLfloat {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3f Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3fv__0010000300.txt b/internal/help/_glColor3fv__0010000300.txt deleted file mode 100644 index a3ed0a3f1..000000000 --- a/internal/help/_glColor3fv__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:37}} -{{DISPLAYTITLE:_glColor3fv}} -The '''_glColor3fv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3fv''' const GLfloat {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3fv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3i__001000030.txt b/internal/help/_glColor3i__001000030.txt deleted file mode 100644 index 020619b1c..000000000 --- a/internal/help/_glColor3i__001000030.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:40}} -{{DISPLAYTITLE:_glColor3i}} -The '''_glColor3i''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3i''' GLint {{Parameter|red}}, GLint {{Parameter|green}}, GLint {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3i Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3iv__0010000300.txt b/internal/help/_glColor3iv__0010000300.txt deleted file mode 100644 index 96670f942..000000000 --- a/internal/help/_glColor3iv__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:42}} -{{DISPLAYTITLE:_glColor3iv}} -The '''_glColor3iv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3iv''' const GLint {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3iv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3s__001000030.txt b/internal/help/_glColor3s__001000030.txt deleted file mode 100644 index 91f1d67fa..000000000 --- a/internal/help/_glColor3s__001000030.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:44}} -{{DISPLAYTITLE:_glColor3s}} -The '''_glColor3s''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3s''' GLshort {{Parameter|red}}, GLshort {{Parameter|green}}, GLshort {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3s Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3sv__0010000300.txt b/internal/help/_glColor3sv__0010000300.txt deleted file mode 100644 index eee71e67b..000000000 --- a/internal/help/_glColor3sv__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:46}} -{{DISPLAYTITLE:_glColor3sv}} -The '''_glColor3sv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3sv''' const GLshort {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3sv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3ub__0010000300.txt b/internal/help/_glColor3ub__0010000300.txt deleted file mode 100644 index 62516a4fa..000000000 --- a/internal/help/_glColor3ub__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:48}} -{{DISPLAYTITLE:_glColor3ub}} -The '''_glColor3ub''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3ub''' GLubyte {{Parameter|red}}, GLubyte {{Parameter|green}}, GLubyte {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3ub Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3ubv__00100003000.txt b/internal/help/_glColor3ubv__00100003000.txt deleted file mode 100644 index bff55c124..000000000 --- a/internal/help/_glColor3ubv__00100003000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:51}} -{{DISPLAYTITLE:_glColor3ubv}} -The '''_glColor3ubv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3ubv''' const GLubyte {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3ubv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3ui__0010000300.txt b/internal/help/_glColor3ui__0010000300.txt deleted file mode 100644 index 8070c6dbe..000000000 --- a/internal/help/_glColor3ui__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:53}} -{{DISPLAYTITLE:_glColor3ui}} -The '''_glColor3ui''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3ui''' GLuint {{Parameter|red}}, GLuint {{Parameter|green}}, GLuint {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3ui Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3uiv__00100003000.txt b/internal/help/_glColor3uiv__00100003000.txt deleted file mode 100644 index a6a94b308..000000000 --- a/internal/help/_glColor3uiv__00100003000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:56}} -{{DISPLAYTITLE:_glColor3uiv}} -The '''_glColor3uiv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3uiv''' const GLuint {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3uiv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3us__0010000300.txt b/internal/help/_glColor3us__0010000300.txt deleted file mode 100644 index 918ac6b8d..000000000 --- a/internal/help/_glColor3us__0010000300.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:46:58}} -{{DISPLAYTITLE:_glColor3us}} -The '''_glColor3us''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor3us''' GLushort {{Parameter|red}}, GLushort {{Parameter|green}}, GLushort {{Parameter|blue}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3us Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor3usv__00100003000.txt b/internal/help/_glColor3usv__00100003000.txt deleted file mode 100644 index eec4e5572..000000000 --- a/internal/help/_glColor3usv__00100003000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:00}} -{{DISPLAYTITLE:_glColor3usv}} -The '''_glColor3usv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor3usv''' const GLushort {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor3usv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4b__001000040.txt b/internal/help/_glColor4b__001000040.txt deleted file mode 100644 index cd1893bbc..000000000 --- a/internal/help/_glColor4b__001000040.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:02}} -{{DISPLAYTITLE:_glColor4b}} -The '''_glColor4b''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4b''' GLbyte {{Parameter|red}}, GLbyte {{Parameter|green}}, GLbyte {{Parameter|blue}}, GLbyte {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4b Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4bv__0010000400.txt b/internal/help/_glColor4bv__0010000400.txt deleted file mode 100644 index 359feb240..000000000 --- a/internal/help/_glColor4bv__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:05}} -{{DISPLAYTITLE:_glColor4bv}} -The '''_glColor4bv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4bv''' const GLbyte {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4bv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4d__001000040.txt b/internal/help/_glColor4d__001000040.txt deleted file mode 100644 index 276aa7c4f..000000000 --- a/internal/help/_glColor4d__001000040.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:07}} -{{DISPLAYTITLE:_glColor4d}} -The '''_glColor4d''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4d''' GLdouble {{Parameter|red}}, GLdouble {{Parameter|green}}, GLdouble {{Parameter|blue}}, GLdouble {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4dv__0010000400.txt b/internal/help/_glColor4dv__0010000400.txt deleted file mode 100644 index 44eb701f5..000000000 --- a/internal/help/_glColor4dv__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:09}} -{{DISPLAYTITLE:_glColor4dv}} -The '''_glColor4dv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4dv''' const GLdouble {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4dv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4f__001000040.txt b/internal/help/_glColor4f__001000040.txt deleted file mode 100644 index 99d686ef5..000000000 --- a/internal/help/_glColor4f__001000040.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:11}} -{{DISPLAYTITLE:_glColor4f}} -The '''_glColor4f''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4f''' GLfloat {{Parameter|red}}, GLfloat {{Parameter|green}}, GLfloat {{Parameter|blue}}, GLfloat {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4f Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4fv__0010000400.txt b/internal/help/_glColor4fv__0010000400.txt deleted file mode 100644 index e823eaf94..000000000 --- a/internal/help/_glColor4fv__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:13}} -{{DISPLAYTITLE:_glColor4fv}} -The '''_glColor4fv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4fv''' const GLfloat {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4fv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4i__001000040.txt b/internal/help/_glColor4i__001000040.txt deleted file mode 100644 index d64cc4328..000000000 --- a/internal/help/_glColor4i__001000040.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:15}} -{{DISPLAYTITLE:_glColor4i}} -The '''_glColor4i''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4i''' GLint {{Parameter|red}}, GLint {{Parameter|green}}, GLint {{Parameter|blue}}, GLint {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4i Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4iv__0010000400.txt b/internal/help/_glColor4iv__0010000400.txt deleted file mode 100644 index c8804866c..000000000 --- a/internal/help/_glColor4iv__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:18}} -{{DISPLAYTITLE:_glColor4iv}} -The '''_glColor4iv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4iv''' const GLint {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4iv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4s__001000040.txt b/internal/help/_glColor4s__001000040.txt deleted file mode 100644 index d7bc6cea1..000000000 --- a/internal/help/_glColor4s__001000040.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:20}} -{{DISPLAYTITLE:_glColor4s}} -The '''_glColor4s''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4s''' GLshort {{Parameter|red}}, GLshort {{Parameter|green}}, GLshort {{Parameter|blue}}, GLshort {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4s Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4sv__0010000400.txt b/internal/help/_glColor4sv__0010000400.txt deleted file mode 100644 index cddacc61a..000000000 --- a/internal/help/_glColor4sv__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:22}} -{{DISPLAYTITLE:_glColor4sv}} -The '''_glColor4sv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4sv''' const GLshort {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4sv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4ub__0010000400.txt b/internal/help/_glColor4ub__0010000400.txt deleted file mode 100644 index fb95ee5f4..000000000 --- a/internal/help/_glColor4ub__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:24}} -{{DISPLAYTITLE:_glColor4ub}} -The '''_glColor4ub''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4ub''' GLubyte {{Parameter|red}}, GLubyte {{Parameter|green}}, GLubyte {{Parameter|blue}}, GLubyte {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4ub Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4ubv__00100004000.txt b/internal/help/_glColor4ubv__00100004000.txt deleted file mode 100644 index 999ae9f22..000000000 --- a/internal/help/_glColor4ubv__00100004000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:26}} -{{DISPLAYTITLE:_glColor4ubv}} -The '''_glColor4ubv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4ubv''' const GLubyte {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4ubv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4ui__0010000400.txt b/internal/help/_glColor4ui__0010000400.txt deleted file mode 100644 index eaf571bd2..000000000 --- a/internal/help/_glColor4ui__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:29}} -{{DISPLAYTITLE:_glColor4ui}} -The '''_glColor4ui''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4ui''' GLuint {{Parameter|red}}, GLuint {{Parameter|green}}, GLuint {{Parameter|blue}}, GLuint {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4ui Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4uiv__00100004000.txt b/internal/help/_glColor4uiv__00100004000.txt deleted file mode 100644 index 57c50ee51..000000000 --- a/internal/help/_glColor4uiv__00100004000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:31}} -{{DISPLAYTITLE:_glColor4uiv}} -The '''_glColor4uiv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4uiv''' const GLuint {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4uiv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4us__0010000400.txt b/internal/help/_glColor4us__0010000400.txt deleted file mode 100644 index 2f6445559..000000000 --- a/internal/help/_glColor4us__0010000400.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:33}} -{{DISPLAYTITLE:_glColor4us}} -The '''_glColor4us''' statement sets the current color. - - -{{PageSyntax}} -: '''_glColor4us''' GLushort {{Parameter|red}}, GLushort {{Parameter|green}}, GLushort {{Parameter|blue}}, GLushort {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4us Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColor4usv__00100004000.txt b/internal/help/_glColor4usv__00100004000.txt deleted file mode 100644 index 857bd712c..000000000 --- a/internal/help/_glColor4usv__00100004000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:36}} -{{DISPLAYTITLE:_glColor4usv}} -The '''_glColor4usv''' statement sets the current color from an already existing array of color values. - - -{{PageSyntax}} -: '''_glColor4usv''' const GLushort {{Parameter|*v}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor4usv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColorMask__00100001000.txt b/internal/help/_glColorMask__00100001000.txt deleted file mode 100644 index 5acf6f851..000000000 --- a/internal/help/_glColorMask__00100001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:38}} -{{DISPLAYTITLE:_glColorMask}} -The '''_glColorMask''' statement enables and disables writing of frame-buffer color components. - - -{{PageSyntax}} -: '''_glColorMask''' GLboolean {{Parameter|red}}, GLboolean {{Parameter|green}}, GLboolean {{Parameter|blue}}, GLboolean {{Parameter|alpha}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolormask Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor-functions _glColor], [[_glDepthMask]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex], [[_glIndexMask]], [[_glStencilMask]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColorMaterial__001000010000000.txt b/internal/help/_glColorMaterial__001000010000000.txt deleted file mode 100644 index 68f6dba47..000000000 --- a/internal/help/_glColorMaterial__001000010000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:40}} -{{DISPLAYTITLE:_glColorMaterial}} -The '''_glColorMaterial''' statement causes a material color to track the current color. - - -{{PageSyntax}} -: '''_glColorMaterial''' GLenum {{Parameter|face}}, GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolormaterial Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor-functions _glColor], [[_glDisable]], [[_glEnable]] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllight-functions _glLight] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gllightmodel-functions _glLightModel], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glColorPointer__00100001000000.txt b/internal/help/_glColorPointer__00100001000000.txt deleted file mode 100644 index affad35b7..000000000 --- a/internal/help/_glColorPointer__00100001000000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:42}} -{{DISPLAYTITLE:_glColorPointer}} -The '''_glColorPointer''' statement defines an array of colors. - - -{{PageSyntax}} -: '''_glColorPointer''' GLint {{Parameter|size}}, GLenum {{Parameter|type}}, GLsizei {{Parameter|stride}}, const GLvoid {{Parameter|*pointer}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolorpointer Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glDrawArrays]], [[_glEdgeFlagPointer]] -* [[_glEnableClientState]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glGetString]] -* [[_glGetPointerv]], [[_glIndexPointer]], [[_glIsEnabled]], [[_glNormalPointer]] -* [[_glPopAttrib]], [[_glPushAttrib]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCopyPixels__001000100000.txt b/internal/help/_glCopyPixels__001000100000.txt deleted file mode 100644 index dcdd3ff39..000000000 --- a/internal/help/_glCopyPixels__001000100000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:44}} -{{DISPLAYTITLE:_glCopyPixels}} -The '''_glCopyPixels''' statement copies pixels in the framebuffer. - - -{{PageSyntax}} -: '''_glCopyPixels''' GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLenum {{Parameter|type}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcopypixels Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDepthFunc]], [[_glDrawBuffer]], [[_glDrawPixels]] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelmap _glPixelMap], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [[_glPixelZoom]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glrasterpos-functions _glRasterPos], [[_glReadBuffer]] -* [[_glReadPixels]], [[_glStencilFunc]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCopyTexImage1D__0010001001000011.txt b/internal/help/_glCopyTexImage1D__0010001001000011.txt deleted file mode 100644 index cdfaae23b..000000000 --- a/internal/help/_glCopyTexImage1D__0010001001000011.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:47}} -{{DISPLAYTITLE:_glCopyTexImage1D}} -The '''_glCopyTexImage1D''' statement copies pixels from the framebuffer into a one-dimensional texture image. - - -{{PageSyntax}} -: '''_glCopyTexImage1D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|internalFormat}}, GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLint {{Parameter|border}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcopyteximage1d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glCopyPixels]], [[_glCopyTexImage2D]], [[_glDrawPixels]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen] -* [[_glTexImage1D]], [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCopyTexImage2D__0010001001000021.txt b/internal/help/_glCopyTexImage2D__0010001001000021.txt deleted file mode 100644 index 54441bb3f..000000000 --- a/internal/help/_glCopyTexImage2D__0010001001000021.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:49}} -{{DISPLAYTITLE:_glCopyTexImage2D}} -The '''_glCopyTexImage2D''' statement copies pixels from the framebuffer into a two-dimensional texture image. - - -{{PageSyntax}} -: '''_glCopyTexImage2D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|internalFormat}}, GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLint {{Parameter|border}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcopyteximage2d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyTexImage1D]], [[_glDrawPixels]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCopyTexSubImage1D__0010001001001000011.txt b/internal/help/_glCopyTexSubImage1D__0010001001001000011.txt deleted file mode 100644 index 11b62e94a..000000000 --- a/internal/help/_glCopyTexSubImage1D__0010001001001000011.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:51}} -{{DISPLAYTITLE:_glCopyTexSubImage1D}} -The '''_glCopyTexSubImage1D''' statement copies a sub-image of a one-dimensional texture image from the framebuffer. - - -{{PageSyntax}} -: '''_glCopyTexSubImage1D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|xoffset}}, GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcopytexsubimage1d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyTexSubImage2D]], [[_glDrawPixels]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [[_glTexImage2D]], [[_glTexSubImage1D]] -* [[_glTexSubImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCopyTexSubImage2D__0010001001001000021.txt b/internal/help/_glCopyTexSubImage2D__0010001001001000021.txt deleted file mode 100644 index 0b56d084b..000000000 --- a/internal/help/_glCopyTexSubImage2D__0010001001001000021.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:54}} -{{DISPLAYTITLE:_glCopyTexSubImage2D}} -The '''_glCopyTexSubImage2D''' statement copies a sub-image of a two-dimensional texture image from the framebuffer. - - -{{PageSyntax}} -: '''_glCopyTexSubImage2D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|xoffset}}, GLint {{Parameter|yoffset}}, GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcopytexsubimage2d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyPixels]], [[_glCopyTexSubImage1D]], [[_glDrawPixels]] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage2D]], [[_glTexSubImage2D]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glCullFace__0010001000.txt b/internal/help/_glCullFace__0010001000.txt deleted file mode 100644 index dc04a126a..000000000 --- a/internal/help/_glCullFace__0010001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:56}} -{{DISPLAYTITLE:_glCullFace}} -The '''_glCullFace''' statement specifies whether front-facing or back-facing facets can be culled. - - -{{PageSyntax}} -: '''_glCullFace''' GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glcullface Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDisable]], [[_glEnable]], [[_glEnd]] -* [[_glFrontFace]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsEnabled]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDeleteLists__0010000010000.txt b/internal/help/_glDeleteLists__0010000010000.txt deleted file mode 100644 index 58fe44f76..000000000 --- a/internal/help/_glDeleteLists__0010000010000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:47:58}} -{{DISPLAYTITLE:_glDeleteLists}} -The '''_glDeleteLists''' statement deletes a contiguous group of display lists. - - -{{PageSyntax}} -: '''_glDeleteLists''' GLuint {{Parameter|list}}, GLsizei {{Parameter|range}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldeletelists Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCallList]], [[_glCallLists]], [[_glEnd]] -* [[_glGenLists]], [[_glIsList]], [[_glNewList]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDeleteTextures__0010000010000000.txt b/internal/help/_glDeleteTextures__0010000010000000.txt deleted file mode 100644 index 344c39411..000000000 --- a/internal/help/_glDeleteTextures__0010000010000000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:00}} -{{DISPLAYTITLE:_glDeleteTextures}} -The '''_glDeleteTextures''' statement deletes named textures. - - -{{PageSyntax}} -: '''_glDeleteTextures''' GLsizei {{Parameter|n}}, const GLuint {{Parameter|*textures}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldeletetextures Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAreTexturesResident]], [[_glBegin]], [[_glBindTexture]], [[_glEnd]] -* [[_glGenTextures]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexparameter _glGetTexParameter], [[_glIsTexture]] -* [[_glPrioritizeTextures]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [[_glTexImage2D]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDepthFunc__00100001000.txt b/internal/help/_glDepthFunc__00100001000.txt deleted file mode 100644 index 597912675..000000000 --- a/internal/help/_glDepthFunc__00100001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:02}} -{{DISPLAYTITLE:_glDepthFunc}} -The '''_glDepthFunc''' statement specifies the value used for depth-buffer comparisons. - - -{{PageSyntax}} -: '''_glDepthFunc''' GLenum {{Parameter|func}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldepthfunc Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDepthRange]], [[_glEnable]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIsEnabled]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDepthMask__00100001000.txt b/internal/help/_glDepthMask__00100001000.txt deleted file mode 100644 index 6389d57ac..000000000 --- a/internal/help/_glDepthMask__00100001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:05}} -{{DISPLAYTITLE:_glDepthMask}} -The '''_glDepthMask''' statement enables or disables writing into the depth buffer. - - -{{PageSyntax}} -: '''_glDepthMask''' GLboolean {{Parameter|flag}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldepthmask Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glColorMask]], [[_glDepthFunc]], [[_glDepthRange]] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIndexMask]], [[_glStencilMask]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDepthRange__001000010000.txt b/internal/help/_glDepthRange__001000010000.txt deleted file mode 100644 index 0ff3e597a..000000000 --- a/internal/help/_glDepthRange__001000010000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:07}} -{{DISPLAYTITLE:_glDepthRange}} -The '''_glDepthRange''' statement specifies the mapping of z values from normalized device coordinates to window coordinates. - - -{{PageSyntax}} -: '''_glDepthRange''' GLclampd {{Parameter|zNear}}, GLclampd {{Parameter|zFar}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldepthrange Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDepthFunc]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] -* [[_glViewport]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDisableClientState__00100000010000010000.txt b/internal/help/_glDisableClientState__00100000010000010000.txt deleted file mode 100644 index dfdce673c..000000000 --- a/internal/help/_glDisableClientState__00100000010000010000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:11}} -{{DISPLAYTITLE:_glDisableClientState}} -The '''_glEnableClientState''' and '''_glDisableClientState''' statements enable and disable arrays respectively. - - -{{PageSyntax}} -: '''_glDisableClientState''' GLenum {{Parameter|array}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldisableclientstate Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glColorPointer]], [[_glDrawArrays]] -* [[_glDrawElements]], [[_glEdgeFlagPointer]], [[_glEnable]], [[_glEnableClientState]] -* [[_glEnd]], [[_glGetPointerv]], [[_glIndexPointer]], [[_glInterleavedArrays]] -* [[_glNormalPointer]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDisable__001000000.txt b/internal/help/_glDisable__001000000.txt deleted file mode 100644 index b33d690a0..000000000 --- a/internal/help/_glDisable__001000000.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:09}} -{{DISPLAYTITLE:_glDisable}} -The '''_glEnable''' and '''_glDisable''' statements enable or disable OpenGL capabilities. - - -{{PageSyntax}} -: '''_glDisable''' GLenum {{Parameter|cap}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldisable Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glArrayElement]], [[_glBegin]], [[_glBlendFunc]] -* [[_glClipPlane]], [[_glColorMaterial]], [[_glColorPointer]], [[_glCullFace]] -* [[_glDepthFunc]], [[_glDepthRange]], [[_glDrawArrays]], [[_glEdgeFlagPointer]] -* [[_glEnable]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalcoord-functions _glEvalCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalmesh-functions _glEvalMesh] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalpoint _glEvalPoint], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIndexPointer]] -* [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllight-functions _glLight], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllightmodel-functions _glLightModel], [[_glLineWidth]] -* [[_glLineStipple]], [[_glLogicOp]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmap1 _glMap1], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmap2 _glMap2] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial], [https://docs.microsoft.com/en-us/windows/win32/opengl/glnormal-functions _glNormal], [[_glNormalPointer]], [[_glPointSize]] -* [[_glPolygonMode]], [[_glPolygonStipple]], [[_glScissor]], [[_glStencilFunc]] -* [[_glStencilOp]], [[_glTexCoordPointer]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]] -* [[_glTexImage2D]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDrawArrays__001000100000.txt b/internal/help/_glDrawArrays__001000100000.txt deleted file mode 100644 index 6f9ef0553..000000000 --- a/internal/help/_glDrawArrays__001000100000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:14}} -{{DISPLAYTITLE:_glDrawArrays}} -The '''_glDrawArrays''' statement specifies multiple primitives to render. - - -{{PageSyntax}} -: '''_glDrawArrays''' GLenum {{Parameter|mode}}, GLint {{Parameter|first}}, GLsizei {{Parameter|count}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldrawarrays Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glColorPointer]], [[_glEdgeFlagPointer]] -* [[_glEnd]], [[_glGetPointerv]], [[_glGetString]], [[_glIndexPointer]] -* [[_glNormalPointer]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDrawBuffer__001000100000.txt b/internal/help/_glDrawBuffer__001000100000.txt deleted file mode 100644 index 40f50381f..000000000 --- a/internal/help/_glDrawBuffer__001000100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:16}} -{{DISPLAYTITLE:_glDrawBuffer}} -The '''_glDrawBuffer''' statement specifies which color buffers are to be drawn into. - - -{{PageSyntax}} -: '''_glDrawBuffer''' GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldrawbuffer Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBlendFunc]], [[_glColorMask]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIndexMask]], [[_glLogicOp]], [[_glReadBuffer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDrawElements__00100010000000.txt b/internal/help/_glDrawElements__00100010000000.txt deleted file mode 100644 index 18c6752c2..000000000 --- a/internal/help/_glDrawElements__00100010000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:19}} -{{DISPLAYTITLE:_glDrawElements}} -The '''_glDrawElements''' statement renders primitives from array data. - - -{{PageSyntax}} -: '''_glDrawElements''' GLenum {{Parameter|mode}}, GLsizei {{Parameter|count}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*indices}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldrawelements Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glColorPointer]], [[_glDrawArrays]] -* [[_glEdgeFlagPointer]], [[_glEnd]], [[_glGetPointerv]], [[_glIndexPointer]] -* [[_glNormalPointer]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glDrawPixels__001000100000.txt b/internal/help/_glDrawPixels__001000100000.txt deleted file mode 100644 index 489aec868..000000000 --- a/internal/help/_glDrawPixels__001000100000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:21}} -{{DISPLAYTITLE:_glDrawPixels}} -The '''_glDrawPixels''' statement writes a block of pixels to the framebuffer. - - -{{PageSyntax}} -: '''_glDrawPixels''' GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gldrawpixels Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glBegin]], [[_glBlendFunc]], [[_glCopyPixels]] -* [[_glDepthFunc]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glLogicOp]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelmap _glPixelMap], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [[_glPixelZoom]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glrasterpos-functions _glRasterPos], [[_glReadPixels]], [[_glScissor]], [[_glStencilFunc]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEdgeFlagPointer__00100010001000000.txt b/internal/help/_glEdgeFlagPointer__00100010001000000.txt deleted file mode 100644 index cf6628889..000000000 --- a/internal/help/_glEdgeFlagPointer__00100010001000000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:28}} -{{DISPLAYTITLE:_glEdgeFlagPointer}} -The '''_glEdgeFlagPointer''' statement defines an array of edge flags. - - -{{PageSyntax}} -: '''_glEdgeFlagPointer''' GLsizei {{Parameter|stride}}, const GLvoid {{Parameter|*pointer}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflagpointer Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glColorPointer]], [[_glDrawArrays]] -* [[_glEnableClientState]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glGetPointerv]] -* [[_glGetString]], [[_glIndexPointer]], [[_glIsEnabled]], [[_glNormalPointer]] -* [[_glPopAttrib]], [[_glPushAttrib]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEdgeFlag__0010001000.txt b/internal/help/_glEdgeFlag__0010001000.txt deleted file mode 100644 index 4a1df4768..000000000 --- a/internal/help/_glEdgeFlag__0010001000.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:23}} -{{DISPLAYTITLE:_glEdgeFlag}} -The '''_glEdgeFlag''' statement flags edges as either boundary or nonboundary. - - -{{PageSyntax}} -: '''_glEdgeFlag''' GLboolean {{Parameter|flag}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflag Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEdgeFlagv__00100010000.txt b/internal/help/_glEdgeFlagv__00100010000.txt deleted file mode 100644 index d7f75bd5c..000000000 --- a/internal/help/_glEdgeFlagv__00100010000.txt +++ /dev/null @@ -1,28 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:26}} -{{DISPLAYTITLE:_glEdgeFlagv}} -The '''_glEdgeFlagv''' statement flags edges as either boundary or nonboundary. - - -{{PageSyntax}} -: '''_glEdgeFlagv''' const GLboolean {{Parameter|*flag}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflagv Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEnableClientState__0010000010000010000.txt b/internal/help/_glEnableClientState__0010000010000010000.txt deleted file mode 100644 index ad13a8c35..000000000 --- a/internal/help/_glEnableClientState__0010000010000010000.txt +++ /dev/null @@ -1,32 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:32}} -{{DISPLAYTITLE:_glEnableClientState}} -The '''_glEnableClientState''' and '''_glDisableClientState''' statements enable and disable arrays respectively. - - -{{PageSyntax}} -: '''_glEnableClientState''' GLenum {{Parameter|array}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glenableclientstate Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glArrayElement]], [[_glBegin]], [[_glColorPointer]], [[_glDisableClientState]] -* [[_glDrawArrays]], [[_glDrawElements]], [[_glEdgeFlagPointer]], [[_glEnable]] -* [[_glEnd]], [[_glGetPointerv]], [[_glIndexPointer]], [[_glInterleavedArrays]] -* [[_glNormalPointer]], [[_glTexCoordPointer]], [[_glVertexPointer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEnable__00100000.txt b/internal/help/_glEnable__00100000.txt deleted file mode 100644 index ba8aa4fd3..000000000 --- a/internal/help/_glEnable__00100000.txt +++ /dev/null @@ -1,39 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:30}} -{{DISPLAYTITLE:_glEnable}} -The '''_glEnable''' and '''_glDisable''' statements enable or disable OpenGL capabilities. - - -{{PageSyntax}} -: '''_glEnable''' GLenum {{Parameter|cap}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glenable Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glArrayElement]], [[_glBegin]], [[_glBlendFunc]] -* [[_glClipPlane]], [[_glColorMaterial]], [[_glColorPointer]], [[_glCullFace]] -* [[_glDepthFunc]], [[_glDepthRange]], [[_glDisable]], [[_glDrawArrays]] -* [[_glEdgeFlagPointer]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalcoord-functions _glEvalCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalmesh-functions _glEvalMesh] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalpoint _glEvalPoint], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIndexPointer]] -* [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllight-functions _glLight], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllightmodel-functions _glLightModel], [[_glLineWidth]] -* [[_glLineStipple]], [[_glLogicOp]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmap1 _glMap1], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmap2 _glMap2] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial], [https://docs.microsoft.com/en-us/windows/win32/opengl/glnormal-functions _glNormal], [[_glNormalPointer]], [[_glPointSize]] -* [[_glPolygonMode]], [[_glPolygonStipple]], [[_glScissor]], [[_glStencilFunc]] -* [[_glStencilOp]], [[_glTexCoordPointer]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]] -* [[_glTexImage2D]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEndList__001001000.txt b/internal/help/_glEndList__001001000.txt deleted file mode 100644 index a13351ba7..000000000 --- a/internal/help/_glEndList__001001000.txt +++ /dev/null @@ -1,24 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:36}} -{{DISPLAYTITLE:_glEndList}} -The '''_glNewList''' and '''_glEndList''' statements create or replace a display list. - - -{{PageSyntax}} -: '''_glEndList''' - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glendlist Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCallList]], [[_glCallLists]], [[_glDeleteLists]] -* [[_glEnd]], [[_glGenLists]], [[_glIsList]], [[_glNewList]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glEnd__00100.txt b/internal/help/_glEnd__00100.txt deleted file mode 100644 index 2f4493ca4..000000000 --- a/internal/help/_glEnd__00100.txt +++ /dev/null @@ -1,25 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:35}} -{{DISPLAYTITLE:_glEnd}} -The '''_glBegin''' and '''_glEnd''' statements delimit the vertices of a primitive or a group of like primitives. - - -{{PageSyntax}} -: '''_glEnd''' - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glend Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCallLists]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glcolor-functions _glColor], [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflag-functions _glEdgeFlag] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalcoord-functions _glEvalCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glevalpoint _glEvalPoint], [https://docs.microsoft.com/en-us/windows/win32/opengl/glindex-functions _glIndex], [https://docs.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glnormal-functions _glNormal], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexcoord-functions _glTexCoord], [https://docs.microsoft.com/en-us/windows/win32/opengl/glvertex-functions _glVertex] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glFeedbackBuffer__0010000000100000.txt b/internal/help/_glFeedbackBuffer__0010000000100000.txt deleted file mode 100644 index dc9d2502c..000000000 --- a/internal/help/_glFeedbackBuffer__0010000000100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:50}} -{{DISPLAYTITLE:_glFeedbackBuffer}} -The '''_glFeedbackBuffer''' statement controls feedback mode. - - -{{PageSyntax}} -: '''_glFeedbackBuffer''' GLsizei {{Parameter|size}}, GLenum {{Parameter|type}}, GLfloat {{Parameter|*buffer}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glfeedbackbuffer Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glLineStipple]] -* [[_glPassThrough]], [[_glPolygonMode]], [[_glRenderMode]], [[_glSelectBuffer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glFinish__00100000.txt b/internal/help/_glFinish__00100000.txt deleted file mode 100644 index ddd2879c6..000000000 --- a/internal/help/_glFinish__00100000.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:52}} -{{DISPLAYTITLE:_glFinish}} -The '''_glFinish''' statement blocks until all OpenGL execution is complete. - - -{{PageSyntax}} -: '''_glFinish''' - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glfinish Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [[_glFlush]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glFlush__0010000.txt b/internal/help/_glFlush__0010000.txt deleted file mode 100644 index 35abb8033..000000000 --- a/internal/help/_glFlush__0010000.txt +++ /dev/null @@ -1,23 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:53}} -{{DISPLAYTITLE:_glFlush}} -The '''_glFlush''' statement forces execution of OpenGL functions in finite time. - - -{{PageSyntax}} -: '''_glFlush''' - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glflush Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [[_glFinish]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glFrontFace__00100001000.txt b/internal/help/_glFrontFace__00100001000.txt deleted file mode 100644 index 1c70d8dab..000000000 --- a/internal/help/_glFrontFace__00100001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:48:59}} -{{DISPLAYTITLE:_glFrontFace}} -The '''_glFrontFace''' statement defines front-facing and back-facing polygons. - - -{{PageSyntax}} -: '''_glFrontFace''' GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glfrontface Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCullFace]], [[_glDisable]], [[_glEnable]] -* [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/gllightmodel-functions _glLightModel] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glFrustum__001000000.txt b/internal/help/_glFrustum__001000000.txt deleted file mode 100644 index 048a85b5e..000000000 --- a/internal/help/_glFrustum__001000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:01}} -{{DISPLAYTITLE:_glFrustum}} -The '''_glFrustum''' statement multiplies the current matrix by a perspective matrix. - - -{{PageSyntax}} -: '''_glFrustum''' GLdouble {{Parameter|left}}, GLdouble {{Parameter|right}}, GLdouble {{Parameter|bottom}}, GLdouble {{Parameter|top}}, GLdouble {{Parameter|zNear}}, GLdouble {{Parameter|zFar}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glfrustum Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glMatrixMode]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glmultmatrix _glMultMatrix], [[_glOrtho]], [[_glPopMatrix]], [[_glPushMatrix]] -* [[_glViewport]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glGenTextures__0010010000000.txt b/internal/help/_glGenTextures__0010010000000.txt deleted file mode 100644 index 23d366a2a..000000000 --- a/internal/help/_glGenTextures__0010010000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:04}} -{{DISPLAYTITLE:_glGenTextures}} -The '''_glGenTextures''' statement generates texture names. - - -{{PageSyntax}} -: '''_glGenTextures''' GLsizei {{Parameter|n}}, GLuint {{Parameter|*textures}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glgentextures Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBindTexture]], [[_glDeleteTextures]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexparameter _glGetTexParameter], [[_glIsTexture]], [[_glTexImage1D]] -* [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glGetError__0010010000.txt b/internal/help/_glGetError__0010010000.txt deleted file mode 100644 index b750cfbf4..000000000 --- a/internal/help/_glGetError__0010010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:10}} -{{DISPLAYTITLE:_glGetError}} -The '''_glGetError''' function returns error information. - - -{{PageSyntax}} -: GLenum {{Parameter|result}} = '''_glGetError''' - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glgeterror Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glGetString__00100100000.txt b/internal/help/_glGetString__00100100000.txt deleted file mode 100644 index 5dc3ff9f0..000000000 --- a/internal/help/_glGetString__00100100000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:29}} -{{DISPLAYTITLE:_glGetString}} -The '''_glGetString''' function returns a string describing the current OpenGL connection. - - -{{PageSyntax}} -: const GLubyte {{Parameter|*result}} = '''_glGetString''' (GLenum {{Parameter|name}}) - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetstring Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glGetTexImage__0010010010000.txt b/internal/help/_glGetTexImage__0010010010000.txt deleted file mode 100644 index 8313a8d67..000000000 --- a/internal/help/_glGetTexImage__0010010010000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:36}} -{{DISPLAYTITLE:_glGetTexImage}} -The '''_glGetTexImage''' statement returns a texture image. - - -{{PageSyntax}} -: '''_glGetTexImage''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetteximage Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDrawPixels]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexlevelparameter _glGetTexLevelParameter] -* [[_glReadPixels]], [[_glTexImage1D]], [[_glTexImage2D]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glHint__001000.txt b/internal/help/_glHint__001000.txt deleted file mode 100644 index 2fc6317f3..000000000 --- a/internal/help/_glHint__001000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:49:43}} -{{DISPLAYTITLE:_glHint}} -The '''_glHint''' statement specifies implementation-specific hints. - - -{{PageSyntax}} -: '''_glHint''' GLenum {{Parameter|target}}, GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glhint Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnd]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glIsEnabled__00101000000.txt b/internal/help/_glIsEnabled__00101000000.txt deleted file mode 100644 index 2de55cbb2..000000000 --- a/internal/help/_glIsEnabled__00101000000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:50:00}} -{{DISPLAYTITLE:_glIsEnabled}} -The '''_glIsEnabled''' function tests whether a capability is enabled. - - -{{PageSyntax}} -: GLboolean {{Parameter|result}} = '''_glIsEnabled''' (GLenum {{Parameter|cap}}) - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glisenabled Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnable]], [[_glEnd]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glIsTexture__00101000000.txt b/internal/help/_glIsTexture__00101000000.txt deleted file mode 100644 index 9164596fe..000000000 --- a/internal/help/_glIsTexture__00101000000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:50:03}} -{{DISPLAYTITLE:_glIsTexture}} -The '''_glIsTexture''' function determines if a name corresponds to a texture. - - -{{PageSyntax}} -: GLboolean {{Parameter|result}} = '''_glIsTexture''' (GLuint {{Parameter|texture}}) - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glistexture Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glBindTexture]], [[_glEnd]], [[_glGenTextures]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgettexparameter _glGetTexParameter], [[_glTexImage1D]], [[_glTexImage2D]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glLineWidth__00100010000.txt b/internal/help/_glLineWidth__00100010000.txt deleted file mode 100644 index 929b438da..000000000 --- a/internal/help/_glLineWidth__00100010000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:50:16}} -{{DISPLAYTITLE:_glLineWidth}} -The '''_glLineWidth''' statement specifies the width of rasterized lines. - - -{{PageSyntax}} -: '''_glLineWidth''' GLfloat {{Parameter|width}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gllinewidth Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnable]], [[_glEnd]], [[_glIsEnabled]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glLogicOp__001000010.txt b/internal/help/_glLogicOp__001000010.txt deleted file mode 100644 index 85a0b9aff..000000000 --- a/internal/help/_glLogicOp__001000010.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:50:23}} -{{DISPLAYTITLE:_glLogicOp}} -The '''_glLogicOp''' statement specifies a logical pixel operation for color index rendering. - - -{{PageSyntax}} -: '''_glLogicOp''' GLenum {{Parameter|opcode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gllogicop Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glBegin]], [[_glBlendFunc]], [[_glDrawBuffer]] -* [[_glEnable]], [[_glEnd]], [[_glIsEnabled]], [[_glStencilOp]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glPointSize__00100001000.txt b/internal/help/_glPointSize__00100001000.txt deleted file mode 100644 index f967cebb0..000000000 --- a/internal/help/_glPointSize__00100001000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:51:05}} -{{DISPLAYTITLE:_glPointSize}} -The '''_glPointSize''' statement specifies the diameter of rasterized points. - - -{{PageSyntax}} -: '''_glPointSize''' GLfloat {{Parameter|size}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glpointsize Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnable]], [[_glEnd]], [[_glIsEnabled]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glPolygonMode__0010000001000.txt b/internal/help/_glPolygonMode__0010000001000.txt deleted file mode 100644 index 067ec2f2b..000000000 --- a/internal/help/_glPolygonMode__0010000001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:51:07}} -{{DISPLAYTITLE:_glPolygonMode}} -The '''_glPolygonMode''' statement selects a polygon rasterization mode. - - -{{PageSyntax}} -: '''_glPolygonMode''' GLenum {{Parameter|face}}, GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glpolygonmode Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gledgeflag-functions _glEdgeFlag], [[_glEnd]], [[_glLineStipple]] -* [[_glLineWidth]], [[_glPointSize]], [[_glPolygonStipple]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glPolygonOffset__001000000100000.txt b/internal/help/_glPolygonOffset__001000000100000.txt deleted file mode 100644 index 5cd012817..000000000 --- a/internal/help/_glPolygonOffset__001000000100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:51:10}} -{{DISPLAYTITLE:_glPolygonOffset}} -The '''_glPolygonOffset''' statement sets the scale and units OpenGL uses to calculate depth values. - - -{{PageSyntax}} -: '''_glPolygonOffset''' GLfloat {{Parameter|factor}}, GLfloat {{Parameter|units}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glpolygonoffset Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glDepthFunc]], [[_glDisable]], [[_glEnable]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet] -* [[_glIsEnabled]], [[_glLineWidth]], [[_glStencilOp]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glReadBuffer__001000100000.txt b/internal/help/_glReadBuffer__001000100000.txt deleted file mode 100644 index 49164eeeb..000000000 --- a/internal/help/_glReadBuffer__001000100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:51:50}} -{{DISPLAYTITLE:_glReadBuffer}} -The '''_glReadBuffer''' statement selects a color buffer source for pixels. - - -{{PageSyntax}} -: '''_glReadBuffer''' GLenum {{Parameter|mode}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glreadbuffer Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyPixels]], [[_glDrawBuffer]], [[_glEnd]] -* [[_glReadPixels]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glReadPixels__001000100000.txt b/internal/help/_glReadPixels__001000100000.txt deleted file mode 100644 index e86f1d9bb..000000000 --- a/internal/help/_glReadPixels__001000100000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:51:52}} -{{DISPLAYTITLE:_glReadPixels}} -The '''_glReadPixels''' statement reads a block of pixels from the framebuffer. - - -{{PageSyntax}} -: '''_glReadPixels''' GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glreadpixels Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyPixels]], [[_glDrawPixels]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelmap _glPixelMap], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [[_glReadBuffer]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glScissor__001000000.txt b/internal/help/_glScissor__001000000.txt deleted file mode 100644 index 654f63a72..000000000 --- a/internal/help/_glScissor__001000000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:52:09}} -{{DISPLAYTITLE:_glScissor}} -The '''_glScissor''' statement defines the scissor box. - - -{{PageSyntax}} -: '''_glScissor''' GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glscissor Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glEnable]], [[_glEnd]], [[_glIsEnabled]] -* [[_glViewport]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glStencilFunc__0010000001000.txt b/internal/help/_glStencilFunc__0010000001000.txt deleted file mode 100644 index 240a7d2fe..000000000 --- a/internal/help/_glStencilFunc__0010000001000.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:52:14}} -{{DISPLAYTITLE:_glStencilFunc}} -The '''_glStencilFunc''' statement sets the statement and reference value for stencil testing. - - -{{PageSyntax}} -: '''_glStencilFunc''' GLenum {{Parameter|func}}, GLint {{Parameter|ref}}, GLuint {{Parameter|mask}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glstencilfunc Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glBegin]], [[_glBlendFunc]], [[_glDepthFunc]] -* [[_glEnable]], [[_glEnd]], [[_glIsEnabled]], [[_glLogicOp]] -* [[_glStencilOp]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glStencilMask__0010000001000.txt b/internal/help/_glStencilMask__0010000001000.txt deleted file mode 100644 index ddcb329b6..000000000 --- a/internal/help/_glStencilMask__0010000001000.txt +++ /dev/null @@ -1,30 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:52:16}} -{{DISPLAYTITLE:_glStencilMask}} -The '''_glStencilMask''' statement controls the writing of individual bits in the stencil planes. - - -{{PageSyntax}} -: '''_glStencilMask''' GLuint {{Parameter|mask}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glstencilmask Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glColorMask]], [[_glDepthMask]], [[_glEnd]] -* [[_glIndexMask]], [[_glStencilFunc]], [[_glStencilOp]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glStencilOp__00100000010.txt b/internal/help/_glStencilOp__00100000010.txt deleted file mode 100644 index 71be2fd5e..000000000 --- a/internal/help/_glStencilOp__00100000010.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:52:18}} -{{DISPLAYTITLE:_glStencilOp}} -The '''_glStencilOp''' statement sets the stencil test actions. - - -{{PageSyntax}} -: '''_glStencilOp''' GLenum {{Parameter|fail}}, GLenum {{Parameter|zfail}}, GLenum {{Parameter|zpass}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glstencilop Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glAlphaFunc]], [[_glBegin]], [[_glBlendFunc]], [[_glDepthFunc]] -* [[_glEnable]], [[_glEnd]], [[_glIsEnabled]], [[_glLogicOp]] -* [[_glStencilFunc]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glTexImage1D__001001000011.txt b/internal/help/_glTexImage1D__001001000011.txt deleted file mode 100644 index f6663fbcc..000000000 --- a/internal/help/_glTexImage1D__001001000011.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:07}} -{{DISPLAYTITLE:_glTexImage1D}} -The '''_glTexImage1D''' statement specifies a one-dimensional texture image. - - -{{PageSyntax}} -: '''_glTexImage1D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|internalformat}}, GLsizei {{Parameter|width}}, GLint {{Parameter|border}}, GLint {{Parameter|format}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glteximage1d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glCopyPixels]], [[_glCopyTexImage1D]], [[_glCopyTexImage2D]] -* [[_glCopyTexSubImage1D]], [[_glCopyTexSubImage2D]], [[_glDrawPixels]], [[_glEnd]] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [[_glGetTexImage]], [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage2D]] -* [[_glTexSubImage1D]], [[_glTexSubImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glTexImage2D__001001000021.txt b/internal/help/_glTexImage2D__001001000021.txt deleted file mode 100644 index 7ef1ac521..000000000 --- a/internal/help/_glTexImage2D__001001000021.txt +++ /dev/null @@ -1,31 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:10}} -{{DISPLAYTITLE:_glTexImage2D}} -The '''_glTexImage2D''' statement specifies a two-dimensional texture image. - - -{{PageSyntax}} -: '''_glTexImage2D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|internalformat}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLint {{Parameter|border}}, GLint {{Parameter|format}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glteximage2d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDrawPixels]], [[_glEnd]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog] -* [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glTexSubImage1D__001001001000011.txt b/internal/help/_glTexSubImage1D__001001001000011.txt deleted file mode 100644 index 10e0cfa5e..000000000 --- a/internal/help/_glTexSubImage1D__001001001000011.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:16}} -{{DISPLAYTITLE:_glTexSubImage1D}} -The '''_glTexSubImage1D''' statement specifies a portion of an existing one-dimensional texture image. You cannot define a new texture with '''_glTexSubImage1D'''. - - -{{PageSyntax}} -: '''_glTexSubImage1D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|xoffset}}, GLsizei {{Parameter|width}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexsubimage1d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glCopyTexImage1D]], [[_glCopyTexImage2D]], [[_glCopyTexSubImage1D]], [[_glCopyTexSubImage2D]] -* [[_glDrawPixels]], [[_glEnable]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [[_glGetTexImage]] -* [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] -* [[_glTexSubImage2D]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glTexSubImage2D__001001001000021.txt b/internal/help/_glTexSubImage2D__001001001000021.txt deleted file mode 100644 index 1be7648db..000000000 --- a/internal/help/_glTexSubImage2D__001001001000021.txt +++ /dev/null @@ -1,33 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:18}} -{{DISPLAYTITLE:_glTexSubImage2D}} -The '''_glTexSubImage2D''' statement specifies a portion of an existing one-dimensional texture image. You cannot define a new texture with '''_glTexSubImage2D'''. - - -{{PageSyntax}} -: '''_glTexSubImage2D''' GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLint {{Parameter|xoffset}}, GLint {{Parameter|yoffset}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, const GLvoid {{Parameter|*pixels}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexsubimage2d Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glCopyTexImage1D]], [[_glCopyTexImage2D]], [[_glCopyTexSubImage1D]], [[_glCopyTexSubImage2D]] -* [[_glDrawPixels]], [[_glEnable]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [[_glGetTexImage]] -* [[_glIsEnabled]], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixelstore-functions _glPixelStore], [https://docs.microsoft.com/en-us/windows/win32/opengl/glpixeltransfer _glPixelTransfer], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexenv-functions _glTexEnv] -* [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]], [[_glTexImage2D]], [[_glTexSubImage1D]] -* [[_glTexImage2D]], [https://docs.microsoft.com/en-us/windows/win32/opengl/gltexparameter-functions _glTexParameter] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/_glViewport__0010000000.txt b/internal/help/_glViewport__0010000000.txt deleted file mode 100644 index 03aa0e2e5..000000000 --- a/internal/help/_glViewport__0010000000.txt +++ /dev/null @@ -1,29 +0,0 @@ -{{QBDLDATE:07-31-2022}} -{{QBDLTIME:23:53:50}} -{{DISPLAYTITLE:_glViewport}} -The '''_glViewport''' statement sets the viewport. - - -{{PageSyntax}} -: '''_glViewport''' GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}} - - -{{PageParameters}} -* OpenGL is using its own set of variable types to describe its command parameters. -* Use the following table to find the respective QB64 [[Variable Types]]. -{{OpenGLTypesPlugin}} - - -{{PageDescription}} -* OpenGL's documentation is available in several places, so we won't reproduce it here for another time. -* The full description for this command can be found at [https://docs.microsoft.com/en-us/windows/win32/opengl/glviewport Microsoft Docs] and is also valid for QB64 usage. - - -{{PageSeeAlso}} -* [[_GL|SUB _GL]] -* [[_glBegin]], [[_glDepthRange]] - - -{{PageNavigation}} - -[[Category:Final]] diff --git a/internal/help/links.bin b/internal/help/links.bin deleted file mode 100644 index 89af81ffc..000000000 --- a/internal/help/links.bin +++ /dev/null @@ -1,922 +0,0 @@ -_ACCEPTFILEDROP,_ACCEPTFILEDROP -_ACOS,_ACOS -_ACOSH,_ACOSH -_ALLOWFULLSCREEN,_ALLOWFULLSCREEN -_ALPHA,_ALPHA -_ALPHA32,_ALPHA32 -_ARCCOT,Mathematical Operations -_ARCCSC,Mathematical Operations -_ARCSEC,Mathematical Operations -_ASIN,_ASIN -_ASINH,_ASINH -_ASSERT,_ASSERT -$ASSERTS,$ASSERTS -_ATAN2,_ATAN2 -_ATANH,_ATANH -_AUTODISPLAY,_AUTODISPLAY -_AUTODISPLAY,_AUTODISPLAY (function) -_AXIS,_AXIS -_BACKGROUNDCOLOR,_BACKGROUNDCOLOR -_BIT,_BIT -_BIN$,_BIN$ -_BLEND,_BLEND -_BLEND,_BLEND (function) -_BLINK,_BLINK -_BLINK,_BLINK (function) -_BLUE,_BLUE -_BLUE32,_BLUE32 -_BUTTON,_BUTTON -_BUTTONCHANGE,_BUTTONCHANGE -_BYTE,_BYTE -_CAPSLOCK,_CAPSLOCK (function) -_CAPSLOCK,_CAPSLOCK -$CHECKING,$CHECKING -_CEIL,_CEIL -_CINP,_CINP -_CLEARCOLOR,_CLEARCOLOR (function) -_CLEARCOLOR,_CLEARCOLOR -_CLIP,_CLIP -_CLIPBOARD$,_CLIPBOARD$ -_CLIPBOARD$,_CLIPBOARD$ (statement) -_CLIPBOARDIMAGE,_CLIPBOARDIMAGE (function) -_CLIPBOARDIMAGE,_CLIPBOARDIMAGE -$COLOR,$COLOR -_COMMANDCOUNT,_COMMANDCOUNT -_CONNECTED,_CONNECTED -_CONNECTIONADDRESS$,_CONNECTIONADDRESS$ -$CONSOLE,$CONSOLE -_CONSOLE,_CONSOLE -_CONSOLEINPUT,_CONSOLEINPUT -_CONSOLETITLE,_CONSOLETITLE -_CONTINUE,_CONTINUE -_CONTROLCHR,_CONTROLCHR -_CONTROLCHR,_CONTROLCHR (function) -_COPYIMAGE,_COPYIMAGE -_COPYPALETTE,_COPYPALETTE -_COT,Mathematical Operations -_COTH,Mathematical Operations -_COSH,Mathematical Operations -_CSC,Mathematical Operations -_CSCH,Mathematical Operations -_CV,_CV -_CWD$,_CWD$ -_D2G,_D2G -_D2R,_D2R -$DEBUG,$DEBUG -DECLARE,DECLARE LIBRARY -DECLARE,DECLARE DYNAMIC LIBRARY -_DEFAULTCOLOR,_DEFAULTCOLOR -_DEFINE,_DEFINE -_DEFLATE$,_DEFLATE$ -_DELAY,_DELAY -_DEPTHBUFFER,_DEPTHBUFFER -_DESKTOPHEIGHT,_DESKTOPHEIGHT -_DESKTOPWIDTH,_DESKTOPWIDTH -_DEST,_DEST -_DEST,_DEST (function) -_DEVICE$,_DEVICE$ -_DEVICEINPUT,_DEVICEINPUT -_DEVICES,_DEVICES -_DIR$,_DIR$ -_DIREXISTS,_DIREXISTS -_DISPLAY,_DISPLAY -_DISPLAY,_DISPLAY (function) -_DISPLAYORDER,_DISPLAYORDER -_DONTBLEND,_DONTBLEND -_DONTWAIT,_DONTWAIT -_DROPPEDFILE,_DROPPEDFILE -_ECHO,_ECHO -$ELSE,$ELSE -$ELSEIF,$ELSEIF -$END,$END IF -_ENVIRONCOUNT,_ENVIRONCOUNT -$ERROR,$ERROR -_ERRORLINE,_ERRORLINE -_ERRORMESSAGE$,_ERRORMESSAGE$ -$EXEICON,$EXEICON -_EXIT,_EXIT (function) -_FILEEXISTS,_FILEEXISTS -_FINISHDROP,_FINISHDROP -_FLOAT,_FLOAT -_FONT,_FONT -_FONT,_FONT (function) -_FONTHEIGHT,_FONTHEIGHT -_FONTWIDTH,_FONTWIDTH -_FREEFONT,_FREEFONT -_FREEIMAGE,_FREEIMAGE -_FREETIMER,_FREETIMER -_FULLSCREEN,_FULLSCREEN -_FULLSCREEN,_FULLSCREEN (function) -_G2D,_G2D -_G2R,_G2R -_GLRENDER,_GLRENDER -_GREEN,_GREEN -_GREEN32,_GREEN32 -_HEIGHT,_HEIGHT -_HIDE,_HIDE -_HYPOT,_HYPOT -$IF,$IF -_ICON,_ICON -_INCLERRORFILE$,_INCLERRORFILE$ -_INCLERRORLINE,_INCLERRORLINE -_INFLATE$,_INFLATE$ -_INSTRREV,_INSTRREV -_INTEGER64,_INTEGER64 -_KEYCLEAR,_KEYCLEAR -_KEYHIT,_KEYHIT -_KEYDOWN,_KEYDOWN -$LET,$LET -_LASTAXIS,_LASTAXIS -_LASTBUTTON,_LASTBUTTON -_LASTWHEEL,_LASTWHEEL -_LIMIT,_LIMIT -_LOADFONT,_LOADFONT -_LOADIMAGE,_LOADIMAGE -_MAPTRIANGLE,_MAPTRIANGLE -_MAPUNICODE,_MAPUNICODE -_MAPUNICODE,_MAPUNICODE (function) -_MEM,_MEM (function) -_MEM,_MEM -_MEMCOPY,_MEMCOPY -_MEMELEMENT,_MEMELEMENT -_MEMEXISTS,_MEMEXISTS -_MEMFILL,_MEMFILL -_MEMFREE,_MEMFREE -_MEMGET,_MEMGET -_MEMGET,_MEMGET (function) -_MEMIMAGE,_MEMIMAGE -_MEMNEW,_MEMNEW -_MEMPUT,_MEMPUT -_MEMSOUND,_MEMSOUND -_MIDDLE,_SCREENMOVE -_SCREENMOVE,_SCREENMOVE -_MK$,_MK$ -_MOUSEBUTTON,_MOUSEBUTTON -_MOUSEHIDE,_MOUSEHIDE -_MOUSEINPUT,_MOUSEINPUT -_MOUSEMOVE,_MOUSEMOVE -_MOUSEMOVEMENTX,_MOUSEMOVEMENTX -_MOUSEMOVEMENTY,_MOUSEMOVEMENTY -_MOUSESHOW,_MOUSESHOW -_MOUSEWHEEL,_MOUSEWHEEL -_MOUSEX,_MOUSEX -_MOUSEY,_MOUSEY -_NEWIMAGE,_NEWIMAGE -$NOPREFIX,$NOPREFIX -_NUMLOCK,_NUMLOCK (function) -_NUMLOCK,_NUMLOCK -_OFFSET,_OFFSET (function) -_OFFSET,_OFFSET -_OPENCLIENT,_OPENCLIENT -_OPENCONNECTION,_OPENCONNECTION -_OPENHOST,_OPENHOST -OPTION,OPTION _EXPLICIT -OPTION,OPTION _EXPLICITARRAY -_OS$,_OS$ -_PALETTECOLOR,_PALETTECOLOR -_PALETTECOLOR,_PALETTECOLOR (function) -_PI,_PI -_PIXELSIZE,_PIXELSIZE -_PRESERVE,_PRESERVE -_PRINTIMAGE,_PRINTIMAGE -_PRINTMODE,_PRINTMODE -_PRINTMODE,_PRINTMODE (function) -_PRINTSTRING,_PRINTSTRING -_PRINTWIDTH,_PRINTWIDTH -_PUTIMAGE,_PUTIMAGE -_R2D,_R2D -_R2G,_R2G -_RED,_RED -_RED32,_RED32 -_READBIT,_READBIT -_RESETBIT,_RESETBIT -$RESIZE,$RESIZE -_RESIZE,_RESIZE -_RESIZE,_RESIZE (function) -_RESIZEHEIGHT,_RESIZEHEIGHT -_RESIZEWIDTH,_RESIZEWIDTH -_RGB,_RGB -_RGB32,_RGB32 -_RGBA,_RGBA -_RGBA32,_RGBA32 -_ROUND,_ROUND -_SEC,Mathematical Operations -_SECH,Mathematical Operations -_SCREENCLICK,_SCREENCLICK -_SCREENEXISTS,_SCREENEXISTS -$SCREENHIDE,$SCREENHIDE -_SCREENHIDE,_SCREENHIDE -_SCREENICON,_SCREENICON (function) -_SCREENICON,_SCREENICON -_SCREENIMAGE,_SCREENIMAGE -_SCREENMOVE,_SCREENMOVE -_SCREENPRINT,_SCREENPRINT -$SCREENSHOW,$SCREENSHOW -_SCREENSHOW,_SCREENSHOW -_SCREENX,_SCREENX -_SCREENY,_SCREENY -_SCROLLLOCK,_SCROLLLOCK (function) -_SCROLLLOCK,_SCROLLLOCK -_SETALPHA,_SETALPHA -_SETBIT,_SETBIT -_SHELLHIDE,_SHELLHIDE -_SHL,_SHL -_SHR,_SHR -_SINH,Mathematical Operations -_SNDBAL,_SNDBAL -_SNDCLOSE,_SNDCLOSE -_SNDCOPY,_SNDCOPY -_SNDGETPOS,_SNDGETPOS -_SNDLEN,_SNDLEN -_SNDLIMIT,_SNDLIMIT -_SNDLOOP,_SNDLOOP -_SNDOPEN,_SNDOPEN -_SNDOPENRAW,_SNDOPENRAW -_SNDPAUSE,_SNDPAUSE -_SNDPAUSED,_SNDPAUSED -_SNDPLAY,_SNDPLAY -_SNDPLAYCOPY,_SNDPLAYCOPY -_SNDPLAYFILE,_SNDPLAYFILE -_SNDPLAYING,_SNDPLAYING -_SNDRATE,_SNDRATE -_SNDRAW,_SNDRAW -_SNDRAWDONE,_SNDRAWDONE -_SNDRAWLEN,_SNDRAWLEN -_SNDSETPOS,_SNDSETPOS -_SNDSTOP,_SNDSTOP -_SNDVOL,_SNDVOL -_SOURCE,_SOURCE -_SOURCE,_SOURCE (function) -_STARTDIR$,_STARTDIR$ -_STRCMP,_STRCMP -_STRICMP,_STRICMP -_TANH,Mathematical Operations -_TITLE,_TITLE -_TITLE$,_TITLE$ -_TOGGLEBIT,_TOGGLEBIT -_TOTALDROPPEDFILES,_TOTALDROPPEDFILES -_TRIM$,_TRIM$ -_UNSIGNED,_UNSIGNED -$VERSIONINFO,$VERSIONINFO -$VIRTUALKEYBOARD,$VIRTUALKEYBOARD -_WHEEL,_WHEEL -_WIDTH,_WIDTH (function) -_WINDOWHANDLE,_WINDOWHANDLE -_WINDOWHASFOCUS,_WINDOWHASFOCUS -ABS,ABS -ABSOLUTE,CALL ABSOLUTE -CALL,CALL ABSOLUTE -ACCESS,ACCESS -ALIAS,ALIAS -AND,AND -AND,AND (boolean) -APPEND,APPEND -AS,AS -ASC,ASC -ASC,ASC (statement) -ATN,ATN -BEEP,BEEP -BINARY,BINARY -BLOAD,BLOAD -BSAVE,BSAVE -BYVAL,BYVAL -CALL,CALL -CALL,CALL ABSOLUTE -CASE,CASE -CASE,CASE ELSE -CASE,CASE IS -CDBL,CDBL -CHAIN,CHAIN -CHDIR,CHDIR -CHR$,CHR$ -CINT,CINT -CIRCLE,CIRCLE -CLEAR,CLEAR -CLNG,CLNG -CLOSE,CLOSE -CLS,CLS -COLOR,COLOR -COMMAND$,COMMAND$ -COMMON,COMMON -CONST,CONST -COS,COS -CSNG,CSNG -CSRLIN,CSRLIN -CVD,CVD -CVDMBF,CVDMBF -CVI,CVI -CVL,CVL -CVS,CVS -CVSMBF,CVSMBF -DATA,DATA -DATE$,DATE$ -DECLARE,DECLARE LIBRARY -DECLARE,DECLARE DYNAMIC LIBRARY -DEF,DEF SEG -DEFDBL,DEFDBL -DEFINT,DEFINT -DEFLNG,DEFLNG -DEFSNG,DEFSNG -DEFSTR,DEFSTR -DIM,DIM -LOOP,DO...LOOP -DO,DO...LOOP -LOOP,DO...LOOP -DOUBLE,DOUBLE -DRAW,DRAW -$DYNAMIC,$DYNAMIC -ELSE,ELSE -ELSEIF,ELSEIF -END,END -END,IF...THEN -THEN,IF...THEN -IF,IF...THEN -ENVIRON,ENVIRON -ENVIRON$,ENVIRON$ -EOF,EOF -EQV,EQV -ERASE,ERASE -ERL,ERL -ERR,ERR -ERROR,ERROR -EXIT,EXIT -EXP,EXP -FIELD,FIELD -FILES,FILES -FIX,FIX -NEXT,FOR...NEXT -FOR,FOR...NEXT -NEXT,FOR...NEXT -FOR,FOR (file statement) -FREE,TIMER (statement) -TIMER,TIMER (statement) -FREEFILE,FREEFILE -FUNCTION,FUNCTION -GET,GET -GET,GET (TCP/IP statement) -GET,GET (graphics statement) -GOSUB,GOSUB -GOTO,GOTO -HEX$,HEX$ -THEN,IF...THEN -IF,IF...THEN -THEN,IF...THEN -IMP,IMP -$INCLUDE,$INCLUDE -INKEY$,INKEY$ -INP,INP -INPUT,INPUT -INPUT,INPUT (file mode) -INPUT,INPUT (file statement) -INPUT$,INPUT$ -INSTR,INSTR -INT,INT -INTEGER,INTEGER -INTERRUPT,INTERRUPT -INTERRUPTX,INTERRUPTX -KEY,KEY n -KEY,KEY(n) -KEY,KEY LIST -KILL,KILL -LBOUND,LBOUND -LCASE$,LCASE$ -LEFT$,LEFT$ -LEN,LEN -LET,LET -LINE,LINE -LINE,LINE INPUT -LINE,LINE INPUT (file statement) -LIST,KEY LIST -KEY,KEY LIST -LOC,LOC -LOCATE,LOCATE -LOCK,LOCK -LOF,LOF -LOG,LOG -LONG,LONG -LOOP,DO...LOOP -LOOP,DO...LOOP -DO,DO...LOOP -LPOS,LPOS -LPRINT,LPRINT -LPRINT,LPRINT USING -LSET,LSET -LTRIM$,LTRIM$ -MID$,MID$ -MID$,MID$ (statement) -MKD$,MKD$ -MKDIR,MKDIR -MKDMBF$,MKDMBF$ -MKI$,MKI$ -MKL$,MKL$ -MKS$,MKS$ -MKSMBF$,MKSMBF$ -MOD,MOD -NAME,NAME -NEXT,NEXT -NOT,NOT -OCT$,OCT$ -OFF,OFF -ON,ON COM(n) -ON,ON ERROR -ON,ON KEY(n) -ON,ON PEN -ON,ON PLAY(n) -ON,ON STRIG(n) -ON,ON TIMER(n) -ON,ON UEVENT -GOSUB,ON...GOSUB -ON,ON...GOSUB -GOSUB,ON...GOSUB -GOTO,ON...GOTO -ON,ON...GOTO -GOTO,ON...GOTO -OPEN,OPEN -OPEN,OPEN COM -OPTION,OPTION BASE -OR,OR -OR,OR (boolean) -OUT,OUT -OUTPUT,OUTPUT -PAINT,PAINT -PALETTE,PALETTE -PALETTE,PALETTE USING -PCOPY,PCOPY -PEEK,PEEK -PEN,PEN -PEN,PEN (statement) -PLAY,PLAY(n) -PLAY,PLAY -PMAP,PMAP -POINT,POINT -POKE,POKE -POS,POS -PRESET,PRESET -PRINT,PRINT -PRINT,PRINT (file statement) -PRINT,PRINT USING -PRINT,PRINT USING (file statement) -PSET,PSET -PUT,PUT -PUT,PUT (TCP/IP statement) -PUT,PUT (graphics statement) -RANDOM,RANDOM -RANDOMIZE,RANDOMIZE -RANDOMIZE,RANDOMIZE -READ,READ -REDIM,REDIM -REM,REM -RESET,RESET -RESTORE,RESTORE -RESUME,RESUME -RETURN,RETURN -RIGHT$,RIGHT$ -RMDIR,RMDIR -RND,RND -RSET,RSET -RTRIM$,RTRIM$ -RUN,RUN -SADD,SADD -SCREEN,SCREEN (function) -SCREEN,SCREEN -SEEK,SEEK -SEEK,SEEK (statement) -SELECT,SELECT CASE -SGN,SGN -SHARED,SHARED -SHELL,SHELL -SHELL,SHELL (function) -SIN,SIN -SINGLE,SINGLE -SLEEP,SLEEP -SOUND,SOUND -SPACE$,SPACE$ -SPC,SPC -SQR,SQR -STATIC,STATIC -$STATIC,$STATIC -STEP,STEP -STICK,STICK -STOP,STOP -STR$,STR$ -STRIG,STRIG -STRIG,STRIG(n) -STRING,STRING -STRING$,STRING$ -SUB,SUB -SWAP,SWAP -SYSTEM,SYSTEM -TAB,TAB -TAN,TAN -THEN,THEN -TIME$,TIME$ -TIMER,TIMER -TIMER,TIMER (statement) -TO,TO -TYPE,TYPE -UBOUND,UBOUND -UCASE$,UCASE$ -UEVENT,UEVENT -UNLOCK,UNLOCK -UNTIL,UNTIL -VAL,VAL -VARPTR,VARPTR -VARPTR$,VARPTR$ -VARSEG,VARSEG -VIEW,VIEW -VIEW,VIEW PRINT -WAIT,WAIT -WEND,WEND -WHILE,WHILE -WEND,WHILE...WEND -WHILE,WHILE...WEND -WEND,WHILE...WEND -WIDTH,WIDTH -WINDOW,WINDOW -WRITE,WRITE -WRITE,WRITE (file statement) -XOR,XOR -_glAccum,_glAccum -_glAlphaFunc,_glAlphaFunc -_glAreTexturesResident,_glAreTexturesResident -_glArrayElement,_glArrayElement -_glBegin,_glBegin -_glBindTexture,_glBindTexture -_glBitmap,_glBitmap -_glBlendFunc,_glBlendFunc -_glCallList,_glCallList -_glCallLists,_glCallLists -_glClear,_glClear -_glClearAccum,_glClearAccum -_glClearColor,_glClearColor -_glClearDepth,_glClearDepth -_glClearIndex,_glClearIndex -_glClearStencil,_glClearStencil -_glClipPlane,_glClipPlane -_glColor3b,_glColor3b -_glColor3bv,_glColor3bv -_glColor3d,_glColor3d -_glColor3dv,_glColor3dv -_glColor3f,_glColor3f -_glColor3fv,_glColor3fv -_glColor3i,_glColor3i -_glColor3iv,_glColor3iv -_glColor3s,_glColor3s -_glColor3sv,_glColor3sv -_glColor3ub,_glColor3ub -_glColor3ubv,_glColor3ubv -_glColor3ui,_glColor3ui -_glColor3uiv,_glColor3uiv -_glColor3us,_glColor3us -_glColor3usv,_glColor3usv -_glColor4b,_glColor4b -_glColor4bv,_glColor4bv -_glColor4d,_glColor4d -_glColor4dv,_glColor4dv -_glColor4f,_glColor4f -_glColor4fv,_glColor4fv -_glColor4i,_glColor4i -_glColor4iv,_glColor4iv -_glColor4s,_glColor4s -_glColor4sv,_glColor4sv -_glColor4ub,_glColor4ub -_glColor4ubv,_glColor4ubv -_glColor4ui,_glColor4ui -_glColor4uiv,_glColor4uiv -_glColor4us,_glColor4us -_glColor4usv,_glColor4usv -_glColorMask,_glColorMask -_glColorMaterial,_glColorMaterial -_glColorPointer,_glColorPointer -_glCopyPixels,_glCopyPixels -_glCopyTexImage1D,_glCopyTexImage1D -_glCopyTexImage2D,_glCopyTexImage2D -_glCopyTexSubImage1D,_glCopyTexSubImage1D -_glCopyTexSubImage2D,_glCopyTexSubImage2D -_glCullFace,_glCullFace -_glDeleteLists,_glDeleteLists -_glDeleteTextures,_glDeleteTextures -_glDepthFunc,_glDepthFunc -_glDepthMask,_glDepthMask -_glDepthRange,_glDepthRange -_glDisable,_glDisable -_glDisableClientState,_glDisableClientState -_glDrawArrays,_glDrawArrays -_glDrawBuffer,_glDrawBuffer -_glDrawElements,_glDrawElements -_glDrawPixels,_glDrawPixels -_glEdgeFlag,_glEdgeFlag -_glEdgeFlagv,_glEdgeFlagv -_glEdgeFlagPointer,_glEdgeFlagPointer -_glEnable,_glEnable -_glEnableClientState,_glEnableClientState -_glEnd,_glEnd -_glEndList,_glEndList -_glEvalCoord1d,_glEvalCoord1d -_glEvalCoord1dv,_glEvalCoord1dv -_glEvalCoord1f,_glEvalCoord1f -_glEvalCoord1fv,_glEvalCoord1fv -_glEvalCoord2d,_glEvalCoord2d -_glEvalCoord2dv,_glEvalCoord2dv -_glEvalCoord2f,_glEvalCoord2f -_glEvalCoord2fv,_glEvalCoord2fv -_glEvalMesh1,_glEvalMesh1 -_glEvalMesh2,_glEvalMesh2 -_glEvalPoint1,_glEvalPoint1 -_glEvalPoint2,_glEvalPoint2 -_glFeedbackBuffer,_glFeedbackBuffer -_glFinish,_glFinish -_glFlush,_glFlush -_glFogf,_glFogf -_glFogfv,_glFogfv -_glFogi,_glFogi -_glFogiv,_glFogiv -_glFrontFace,_glFrontFace -_glFrustum,_glFrustum -_glGenLists,_glGenLists -_glGenTextures,_glGenTextures -_glGetBooleanv,_glGetBooleanv -_glGetClipPlane,_glGetClipPlane -_glGetDoublev,_glGetDoublev -_glGetError,_glGetError -_glGetFloatv,_glGetFloatv -_glGetIntegerv,_glGetIntegerv -_glGetLightfv,_glGetLightfv -_glGetLightiv,_glGetLightiv -_glGetMapdv,_glGetMapdv -_glGetMapfv,_glGetMapfv -_glGetMapiv,_glGetMapiv -_glGetMaterialfv,_glGetMaterialfv -_glGetMaterialiv,_glGetMaterialiv -_glGetPixelMapfv,_glGetPixelMapfv -_glGetPixelMapuiv,_glGetPixelMapuiv -_glGetPixelMapusv,_glGetPixelMapusv -_glGetPointerv,_glGetPointerv -_glGetPolygonStipple,_glGetPolygonStipple -_glGetString,_glGetString -_glGetTexEnvfv,_glGetTexEnvfv -_glGetTexEnviv,_glGetTexEnviv -_glGetTexGendv,_glGetTexGendv -_glGetTexGenfv,_glGetTexGenfv -_glGetTexGeniv,_glGetTexGeniv -_glGetTexImage,_glGetTexImage -_glGetTexLevelParameterfv,_glGetTexLevelParameterfv -_glGetTexLevelParameteriv,_glGetTexLevelParameteriv -_glGetTexParameterfv,_glGetTexParameterfv -_glGetTexParameteriv,_glGetTexParameteriv -_glHint,_glHint -_glIndexMask,_glIndexMask -_glIndexPointer,_glIndexPointer -_glIndexd,_glIndexd -_glIndexdv,_glIndexdv -_glIndexf,_glIndexf -_glIndexfv,_glIndexfv -_glIndexi,_glIndexi -_glIndexiv,_glIndexiv -_glIndexs,_glIndexs -_glIndexsv,_glIndexsv -_glIndexub,_glIndexub -_glIndexubv,_glIndexubv -_glInitNames,_glInitNames -_glInterleavedArrays,_glInterleavedArrays -_glIsEnabled,_glIsEnabled -_glIsList,_glIsList -_glIsTexture,_glIsTexture -_glLightModelf,_glLightModelf -_glLightModelfv,_glLightModelfv -_glLightModeli,_glLightModeli -_glLightModeliv,_glLightModeliv -_glLightf,_glLightf -_glLightfv,_glLightfv -_glLighti,_glLighti -_glLightiv,_glLightiv -_glLineStipple,_glLineStipple -_glLineWidth,_glLineWidth -_glListBase,_glListBase -_glLoadIdentity,_glLoadIdentity -_glLoadMatrixd,_glLoadMatrixd -_glLoadMatrixf,_glLoadMatrixf -_glLoadName,_glLoadName -_glLogicOp,_glLogicOp -_glMap1d,_glMap1d -_glMap1f,_glMap1f -_glMap2d,_glMap2d -_glMap2f,_glMap2f -_glMapGrid1d,_glMapGrid1d -_glMapGrid1f,_glMapGrid1f -_glMapGrid2d,_glMapGrid2d -_glMapGrid2f,_glMapGrid2f -_glMaterialf,_glMaterialf -_glMaterialfv,_glMaterialfv -_glMateriali,_glMateriali -_glMaterialiv,_glMaterialiv -_glMatrixMode,_glMatrixMode -_glMultMatrixd,_glMultMatrixd -_glMultMatrixf,_glMultMatrixf -_glNewList,_glNewList -_glNormal3b,_glNormal3b -_glNormal3bv,_glNormal3bv -_glNormal3d,_glNormal3d -_glNormal3dv,_glNormal3dv -_glNormal3f,_glNormal3f -_glNormal3fv,_glNormal3fv -_glNormal3i,_glNormal3i -_glNormal3iv,_glNormal3iv -_glNormal3s,_glNormal3s -_glNormal3sv,_glNormal3sv -_glNormalPointer,_glNormalPointer -_glOrtho,_glOrtho -_glPassThrough,_glPassThrough -_glPixelMapfv,_glPixelMapfv -_glPixelMapuiv,_glPixelMapuiv -_glPixelMapusv,_glPixelMapusv -_glPixelStoref,_glPixelStoref -_glPixelStorei,_glPixelStorei -_glPixelTransferf,_glPixelTransferf -_glPixelTransferi,_glPixelTransferi -_glPixelZoom,_glPixelZoom -_glPointSize,_glPointSize -_glPolygonMode,_glPolygonMode -_glPolygonOffset,_glPolygonOffset -_glPolygonStipple,_glPolygonStipple -_glPopAttrib,_glPopAttrib -_glPopClientAttrib,_glPopClientAttrib -_glPopMatrix,_glPopMatrix -_glPopName,_glPopName -_glPrioritizeTextures,_glPrioritizeTextures -_glPushAttrib,_glPushAttrib -_glPushClientAttrib,_glPushClientAttrib -_glPushMatrix,_glPushMatrix -_glPushName,_glPushName -_glRasterPos2d,_glRasterPos2d -_glRasterPos2dv,_glRasterPos2dv -_glRasterPos2f,_glRasterPos2f -_glRasterPos2fv,_glRasterPos2fv -_glRasterPos2i,_glRasterPos2i -_glRasterPos2iv,_glRasterPos2iv -_glRasterPos2s,_glRasterPos2s -_glRasterPos2sv,_glRasterPos2sv -_glRasterPos3d,_glRasterPos3d -_glRasterPos3dv,_glRasterPos3dv -_glRasterPos3f,_glRasterPos3f -_glRasterPos3fv,_glRasterPos3fv -_glRasterPos3i,_glRasterPos3i -_glRasterPos3iv,_glRasterPos3iv -_glRasterPos3s,_glRasterPos3s -_glRasterPos3sv,_glRasterPos3sv -_glRasterPos4d,_glRasterPos4d -_glRasterPos4dv,_glRasterPos4dv -_glRasterPos4f,_glRasterPos4f -_glRasterPos4fv,_glRasterPos4fv -_glRasterPos4i,_glRasterPos4i -_glRasterPos4iv,_glRasterPos4iv -_glRasterPos4s,_glRasterPos4s -_glRasterPos4sv,_glRasterPos4sv -_glReadBuffer,_glReadBuffer -_glReadPixels,_glReadPixels -_glRectd,_glRectd -_glRectdv,_glRectdv -_glRectf,_glRectf -_glRectfv,_glRectfv -_glRecti,_glRecti -_glRectiv,_glRectiv -_glRects,_glRects -_glRectsv,_glRectsv -_glRenderMode,_glRenderMode -_glRotated,_glRotated -_glRotatef,_glRotatef -_glScaled,_glScaled -_glScalef,_glScalef -_glScissor,_glScissor -_glSelectBuffer,_glSelectBuffer -_glShadeModel,_glShadeModel -_glStencilFunc,_glStencilFunc -_glStencilMask,_glStencilMask -_glStencilOp,_glStencilOp -_glTexCoord1d,_glTexCoord1d -_glTexCoord1dv,_glTexCoord1dv -_glTexCoord1f,_glTexCoord1f -_glTexCoord1fv,_glTexCoord1fv -_glTexCoord1i,_glTexCoord1i -_glTexCoord1iv,_glTexCoord1iv -_glTexCoord1s,_glTexCoord1s -_glTexCoord1sv,_glTexCoord1sv -_glTexCoord2d,_glTexCoord2d -_glTexCoord2dv,_glTexCoord2dv -_glTexCoord2f,_glTexCoord2f -_glTexCoord2fv,_glTexCoord2fv -_glTexCoord2i,_glTexCoord2i -_glTexCoord2iv,_glTexCoord2iv -_glTexCoord2s,_glTexCoord2s -_glTexCoord2sv,_glTexCoord2sv -_glTexCoord3d,_glTexCoord3d -_glTexCoord3dv,_glTexCoord3dv -_glTexCoord3f,_glTexCoord3f -_glTexCoord3fv,_glTexCoord3fv -_glTexCoord3i,_glTexCoord3i -_glTexCoord3iv,_glTexCoord3iv -_glTexCoord3s,_glTexCoord3s -_glTexCoord3sv,_glTexCoord3sv -_glTexCoord4d,_glTexCoord4d -_glTexCoord4dv,_glTexCoord4dv -_glTexCoord4f,_glTexCoord4f -_glTexCoord4fv,_glTexCoord4fv -_glTexCoord4i,_glTexCoord4i -_glTexCoord4iv,_glTexCoord4iv -_glTexCoord4s,_glTexCoord4s -_glTexCoord4sv,_glTexCoord4sv -_glTexCoordPointer,_glTexCoordPointer -_glTexEnvf,_glTexEnvf -_glTexEnvfv,_glTexEnvfv -_glTexEnvi,_glTexEnvi -_glTexEnviv,_glTexEnviv -_glTexGend,_glTexGend -_glTexGendv,_glTexGendv -_glTexGenf,_glTexGenf -_glTexGenfv,_glTexGenfv -_glTexGeni,_glTexGeni -_glTexGeniv,_glTexGeniv -_glTexImage1D,_glTexImage1D -_glTexImage2D,_glTexImage2D -_glTexParameterf,_glTexParameterf -_glTexParameterfv,_glTexParameterfv -_glTexParameteri,_glTexParameteri -_glTexParameteriv,_glTexParameteriv -_glTexSubImage1D,_glTexSubImage1D -_glTexSubImage2D,_glTexSubImage2D -_glTranslated,_glTranslated -_glTranslatef,_glTranslatef -_glVertex2d,_glVertex2d -_glVertex2dv,_glVertex2dv -_glVertex2f,_glVertex2f -_glVertex2fv,_glVertex2fv -_glVertex2i,_glVertex2i -_glVertex2iv,_glVertex2iv -_glVertex2s,_glVertex2s -_glVertex2sv,_glVertex2sv -_glVertex3d,_glVertex3d -_glVertex3dv,_glVertex3dv -_glVertex3f,_glVertex3f -_glVertex3fv,_glVertex3fv -_glVertex3i,_glVertex3i -_glVertex3iv,_glVertex3iv -_glVertex3s,_glVertex3s -_glVertex3sv,_glVertex3sv -_glVertex4d,_glVertex4d -_glVertex4dv,_glVertex4dv -_glVertex4f,_glVertex4f -_glVertex4fv,_glVertex4fv -_glVertex4i,_glVertex4i -_glVertex4iv,_glVertex4iv -_glVertex4s,_glVertex4s -_glVertex4sv,_glVertex4sv -_glVertexPointer,_glVertexPointer -_glViewport,_glViewport -;,Semicolon -",Quotation mark -?,Question mark -',Apostrophe -:,Colon -$,Dollar_Sign -,Parenthesis -+,+ -",Quotation mark -_,Underscore -$,STRING -STRING,STRING -!,SINGLE -SINGLE,SINGLE -#,DOUBLE -DOUBLE,DOUBLE -##,_FLOAT -_FLOAT,_FLOAT -~,_UNSIGNED -_UNSIGNED,_UNSIGNED -%,INTEGER -INTEGER,INTEGER -&,LONG -LONG,LONG -&&,_INTEGER64 -_INTEGER64,_INTEGER64 -`,_BIT -_BIT,_BIT -%%,_BYTE -_BYTE,_BYTE -%&,_OFFSET -_OFFSET,_OFFSET -&B,&B -&O,&O -&H,&H -+,+ --,- -*,* -/,/ -\,\ -^,^ -MOD,MOD -=,Equal -<>,Not_Equal ->,Greater_Than -<,Less_Than ->=,Greater_Than_Or_Equal -<=,Less_Than_Or_Equal diff --git a/internal/source/icon.ico b/internal/source/icon.ico index ca26aacfd..541e29c47 100644 Binary files a/internal/source/icon.ico and b/internal/source/icon.ico differ diff --git a/internal/source/icon.rc b/internal/source/icon.rc index 2cebf6c44..4089c2158 100644 --- a/internal/source/icon.rc +++ b/internal/source/icon.rc @@ -12,14 +12,14 @@ BEGIN BEGIN BLOCK "040904E4" BEGIN - VALUE "CompanyName","QB64\0" - VALUE "FileDescription","QB64 Compiler\0" + VALUE "CompanyName","QB64 Phoenix Edition\0" + VALUE "FileDescription","QB64 IDE and Compiler\0" VALUE "FileVersion","0,8,2,0\0" - VALUE "InternalName","qb64.bas\0" + VALUE "InternalName","qb64pe.bas\0" VALUE "LegalCopyright","MIT\0" VALUE "LegalTrademarks","\0" - VALUE "OriginalFilename","qb64.exe\0" - VALUE "ProductName","QB64\0" + VALUE "OriginalFilename","qb64pe.exe\0" + VALUE "ProductName","QB64-PE\0" VALUE "ProductVersion","0,8,2,0\0" VALUE "Comments","QB64 is a modern extended BASIC programming language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows, Linux and macOS.\0" VALUE "Web","\0" diff --git a/internal/source/qb64.ico b/internal/source/qb64.ico deleted file mode 100644 index ca26aacfd..000000000 Binary files a/internal/source/qb64.ico and /dev/null differ diff --git a/internal/source/qb64icon32.png b/internal/source/qb64icon32.png deleted file mode 100644 index d081eb23e..000000000 Binary files a/internal/source/qb64icon32.png and /dev/null differ diff --git a/internal/source/qbicon16.png b/internal/source/qbicon16.png deleted file mode 100644 index 45f05ed5b..000000000 Binary files a/internal/source/qbicon16.png and /dev/null differ diff --git a/internal/source/qbicon32.png b/internal/source/qbicon32.png deleted file mode 100644 index e7e33e290..000000000 Binary files a/internal/source/qbicon32.png and /dev/null differ diff --git a/qb64.1 b/qb64pe.1 similarity index 80% rename from qb64.1 rename to qb64pe.1 index 68b86863d..0adcc3a11 100644 --- a/qb64.1 +++ b/qb64pe.1 @@ -1,10 +1,10 @@ -.TH qb64 "1" "November 2018" "QB64 IDE AND COMPILER" "User Commands" +.TH qb64pe "1" "August 2022" "QB64 IDE AND COMPILER (Phoenix Edition)" "User Commands" .SH NAME -qb64 \- manual page for QB64 +qb64pe \- manual page for QB64-PE .SH DESCRIPTION -QB64 COMPILER +QB64 COMPILER (Phoenix Edition) .PP -USAGE: qb64 [switches] +USAGE: qb64pe [switches] .SS "OPTIONS:" .TP diff --git a/setup_lnx.sh b/setup_lnx.sh index 2a22568c7..a594b8079 100755 --- a/setup_lnx.sh +++ b/setup_lnx.sh @@ -1,10 +1,10 @@ #!/bin/bash -# QB64 Installer -# Argument 1: If not blank, qb64 will not be started after compilation +# QB64-PE Installer +# Argument 1: If not blank, qb64pe will not be started after compilation dont_run="$1" -#This checks the currently installed packages for the one's QB64 needs +#This checks the currently installed packages for the one's QB64-PE needs #And runs the package manager to install them if that is the case pkg_install() { #Search @@ -33,10 +33,10 @@ fi GET_WGET= #Path to Icon #Relative Path to icon -- Don't include beginning or trailing '/' -QB64_ICON_PATH="internal/source" +QB64_ICON_PATH="source" #Name of the Icon picture -QB64_ICON_NAME="qb64icon32.png" +QB64_ICON_NAME="qb64pe.png" DISTRO= @@ -100,7 +100,7 @@ elif [ "$DISTRO" == "voidlinux" ]; then elif [ -z "$DISTRO" ]; then echo "Unable to detect distro, skipping package installation" - echo "Please be aware that for QB64 to compile, you will need the following installed:" + echo "Please be aware that for QB64-PE to compile, you will need the following installed:" echo " OpenGL developement libraries" echo " ALSA development libraries" echo " GNU C++ Compiler (g++)" @@ -108,27 +108,27 @@ elif [ -z "$DISTRO" ]; then echo " zlib" fi -echo "Compiling and installing QB64..." +echo "Compiling and installing QB64-PE..." make clean OS=lnx make OS=lnx BUILD_QB64=y -j3 -if [ -e "./qb64" ]; then +if [ -e "./qb64pe" ]; then echo "Done compiling!!" - echo "Creating ./run_qb64.sh script..." + echo "Creating ./run_qb64pe.sh script..." _pwd=`pwd` - echo "#!/bin/sh" > ./run_qb64.sh - echo "cd $_pwd" >> ./run_qb64.sh - echo "./qb64 &" >> ./run_qb64.sh + echo "#!/bin/sh" > ./run_qb64pe.sh + echo "cd $_pwd" >> ./run_qb64pe.sh + echo "./qb64pe &" >> ./run_qb64pe.sh - chmod +x ./run_qb64.sh + chmod +x ./run_qb64pe.sh #chmod -R 777 ./ - echo "Adding QB64 menu entry..." - cat > ~/.local/share/applications/qb64.desktop < ~/.local/share/applications/qb64pe.desktop </dev/null stty $OLDCONFIG } -echo "QB64 Setup" +echo "QB64-PE Setup" echo "" find . -name "*.command" -exec chmod +x {} \; @@ -25,23 +25,23 @@ if [ -z "$(which clang++)" ]; then exit 1 fi -echo "Building 'QB64'" +echo "Building 'QB64-PE'" make OS=osx clean make OS=osx BUILD_QB64=y -j3 echo "" -if [ -f ./qb64 ]; then +if [ -f ./qb64pe ]; then if [ -z "$dont_run" ]; then - echo "Launching 'QB64'" - ./qb64 + echo "Launching 'QB64-PE'" + ./qb64pe fi echo "" - echo "Note: 'qb64' is located in same folder as this setup program." + echo "Note: 'qb64pe' is located in same folder as this setup program." echo "Press any key to continue..." [ -z "$dont_run" ] && Pause exit 0 else - echo "Compilation of QB64 failed!" + echo "Compilation of QB64-PE failed!" [ -z "$dont_run" ] && Pause exit 1 fi diff --git a/setup_win.bat b/setup_win.bat index bf1f7086b..bde392405 100644 --- a/setup_win.bat +++ b/setup_win.bat @@ -1,6 +1,6 @@ @echo off setlocal -echo QB64 Setup +echo QB64-PE Setup echo. mkdir internal\c\c_compiler @@ -23,12 +23,12 @@ del %MINGW% echo Cleaning... internal\c\c_compiler\bin\mingw32-make.exe OS=win clean >NUL 2>NUL -echo Building QB64... +echo Building QB64-PE... internal\c\c_compiler\bin\mingw32-make.exe OS=win BUILD_QB64=y || goto report_error echo. -echo Launching 'QB64' -qb64 +echo Launching 'QB64-PE' +qb64pe echo. pause @@ -36,6 +36,6 @@ pause exit 0 report_error: -echo "Error compiling QB64." +echo "Error compiling QB64-PE." echo "Please review above steps and report to https://github.com/QB64-Phoenix-Edition/QB64pe/issues if you can't get it to work" exit 1 diff --git a/source/icon.rc b/source/icon.rc deleted file mode 100644 index 1791fe5c9..000000000 --- a/source/icon.rc +++ /dev/null @@ -1,28 +0,0 @@ -0 ICON "qb64.ico" - -1 VERSIONINFO -FILEVERSION 2,1,0,0 -PRODUCTVERSION 2,1,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "CompanyName","QB64\0" - VALUE "FileDescription","QB64 Compiler\0" - VALUE "FileVersion","2.1\0" - VALUE "InternalName","qb64.bas\0" - VALUE "LegalCopyright","LGPL\0" - VALUE "LegalTrademarks","\0" - VALUE "OriginalFilename","qb64.exe\0" - VALUE "ProductName","QB64\0" - VALUE "ProductVersion","2.1\0" - VALUE "Comments","QB64 is a modern extended BASIC programming language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows, Linux and macOS.\0" - END - END - - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 0x04E4 - END -END diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 2b33be969..036740177 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -339,7 +339,7 @@ FUNCTION ide2 (ignore) RunMenuSaveExeWithSource = i menu$(m, i) = "Output EXE to Source #Folder": i = i + 1 - menuDesc$(m, i - 1) = "Toggles compiling program to QB64's folder or to source folder" + menuDesc$(m, i - 1) = "Toggles compiling program to QB64-PE's folder or to source folder" IF SaveExeWithSource THEN menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + menu$(RunMenuID, RunMenuSaveExeWithSource) END IF @@ -479,9 +479,9 @@ FUNCTION ide2 (ignore) menuDesc$(m, i - 1) = "Launches the default browser and navigates to the current article on the wiki" menu$(m, i) = "-": i = i + 1 'menu$(m, i) = "Check for #Newer Version...": i = i + 1 - 'menuDesc$(m, i - 1) = "Displays the current version of QB64" + 'menuDesc$(m, i - 1) = "Displays the current version of QB64-PE" menu$(m, i) = "#About...": i = i + 1 - menuDesc$(m, i - 1) = "Displays the current version of QB64" + menuDesc$(m, i - 1) = "Displays the current version of QB64-PE" menusize(m) = i - 1 menus = m @@ -1167,12 +1167,12 @@ FUNCTION ide2 (ignore) END IF 'skipdisplay IF WhiteListQB64FirstTimeMsg = 0 THEN - IF INSTR(_OS$, "WIN") THEN whiteListProcess$ = "and the process 'qb64.exe' " ELSE whiteListProcess$ = "" - result = idemessagebox("Welcome to QB64", "QB64 is an independently distributed program, and as such" + CHR$(10) + _ - "both 'qb64" + extension$ + "' and the programs you create with it may" + CHR$(10) + _ + IF INSTR(_OS$, "WIN") THEN whiteListProcess$ = "and the process 'qb64pe.exe' " ELSE whiteListProcess$ = "" + result = idemessagebox("Welcome to QB64-PE", "QB64-PE is an independently distributed program, and as such" + CHR$(10) + _ + "both 'qb64pe" + extension$ + "' and the programs you create with it may" + CHR$(10) + _ "eventually be flagged as false positives by your" + CHR$(10) + _ "antivirus/antimalware software." + CHR$(10) + CHR$(10) + _ - "It is advisable to whitelist your whole QB64 folder" + CHR$(10) + _ + "It is advisable to whitelist your whole 'qb64pe' folder" + CHR$(10) + _ whiteListProcess$ + "to avoid operation errors.", "#OK;#Don't show this again") PCOPY 3, 0: SCREEN , , 3, 0 @@ -1684,7 +1684,7 @@ FUNCTION ide2 (ignore) "source code is saved. You can change that by unchecking the" + CHR$(10) + _ "option 'Output EXE to Source Folder' in the Run menu.", "#OK;#Don't show this again;#Cancel") ELSE - result = idemessagebox("Run", "Your program will be compiled to your QB64 folder. You can" + CHR$(10) + _ + result = idemessagebox("Run", "Your program will be compiled to your 'qb64pe' folder. You can" + CHR$(10) + _ "change that by checking the option 'Output EXE to Source" + CHR$(10) + _ "Folder' in the Run menu.", "#OK;#Don't show this again;#Cancel") END IF @@ -2980,7 +2980,7 @@ FUNCTION ide2 (ignore) GOTO regularTextBox_click ELSEIF ActiveINCLUDELink > 0 THEN 'Double-click on an $INCLUDE statement launches that file in - 'a separate instance of QB64: + 'a separate instance of QB64-PE: p$ = idepath$ + pathsep$ f$ = p$ + ActiveINCLUDELinkFile IF _FILEEXISTS(f$) = 0 THEN f$ = ActiveINCLUDELinkFile @@ -12842,6 +12842,7 @@ SUB ideshowtext 'Restore BG color in case a matching bracket was printed with different BG IF l = idecy THEN COLOR , 6 IF isKeyword > 0 THEN isKeyword = isKeyword - 1 + IF isKeyword = 0 AND checkKeyword$ = "REM" THEN comment = -1 IF isKeyword = 0 THEN checkKeyword$ = "": metacommand = 0: is_Number = 0: isCustomKeyword = 0 NEXT m @@ -18198,7 +18199,7 @@ SUB IdeMakeFileMenu END IF menu$(m, i) = "-": i = i + 1 menu$(m, i) = "E#xit": i = i + 1 - menuDesc$(m, i - 1) = "Exits QB64" + menuDesc$(m, i - 1) = "Exits QB64-PE" menusize(m) = i - 1 END SUB @@ -18838,8 +18839,12 @@ FUNCTION ideupdatehelpbox SELECT CASE UpdateStep CASE 1 'Create a list of all files to be recached - f$ = CHR$(0) + idezfilelist$("internal/help", 2, "*.txt") + CHR$(0) - IF LEN(f$) = 2 THEN f$ = CHR$(0) + IF Help_Recaching < 2 THEN + f$ = CHR$(0) + idezfilelist$("internal/help", 2, "*.txt") + CHR$(0) + IF LEN(f$) = 2 THEN f$ = CHR$(0) + ELSE + f$ = CHR$(0) 'no dir scan for 'qb64pe -u' (build time update) + END IF 'Prepend core pages to list f$ = CHR$(0) + "Keyword_Reference_-_By_usage.txt" + f$ @@ -18863,22 +18868,24 @@ FUNCTION ideupdatehelpbox LINE INPUT #fh, l$ IF LEN(l$) THEN c = INSTR(l$, ","): l$ = RIGHT$(l$, LEN(l$) - c) - 'Escape all invalid and other critical chars in filenames - PageName2$ = "" - FOR i = 1 TO LEN(l$) - c = ASC(l$, i) - SELECT CASE c - CASE 32 ' '(space) - PageName2$ = PageName2$ + "_" - CASE 34, 38, 42, 43, 47, 58, 60, 62, 63, 92, 124 '("&*+/:<>?\|) - PageName2$ = PageName2$ + "%" + HEX$(c) - CASE ELSE - PageName2$ = PageName2$ + CHR$(c) - END SELECT - NEXT - PageName2$ = PageName2$ + ".txt" - IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN - f$ = f$ + PageName2$ + CHR$(0) + IF Help_Recaching < 2 OR LEFT$(l$, 3) <> "_gl" THEN 'ignore _GL pages for 'qb64pe -u' (build time update) + 'Escape all invalid and other critical chars in filenames + PageName2$ = "" + FOR i = 1 TO LEN(l$) + c = ASC(l$, i) + SELECT CASE c + CASE 32 ' '(space) + PageName2$ = PageName2$ + "_" + CASE 34, 36, 38, 42, 43, 47, 58, 60, 62, 63, 92, 124 '("$&*+/:<>?\|) + PageName2$ = PageName2$ + "%" + HEX$(c) + CASE ELSE + PageName2$ = PageName2$ + CHR$(c) + END SELECT + NEXT + PageName2$ = PageName2$ + ".txt" + IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN + f$ = f$ + PageName2$ + CHR$(0) + END IF END IF END IF LOOP @@ -19718,9 +19725,9 @@ FUNCTION BinaryFormatCheck% (pathToCheck$, pathSepToCheck$, fileToCheck$) _PRINTSTRING (2, idewy - 3), "Preparing to convert..." PCOPY 3, 0 IF INSTR(_OS$, "WIN") THEN - SHELL _HIDE "qb64 -x internal/support/converter/QB45BIN.bas -o internal/utilities/QB45BIN" + SHELL _HIDE "qb64pe -x internal/support/converter/QB45BIN.bas -o internal/utilities/QB45BIN" ELSE - SHELL _HIDE "./qb64 -x ./internal/support/converter/QB45BIN.bas -o ./internal/utilities/QB45BIN" + SHELL _HIDE "./qb64pe -x ./internal/support/converter/QB45BIN.bas -o ./internal/utilities/QB45BIN" END IF IF _FILEEXISTS(convertUtility$) THEN GOTO ConvertIt clearStatusWindow 0 diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas index aa470ba51..e9eb1f0bc 100644 --- a/source/ide/wiki/wiki_methods.bas +++ b/source/ide/wiki/wiki_methods.bas @@ -14,9 +14,9 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached) FOR i = 1 TO LEN(PageName$) c = ASC(PageName$, i) SELECT CASE c - CASE 32 ' '(space) + CASE 32 ' '(space) PageName2$ = PageName2$ + "_" - CASE 34, 38, 42, 43, 47, 58, 60, 62, 63, 92, 124 '("&*+/:<>?\|) + CASE 34, 36, 38, 42, 43, 47, 58, 60, 62, 63, 92, 124 '("$&*+/:<>?\|) PageName2$ = PageName2$ + "%" + HEX$(c) CASE ELSE PageName2$ = PageName2$ + CHR$(c) @@ -38,7 +38,7 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached) END IF 'Check for curl - IF _SHELLHIDE("curl --version") <> 0 THEN + IF _SHELLHIDE("curl --version >NUL") <> 0 THEN a$ = CHR$(10) + "{{PageInternalError}}" + CHR$(10) IF PageName$ = "Initialize" THEN a$ = a$ + "To be able to initialize the help system, " @@ -50,8 +50,8 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached) a$ = a$ + "a tool called ''curl'' is required, but it wasn't found on your system." + CHR$(10) + CHR$(10) a$ = a$ + "* To get ''curl'', visit the official [https://curl.se/download.html download page]." + CHR$(10) a$ = a$ + "** Grab the latest ''binary'' archive available for your system." + CHR$(10) - a$ = a$ + "** Unpack and drop the ''curl'' executable into the QB64 folder." + CHR$(10) - a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the QB64 folder too." + CHR$(10) + a$ = a$ + "** Unpack and drop the ''curl'' executable into the '''qb64pe''' folder." + CHR$(10) + a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the '''qb64pe''' folder too." + CHR$(10) Wiki$ = a$: EXIT FUNCTION END IF @@ -75,7 +75,7 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached) s2$ = "" 'Download page using curl - SHELL _HIDE "curl -o " + CHR$(34) + outputFile$ + CHR$(34) + " " + url$ + SHELL _HIDE "curl --silent -o " + CHR$(34) + outputFile$ + CHR$(34) + " " + url$ fh = FREEFILE OPEN outputFile$ FOR BINARY AS #fh 'get new content a$ = SPACE$(LOF(fh)) @@ -321,12 +321,13 @@ SUB WikiParse (a$) 'Wiki page interpret t$ = MID$(t$, 5) END IF i = LEN(d$): ii = LEN(t$) - Help_AddTxt " Ú" + STRING$(ii + 2, "Ä") + "¿", 14, 0: Help_NewLine - Help_AddTxt " ³ ", 14, 0: Help_AddTxt t$, 12, 0: Help_AddTxt " ³", 14, 0 - Help_AddTxt SPACE$(Help_ww - i - 2 - Help_Pos) + CHR$(4), 14, 0 + Help_AddTxt " Ú" + STRING$(ii + 2, "Ä") + "¿", 14, 0: Help_NewLine + Help_AddTxt " ³ ", 14, 0: Help_AddTxt t$, 12, 0: Help_AddTxt " ³", 14, 0 + i = Help_ww - i - 2 - Help_Pos: IF i < 2 THEN i = 2 + Help_AddTxt SPACE$(i) + CHR$(4), 14, 0 IF LEFT$(d$, 4) = "Page" THEN i = 8: ELSE i = 7 - Help_AddTxt " " + d$, i, 0: Help_NewLine - Help_AddTxt "ÄÄÄÁ" + STRING$(ii + 2, "Ä") + "Á" + STRING$(Help_ww - ii - 7, "Ä"), 14, 0: Help_NewLine + Help_LockWrap = 1: Help_AddTxt " " + d$, i, 0: Help_NewLine: Help_LockWrap = 0 + Help_AddTxt "ÄÄÁ" + STRING$(ii + 2, "Ä") + "Á" + STRING$(Help_ww - ii - 6, "Ä"), 14, 0: Help_NewLine 'Init prefetch array prefetch = 20 diff --git a/source/peLogo.png b/source/peLogo.png new file mode 100644 index 000000000..03033cfe7 Binary files /dev/null and b/source/peLogo.png differ diff --git a/source/qb64.ico b/source/qb64.ico deleted file mode 100644 index ca26aacfd..000000000 Binary files a/source/qb64.ico and /dev/null differ diff --git a/source/qb64.bas b/source/qb64pe.bas similarity index 97% rename from source/qb64.bas rename to source/qb64pe.bas index 9d4b9449d..1243355d8 100644 --- a/source/qb64.bas +++ b/source/qb64pe.bas @@ -1,25838 +1,25838 @@ -'All variables will be of type LONG unless explicitly defined -DEFLNG A-Z - -'All arrays will be dynamically allocated so they can be REDIM-ed -'$DYNAMIC - -'We need console access to support command-line compilation via the -x command line compile option -$CONSOLE - -'Initially the "SCREEN" will be hidden, if the -x option is used it will never be created -$SCREENHIDE - -$EXEICON:'./qb64.ico' - -$VERSIONINFO:CompanyName=QB64 -$VERSIONINFO:FileDescription=QB64 Compiler -$VERSIONINFO:InternalName=qb64.bas -$VERSIONINFO:LegalCopyright=MIT -$VERSIONINFO:LegalTrademarks= -$VERSIONINFO:OriginalFilename=qb64.exe -$VERSIONINFO:ProductName=QB64 -$VERSIONINFO:Comments=QB64 is a modern extended BASIC programming language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows, Linux and macOS. - -'$INCLUDE:'global\version.bas' -'$INCLUDE:'global\settings.bas' -'$INCLUDE:'global\constants.bas' -'$INCLUDE:'subs_functions\extensions\opengl\opengl_global.bas' -'$INCLUDE:'utilities\ini-manager\ini.bi' - -DEFLNG A-Z - -'-------- Optional IDE Component (1/2) -------- -'$INCLUDE:'ide\ide_global.bas' - -REDIM SHARED OName(1000) AS STRING 'Operation Name -REDIM SHARED PL(1000) AS INTEGER 'Priority Level -REDIM SHARED PP_TypeMod(0) AS STRING, PP_ConvertedMod(0) AS STRING 'Prepass Name Conversion variables. -Set_OrderOfOperations - -DIM SHARED NoExeSaved AS INTEGER - -DIM SHARED vWatchOn, vWatchRecompileAttempts, vWatchDesiredState, vWatchErrorCall$ -DIM SHARED vWatchNewVariable$, vWatchVariableExclusions$ -vWatchErrorCall$ = "if (stop_program) {*__LONG_VWATCH_LINENUMBER=0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);};if(new_error){bkp_new_error=new_error;new_error=0;*__LONG_VWATCH_LINENUMBER=-1; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);new_error=bkp_new_error;};" -vWatchVariableExclusions$ = "@__LONG_VWATCH_LINENUMBER@__LONG_VWATCH_SUBLEVEL@__LONG_VWATCH_GOTO@" + _ - "@__STRING_VWATCH_SUBNAME@__STRING_VWATCH_CALLSTACK@__ARRAY_BYTE_VWATCH_BREAKPOINTS" + _ - "@__ARRAY_BYTE_VWATCH_SKIPLINES@__STRING_VWATCH_INTERNALSUBNAME@__ARRAY_STRING_VWATCH_STACK@" - -DIM SHARED nativeDataTypes$ -nativeDataTypes$ = "@_OFFSET@OFFSET@_UNSIGNED _OFFSET@UNSIGNED OFFSET@_BIT@BIT@_UNSIGNED _BIT@UNSIGNED BIT@_BYTE@_UNSIGNED _BYTE@BYTE@UNSIGNED BYTE@INTEGER@_UNSIGNED INTEGER@UNSIGNED INTEGER@LONG@_UNSIGNED LONG@UNSIGNED LONG@_INTEGER64@INTEGER64@_UNSIGNED _INTEGER64@UNSIGNED INTEGER64@SINGLE@DOUBLE@_FLOAT@FLOAT@STRING@" - -DIM SHARED qb64prefix_set_recompileAttempts, qb64prefix_set_desiredState -DIM SHARED opex_recompileAttempts, opex_desiredState -DIM SHARED opexarray_recompileAttempts, opexarray_desiredState - -REDIM EveryCaseSet(100), SelectCaseCounter AS _UNSIGNED LONG -REDIM SelectCaseHasCaseBlock(100) -DIM ExecLevel(255), ExecCounter AS INTEGER -REDIM SHARED UserDefine(1, 100) AS STRING '0 element is the name, 1 element is the string value -REDIM SHARED InValidLine(10000) AS _BYTE -DIM DefineElse(255) AS _BYTE -DIM SHARED UserDefineCount AS INTEGER, UserDefineList$ -UserDefineList$ = "@DEFINED@UNDEFINED@WINDOWS@WIN@LINUX@MAC@MACOSX@32BIT@64BIT@VERSION@" -UserDefine(0, 0) = "WINDOWS": UserDefine(0, 1) = "WIN" -UserDefine(0, 2) = "LINUX" -UserDefine(0, 3) = "MAC": UserDefine(0, 4) = "MACOSX" -UserDefine(0, 5) = "32BIT": UserDefine(0, 6) = "64BIT" -UserDefine(0, 7) = "VERSION" -IF INSTR(_OS$, "WIN") THEN UserDefine(1, 0) = "-1": UserDefine(1, 1) = "-1" ELSE UserDefine(1, 0) = "0": UserDefine(1, 1) = "0" -IF INSTR(_OS$, "LINUX") THEN UserDefine(1, 2) = "-1" ELSE UserDefine(1, 2) = "0" -IF INSTR(_OS$, "MAC") THEN UserDefine(1, 3) = "-1": UserDefine(1, 4) = "-1" ELSE UserDefine(1, 3) = "0": UserDefine(1, 4) = "0" -IF INSTR(_OS$, "32BIT") THEN UserDefine(1, 5) = "-1": UserDefine(1, 6) = "0" ELSE UserDefine(1, 5) = "0": UserDefine(1, 6) = "-1" -UserDefine(1, 7) = Version$ - -DIM SHARED QB64_uptime! - -QB64_uptime! = TIMER - -NoInternalFolder: -IF _DIREXISTS("internal") = 0 THEN - _SCREENSHOW - PRINT "QB64 cannot locate the 'internal' folder" - PRINT - PRINT "Check that QB64 has been extracted properly." - PRINT "For MacOSX, launch 'qb64_start.command' or enter './qb64' in Terminal." - PRINT "For Linux, in the console enter './qb64'." - DO - _LIMIT 1 - LOOP UNTIL INKEY$ <> "" - SYSTEM 1 -END IF - -DIM SHARED Include_GDB_Debugging_Info 'set using "options.bin" - -DIM SHARED DEPENDENCY_LAST -CONST DEPENDENCY_LOADFONT = 1: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_CONVERSION = 2: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_DECODE = 3: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_OUT = 4: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_GL = 5: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_IMAGE_CODEC = 6: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_CONSOLE_ONLY = 7: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 '=2 if via -g switch, =1 if via metacommand $CONSOLE:ONLY -CONST DEPENDENCY_SOCKETS = 8: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_PRINTER = 9: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_ICON = 10: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_SCREENIMAGE = 11: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_DEVICEINPUT = 12: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'removes support for gamepad input if not present -CONST DEPENDENCY_ZLIB = 13: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'ZLIB library linkage, if desired, for compression/decompression. - - - -DIM SHARED DEPENDENCY(1 TO DEPENDENCY_LAST) - -DIM SHARED UseGL 'declared SUB _GL (no params) - - -DIM SHARED OS_BITS AS LONG, WindowTitle AS STRING -OS_BITS = 64: IF INSTR(_OS$, "[32BIT]") THEN OS_BITS = 32 - -IF OS_BITS = 32 THEN WindowTitle = "QB64 x32" ELSE WindowTitle = "QB64 x64" -_TITLE WindowTitle - -DIM SHARED ConsoleMode, No_C_Compile_Mode, NoIDEMode -DIM SHARED ShowWarnings AS _BYTE, QuietMode AS _BYTE, CMDLineFile AS STRING -DIM SHARED MonochromeLoggingMode AS _BYTE - -TYPE usedVarList - AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex - AS LONG arrayElementSize - AS _BYTE used, watch, isarray, displayFormat 'displayFormat: 0=DEC;1=HEX;2=BIN;3=OCT - AS STRING name, cname, varType, includedFile, subfunc - AS STRING watchRange, indexes, elements, elementTypes 'for Arrays and UDTs - AS STRING elementOffset, storage -END TYPE - -REDIM SHARED backupUsedVariableList(1000) AS usedVarList -DIM SHARED typeDefinitions$, backupTypeDefinitions$ -DIM SHARED totalVariablesCreated AS LONG, totalMainVariablesCreated AS LONG -DIM SHARED bypassNextVariable AS _BYTE -DIM SHARED totalWarnings AS LONG, warningListItems AS LONG, lastWarningHeader AS STRING -DIM SHARED duplicateConstWarning AS _BYTE, warningsissued AS _BYTE -DIM SHARED emptySCWarning AS _BYTE, maxLineNumber AS LONG -DIM SHARED ExeIconSet AS LONG, qb64prefix$, qb64prefix_set -DIM SHARED VersionInfoSet AS _BYTE - -'Variables to handle $VERSIONINFO metacommand: -DIM SHARED viFileVersionNum$, viProductVersionNum$, viCompanyName$ -DIM SHARED viFileDescription$, viFileVersion$, viInternalName$ -DIM SHARED viLegalCopyright$, viLegalTrademarks$, viOriginalFilename$ -DIM SHARED viProductName$, viProductVersion$, viComments$, viWeb$ - -DIM SHARED NoChecks - -DIM SHARED Console -DIM SHARED ScreenHide -DIM SHARED Asserts -DIM SHARED OptMax AS LONG -OptMax = 256 -REDIM SHARED Opt(1 TO OptMax, 1 TO 10) AS STRING * 256 -' (1,1)="READ" -' (1,2)="WRITE" -' (1,3)="READ WRITE" -REDIM SHARED OptWords(1 TO OptMax, 1 TO 10) AS INTEGER 'The number of words of each opt () element -' (1,1)=1 '"READ" -' (1,2)=1 '"WRITE" -' (1,3)=2 '"READ WRITE" -REDIM SHARED T(1 TO OptMax) AS INTEGER 'The type of the entry -' t is 0 for ? opts -' ---------- 0 means ? , 1+ means a symbol or {}block ---------- -' t is 1 for symbol opts -' t is the number of rhs opt () index enteries for {READ|WRITE|READ WRITE} like opts -REDIM SHARED Lev(1 TO OptMax) AS INTEGER 'The indwelling level of each opt () element (the lowest is 0) -REDIM SHARED EntryLev(1 TO OptMax) AS INTEGER 'The level required from which this opt () can be validly be entered/checked-for -REDIM SHARED DitchLev(1 TO OptMax) AS INTEGER 'The lowest level recorded between the previous Opt and this Opt -REDIM SHARED DontPass(1 TO OptMax) AS INTEGER 'Set to 1 or 0, with 1 meaning don't pass -'Determines whether the opt () entry needs to actually be passed to the C++ sub/function -REDIM SHARED TempList(1 TO OptMax) AS INTEGER -REDIM SHARED PassRule(1 TO OptMax) AS LONG -'0 means no pass rule -'negative values refer to an opt () element -'positive values refer to a flag value -REDIM SHARED LevelEntered(OptMax) 'up to 64 levels supported -REDIM SHARED separgs(OptMax + 1) AS STRING -REDIM SHARED separgslayout(OptMax + 1) AS STRING -REDIM SHARED separgs2(OptMax + 1) AS STRING -REDIM SHARED separgslayout2(OptMax + 1) AS STRING - - - - - -DIM SHARED E - - - - - - - - - - -DIM SHARED ResolveStaticFunctions -REDIM SHARED ResolveStaticFunction_File(1 TO 100) AS STRING -REDIM SHARED ResolveStaticFunction_Name(1 TO 100) AS STRING -REDIM SHARED ResolveStaticFunction_Method(1 TO 100) AS LONG - - - - - -DIM SHARED Error_Happened AS LONG -DIM SHARED Error_Message AS STRING - -DIM SHARED os AS STRING -os$ = "WIN" -IF INSTR(_OS$, "[LINUX]") THEN os$ = "LNX" - -DIM SHARED MacOSX AS LONG -IF INSTR(_OS$, "[MACOSX]") THEN MacOSX = 1 - -DIM SHARED inline_DATA -IF MacOSX THEN inline_DATA = 1 - -DIM SHARED BATCHFILE_EXTENSION AS STRING -BATCHFILE_EXTENSION = ".bat" -IF os$ = "LNX" THEN BATCHFILE_EXTENSION = ".sh" -IF MacOSX THEN BATCHFILE_EXTENSION = ".command" - - -DIM inlinedatastr(255) AS STRING -FOR i = 0 TO 255 - inlinedatastr(i) = str2$(i) + "," -NEXT - - -DIM SHARED extension AS STRING -DIM SHARED path.exe$, path.source$, lastBinaryGenerated$ -extension$ = ".exe" -IF os$ = "LNX" THEN extension$ = "" 'no extension under Linux - -DIM SHARED pathsep AS STRING * 1 -pathsep$ = "\" -IF os$ = "LNX" THEN pathsep$ = "/" -'note: QB64 handles OS specific path separators automatically except under SHELL calls - -ON ERROR GOTO qberror_test - -DIM SHARED tmpdir AS STRING, tmpdir2 AS STRING -IF os$ = "WIN" THEN tmpdir$ = ".\internal\temp\": tmpdir2$ = "..\\temp\\" -IF os$ = "LNX" THEN tmpdir$ = "./internal/temp/": tmpdir2$ = "../temp/" - -IF NOT _DIREXISTS(tmpdir$) THEN MKDIR tmpdir$ - -DECLARE LIBRARY - FUNCTION getpid& () -END DECLARE - -thisinstancepid = getpid& -DIM SHARED tempfolderindex - -IF INSTR(_OS$, "LINUX") THEN - fh = FREEFILE - OPEN ".\internal\temp\tempfoldersearch.bin" FOR RANDOM AS #fh LEN = LEN(tempfolderindex) - tempfolderrecords = LOF(fh) / LEN(tempfolderindex) - i = 1 - IF tempfolderrecords = 0 THEN - 'first run ever? - PUT #fh, 1, thisinstancepid - ELSE - FOR i = 1 TO tempfolderrecords - 'check if any of the temp folders is being used = pid still active - GET #fh, i, tempfoldersearch - - SHELL _HIDE "ps -p " + STR$(tempfoldersearch) + " > /dev/null 2>&1; echo $? > internal/temp/checkpid.bin" - fh2 = FREEFILE - OPEN "internal/temp/checkpid.bin" FOR BINARY AS #fh2 - LINE INPUT #fh2, checkpid$ - CLOSE #fh2 - IF VAL(checkpid$) = 1 THEN - 'This temp folder was locked by an instance that's no longer active, so - 'this will be our temp folder - PUT #fh, i, thisinstancepid - EXIT FOR - END IF - NEXT - IF i > tempfolderrecords THEN - 'All indexes were busy. Let's initiate a new one: - PUT #fh, i, thisinstancepid - END IF - END IF - CLOSE #fh - IF i > 1 THEN - tmpdir$ = "./internal/temp" + str2$(i) + "/": tmpdir2$ = "../temp" + str2$(i) + "/" - IF _DIREXISTS(tmpdir$) = 0 THEN - MKDIR tmpdir$ - END IF - END IF - OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 -ELSE - ON ERROR GOTO qberror_test - E = 0 - i = 1 - OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 - DO WHILE E - i = i + 1 - IF i = 1000 THEN PRINT "Unable to locate the 'internal' folder": END 1 - MKDIR ".\internal\temp" + str2$(i) - IF os$ = "WIN" THEN tmpdir$ = ".\internal\temp" + str2$(i) + "\": tmpdir2$ = "..\\temp" + str2$(i) + "\\" - IF os$ = "LNX" THEN tmpdir$ = "./internal/temp" + str2$(i) + "/": tmpdir2$ = "../temp" + str2$(i) + "/" - E = 0 - OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 - LOOP -END IF - - -'temp folder established -tempfolderindex = i -IF i > 1 THEN - 'create modified version of qbx.cpp - OPEN ".\internal\c\qbx" + str2$(i) + ".cpp" FOR OUTPUT AS #2 - OPEN ".\internal\c\qbx.cpp" FOR BINARY AS #1 - DO UNTIL EOF(1) - LINE INPUT #1, a$ - x = INSTR(a$, "..\\temp\\"): IF x THEN a$ = LEFT$(a$, x - 1) + "..\\temp" + str2$(i) + "\\" + RIGHT$(a$, LEN(a$) - (x + 9)) - x = INSTR(a$, "../temp/"): IF x THEN a$ = LEFT$(a$, x - 1) + "../temp" + str2$(i) + "/" + RIGHT$(a$, LEN(a$) - (x + 7)) - PRINT #2, a$ - LOOP - CLOSE #1, #2 -END IF - -IF Debug THEN OPEN tmpdir$ + "debug.txt" FOR OUTPUT AS #9 - -ON ERROR GOTO qberror - - - -DIM SHARED tempfolderindexstr AS STRING 'appended to "Untitled" -DIM SHARED tempfolderindexstr2 AS STRING -IF tempfolderindex <> 1 THEN tempfolderindexstr$ = "(" + str2$(tempfolderindex) + ")": tempfolderindexstr2$ = str2$(tempfolderindex) - - -DIM SHARED idedebuginfo -DIM SHARED seperateargs_error -DIM SHARED seperateargs_error_message AS STRING - -DIM SHARED compfailed - -DIM SHARED reginternalsubfunc -DIM SHARED reginternalvariable - - -DIM SHARED symboltype_size -symboltype_size = 0 - -DIM SHARED use_global_byte_elements -use_global_byte_elements = 0 - -'compiler-side IDE data & definitions -'SHARED variables "passed" to/from the compiler & IDE -DIM SHARED idecommand AS STRING 'a 1 byte message-type code, followed by optional string data -DIM SHARED idereturn AS STRING 'used to pass formatted-lines and return information back to the IDE -DIM SHARED ideerror AS LONG -DIM SHARED idecompiled AS LONG -DIM SHARED idemode '1 if using the IDE to compile -DIM SHARED ideerrorline AS LONG 'set by qb64-error(...) to the line number it would have reported, this number -'is later passed to the ide in message #8 -DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to be reported, this -'is later passed to the ide in message #8 - -DIM SHARED optionexplicit AS _BYTE -DIM SHARED optionexplicitarray AS _BYTE -DIM SHARED optionexplicit_cmd AS _BYTE -DIM SHARED ideStartAtLine AS LONG, errorLineInInclude AS LONG -DIM SHARED warningInInclude AS LONG, warningInIncludeLine AS LONG -DIM SHARED outputfile_cmd$ -DIM SHARED compilelog$ - -'$INCLUDE:'global\IDEsettings.bas' - -CMDLineFile = ParseCMDLineArgs$ - -IF ConsoleMode THEN - _DEST _CONSOLE -ELSE - _CONSOLE OFF - _SCREENSHOW - _ICON -END IF - -'the function ?=ide(?) should always be passed 0, it returns a message code number, any further information -'is passed back in idereturn - -'message code numbers: -'0 no ide present (auto defined array ide() return 0) - -'1 launch ide & with passed filename (compiler->ide) - -'2 begin new compilation with returned line of code (compiler<-ide) -' [2][line of code] - -'3 request next line (compiler->ide) -' [3] - -'4 next line of code returned (compiler<-ide) -' [4][line of code] - -'5 no more lines of code exist (compiler<-ide) -' [5] - -'6 code is OK/ready (compiler->ide) -' [6] - -'7 repass the code from the beginning (compiler->ide) -' [7] - -'8 an error has occurred with 'this' message on 'this' line(compiler->ide) -' [8][error message][line as LONG] - -'9 C++ compile (if necessary) and run with 'this' name (compiler<-ide) -' [9][name(no path, no .bas)] - -'10 The line requires more time to process -' Pass-back 'line of code' using method [4] when ready -' [10][line of code] - -'11 ".EXE file created" message - -'12 The name of the exe I'll create is '...' (compiler->ide) -' [12][exe name without .exe] - -'255 A qb error happened in the IDE (compiler->ide) -' note: detected by the fact that ideerror was not set to 0 -' [255] - -'hash table data -TYPE HashListItem - Flags AS LONG - Reference AS LONG - NextItem AS LONG - PrevItem AS LONG - LastItem AS LONG 'note: this value is only valid on the first item in the list - 'note: name is stored in a seperate array of strings -END TYPE -DIM SHARED HashFind_NextListItem AS LONG -DIM SHARED HashFind_Reverse AS LONG -DIM SHARED HashFind_SearchFlags AS LONG -DIM SHARED HashFind_Name AS STRING -DIM SHARED HashRemove_LastFound AS LONG -DIM SHARED HashListSize AS LONG -DIM SHARED HashListNext AS LONG -DIM SHARED HashListFreeSize AS LONG -DIM SHARED HashListFreeLast AS LONG -'hash lookup tables -DIM SHARED hash1char(255) AS INTEGER -DIM SHARED hash2char(65535) AS INTEGER -FOR x = 1 TO 26 - hash1char(64 + x) = x - hash1char(96 + x) = x -NEXT -hash1char(95) = 27 '_ -hash1char(48) = 28 '0 -hash1char(49) = 29 '1 -hash1char(50) = 30 '2 -hash1char(51) = 31 '3 -hash1char(52) = 23 '4 'note: x, y, z and beginning alphabet letters avoided because of common usage (eg. a2, y3) -hash1char(53) = 22 '5 -hash1char(54) = 20 '6 -hash1char(55) = 19 '7 -hash1char(56) = 18 '8 -hash1char(57) = 17 '9 -FOR c1 = 0 TO 255 - FOR c2 = 0 TO 255 - hash2char(c1 + c2 * 256) = hash1char(c1) + hash1char(c2) * 32 - NEXT -NEXT -'init -HashListSize = 65536 -HashListNext = 1 -HashListFreeSize = 1024 -HashListFreeLast = 0 -REDIM SHARED HashList(1 TO HashListSize) AS HashListItem -REDIM SHARED HashListName(1 TO HashListSize) AS STRING * 256 -REDIM SHARED HashListFree(1 TO HashListFreeSize) AS LONG -REDIM SHARED HashTable(16777215) AS LONG '64MB lookup table with indexes to the hashlist - -CONST HASHFLAG_LABEL = 2 -CONST HASHFLAG_TYPE = 4 -CONST HASHFLAG_RESERVED = 8 -CONST HASHFLAG_OPERATOR = 16 -CONST HASHFLAG_CUSTOMSYNTAX = 32 -CONST HASHFLAG_SUB = 64 -CONST HASHFLAG_FUNCTION = 128 -CONST HASHFLAG_UDT = 256 -CONST HASHFLAG_UDTELEMENT = 512 -CONST HASHFLAG_CONSTANT = 1024 -CONST HASHFLAG_VARIABLE = 2048 -CONST HASHFLAG_ARRAY = 4096 -CONST HASHFLAG_XELEMENTNAME = 8192 -CONST HASHFLAG_XTYPENAME = 16384 - -TYPE Label_Type - State AS _UNSIGNED _BYTE '0=label referenced, 1=label created - cn AS STRING * 256 - Scope AS LONG - Data_Offset AS _INTEGER64 'offset within data - Data_Referenced AS _UNSIGNED _BYTE 'set to 1 if data is referenced (data_offset will be used to create the data offset variable) - Error_Line AS LONG 'the line number to reference on errors - Scope_Restriction AS LONG 'cannot exist inside this scope (post checked) - SourceLineNumber AS LONG -END TYPE -DIM SHARED nLabels, Labels_Ubound -Labels_Ubound = 100 -REDIM SHARED Labels(1 TO Labels_Ubound) AS Label_Type -DIM SHARED Empty_Label AS Label_Type - -DIM SHARED PossibleSubNameLabels AS STRING 'format: name+sp+name+sp+name <-ucase$'d -DIM SHARED SubNameLabels AS STRING 'format: name+sp+name+sp+name <-ucase$'d -DIM SHARED CreatingLabel AS LONG - -DIM SHARED AllowLocalName AS LONG - -DIM SHARED DataOffset - -DIM SHARED prepass - - -DIM SHARED autoarray - -DIM SHARED ontimerid, onkeyid, onstrigid - -DIM SHARED revertmaymusthave(1 TO 10000) -DIM SHARED revertmaymusthaven - -DIM SHARED linecontinuation - -DIM SHARED dim2typepassback AS STRING 'passes back correct case sensitive version of type - - -DIM SHARED inclevel -DIM SHARED incname(100) AS STRING 'must be full path as given -DIM SHARED inclinenumber(100) AS LONG -DIM SHARED incerror AS STRING - - -DIM SHARED fix046 AS STRING -fix046$ = "__" + "ASCII" + "_" + "CHR" + "_" + "046" + "__" 'broken up to avoid detection for layout reversion - -DIM SHARED layout AS STRING 'passed to IDE -DIM SHARED layoutok AS LONG 'tracks status of entire line - -DIM SHARED layoutcomment AS STRING - -DIM SHARED tlayout AS STRING 'temporary layout string set by supporting functions -DIM SHARED layoutdone AS LONG 'tracks status of single command - - -DIM SHARED fooindwel - -DIM SHARED alphanumeric(255) -FOR i = 48 TO 57 - alphanumeric(i) = -1 -NEXT -FOR i = 65 TO 90 - alphanumeric(i) = -1 -NEXT -FOR i = 97 TO 122 - alphanumeric(i) = -1 -NEXT -'_ is treated as an alphabet letter -alphanumeric(95) = -1 - -DIM SHARED isalpha(255) -FOR i = 65 TO 90 - isalpha(i) = -1 -NEXT -FOR i = 97 TO 122 - isalpha(i) = -1 -NEXT -'_ is treated as an alphabet letter -isalpha(95) = -1 - -DIM SHARED isnumeric(255) -FOR i = 48 TO 57 - isnumeric(i) = -1 -NEXT - - -DIM SHARED lfsinglechar(255) -lfsinglechar(40) = 1 '( -lfsinglechar(41) = 1 ') -lfsinglechar(42) = 1 '* -lfsinglechar(43) = 1 '+ -lfsinglechar(45) = 1 '- -lfsinglechar(47) = 1 '/ -lfsinglechar(60) = 1 '< -lfsinglechar(61) = 1 '= -lfsinglechar(62) = 1 '> -lfsinglechar(92) = 1 '\ -lfsinglechar(94) = 1 '^ - -lfsinglechar(44) = 1 ', -lfsinglechar(46) = 1 '. -lfsinglechar(58) = 1 ': -lfsinglechar(59) = 1 '; - -lfsinglechar(35) = 1 '# (file no only) -lfsinglechar(36) = 1 '$ (metacommand only) -lfsinglechar(63) = 1 '? (print macro) -lfsinglechar(95) = 1 '_ - - - - - - - - - - -DIM SHARED nextrunlineindex AS LONG - -DIM SHARED lineinput3buffer AS STRING -DIM SHARED lineinput3index AS LONG - -DIM SHARED dimstatic AS LONG - -DIM SHARED staticarraylist AS STRING -DIM SHARED staticarraylistn AS LONG -DIM SHARED commonarraylist AS STRING -DIM SHARED commonarraylistn AS LONG - -'CONST support -DIM SHARED constmax AS LONG -constmax = 100 -DIM SHARED constlast AS LONG -constlast = -1 -REDIM SHARED constname(constmax) AS STRING -REDIM SHARED constcname(constmax) AS STRING -REDIM SHARED constnamesymbol(constmax) AS STRING 'optional name symbol -' `1 and `no-number must be handled correctly -'DIM SHARED constlastshared AS LONG 'so any defined inside a sub/function after this index can be "forgotten" when sub/function exits -'constlastshared = -1 -REDIM SHARED consttype(constmax) AS LONG 'variable type number -'consttype determines storage -REDIM SHARED constinteger(constmax) AS _INTEGER64 -REDIM SHARED constuinteger(constmax) AS _UNSIGNED _INTEGER64 -REDIM SHARED constfloat(constmax) AS _FLOAT -REDIM SHARED conststring(constmax) AS STRING -REDIM SHARED constsubfunc(constmax) AS LONG -REDIM SHARED constdefined(constmax) AS LONG - -'UDT -'names -DIM SHARED lasttype AS LONG -DIM SHARED lasttypeelement AS LONG - -TYPE idstruct - - n AS STRING * 256 'name - cn AS STRING * 256 'case sensitive version of n - - arraytype AS LONG 'similar to t - arrayelements AS INTEGER - staticarray AS INTEGER 'set for arrays declared in the main module with static elements - - mayhave AS STRING * 8 'mayhave and musthave are exclusive of each other - musthave AS STRING * 8 - t AS LONG 'type - - tsize AS LONG - - - subfunc AS INTEGER 'if function=1, sub=2 (max 100 arguments) - Dependency AS INTEGER - internal_subfunc AS INTEGER - - callname AS STRING * 256 - ccall AS INTEGER - overloaded AS _BYTE - args AS INTEGER - minargs AS INTEGER - arg AS STRING * 400 'similar to t - argsize AS STRING * 400 'similar to tsize (used for fixed length strings) - specialformat AS STRING * 256 - secondargmustbe AS STRING * 256 - secondargcantbe AS STRING * 256 - ret AS LONG 'the value it returns if it is a function (again like t) - - insubfunc AS STRING * 256 - insubfuncn AS LONG - - share AS INTEGER - nele AS STRING * 100 - nelereq AS STRING * 100 - linkid AS LONG - linkarg AS INTEGER - staticscope AS INTEGER - 'For variables which are arguments passed to a sub/function - sfid AS LONG 'id number of variable's parent sub/function - sfarg AS INTEGER 'argument/parameter # within call (1=first) - - hr_syntax AS STRING -END TYPE - -DIM SHARED id AS idstruct - -DIM SHARED idn AS LONG -DIM SHARED ids_max AS LONG -ids_max = 1024 -REDIM SHARED ids(1 TO ids_max) AS idstruct -REDIM SHARED cmemlist(1 TO ids_max + 1) AS INTEGER 'variables that must be in cmem -REDIM SHARED sfcmemargs(1 TO ids_max + 1) AS STRING * 100 's/f arg that must be in cmem -REDIM SHARED arrayelementslist(1 TO ids_max + 1) AS INTEGER 'arrayelementslist (like cmemlist) helps to resolve the number of elements in arrays with an unknown number of elements. Note: arrays with an unknown number of elements have .arrayelements=-1 - - -'create blank id template for idclear to copy (stops strings being set to chr$(0)) -DIM SHARED cleariddata AS idstruct -cleariddata.cn = "" -cleariddata.n = "" -cleariddata.mayhave = "" -cleariddata.musthave = "" -cleariddata.callname = "" -cleariddata.arg = "" -cleariddata.argsize = "" -cleariddata.specialformat = "" -cleariddata.secondargmustbe = "" -cleariddata.secondargcantbe = "" -cleariddata.insubfunc = "" -cleariddata.nele = "" -cleariddata.nelereq = "" - -DIM SHARED ISSTRING AS LONG -DIM SHARED ISFLOAT AS LONG -DIM SHARED ISUNSIGNED AS LONG -DIM SHARED ISPOINTER AS LONG -DIM SHARED ISFIXEDLENGTH AS LONG -DIM SHARED ISINCONVENTIONALMEMORY AS LONG -DIM SHARED ISOFFSETINBITS AS LONG -DIM SHARED ISARRAY AS LONG -DIM SHARED ISREFERENCE AS LONG -DIM SHARED ISUDT AS LONG -DIM SHARED ISOFFSET AS LONG - -DIM SHARED STRINGTYPE AS LONG -DIM SHARED BITTYPE AS LONG -DIM SHARED UBITTYPE AS LONG -DIM SHARED BYTETYPE AS LONG -DIM SHARED UBYTETYPE AS LONG -DIM SHARED INTEGERTYPE AS LONG -DIM SHARED UINTEGERTYPE AS LONG -DIM SHARED LONGTYPE AS LONG -DIM SHARED ULONGTYPE AS LONG -DIM SHARED INTEGER64TYPE AS LONG -DIM SHARED UINTEGER64TYPE AS LONG -DIM SHARED SINGLETYPE AS LONG -DIM SHARED DOUBLETYPE AS LONG -DIM SHARED FLOATTYPE AS LONG -DIM SHARED OFFSETTYPE AS LONG -DIM SHARED UOFFSETTYPE AS LONG -DIM SHARED UDTTYPE AS LONG - -DIM SHARED gosubid AS LONG -DIM SHARED redimoption AS INTEGER -DIM SHARED dimoption AS INTEGER -DIM SHARED arraydesc AS INTEGER -DIM SHARED qberrorhappened AS INTEGER -DIM SHARED qberrorcode AS INTEGER -DIM SHARED qberrorline AS INTEGER -'COMMON SHARED defineaz() AS STRING -'COMMON SHARED defineextaz() AS STRING - -DIM SHARED sourcefile AS STRING 'the full path and filename -DIM SHARED file AS STRING 'name of the file (without .bas or path) - -'COMMON SHARED separgs() AS STRING - -DIM SHARED constequation AS INTEGER -DIM SHARED DynamicMode AS INTEGER -DIM SHARED findidsecondarg AS STRING -DIM SHARED findanotherid AS INTEGER -DIM SHARED findidinternal AS LONG -DIM SHARED currentid AS LONG 'is the index of the last ID accessed -DIM SHARED linenumber AS LONG, reallinenumber AS LONG, totallinenumber AS LONG, definingtypeerror AS LONG -DIM SHARED wholeline AS STRING -DIM SHARED firstLineNumberLabelvWatch AS LONG, lastLineNumberLabelvWatch AS LONG -DIM SHARED vWatchUsedLabels AS STRING, vWatchUsedSkipLabels AS STRING -DIM SHARED linefragment AS STRING -'COMMON SHARED bitmask() AS _INTEGER64 -'COMMON SHARED bitmaskinv() AS _INTEGER64 - -DIM SHARED arrayprocessinghappened AS INTEGER -DIM SHARED stringprocessinghappened AS INTEGER -DIM SHARED cleanupstringprocessingcall AS STRING -DIM SHARED inputfunctioncalled AS _BYTE -DIM SHARED recompile AS INTEGER 'forces recompilation -'COMMON SHARED cmemlist() AS INTEGER -DIM SHARED optionbase AS INTEGER - -DIM SHARED addmetastatic AS INTEGER -DIM SHARED addmetadynamic AS INTEGER -DIM SHARED addmetainclude AS STRING - -DIM SHARED closedmain AS INTEGER -DIM SHARED module AS STRING - -DIM SHARED subfunc AS STRING -DIM SHARED subfuncn AS LONG -DIM SHARED closedsubfunc AS _BYTE -DIM SHARED subfuncid AS LONG - -DIM SHARED defdatahandle AS INTEGER -DIM SHARED dimsfarray AS INTEGER -DIM SHARED dimshared AS INTEGER - -'Allows passing of known elements to recompilation -DIM SHARED sflistn AS INTEGER -'COMMON SHARED sfidlist() AS LONG -'COMMON SHARED sfarglist() AS INTEGER -'COMMON SHARED sfelelist() AS INTEGER -DIM SHARED glinkid AS LONG -DIM SHARED glinkarg AS INTEGER -DIM SHARED typname2typsize AS LONG -DIM SHARED uniquenumbern AS LONG - -'CLEAR , , 16384 - - -DIM SHARED bitmask(1 TO 64) AS _INTEGER64 -DIM SHARED bitmaskinv(1 TO 64) AS _INTEGER64 - -DIM SHARED defineextaz(1 TO 27) AS STRING -DIM SHARED defineaz(1 TO 27) AS STRING '27 is an underscore - -ISSTRING = 1073741824 -ISFLOAT = 536870912 -ISUNSIGNED = 268435456 -ISPOINTER = 134217728 -ISFIXEDLENGTH = 67108864 'only set for strings with pointer flag -ISINCONVENTIONALMEMORY = 33554432 -ISOFFSETINBITS = 16777216 -ISARRAY = 8388608 -ISREFERENCE = 4194304 -ISUDT = 2097152 -ISOFFSET = 1048576 - -STRINGTYPE = ISSTRING + ISPOINTER -BITTYPE = 1& + ISPOINTER + ISOFFSETINBITS -UBITTYPE = 1& + ISPOINTER + ISUNSIGNED + ISOFFSETINBITS 'QB64 will also support BIT*n, eg. DIM bitarray[10] AS _UNSIGNED _BIT*10 -BYTETYPE = 8& + ISPOINTER -UBYTETYPE = 8& + ISPOINTER + ISUNSIGNED -INTEGERTYPE = 16& + ISPOINTER -UINTEGERTYPE = 16& + ISPOINTER + ISUNSIGNED -LONGTYPE = 32& + ISPOINTER -ULONGTYPE = 32& + ISPOINTER + ISUNSIGNED -INTEGER64TYPE = 64& + ISPOINTER -UINTEGER64TYPE = 64& + ISPOINTER + ISUNSIGNED -SINGLETYPE = 32& + ISFLOAT + ISPOINTER -DOUBLETYPE = 64& + ISFLOAT + ISPOINTER -FLOATTYPE = 256& + ISFLOAT + ISPOINTER '8-32 bytes -OFFSETTYPE = 64& + ISOFFSET + ISPOINTER: IF OS_BITS = 32 THEN OFFSETTYPE = 32& + ISOFFSET + ISPOINTER -UOFFSETTYPE = 64& + ISOFFSET + ISUNSIGNED + ISPOINTER: IF OS_BITS = 32 THEN UOFFSETTYPE = 32& + ISOFFSET + ISUNSIGNED + ISPOINTER -UDTTYPE = ISUDT + ISPOINTER - - - - - - -DIM SHARED statementn AS LONG -DIM SHARED everycasenewcase AS LONG - - - - -DIM SHARED controllevel AS INTEGER '0=not in a control block -DIM SHARED controltype(1000) AS INTEGER -'1=IF (awaiting END IF) -'2=FOR (awaiting NEXT) -'3=DO (awaiting LOOP [UNTIL|WHILE param]) -'4=DO WHILE/UNTIL (awaiting LOOP) -'5=WHILE (awaiting WEND) -'6=$IF (precompiler) -'10=SELECT CASE qbs (awaiting END SELECT/CASE) -'11=SELECT CASE int64 (awaiting END SELECT/CASE) -'12=SELECT CASE uint64 (awaiting END SELECT/CASE) -'13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) -'14=SELECT CASE float ... -'15=SELECT CASE double -'16=SELECT CASE int32 -'17=SELECT CASE uint32 -'18=CASE (awaiting END SELECT/CASE/CASE ELSE) -'19=CASE ELSE (awaiting END SELECT) -'32=SUB/FUNCTION (awaiting END SUB/FUNCTION) -DIM controlid(1000) AS LONG -DIM controlvalue(1000) AS LONG -DIM controlstate(1000) AS INTEGER -DIM SHARED controlref(1000) AS LONG 'the line number the control was created on - - - - - -ON ERROR GOTO qberror - -i2&& = 1 -FOR i&& = 1 TO 64 - bitmask(i&&) = i2&& - bitmaskinv(i&&) = NOT i2&& - i2&& = i2&& + 2 ^ i&& -NEXT - -DIM id2 AS idstruct - -cleanupstringprocessingcall$ = "qbs_cleanup(qbs_tmp_base," - -DIM SHARED sfidlist(1000) AS LONG -DIM SHARED sfarglist(1000) AS INTEGER -DIM SHARED sfelelist(1000) AS INTEGER - - - - - - - - - - - - - - - -'----------------ripgl.bas-------------------------------------------------------------------------------- -gl_scan_header -'----------------ripgl.bas-------------------------------------------------------------------------------- - - - - - - - -'-----------------------QB64 COMPILER ONCE ONLY SETUP CODE ENDS HERE--------------------------------------- - -IF NoIDEMode THEN IDE_AutoPosition = 0: GOTO noide -DIM FileDropEnabled AS _BYTE -IF FileDropEnabled = 0 THEN FileDropEnabled = -1: _ACCEPTFILEDROP - -IF IDE_AutoPosition AND NOT IDE_BypassAutoPosition THEN _SCREENMOVE IDE_LeftPosition, IDE_TopPosition -idemode = 1 -sendc$ = "" 'no initial message -IF CMDLineFile <> "" THEN sendc$ = CHR$(1) + CMDLineFile -sendcommand: -idecommand$ = sendc$ -C = ide(0) -ideerror = 0 -IF C = 0 THEN idemode = 0: GOTO noide -c$ = idereturn$ - -IF C = 2 THEN 'begin - ideerrorline = 0 'addresses invalid prepass error line numbers being reported - idepass = 1 - GOTO fullrecompile - ideret1: - wholeline$ = c$ - GOTO ideprepass - ideret2: - IF lastLineReturn THEN GOTO lastLineReturn - sendc$ = CHR$(3) 'request next line - GOTO sendcommand -END IF - -IF C = 4 THEN 'next line - IF idepass = 1 THEN - wholeline$ = c$ - GOTO ideprepass - '(returns to ideret2: above) - END IF - 'assume idepass>1 - a3$ = c$ - continuelinefrom = 0 - GOTO ide4 - ideret4: - IF lastLineReturn THEN GOTO lastLineReturn - sendc$ = CHR$(3) 'request next line - GOTO sendcommand -END IF - -IF C = 5 THEN 'end of program reached - - lastLine = 1 - lastLineReturn = 1 - IF idepass = 1 THEN - wholeline$ = "" - GOTO ideprepass - '(returns to ideret2: above, then to lastLinePrepassReturn below) - END IF - 'idepass>1 - a3$ = "" - continuelinefrom = 0 - GOTO ide4 'returns to ideret4, then to lastLinePrepassReturn below - lastLineReturn: - lastLineReturn = 0 - lastLine = 0 - - IF idepass = 1 THEN - 'prepass complete - idepass = 2 - GOTO ide3 - ideret3: - sendc$ = CHR$(7) 'repass request - firstLine = 1 - GOTO sendcommand - END IF - 'assume idepass=2 - 'finalize program - GOTO ide5 - ideret5: 'note: won't return here if a recompile was required! - sendc$ = CHR$(6) 'ready - idecompiled = 0 - GOTO sendcommand -END IF - -IF C = 9 THEN 'run - - IF idecompiled = 0 THEN 'exe needs to be compiled - file$ = c$ - - 'locate accessible file and truncate - f$ = file$ - - path.exe$ = "" - IF SaveExeWithSource THEN - IF LEN(ideprogname) THEN path.exe$ = idepath$ + pathsep$ - END IF - - i = 1 - nextexeindex: - IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN - E = 0 - ON ERROR GOTO qberror_test - KILL path.exe$ + file$ + extension$ - ON ERROR GOTO qberror - IF E = 1 THEN - i = i + 1 - file$ = f$ + "(" + str2$(i) + ")" - GOTO nextexeindex - END IF - END IF - - 'inform IDE of name change if necessary (IDE will respond with message 9 and corrected name) - IF i <> 1 THEN - sendc$ = CHR$(12) + file$ - GOTO sendcommand - END IF - - ideerrorline = 0 'addresses C++ comp. error's line number - GOTO ide6 - ideret6: - idecompiled = 1 - END IF - - IF iderunmode = 2 THEN - sendc$ = CHR$(11) '.EXE file created - GOTO sendcommand - END IF - - 'execute program - - - - - IF iderunmode = 1 THEN - IF NoExeSaved THEN - 'This is the section which deals with if the user selected to run the program without - 'saving an EXE file to the disk. - 'We start off by first running the EXE, and then we delete it from the drive. - 'making it a temporary file when all is said and done. - IF os$ = "WIN" THEN - SHELL QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ 'run the newly created program - SHELL _HIDE _DONTWAIT "del " + QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) 'kill it - END IF - IF path.exe$ = "" THEN path.exe$ = "./" - IF os$ = "LNX" THEN - IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN - SHELL QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ - KILL lastBinaryGenerated$ - ELSE - SHELL QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ - KILL path.exe$ + lastBinaryGenerated$ - END IF - END IF - IF path.exe$ = "./" THEN path.exe$ = "" - NoExeSaved = 0 'reset the flag for a temp EXE - sendc$ = CHR$(6) 'ready - GOTO sendcommand - END IF - - - - IF os$ = "WIN" THEN SHELL _DONTWAIT QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ - IF path.exe$ = "" THEN path.exe$ = "./" - IF os$ = "LNX" THEN - IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN - SHELL _DONTWAIT QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ - ELSE - SHELL _DONTWAIT QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ - END IF - END IF - IF path.exe$ = "./" THEN path.exe$ = "" - ELSE - IF os$ = "WIN" THEN SHELL QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ - IF path.exe$ = "" THEN path.exe$ = "./" - IF os$ = "LNX" THEN - IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN - SHELL QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ - ELSE - SHELL QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ - END IF - END IF - IF path.exe$ = "./" THEN path.exe$ = "" - DO: LOOP UNTIL INKEY$ = "" - DO: LOOP UNTIL _KEYHIT = 0 - END IF - - IF idemode THEN - 'Darken fg/bg colors - dummy = DarkenFGBG(0) - END IF - - IF vWatchOn THEN - sendc$ = CHR$(254) 'launch debug interface - ELSE - sendc$ = CHR$(6) 'ready - END IF - GOTO sendcommand -END IF - -PRINT "Invalid IDE message": END - -ideerror: -IF INSTR(idemessage$, sp$) THEN - 'Something went wrong here, so let's give a generic error message to the user. - '(No error message should contain sp$ - that is, CHR$(13), when not in Debug mode) - terrmsg$ = _ERRORMESSAGE$ - IF terrmsg$ = "No error" THEN terrmsg$ = "Internal error" - idemessage$ = "Compiler error (check for syntax errors) (" + terrmsg$ + ":" - IF ERR THEN idemessage$ = idemessage$ + str2$(ERR) + "-" - IF _ERRORLINE THEN idemessage$ = idemessage$ + str2$(_ERRORLINE) - IF _INCLERRORLINE THEN idemessage$ = idemessage$ + "-" + _INCLERRORFILE$ + "-" + str2$(_INCLERRORLINE) - idemessage$ = idemessage$ + ")" - IF inclevel > 0 THEN idemessage$ = idemessage$ + incerror$ -END IF - -sendc$ = CHR$(8) + idemessage$ + MKL$(ideerrorline) -GOTO sendcommand - - -noide: -IF (qb64versionprinted = 0 OR ConsoleMode = 0) AND NOT QuietMode THEN - qb64versionprinted = -1 - PRINT "QB64 Compiler V" + Version$ -END IF - -IF CMDLineFile = "" THEN - LINE INPUT ; "COMPILE (.bas)>", f$ -ELSE - f$ = CMDLineFile -END IF - -f$ = LTRIM$(RTRIM$(f$)) - -IF FileHasExtension(f$) = 0 THEN f$ = f$ + ".bas" - -sourcefile$ = f$ -CMDLineFile = sourcefile$ -'derive name from sourcefile -f$ = RemoveFileExtension$(f$) - -path.exe$ = "" -currentdir$ = _CWD$ -path.source$ = getfilepath$(sourcefile$) -IF LEN(path.source$) THEN - IF _DIREXISTS(path.source$) = 0 THEN - PRINT - PRINT "Cannot locate source file: " + sourcefile$ - IF ConsoleMode THEN SYSTEM 1 - END 1 - END IF - CHDIR path.source$ - path.source$ = _CWD$ - IF RIGHT$(path.source$, 1) <> pathsep$ THEN path.source$ = path.source$ + pathsep$ - CHDIR currentdir$ -END IF -IF SaveExeWithSource THEN path.exe$ = path.source$ - -FOR x = LEN(f$) TO 1 STEP -1 - a$ = MID$(f$, x, 1) - IF a$ = "/" OR a$ = "\" THEN - f$ = RIGHT$(f$, LEN(f$) - x) - EXIT FOR - END IF -NEXT -file$ = f$ - -'if cmemlist(currentid+1)<>0 before calling regid the variable -'MUST be defined in cmem! - -fullrecompile: - -BU_DEPENDENCY_CONSOLE_ONLY = DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) -FOR i = 1 TO UBOUND(DEPENDENCY): DEPENDENCY(i) = 0: NEXT -DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) = BU_DEPENDENCY_CONSOLE_ONLY AND 2 'Restore -g switch if used - -Error_Happened = 0 - -FOR closeall = 1 TO 255: CLOSE closeall: NEXT - -OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock - -fh = FREEFILE: OPEN tmpdir$ + "dyninfo.txt" FOR OUTPUT AS #fh: CLOSE #fh - -IF Debug THEN CLOSE #9: OPEN tmpdir$ + "debug.txt" FOR OUTPUT AS #9 - -FOR i = 1 TO ids_max + 1 - arrayelementslist(i) = 0 - cmemlist(i) = 0 - sfcmemargs(i) = "" -NEXT - -'erase cmemlist -'erase sfcmemargs - -lastunresolved = -1 'first pass -sflistn = -1 'no entries - -SubNameLabels = sp 'QB64 will perform a repass to resolve sub names used as labels - -vWatchDesiredState = 0 -vWatchRecompileAttempts = 0 - -qb64prefix_set_desiredState = 0 -qb64prefix_set_recompileAttempts = 0 - -opex_desiredState = 0 -opex_recompileAttempts = 0 - -opexarray_desiredState = 0 -opexarray_recompileAttempts = 0 - -recompile: -vWatchOn = vWatchDesiredState -vWatchVariable "", -1 'reset internal variables list - -qb64prefix_set = qb64prefix_set_desiredState -qb64prefix$ = "_" - -optionexplicit = opex_desiredState -IF optionexplicit_cmd = -1 AND NoIDEMode = 1 THEN optionexplicit = -1 -optionexplicitarray = opexarray_desiredState - -lastLineReturn = 0 -lastLine = 0 -firstLine = 1 - -Resize = 0 -Resize_Scale = 0 - -UseGL = 0 - -Error_Happened = 0 - -HashClear 'clear the hash table - -'add reserved words to hashtable - -f = HASHFLAG_TYPE + HASHFLAG_RESERVED -HashAdd "_UNSIGNED", f, 0 -HashAdd "_BIT", f, 0 -HashAdd "_BYTE", f, 0 -HashAdd "INTEGER", f, 0 -HashAdd "LONG", f, 0 -HashAdd "_INTEGER64", f, 0 -HashAdd "_OFFSET", f, 0 -HashAdd "SINGLE", f, 0 -HashAdd "DOUBLE", f, 0 -HashAdd "_FLOAT", f, 0 -HashAdd "STRING", f, 0 -HashAdd "ANY", f, 0 - -f = HASHFLAG_OPERATOR + HASHFLAG_RESERVED -HashAdd "NOT", f, 0 -HashAdd "IMP", f, 0 -HashAdd "EQV", f, 0 -HashAdd "AND", f, 0 -HashAdd "OR", f, 0 -HashAdd "XOR", f, 0 -HashAdd "MOD", f, 0 - -f = HASHFLAG_RESERVED + HASHFLAG_CUSTOMSYNTAX -HashAdd "LIST", f, 0 -HashAdd "BASE", f, 0 -HashAdd "_EXPLICIT", f, 0 -HashAdd "AS", f, 0 -HashAdd "IS", f, 0 -HashAdd "OFF", f, 0 -HashAdd "ON", f, 0 -HashAdd "STOP", f, 0 -HashAdd "TO", f, 0 -HashAdd "USING", f, 0 -'PUT(graphics) statement: -HashAdd "PRESET", f, 0 -HashAdd "PSET", f, 0 -'OPEN statement: -HashAdd "FOR", f, 0 -HashAdd "OUTPUT", f, 0 -HashAdd "RANDOM", f, 0 -HashAdd "BINARY", f, 0 -HashAdd "APPEND", f, 0 -HashAdd "SHARED", f, 0 -HashAdd "ACCESS", f, 0 -HashAdd "LOCK", f, 0 -HashAdd "READ", f, 0 -HashAdd "WRITE", f, 0 -'LINE statement: -HashAdd "STEP", f, 0 -'WIDTH statement: -HashAdd "LPRINT", f, 0 -'VIEW statement: -HashAdd "PRINT", f, 0 - -f = HASHFLAG_RESERVED + HASHFLAG_XELEMENTNAME + HASHFLAG_XTYPENAME -'A -'B -'C -HashAdd "COMMON", f, 0 -HashAdd "CALL", f, 0 -HashAdd "CASE", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "COM", f, 0 '(ON...) -HashAdd "CONST", f, 0 -'D -HashAdd "DATA", f, 0 -HashAdd "DECLARE", f, 0 -HashAdd "DEF", f, 0 -HashAdd "DEFDBL", f, 0 -HashAdd "DEFINT", f, 0 -HashAdd "DEFLNG", f, 0 -HashAdd "DEFSNG", f, 0 -HashAdd "DEFSTR", f, 0 -HashAdd "DIM", f, 0 -HashAdd "DO", f - HASHFLAG_XELEMENTNAME, 0 -'E -HashAdd "ERROR", f - HASHFLAG_XELEMENTNAME, 0 '(ON ...) -HashAdd "ELSE", f, 0 -HashAdd "ELSEIF", f, 0 -HashAdd "ENDIF", f, 0 -HashAdd "EXIT", f - HASHFLAG_XELEMENTNAME, 0 -'F -HashAdd "FIELD", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "FUNCTION", f, 0 -'G -HashAdd "GOSUB", f, 0 -HashAdd "GOTO", f, 0 -'H -'I -HashAdd "INPUT", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(INPUT$ function exists, so conflicts if allowed as custom syntax) -HashAdd "IF", f, 0 -'K -HashAdd "KEY", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) -'L -HashAdd "LET", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "LOOP", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "LEN", f - HASHFLAG_XELEMENTNAME, 0 '(LEN function exists, so conflicts if allowed as custom syntax) -'M -'N -HashAdd "NEXT", f - HASHFLAG_XELEMENTNAME, 0 -'O -'P -HashAdd "PLAY", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) -HashAdd "PEN", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) -'Q -'R -HashAdd "REDIM", f, 0 -HashAdd "REM", f, 0 -HashAdd "RESTORE", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "RESUME", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "RETURN", f - HASHFLAG_XELEMENTNAME, 0 -HashAdd "RUN", f - HASHFLAG_XELEMENTNAME, 0 -'S -HashAdd "STATIC", f, 0 -HashAdd "STRIG", f, 0 '(ON...) -HashAdd "SEG", f, 0 -HashAdd "SELECT", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 -HashAdd "SUB", f, 0 -HashAdd "SCREEN", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 -'T -HashAdd "THEN", f, 0 -HashAdd "TIMER", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) -HashAdd "TYPE", f - HASHFLAG_XELEMENTNAME, 0 -'U -HashAdd "UNTIL", f, 0 -HashAdd "UEVENT", f, 0 -'V -'W -HashAdd "WEND", f, 0 -HashAdd "WHILE", f, 0 -'X -'Y -'Z - - - - - - - -'clear/init variables -Console = 0 -ScreenHide = 0 -Asserts = 0 -ResolveStaticFunctions = 0 -dynamiclibrary = 0 -dimsfarray = 0 -dimstatic = 0 -AllowLocalName = 0 -PossibleSubNameLabels = sp 'QB64 will perform a repass to resolve sub names used as labels -use_global_byte_elements = 0 -dimshared = 0: dimmethod = 0: dimoption = 0: redimoption = 0: commonoption = 0 -mylib$ = "": mylibopt$ = "" -declaringlibrary = 0 -nLabels = 0 -dynscope = 0 -elsefollowup = 0 -ontimerid = 0: onkeyid = 0: onstrigid = 0 -commonarraylist = "": commonarraylistn = 0 -staticarraylist = "": staticarraylistn = 0 -fooindwel = 0 -layout = "" -layoutok = 0 -NoChecks = 0 -inclevel = 0 -errorLineInInclude = 0 -addmetainclude$ = "" -nextrunlineindex = 1 -lasttype = 0 -lasttypeelement = 0 -REDIM SHARED udtxname(1000) AS STRING * 256 -REDIM SHARED udtxcname(1000) AS STRING * 256 -REDIM SHARED udtxsize(1000) AS LONG -REDIM SHARED udtxbytealign(1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 -REDIM SHARED udtxnext(1000) AS LONG -REDIM SHARED udtxvariable(1000) AS INTEGER 'true if the udt contains variable length elements -'elements -REDIM SHARED udtename(1000) AS STRING * 256 -REDIM SHARED udtecname(1000) AS STRING * 256 -REDIM SHARED udtebytealign(1000) AS INTEGER -REDIM SHARED udtesize(1000) AS LONG -REDIM SHARED udtetype(1000) AS LONG -REDIM SHARED udtetypesize(1000) AS LONG -REDIM SHARED udtearrayelements(1000) AS LONG -REDIM SHARED udtenext(1000) AS LONG -definingtype = 0 -definingtypeerror = 0 -constlast = -1 -'constlastshared = -1 -defdatahandle = 18 -closedmain = 0 -addmetastatic = 0 -addmetadynamic = 0 -DynamicMode = 0 -optionbase = 0 -ExeIconSet = 0 -VersionInfoSet = 0 -viFileVersionNum$ = "": viProductVersionNum$ = "": viCompanyName$ = "" -viFileDescription$ = "": viFileVersion$ = "": viInternalName$ = "" -viLegalCopyright$ = "": viLegalTrademarks$ = "": viOriginalFilename$ = "" -viProductName$ = "": viProductVersion$ = "": viComments$ = "": viWeb$ = "" -DataOffset = 0 -statementn = 0 -everycasenewcase = 0 -qberrorhappened = 0: qberrorcode = 0: qberrorline = 0 -FOR i = 1 TO 27: defineaz(i) = "SINGLE": defineextaz(i) = "!": NEXT -controllevel = 0 -findidsecondarg$ = "": findanotherid = 0: findidinternal = 0: currentid = 0 -linenumber = 0 -wholeline$ = "" -linefragment$ = "" -idn = 0 -arrayprocessinghappened = 0 -stringprocessinghappened = 0 -inputfunctioncalled = 0 -subfuncn = 0 -closedsubfunc = 0 -subfunc = "" -SelectCaseCounter = 0 -ExecCounter = 0 -UserDefineCount = 7 -totalVariablesCreated = 0 -typeDefinitions$ = "" -totalMainVariablesCreated = 0 -REDIM SHARED usedVariableList(1000) AS usedVarList -totalWarnings = 0 -duplicateConstWarning = 0 -emptySCWarning = 0 -warningListItems = 0 -lastWarningHeader = "" -vWatchUsedLabels = SPACE$(1000) -vWatchUsedSkipLabels = SPACE$(1000) -firstLineNumberLabelvWatch = 0 -REDIM SHARED warning$(1000) -REDIM SHARED warningLines(1000) AS LONG -REDIM SHARED warningIncLines(1000) AS LONG -REDIM SHARED warningIncFiles(1000) AS STRING -maxLineNumber = 0 -uniquenumbern = 0 - - -''create a type for storing memory blocks -''UDT -''names -'DIM SHARED lasttype AS LONG -'DIM SHARED udtxname(1000) AS STRING * 256 -'DIM SHARED udtxcname(1000) AS STRING * 256 -'DIM SHARED udtxsize(1000) AS LONG -'DIM SHARED udtxbytealign(1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 -'DIM SHARED udtxnext(1000) AS LONG -''elements -'DIM SHARED lasttypeelement AS LONG -'DIM SHARED udtename(1000) AS STRING * 256 -'DIM SHARED udtecname(1000) AS STRING * 256 -'DIM SHARED udtebytealign(1000) AS INTEGER -'DIM SHARED udtesize(1000) AS LONG -'DIM SHARED udtetype(1000) AS LONG -'DIM SHARED udtetypesize(1000) AS LONG -'DIM SHARED udtearrayelements(1000) AS LONG -'DIM SHARED udtenext(1000) AS LONG - -'import _MEM type -ptrsz = OS_BITS \ 8 - -lasttype = lasttype + 1: i = lasttype -udtxname(i) = "_MEM" -udtxcname(i) = "_MEM" -udtxsize(i) = ((ptrsz) * 5 + (4) * 2 + (8) * 1) * 8 -udtxbytealign(i) = 1 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "OFFSET" -udtecname(i2) = "OFFSET" -udtebytealign(i2) = 1 -udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 -udtetypesize(i2) = 0 'tsize -udtxnext(i) = i2 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "SIZE" -udtecname(i2) = "SIZE" -udtebytealign(i2) = 1 -udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "$_LOCK_ID" -udtecname(i2) = "$_LOCK_ID" -udtebytealign(i2) = 1 -udtetype(i2) = INTEGER64TYPE: udtesize(i2) = 64 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "$_LOCK_OFFSET" -udtecname(i2) = "$_LOCK_OFFSET" -udtebytealign(i2) = 1 -udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "TYPE" -udtecname(i2) = "TYPE" -udtebytealign(i2) = 1 -udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "ELEMENTSIZE" -udtecname(i2) = "ELEMENTSIZE" -udtebytealign(i2) = 1 -udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -udtenext(i2) = 0 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "IMAGE" -udtecname(i2) = "IMAGE" -udtebytealign(i2) = 1 -udtetype(i2) = LONGTYPE: udtesize(i2) = 32 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -udtenext(i2) = 0 -i3 = i2 -lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement -udtename(i2) = "SOUND" -udtecname(i2) = "SOUND" -udtebytealign(i2) = 1 -udtetype(i2) = LONGTYPE: udtesize(i2) = 32 -udtetypesize(i2) = 0 'tsize -udtenext(i3) = i2 -udtenext(i2) = 0 - - - - - - - - - - -'begin compilation -FOR closeall = 1 TO 255: CLOSE closeall: NEXT -OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock - -ff = FREEFILE: OPEN tmpdir$ + "icon.rc" FOR OUTPUT AS #ff: CLOSE #ff - -IF Debug THEN CLOSE #9: OPEN tmpdir$ + "debug.txt" FOR APPEND AS #9 - -IF idemode = 0 THEN - qberrorhappened = -1 - OPEN sourcefile$ FOR INPUT AS #1 - qberrorhappened1: - IF qberrorhappened = 1 THEN - PRINT - PRINT "Cannot locate source file: " + sourcefile$ - IF ConsoleMode THEN SYSTEM 1 - END 1 - ELSE - CLOSE #1 - END IF - qberrorhappened = 0 -END IF - -reginternal - -IF qb64prefix_set THEN - qb64prefix$ = "" - - 're-add internal keywords without the "_" prefix - reginternal - - f = HASHFLAG_TYPE + HASHFLAG_RESERVED - HashAdd "UNSIGNED", f, 0 - HashAdd "BIT", f, 0 - HashAdd "BYTE", f, 0 - HashAdd "INTEGER64", f, 0 - HashAdd "OFFSET", f, 0 - HashAdd "FLOAT", f, 0 - - f = HASHFLAG_RESERVED + HASHFLAG_CUSTOMSYNTAX - HashAdd "EXPLICIT", f, 0 -END IF - -OPEN tmpdir$ + "global.txt" FOR OUTPUT AS #18 - -IF iderecompile THEN - iderecompile = 0 - idepass = 1 'prepass must be done again - sendc$ = CHR$(7) 'repass request - GOTO sendcommand -END IF - -IF idemode THEN GOTO ideret1 - -IF NOT QuietMode THEN - PRINT - PRINT "Beginning C++ output from QB64 code... " -END IF - -lineinput3load sourcefile$ - -DO - - '### STEVE EDIT FOR CONST EXPANSION 10/11/2013 - - wholeline$ = lineinput3$ - IF wholeline$ = CHR$(13) THEN EXIT DO - - ideprepass: - prepassLastLine: - - IF lastLine <> 0 OR firstLine <> 0 THEN - lineBackup$ = wholeline$ 'backup the real line (will be blank when lastline is set) - forceIncludeFromRoot$ = "" - IF vWatchOn THEN - addingvWatch = 1 - IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bi" - IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bm" - ELSE - 'IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bi" - IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bm" - END IF - firstLine = 0: lastLine = 0 - IF LEN(forceIncludeFromRoot$) THEN GOTO forceInclude_prepass - forceIncludeCompleted_prepass: - addingvWatch = 0 - wholeline$ = lineBackup$ - END IF - - wholestv$ = wholeline$ '### STEVE EDIT FOR CONST EXPANSION 10/11/2013 - - prepass = 1 - layout = "" - layoutok = 0 - - linenumber = linenumber + 1 - reallinenumber = reallinenumber + 1 - - DO UNTIL linenumber < UBOUND(InValidLine) 'color information flag for each line - REDIM _PRESERVE InValidLine(UBOUND(InValidLine) + 1000) AS _BYTE - LOOP - InValidLine(linenumber) = 0 - - IF LEN(wholeline$) THEN - - IF UCASE$(_TRIM$(wholeline$)) = "$NOPREFIX" THEN - qb64prefix_set_desiredState = 1 - IF qb64prefix_set = 0 THEN - IF qb64prefix_set_recompileAttempts = 0 THEN - qb64prefix_set_recompileAttempts = qb64prefix_set_recompileAttempts + 1 - GOTO do_recompile - END IF - END IF - END IF - - wholeline$ = lineformat(wholeline$) - IF Error_Happened THEN GOTO errmes - - - temp$ = LTRIM$(RTRIM$(UCASE$(wholestv$))) - - IF temp$ = "$COLOR:0" THEN - IF qb64prefix_set THEN - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0_noprefix.bi" - ELSE - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0.bi" - END IF - GOTO finishedlinepp - END IF - - IF temp$ = "$COLOR:32" THEN - IF qb64prefix_set THEN - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32_noprefix.bi" - ELSE - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32.bi" - END IF - GOTO finishedlinepp - END IF - - IF temp$ = "$DEBUG" THEN - vWatchDesiredState = 1 - IF vWatchOn = 0 THEN - IF vWatchRecompileAttempts = 0 THEN - 'this is the first time a conflict has occurred, so react immediately with a full recompilation using the desired state - vWatchRecompileAttempts = vWatchRecompileAttempts + 1 - GOTO do_recompile - ELSE - 'continue compilation to retrieve the final state requested and act on that as required - END IF - END IF - END IF - - IF LEFT$(temp$, 4) = "$IF " THEN - IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$IF without THEN": GOTO errmes - temp$ = LTRIM$(MID$(temp$, 4)) 'strip off the $IF and extra spaces - temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces - temp = INSTR(temp$, "=") - ExecCounter = ExecCounter + 1 - ExecLevel(ExecCounter) = -1 'default to a skip value - DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - GOTO finishedlinepp 'and then we're finished -- and at this point we didn't make a match so we exit with a DONT READ type flag on our code. - END IF - - IF temp$ = "$ELSE" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes - DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above - ELSE - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED - END IF - GOTO finishedlinepp - END IF - - IF LEFT$(temp$, 5) = "$ELSE" THEN 'looking for $ELSE IF - temp$ = LTRIM$(MID$(temp$, 6)) - IF LEFT$(temp$, 3) = "IF " THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes - IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 - GOTO finishedlinepp - END IF - temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces - temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - GOTO finishedlinepp 'and then we're finished -- and at this point we didn't make a match so we exit with a DONT READ type flag on our code. - END IF - END IF - - IF temp$ = "$END IF" OR temp$ = "$ENDIF" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes - DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level - ExecCounter = ExecCounter - 1 - GOTO finishedlinepp - END IF - - IF ExecLevel(ExecCounter) THEN - DO UNTIL linenumber < UBOUND(InValidLine) - REDIM _PRESERVE InValidLine(UBOUND(InValidLine) + 1000) AS _BYTE - LOOP - - InValidLine(linenumber) = -1 - GOTO finishedlinepp 'we don't check for anything inside lines that we've marked for skipping - END IF - - IF LEFT$(temp$, 7) = "$ERROR " THEN - temp$ = LTRIM$(MID$(temp$, 7)) - a$ = "Compilation check failed: " + temp$ - GOTO errmes - END IF - - IF LEFT$(temp$, 5) = "$LET " THEN - temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse - 'For starters, let's make certain that we have 3 elements to deal with - temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side - IF temp = 0 THEN a$ = "Invalid Syntax. $LET = ": GOTO errmes - l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) - 'then validate to make certain the left side looks proper - IF validname(l$) = 0 THEN a$ = "Invalid flag name": GOTO errmes - IF LEFT$(r$, 1) = CHR$(34) THEN r$ = LTRIM$(MID$(r$, 2)) - IF RIGHT$(r$, 1) = CHR$(34) THEN r$ = RTRIM$(LEFT$(r$, LEN(r$) - 1)) - IF LEFT$(r$, 1) = "-" THEN - r1$ = "-" - r$ = LTRIM$(MID$(r$, 2)) - ELSE - r1$ = "" - END IF - 'then validate to make certain the left side looks proper - FOR i = 1 TO LEN(r$) - a = ASC(r$, i) - SELECT CASE a - CASE 32 - CASE 46 'periods are fine. - r1$ = r1$ + "." - CASE IS < 48, IS > 90 - a$ = "Invalid value": GOTO errmes - CASE ELSE - r1$ = r1$ + CHR$(a) - END SELECT - NEXT - r$ = r1$ - 'First look to see if we have an existing setting like this and if so, update it - FOR i = 8 TO UserDefineCount 'UserDefineCount 1-7 are reserved for automatic OS/BIT detection & version - IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishedlinepp - NEXT - 'Otherwise create a new setting and set the initial value for it - UserDefineCount = UserDefineCount + 1 - IF UserDefineCount > UBOUND(UserDefine, 2) THEN - REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it - END IF - UserDefine(0, UserDefineCount) = l$ - UserDefine(1, UserDefineCount) = r$ - GOTO finishedlinepp - END IF - - - cwholeline$ = wholeline$ - wholeline$ = eleucase$(wholeline$) '********REMOVE THIS LINE LATER******** - - - addmetadynamic = 0: addmetastatic = 0 - wholelinen = numelements(wholeline$) - - IF wholelinen THEN - - wholelinei = 1 - - 'skip line number? - e$ = getelement$(wholeline$, 1) - IF (ASC(e$) >= 48 AND ASC(e$) <= 59) OR ASC(e$) = 46 THEN wholelinei = 2: GOTO ppskpl - - 'skip 'POSSIBLE' line label? - IF wholelinen >= 2 THEN - x2 = INSTR(wholeline$, sp + ":" + sp): x3 = x2 + 2 - IF x2 = 0 THEN - IF RIGHT$(wholeline$, 2) = sp + ":" THEN x2 = LEN(wholeline$) - 1: x3 = x2 + 1 - END IF - - IF x2 THEN - e$ = LEFT$(wholeline$, x2 - 1) - IF validlabel(e$) THEN - wholeline$ = RIGHT$(wholeline$, LEN(wholeline$) - x3) - cwholeline$ = RIGHT$(cwholeline$, LEN(wholeline$) - x3) - wholelinen = numelements(wholeline$) - GOTO ppskpl - END IF 'valid - END IF 'includes ":" - END IF 'wholelinen>=2 - - ppskpl: - IF wholelinei <= wholelinen THEN - '---------------------------------------- - a$ = "" - ca$ = "" - ppblda: - e$ = getelement$(wholeline$, wholelinei) - ce$ = getelement$(cwholeline$, wholelinei) - IF e$ = ":" OR e$ = "ELSE" OR e$ = "THEN" OR e$ = "" THEN - IF LEN(a$) THEN - IF Debug THEN PRINT #9, "PP[" + a$ + "]" - n = numelements(a$) - firstelement$ = getelement(a$, 1) - secondelement$ = getelement(a$, 2) - thirdelement$ = getelement(a$, 3) - '======================================== - - IF n = 2 AND firstelement$ = "END" AND (secondelement$ = "SUB" OR secondelement$ = "FUNCTION") THEN - closedsubfunc = -1 - END IF - - 'declare library - IF declaringlibrary THEN - - IF firstelement$ = "END" THEN - IF n <> 2 OR secondelement$ <> "DECLARE" THEN a$ = "Expected END DECLARE": GOTO errmes - declaringlibrary = 0 - GOTO finishedlinepp - END IF 'end declare - - declaringlibrary = 2 - - IF firstelement$ = "SUB" OR firstelement$ = "FUNCTION" THEN subfuncn = subfuncn - 1: GOTO declaresubfunc - - a$ = "Expected SUB/FUNCTION definition or END DECLARE (#2)": GOTO errmes - END IF - - 'UDT TYPE definition - IF definingtype THEN - i = definingtype - - IF n >= 1 THEN - IF firstelement$ = "END" THEN - IF n <> 2 OR secondelement$ <> "TYPE" THEN a$ = "Expected END TYPE": GOTO errmes - IF udtxnext(i) = 0 THEN a$ = "No elements defined in TYPE": GOTO errmes - definingtype = 0 - - 'create global buffer for SWAP space - siz$ = str2$(udtxsize(i) \ 8) - PRINT #18, "char *g_tmp_udt_" + RTRIM$(udtxname(i)) + "=(char*)malloc(" + siz$ + ");" - - 'print "END TYPE";udtxsize(i);udtxbytealign(i) - GOTO finishedlinepp - END IF - END IF - - IF n < 3 THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes - n$ = firstelement$ - - IF n$ <> "AS" THEN - 'traditional variable-name AS type syntax, single-element - lasttypeelement = lasttypeelement + 1 - i2 = lasttypeelement - WHILE i2 > UBOUND(udtenext): increaseUDTArrays: WEND - udtenext(i2) = 0 - - ii = 2 - - udtearrayelements(i2) = 0 - - IF ii >= n OR getelement$(a$, ii) <> "AS" THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes - t$ = getelements$(a$, ii + 1, n) - - IF t$ = RTRIM$(udtxname(definingtype)) THEN a$ = "Invalid self-reference": GOTO errmes - typ = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF typ = 0 THEN a$ = "Undefined type": GOTO errmes - typsize = typname2typsize - - IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes - udtename(i2) = n$ - udtecname(i2) = getelement$(ca$, 1) - NormalTypeBlock: - typeDefinitions$ = typeDefinitions$ + MKL$(i2) + MKL$(LEN(n$)) + n$ - udtetype(i2) = typ - udtetypesize(i2) = typsize - - hashname$ = n$ - - 'check for name conflicts (any similar reserved or element from current UDT) - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_UDTELEMENT - hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF hashresflags AND HASHFLAG_UDTELEMENT THEN - IF hashresref = i THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - END IF - IF hashresflags AND HASHFLAG_RESERVED THEN - IF hashresflags AND (HASHFLAG_TYPE + HASHFLAG_CUSTOMSYNTAX + HASHFLAG_OPERATOR + HASHFLAG_XELEMENTNAME) THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - 'add to hash table - HashAdd hashname$, HASHFLAG_UDTELEMENT, i - - 'Calculate element's size - IF typ AND ISUDT THEN - u = typ AND 511 - udtesize(i2) = udtxsize(u) - IF udtxbytealign(u) THEN udtxbytealign(i) = 1: udtebytealign(i2) = 1 - IF udtxvariable(u) THEN udtxvariable(i) = -1 - ELSE - IF (typ AND ISSTRING) THEN - IF (typ AND ISFIXEDLENGTH) = 0 THEN - udtesize(i2) = OFFSETTYPE AND 511 - udtxvariable(i) = -1 - ELSE - udtesize(i2) = typsize * 8 - END IF - udtxbytealign(i) = 1: udtebytealign(i2) = 1 - ELSE - udtesize(i2) = typ AND 511 - IF (typ AND ISOFFSETINBITS) = 0 THEN udtxbytealign(i) = 1: udtebytealign(i2) = 1 - END IF - END IF - - 'Increase block size - IF udtebytealign(i2) THEN - IF udtxsize(i) MOD 8 THEN - udtxsize(i) = udtxsize(i) + (8 - (udtxsize(i) MOD 8)) - END IF - END IF - udtxsize(i) = udtxsize(i) + udtesize(i2) - - 'Link element to previous element - IF udtxnext(i) = 0 THEN - udtxnext(i) = i2 - ELSE - udtenext(i2 - 1) = i2 - END IF - - 'print "+"+rtrim$(udtename(i2));udtetype(i2);udtesize(i2);udtebytealign(i2);udtxsize(i) - IF newAsTypeBlockSyntax THEN RETURN - GOTO finishedlinepp - ELSE - 'new AS type variable-list syntax, multiple elements - ii = 2 - - IF ii >= n THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes - previousElement$ = "" - t$ = "" - lastElement$ = "" - buildTypeName: - lastElement$ = getelement$(a$, ii) - IF lastElement$ <> "," AND lastElement$ <> "" THEN - n$ = lastElement$ - cn$ = getelement$(ca$, ii) - IF LEN(previousElement$) THEN t$ = t$ + previousElement$ + " " - previousElement$ = n$ - lastElement$ = "" - ii = ii + 1 - GOTO buildTypeName - END IF - - t$ = RTRIM$(t$) - IF t$ = RTRIM$(udtxname(definingtype)) THEN a$ = "Invalid self-reference": GOTO errmes - typ = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF typ = 0 THEN a$ = "Undefined type": GOTO errmes - typsize = typname2typsize - - previousElement$ = lastElement$ - nexttypeelement: - lasttypeelement = lasttypeelement + 1 - i2 = lasttypeelement - WHILE i2 > UBOUND(udtenext): increaseUDTArrays: WEND - udtenext(i2) = 0 - udtearrayelements(i2) = 0 - - udtename(i2) = n$ - udtecname(i2) = cn$ - - IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes - - newAsTypeBlockSyntax = -1 - GOSUB NormalTypeBlock - newAsTypeBlockSyntax = 0 - - getNextElement: - ii = ii + 1 - lastElement$ = getelement$(a$, ii) - IF lastElement$ = "" THEN GOTO finishedlinepp - IF ii = n AND lastElement$ = "," THEN a$ = "Expected element-name": GOTO errmes - IF lastElement$ = "," THEN - IF previousElement$ = "," THEN a$ = "Expected element-name": GOTO errmes - previousElement$ = lastElement$ - GOTO getNextElement - END IF - n$ = lastElement$ - IF previousElement$ <> "," THEN a$ = "Expected ,": GOTO errmes - previousElement$ = lastElement$ - cn$ = getelement$(ca$, ii) - GOTO nexttypeelement - END IF - END IF 'definingtype - - IF definingtype AND n >= 1 THEN a$ = "Expected END TYPE": GOTO errmes - - IF n >= 1 THEN - IF firstelement$ = "TYPE" THEN - IF n <> 2 THEN a$ = "Expected TYPE typename": GOTO errmes - lasttype = lasttype + 1 - typeDefinitions$ = typeDefinitions$ + MKL$(-1) + MKL$(lasttype) - definingtype = lasttype - i = definingtype - WHILE i > UBOUND(udtenext): increaseUDTArrays: WEND - IF validname(secondelement$) = 0 THEN a$ = "Invalid name": GOTO errmes - typeDefinitions$ = typeDefinitions$ + MKL$(LEN(secondelement$)) + secondelement$ - udtxname(i) = secondelement$ - udtxcname(i) = getelement(ca$, 2) - udtxnext(i) = 0 - udtxsize(i) = 0 - udtxvariable(i) = 0 - - hashname$ = secondelement$ - hashflags = HASHFLAG_UDT - 'check for name conflicts (any similar reserved/sub/function/UDT name) - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_UDT - hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - allow = 0 - IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN - allow = 1 - END IF - IF hashresflags AND HASHFLAG_RESERVED THEN - IF (hashresflags AND (HASHFLAG_TYPE + HASHFLAG_OPERATOR + HASHFLAG_CUSTOMSYNTAX + HASHFLAG_XTYPENAME)) = 0 THEN allow = 1 - END IF - IF allow = 0 THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - - 'add to hash table - HashAdd hashname$, hashflags, i - - GOTO finishedlinepp - END IF - END IF - - - - - - IF n >= 1 AND firstelement$ = "CONST" THEN - 'l$ = "CONST" - 'DEF... do not change type, the expression is stored in a suitable type - 'based on its value if type isn't forced/specified - - IF subfuncn > 0 AND closedsubfunc <> 0 THEN a$ = "Statement cannot be placed between SUB/FUNCTIONs": GOTO errmes - - 'convert periods to _046_ - i2 = INSTR(a$, sp + "." + sp) - IF i2 THEN - DO - a$ = LEFT$(a$, i2 - 1) + fix046$ + RIGHT$(a$, LEN(a$) - i2 - 2) - ca$ = LEFT$(ca$, i2 - 1) + fix046$ + RIGHT$(ca$, LEN(ca$) - i2 - 2) - i2 = INSTR(a$, sp + "." + sp) - LOOP UNTIL i2 = 0 - n = numelements(a$) - firstelement$ = getelement(a$, 1): secondelement$ = getelement(a$, 2): thirdelement$ = getelement(a$, 3) - END IF - - IF n < 3 THEN a$ = "Expected CONST name = value/expression": GOTO errmes - i = 2 - constdefpendingpp: - pending = 0 - - n$ = getelement$(ca$, i): i = i + 1 - typeoverride = 0 - s$ = removesymbol$(n$) - IF Error_Happened THEN GOTO errmes - IF s$ <> "" THEN - typeoverride = typname2typ(s$) - IF Error_Happened THEN GOTO errmes - IF typeoverride AND ISFIXEDLENGTH THEN a$ = "Invalid constant type": GOTO errmes - IF typeoverride = 0 THEN a$ = "Invalid constant type": GOTO errmes - END IF - - IF getelement$(a$, i) <> "=" THEN a$ = "Expected =": GOTO errmes - i = i + 1 - - 'get expression - e$ = "" - readable_e$ = "" - B = 0 - FOR i2 = i TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN - pending = 1 - i = i2 + 1 - IF i > n - 2 THEN a$ = "Expected CONST ... , name = value/expression": GOTO errmes - EXIT FOR - END IF - IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - - e3$ = e2$ - IF LEN(e2$) > 1 THEN - IF ASC(e2$, 1) = 34 THEN - removeComma = _INSTRREV(e2$, ",") - e3$ = LEFT$(e2$, removeComma - 1) - ELSE - removeComma = INSTR(e2$, ",") - e3$ = MID$(e2$, removeComma + 1) - END IF - END IF - - IF LEN(readable_e$) = 0 THEN - readable_e$ = e3$ - ELSE - readable_e$ = readable_e$ + " " + e3$ - END IF - NEXT - - 'intercept current expression and pass it through Evaluate_Expression$ - '(unless it is a literal string) - IF LEFT$(readable_e$, 1) <> CHR$(34) THEN - temp1$ = _TRIM$(Evaluate_Expression$(readable_e$)) - IF LEFT$(temp1$, 5) <> "ERROR" AND e$ <> temp1$ THEN - e$ = lineformat(temp1$) 'retrieve parseable format - ELSE - IF temp1$ = "ERROR - Division By Zero" THEN a$ = temp1$: GOTO errmes - IF INSTR(temp1$, "Improper operations") THEN - a$ = "Invalid CONST expression.14": GOTO errmes - END IF - END IF - END IF - - 'Proceed as usual - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - - e$ = evaluateconst(e$, t) - IF Error_Happened THEN GOTO errmes - - IF t AND ISSTRING THEN 'string type - - IF typeoverride THEN - IF (typeoverride AND ISSTRING) = 0 THEN a$ = "Type mismatch": GOTO errmes - END IF - - ELSE 'not a string type - - IF typeoverride THEN - IF typeoverride AND ISSTRING THEN a$ = "Type mismatch": GOTO errmes - END IF - - IF t AND ISFLOAT THEN - constval## = _CV(_FLOAT, e$) - constval&& = constval## - constval~&& = constval&& - ELSE - IF (t AND ISUNSIGNED) AND (t AND 511) = 64 THEN - constval~&& = _CV(_UNSIGNED _INTEGER64, e$) - constval&& = constval~&& - constval## = constval&& - ELSE - constval&& = _CV(_INTEGER64, e$) - constval## = constval&& - constval~&& = constval&& - END IF - END IF - - 'override type? - IF typeoverride THEN - 'range check required here (noted in todo) - t = typeoverride - END IF - - END IF 'not a string type - - constlast = constlast + 1 - IF constlast > constmax THEN - constmax = constmax * 2 - REDIM _PRESERVE constname(constmax) AS STRING - REDIM _PRESERVE constcname(constmax) AS STRING - REDIM _PRESERVE constnamesymbol(constmax) AS STRING 'optional name symbol - REDIM _PRESERVE consttype(constmax) AS LONG 'variable type number - REDIM _PRESERVE constinteger(constmax) AS _INTEGER64 - REDIM _PRESERVE constuinteger(constmax) AS _UNSIGNED _INTEGER64 - REDIM _PRESERVE constfloat(constmax) AS _FLOAT - REDIM _PRESERVE conststring(constmax) AS STRING - REDIM _PRESERVE constsubfunc(constmax) AS LONG - REDIM _PRESERVE constdefined(constmax) AS LONG - END IF - - i2 = constlast - - constsubfunc(i2) = subfuncn - 'IF subfunc = "" THEN constlastshared = i2 - - IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes - constname(i2) = UCASE$(n$) - - hashname$ = n$ - 'check for name conflicts (any similar: reserved, sub, function, constant) - - allow = 0 - const_recheck: - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_CONSTANT - hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF hashresflags AND HASHFLAG_CONSTANT THEN - IF constsubfunc(hashresref) = subfuncn THEN - 'If merely redefining a CONST with same value - 'just issue a warning instead of an error - issueWarning = 0 - IF t AND ISSTRING THEN - IF conststring(hashresref) = e$ THEN issueWarning = -1: thisconstval$ = e$ - ELSE - IF t AND ISFLOAT THEN - IF constfloat(hashresref) = constval## THEN issueWarning = -1: thisconstval$ = STR$(constval##) - ELSE - IF t AND ISUNSIGNED THEN - IF constuinteger(hashresref) = constval~&& THEN issueWarning = -1: thisconstval$ = STR$(constval~&&) - ELSE - IF constinteger(hashresref) = constval&& THEN issueWarning = -1: thisconstval$ = STR$(constval&&) - END IF - END IF - END IF - IF issueWarning THEN - IF NOT IgnoreWarnings THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "duplicate constant definition", n$ + " =" + thisconstval$ - END IF - GOTO constAddDone - ELSE - a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - END IF - END IF - END IF - IF hashresflags AND HASHFLAG_RESERVED THEN - a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - END IF - IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN - IF ids(hashresref).internal_subfunc = 0 OR RTRIM$(ids(hashresref).musthave) <> "$" THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - IF t AND ISSTRING THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - - 'add to hash table - HashAdd hashname$, HASHFLAG_CONSTANT, i2 - - - - - - constdefined(i2) = 1 - constcname(i2) = n$ - constnamesymbol(i2) = typevalue2symbol$(t) - IF Error_Happened THEN GOTO errmes - consttype(i2) = t - IF t AND ISSTRING THEN - conststring(i2) = e$ - ELSE - IF t AND ISFLOAT THEN - constfloat(i2) = constval## - ELSE - IF t AND ISUNSIGNED THEN - constuinteger(i2) = constval~&& - ELSE - constinteger(i2) = constval&& - END IF - END IF - END IF - - constAddDone: - - IF pending THEN - 'l$ = l$ + sp2 + "," - GOTO constdefpendingpp - END IF - - 'layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedlinepp - END IF - - - - 'DEFINE - d = 0 - IF firstelement$ = "DEFINT" THEN d = 1 - IF firstelement$ = "DEFLNG" THEN d = 1 - IF firstelement$ = "DEFSNG" THEN d = 1 - IF firstelement$ = "DEFDBL" THEN d = 1 - IF firstelement$ = "DEFSTR" THEN d = 1 - IF firstelement$ = "_DEFINE" OR (firstelement$ = "DEFINE" AND qb64prefix_set = 1) THEN d = 1 - IF d THEN - predefining = 1: GOTO predefine - predefined: predefining = 0 - GOTO finishedlinepp - END IF - - 'declare library - IF firstelement$ = "DECLARE" THEN - IF secondelement$ = "LIBRARY" OR secondelement$ = "DYNAMIC" OR secondelement$ = "CUSTOMTYPE" OR secondelement$ = "STATIC" THEN - declaringlibrary = 1 - indirectlibrary = 0 - IF secondelement$ = "CUSTOMTYPE" OR secondelement$ = "DYNAMIC" THEN indirectlibrary = 1 - GOTO finishedlinepp - END IF - END IF - - 'SUB/FUNCTION - dynamiclibrary = 0 - declaresubfunc: - firstelement$ = getelement$(a$, 1) - sf = 0 - IF firstelement$ = "FUNCTION" THEN sf = 1 - IF firstelement$ = "SUB" THEN sf = 2 - IF sf THEN - - subfuncn = subfuncn + 1 - closedsubfunc = 0 - - IF n = 1 THEN a$ = "Expected name after SUB/FUNCTION": GOTO errmes - - 'convert periods to _046_ - i2 = INSTR(a$, sp + "." + sp) - IF i2 THEN - DO - a$ = LEFT$(a$, i2 - 1) + fix046$ + RIGHT$(a$, LEN(a$) - i2 - 2) - ca$ = LEFT$(ca$, i2 - 1) + fix046$ + RIGHT$(ca$, LEN(ca$) - i2 - 2) - i2 = INSTR(a$, sp + "." + sp) - LOOP UNTIL i2 = 0 - n = numelements(a$) - firstelement$ = getelement(a$, 1): secondelement$ = getelement(a$, 2): thirdelement$ = getelement(a$, 3) - END IF - - n$ = getelement$(ca$, 2) - symbol$ = removesymbol$(n$) - IF Error_Happened THEN GOTO errmes - IF sf = 2 AND symbol$ <> "" THEN a$ = "Type symbols after a SUB name are invalid": GOTO errmes - - 'remove STATIC (which is ignored) - e$ = getelement$(a$, n): IF e$ = "STATIC" THEN a$ = LEFT$(a$, LEN(a$) - 7): ca$ = LEFT$(ca$, LEN(ca$) - 7): n = n - 1 - - 'check for ALIAS - aliasname$ = n$ 'use given name by default - IF n > 2 THEN - e$ = getelement$(a$, 3) - IF e$ = "ALIAS" THEN - IF declaringlibrary = 0 THEN a$ = "ALIAS can only be used with DECLARE LIBRARY": GOTO errmes - IF n = 3 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes - e$ = getelement$(ca$, 4) - 'strip string content (optional) - IF LEFT$(e$, 1) = CHR$(34) THEN - e$ = RIGHT$(e$, LEN(e$) - 1) - x = INSTR(e$, CHR$(34)): IF x = 0 THEN a$ = "Expected " + CHR$(34): GOTO errmes - e$ = LEFT$(e$, x - 1) - END IF - 'strip fix046$ (created by unquoted periods) - DO WHILE INSTR(e$, fix046$) - x = INSTR(e$, fix046$): e$ = LEFT$(e$, x - 1) + "." + RIGHT$(e$, LEN(e$) - x + 1 - LEN(fix046$)) - LOOP - 'validate alias name - IF LEN(e$) = 0 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes - FOR x = 1 TO LEN(e$) - a = ASC(e$, x) - IF alphanumeric(a) = 0 AND a <> ASC_FULLSTOP AND a <> ASC_COLON THEN a$ = "Expected ALIAS name-in-library": GOTO errmes - NEXT - aliasname$ = e$ - 'remove ALIAS section from line - IF n <= 4 THEN a$ = getelements(a$, 1, 2) - IF n >= 5 THEN a$ = getelements(a$, 1, 2) + sp + getelements(a$, 5, n) - IF n <= 4 THEN ca$ = getelements(ca$, 1, 2) - IF n >= 5 THEN ca$ = getelements(ca$, 1, 2) + sp + getelements(ca$, 5, n) - n = n - 2 - END IF - END IF - - IF declaringlibrary THEN - IF indirectlibrary THEN - aliasname$ = n$ 'override the alias name - END IF - END IF - - params = 0 - params$ = "" - paramsize$ = "" - nele$ = "" - nelereq$ = "" - IF n > 2 THEN - e$ = getelement$(a$, 3) - IF e$ <> "(" THEN a$ = "Expected (": GOTO errmes - e$ = getelement$(a$, n) - IF e$ <> ")" THEN a$ = "Expected )": GOTO errmes - IF n < 4 THEN a$ = "Expected ( ... )": GOTO errmes - IF n = 4 THEN GOTO nosfparams - B = 0 - a2$ = "" - FOR i = 4 TO n - 1 - e$ = getelement$(a$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN B = B - 1 - IF e$ = "," AND B = 0 THEN - IF i = n - 1 THEN a$ = "Expected , ... )": GOTO errmes - getlastparam: - IF a2$ = "" THEN a$ = "Expected ... ,": GOTO errmes - a2$ = LEFT$(a2$, LEN(a2$) - 1) - 'possible format: [BYVAL]a[%][(1)][AS][type] - n2 = numelements(a2$) - array = 0 - t2$ = "" - - i2 = 1 - e$ = getelement$(a2$, i2): i2 = i2 + 1 - - byvalue = 0 - IF e$ = "BYVAL" THEN - IF declaringlibrary = 0 THEN a$ = "BYVAL can currently only be used with DECLARE LIBRARY": GOTO errmes - e$ = getelement$(a2$, i2): i2 = i2 + 1: byvalue = 1 - END IF - - n2$ = e$ - symbol2$ = removesymbol$(n2$) - IF validname(n2$) = 0 THEN a$ = "Invalid name": GOTO errmes - - IF Error_Happened THEN GOTO errmes - m = 0 - FOR i2 = i2 TO n2 - e$ = getelement$(a2$, i2) - IF e$ = "(" THEN - IF m <> 0 THEN a$ = "Syntax error - too many opening brackets": GOTO errmes - m = 1 - array = 1 - GOTO gotaa - END IF - IF e$ = ")" THEN - IF m <> 1 THEN a$ = "Syntax error - closing bracket without opening bracket": GOTO errmes - m = 2 - GOTO gotaa - END IF - IF e$ = "AS" THEN - IF m <> 0 AND m <> 2 THEN a$ = "Syntax error - check your brackets": GOTO errmes - m = 3 - GOTO gotaa - END IF - IF m = 1 THEN GOTO gotaa 'ignore contents of bracket - IF m <> 3 THEN a$ = "Syntax error - check your brackets": GOTO errmes - IF t2$ = "" THEN t2$ = e$ ELSE t2$ = t2$ + " " + e$ - gotaa: - NEXT i2 - - params = params + 1: IF params > 100 THEN a$ = "SUB/FUNCTION exceeds 100 parameter limit": GOTO errmes - - argnelereq = 0 - - IF symbol2$ <> "" AND t2$ <> "" THEN a$ = "Syntax error - check parameter types": GOTO errmes - IF t2$ = "" AND e$ = "AS" THEN a$ = "Expected AS type": GOTO errmes - IF t2$ = "" THEN t2$ = symbol2$ - IF t2$ = "" THEN - IF LEFT$(n2$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n2$)) - 64 - t2$ = defineaz(v) - END IF - - paramsize = 0 - IF array = 1 THEN - t = typname2typ(t2$) - IF Error_Happened THEN GOTO errmes - IF t = 0 THEN a$ = "Illegal SUB/FUNCTION parameter": GOTO errmes - IF (t AND ISFIXEDLENGTH) THEN paramsize = typname2typsize - t = t + ISARRAY - 'check for recompilation override - FOR i10 = 0 TO sflistn - IF sfidlist(i10) = idn + 1 THEN - IF sfarglist(i10) = params THEN - argnelereq = sfelelist(i10) - END IF - END IF - NEXT - ELSE - t = typname2typ(t2$) - IF Error_Happened THEN GOTO errmes - IF t = 0 THEN a$ = "Illegal SUB/FUNCTION parameter": GOTO errmes - IF (t AND ISFIXEDLENGTH) THEN paramsize = typname2typsize - - IF byvalue THEN - IF t AND ISPOINTER THEN t = t - ISPOINTER - END IF - - END IF - nelereq$ = nelereq$ + CHR$(argnelereq) - - 'consider changing 0 in following line too! - nele$ = nele$ + CHR$(0) - - paramsize$ = paramsize$ + MKL$(paramsize) - params$ = params$ + MKL$(t) - a2$ = "" - ELSE - a2$ = a2$ + e$ + sp - IF i = n - 1 THEN GOTO getlastparam - END IF - NEXT i - END IF 'n>2 - nosfparams: - - IF sf = 1 THEN - 'function - clearid - id.n = n$ - id.subfunc = 1 - - id.callname = "FUNC_" + UCASE$(n$) - IF declaringlibrary THEN - id.ccall = 1 - IF indirectlibrary = 0 THEN id.callname = aliasname$ - END IF - id.args = params - id.arg = params$ - id.argsize = paramsize$ - id.nele = nele$ - id.nelereq = nelereq$ - IF symbol$ <> "" THEN - id.ret = typname2typ(symbol$) - IF Error_Happened THEN GOTO errmes - ELSE - IF LEFT$(n$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n$)) - 64 - symbol$ = defineaz(v) - id.ret = typname2typ(symbol$) - IF Error_Happened THEN GOTO errmes - END IF - IF id.ret = 0 THEN a$ = "Invalid FUNCTION return type": GOTO errmes - - IF declaringlibrary THEN - - ctype$ = typ2ctyp$(id.ret, "") - IF Error_Happened THEN GOTO errmes - IF ctype$ = "qbs" THEN ctype$ = "char*" - id.callname = "( " + ctype$ + " )" + RTRIM$(id.callname) - - END IF - - s$ = LEFT$(symbol$, 1) - IF s$ <> "~" AND s$ <> "`" AND s$ <> "%" AND s$ <> "&" AND s$ <> "!" AND s$ <> "#" AND s$ <> "$" THEN - symbol$ = type2symbol$(symbol$) - IF Error_Happened THEN GOTO errmes - END IF - id.mayhave = symbol$ - IF id.ret AND ISPOINTER THEN - IF (id.ret AND ISSTRING) = 0 THEN id.ret = id.ret - ISPOINTER - END IF - regid - IF Error_Happened THEN GOTO errmes - ELSE - 'sub - clearid - id.n = n$ - id.subfunc = 2 - id.callname = "SUB_" + UCASE$(n$) - IF declaringlibrary THEN - id.ccall = 1 - IF indirectlibrary = 0 THEN id.callname = aliasname$ - END IF - id.args = params - id.arg = params$ - id.argsize = paramsize$ - id.nele = nele$ - id.nelereq = nelereq$ - - IF UCASE$(n$) = "_GL" AND params = 0 AND UseGL = 0 THEN reginternalsubfunc = 1: UseGL = 1: id.n = "_GL": DEPENDENCY(DEPENDENCY_GL) = 1 - regid - reginternalsubfunc = 0 - - IF Error_Happened THEN GOTO errmes - END IF - - - END IF - - '======================================== - finishedlinepp: - firstLine = 0 - END IF - a$ = "" - ca$ = "" - ELSE - IF a$ = "" THEN a$ = e$: ca$ = ce$ ELSE a$ = a$ + sp + e$: ca$ = ca$ + sp + ce$ - END IF - IF wholelinei <= wholelinen THEN wholelinei = wholelinei + 1: GOTO ppblda - '---------------------------------------- - END IF 'wholelinei<=wholelinen - END IF 'wholelinen - END IF 'len(wholeline$) - - 'Include Manager #1 - - - - IF LEN(addmetainclude$) THEN - IF Debug THEN PRINT #9, "Pre-pass:INCLUDE$-ing file:'" + addmetainclude$ + "':On line"; linenumber - a$ = addmetainclude$: addmetainclude$ = "" 'read/clear message - - IF inclevel = 0 THEN - includingFromRoot = 0 - forceIncludingFile = 0 - forceInclude_prepass: - IF forceIncludeFromRoot$ <> "" THEN - a$ = forceIncludeFromRoot$ - forceIncludeFromRoot$ = "" - forceIncludingFile = 1 - includingFromRoot = 1 - END IF - END IF - - IF inclevel = 100 THEN a$ = "Too many indwelling INCLUDE files": GOTO errmes - '1. Verify file exists (location is either (a)relative to source file or (b)absolute) - fh = 99 + inclevel + 1 - - firstTryMethod = 1 - IF includingFromRoot <> 0 AND inclevel = 0 THEN firstTryMethod = 2 - FOR try = firstTryMethod TO 2 'if including file from root, do not attempt including from relative location - IF try = 1 THEN - IF inclevel = 0 THEN - IF idemode THEN p$ = idepath$ + pathsep$ ELSE p$ = getfilepath$(sourcefile$) - ELSE - p$ = getfilepath$(incname(inclevel)) - END IF - f$ = p$ + a$ - END IF - IF try = 2 THEN f$ = a$ - IF _FILEEXISTS(f$) THEN - qberrorhappened = -3 - 'We're using the faster LINE INPUT, which requires a BINARY open. - OPEN f$ FOR BINARY AS #fh - 'And another line below edited - qberrorhappened3: - IF qberrorhappened = -3 THEN EXIT FOR - END IF - qberrorhappened = 0 - NEXT - IF qberrorhappened <> -3 THEN qberrorhappened = 0: a$ = "File " + a$ + " not found": GOTO errmes - inclevel = inclevel + 1: incname$(inclevel) = f$: inclinenumber(inclevel) = 0 - END IF 'fall through to next section... - '-------------------- - DO WHILE inclevel - - fh = 99 + inclevel - '2. Feed next line - IF EOF(fh) = 0 THEN - LINE INPUT #fh, x$ - - wholeline$ = x$ - inclinenumber(inclevel) = inclinenumber(inclevel) + 1 - 'create extended error string 'incerror$' - errorLineInInclude = inclinenumber(inclevel) - e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" - IF inclevel > 1 THEN - e$ = e$ + " (through " - FOR x = 1 TO inclevel - 1 STEP 1 - e$ = e$ + incname$(x) - IF x < inclevel - 1 THEN 'a sep is req - IF x = inclevel - 2 THEN - e$ = e$ + " then " - ELSE - e$ = e$ + ", " - END IF - END IF - NEXT - e$ = e$ + ")" - END IF - incerror$ = e$ - linenumber = linenumber - 1 'lower official linenumber to counter later increment - - IF Debug THEN PRINT #9, "Pre-pass:Feeding INCLUDE$ line:[" + wholeline$ + "]" - - IF idemode THEN sendc$ = CHR$(10) + wholeline$: GOTO sendcommand 'passback - GOTO ideprepass - END IF - '3. Close & return control - CLOSE #fh - inclevel = inclevel - 1 - IF forceIncludingFile = 1 AND inclevel = 0 THEN - forceIncludingFile = 0 - GOTO forceIncludeCompleted_prepass - END IF - LOOP - '(end manager) - - IF idemode THEN GOTO ideret2 -LOOP - -'add final line -IF lastLineReturn = 0 THEN - lastLineReturn = 1 - lastLine = 1 - wholeline$ = "" - GOTO prepassLastLine -END IF - -IF definingtype THEN definingtype = 0 'ignore this error so that auto-formatting can be performed and catch it again later -IF declaringlibrary THEN declaringlibrary = 0 'ignore this error so that auto-formatting can be performed and catch it again later - -totallinenumber = reallinenumber - -'IF idemode = 0 AND NOT QuietMode THEN PRINT "first pass finished.": PRINT "Translating code... " - -'prepass finished - -lineinput3index = 1 'reset input line - -'ide specific -ide3: - -addmetainclude$ = "" 'reset stray meta-includes - -'reset altered variables -DataOffset = 0 -inclevel = 0 -subfuncn = 0 -lastLineReturn = 0 -lastLine = 0 -firstLine = 1 -UserDefineCount = 7 - -FOR i = 0 TO constlast: constdefined(i) = 0: NEXT 'undefine constants - -FOR i = 1 TO 27: defineaz(i) = "SINGLE": defineextaz(i) = "!": NEXT - -OPEN tmpdir$ + "data.bin" FOR OUTPUT AS #16: CLOSE #16 -OPEN tmpdir$ + "data.bin" FOR BINARY AS #16 - - -OPEN tmpdir$ + "main.txt" FOR OUTPUT AS #12 -OPEN tmpdir$ + "maindata.txt" FOR OUTPUT AS #13 - -OPEN tmpdir$ + "regsf.txt" FOR OUTPUT AS #17 - -OPEN tmpdir$ + "mainfree.txt" FOR OUTPUT AS #19 -OPEN tmpdir$ + "runline.txt" FOR OUTPUT AS #21 - -OPEN tmpdir$ + "mainerr.txt" FOR OUTPUT AS #14 'main error handler -'i. check the value of error_line -'ii. jump to the appropriate label -errorlabels = 0 -PRINT #14, "if (error_occurred){ error_occurred=0;" - -OPEN tmpdir$ + "chain.txt" FOR OUTPUT AS #22: CLOSE #22 'will be appended to as necessary -OPEN tmpdir$ + "inpchain.txt" FOR OUTPUT AS #23: CLOSE #23 'will be appended to as necessary -'*** #22 & #23 are reserved for usage by chain & inpchain *** - -OPEN tmpdir$ + "ontimer.txt" FOR OUTPUT AS #24 -OPEN tmpdir$ + "ontimerj.txt" FOR OUTPUT AS #25 - -'*****#26 used for locking qb64 - -OPEN tmpdir$ + "onkey.txt" FOR OUTPUT AS #27 -OPEN tmpdir$ + "onkeyj.txt" FOR OUTPUT AS #28 - -OPEN tmpdir$ + "onstrig.txt" FOR OUTPUT AS #29 -OPEN tmpdir$ + "onstrigj.txt" FOR OUTPUT AS #30 - -gosubid = 1 -'to be included whenever return without a label is called - -'return [label] in QBASIC was not possible in a sub/function, but QB64 will support this -'special codes will represent special return conditions: -'0=return from main to calling sub/function/proc by return [NULL]; -'1... a global number representing a return point after a gosub -'note: RETURN [label] should fail if a "return [NULL];" type return is required -OPEN tmpdir$ + "ret0.txt" FOR OUTPUT AS #15 -PRINT #15, "if (next_return_point){" -PRINT #15, "next_return_point--;" -PRINT #15, "switch(return_point[next_return_point]){" -PRINT #15, "case 0:" - -PRINT #15, "return;" - -PRINT #15, "break;" - -continueline = 0 -endifs = 0 -lineelseused = 0 -continuelinefrom = 0 -linenumber = 0 -reallinenumber = 0 -declaringlibrary = 0 - -PRINT #12, "S_0:;" 'note: REQUIRED by run statement - -IF UseGL THEN gl_include_content - - -'ide specific -IF idemode THEN GOTO ideret3 - -DO - ide4: - includeline: - mainpassLastLine: - - IF lastLine <> 0 OR firstLine <> 0 THEN - lineBackup$ = a3$ 'backup the real first line (will be blank when lastline is set) - forceIncludeFromRoot$ = "" - IF vWatchOn THEN - addingvWatch = 1 - IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bi" - IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bm" - ELSE - 'IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bi" - IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bm" - END IF - firstLine = 0: lastLine = 0 - IF LEN(forceIncludeFromRoot$) THEN GOTO forceInclude - forceIncludeCompleted: - addingvWatch = 0 - a3$ = lineBackup$ - END IF - - prepass = 0 - - stringprocessinghappened = 0 - - IF continuelinefrom THEN - start = continuelinefrom - continuelinefrom = 0 - GOTO contline - END IF - - 'begin a new line - - impliedendif = 0 - THENGOTO = 0 - continueline = 0 - endifs = 0 - lineelseused = 0 - newif = 0 - - 'apply metacommands from previous line - IF addmetadynamic = 1 THEN addmetadynamic = 0: DynamicMode = 1 - IF addmetastatic = 1 THEN addmetastatic = 0: DynamicMode = 0 - - 'a3$ is passed in idemode and when using $include - IF idemode = 0 AND inclevel = 0 THEN a3$ = lineinput3$ - IF a3$ = CHR$(13) THEN EXIT DO - linenumber = linenumber + 1 - reallinenumber = reallinenumber + 1 - - IF InValidLine(linenumber) THEN - layoutok = 1 - layout$ = SPACE$(controllevel + 1) + LTRIM$(RTRIM$(a3$)) - IF idemode GOTO ideret4 ELSE GOTO skipide4 - END IF - - layout = "" - layoutok = 1 - - IF idemode = 0 AND NOT QuietMode THEN - 'IF LEN(a3$) THEN - ' dotlinecount = dotlinecount + 1: IF dotlinecount >= 100 THEN dotlinecount = 0: PRINT "."; - 'END IF - maxprogresswidth = 50 'arbitrary - percentage = INT(reallinenumber / totallinenumber * 100) - percentagechars = INT(maxprogresswidth * reallinenumber / totallinenumber) - IF percentage <> prevpercentage AND percentagechars <> prevpercentagechars THEN - prevpercentage = percentage - prevpercentagechars = percentagechars - IF ConsoleMode THEN - PRINT "[" + STRING$(percentagechars, ".") + SPACE$(maxprogresswidth - percentagechars) + "]" + STR$(percentage) + "%"; - IF os$ = "LNX" THEN - PRINT CHR$(27) + "[A" - ELSE - PRINT CHR$(13); - END IF - ELSE - LOCATE , 1 - PRINT STRING$(percentagechars, 219) + STRING$(maxprogresswidth - percentagechars, 176) + STR$(percentage) + "%"; - END IF - END IF - END IF - - a3$ = LTRIM$(RTRIM$(a3$)) - wholeline = a3$ - - layoutoriginal$ = a3$ - layoutcomment$ = "" 'clear any previous layout comment - lhscontrollevel = controllevel - - linefragment = "[INFORMATION UNAVAILABLE]" - IF LEN(a3$) = 0 THEN GOTO finishednonexec - IF Debug THEN PRINT #9, "########" + a3$ + "########" - - layoutdone = 1 'validates layout of any following goto finishednonexec/finishedline - - 'We've already figured out in the prepass which lines are invalidated by the precompiler - 'No need to go over those lines again. - 'IF InValidLine(linenumber) THEN goto skipide4 'layoutdone = 0: GOTO finishednonexec - - a3u$ = UCASE$(a3$) - - 'QB64 Metacommands - IF ASC(a3$) = 36 THEN '$ - - 'precompiler commands should always be executed FIRST. - IF a3u$ = "$END IF" OR a3u$ = "$ENDIF" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes - DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level - ExecCounter = ExecCounter - 1 - layout$ = SCase$("$End If") - controltype(controllevel) = 0 - controllevel = controllevel - 1 - GOTO finishednonexec - END IF - - IF LEFT$(a3u$, 4) = "$IF " THEN - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - temp$ = LTRIM$(MID$(a3u$, 4)) 'strip off the $IF and extra spaces - temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces - temp = 0 - IF temp = 0 THEN tempOp$ = "<=": temp = INSTR(temp$, tempOp$) - IF temp = 0 THEN tempOp$ = "=<": temp = INSTR(temp$, tempOp$): tempOp$ = "<=" - IF temp = 0 THEN tempOp$ = ">=": temp = INSTR(temp$, tempOp$) - IF temp = 0 THEN tempOp$ = "=>": temp = INSTR(temp$, tempOp$): tempOp$ = ">=" - IF temp = 0 THEN tempOp$ = "<>": temp = INSTR(temp$, tempOp$) - IF temp = 0 THEN tempOp$ = "><": temp = INSTR(temp$, tempOp$): tempOp$ = "<>" - IF temp = 0 THEN tempOp$ = "=": temp = INSTR(temp$, tempOp$) - IF temp = 0 THEN tempOp$ = ">": temp = INSTR(temp$, tempOp$) - IF temp = 0 THEN tempOp$ = "<": temp = INSTR(temp$, tempOp$) - - ExecCounter = ExecCounter + 1 - ExecLevel(ExecCounter) = -1 'default to a skip value - DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - - controllevel = controllevel + 1 - controltype(controllevel) = 6 - IF temp = 0 THEN layout$ = SCase$("$If ") + temp$ + SCase$(" Then"): GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag - l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + LEN(tempOp$))) - layout$ = SCase$("$If ") + l$ + " " + tempOp$ + " " + r$ + SCase$(" Then") - GOTO finishednonexec - END IF - - IF a3u$ = "$ELSE" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes - DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above - ELSE - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED - END IF - layout$ = SCase$("$Else") - lhscontrollevel = lhscontrollevel - 1 - GOTO finishednonexec - END IF - - IF LEFT$(a3u$, 5) = "$ELSE" THEN - temp$ = LTRIM$(MID$(a3u$, 6)) - IF LEFT$(temp$, 3) = "IF " THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes - IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes - temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces - temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 - ELSE - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - END IF - - - lhscontrollevel = lhscontrollevel - 1 - temp = INSTR(temp$, "=") - IF temp = 0 THEN layout$ = SCase$("$ElseIf ") + temp$ + SCase$(" Then"): GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag - l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) - layout$ = SCase$("$ElseIf ") + l$ + " = " + r$ + SCase$(" Then") - GOTO finishednonexec - END IF - END IF - - IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler - layoutdone = 0 - GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping - END IF - - IF LEFT$(a3u$, 5) = "$LET " THEN - temp$ = a3u$ - temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse - 'For starters, let's make certain that we have 3 elements to deal with - temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side - l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) - layout$ = SCase$("$Let ") + l$ + " = " + r$ - 'First look to see if we have an existing setting like this and if so, update it - FOR i = 7 TO UserDefineCount 'UserDefineCount 1-7 are reserved for automatic OS/BIT detection & version - IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishednonexec - NEXT - 'Otherwise create a new setting and set the initial value for it - UserDefineCount = UserDefineCount + 1 - IF UserDefineCount > UBOUND(UserDefine, 2) THEN - REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it - END IF - UserDefine(0, UserDefineCount) = l$ - UserDefine(1, UserDefineCount) = r$ - GOTO finishednonexec - END IF - - IF a3u$ = "$COLOR:0" THEN - layout$ = SCase$("$Color:0") - IF qb64prefix_set THEN - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0_noprefix.bi" - ELSE - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0.bi" - END IF - layoutdone = 1 - GOTO finishednonexec - END IF - - IF a3u$ = "$COLOR:32" THEN - layout$ = SCase$("$Color:32") - IF qb64prefix_set THEN - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32_noprefix.bi" - ELSE - addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32.bi" - END IF - layoutdone = 1 - GOTO finishednonexec - END IF - - IF a3u$ = "$NOPREFIX" THEN - 'already set in prepass - layout$ = SCase$("$NoPrefix") - GOTO finishednonexec - END IF - - IF a3u$ = "$VIRTUALKEYBOARD:ON" THEN - 'Deprecated; does nothing. - layout$ = SCase$("$VirtualKeyboard:On") - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Deprecated feature", "$VirtualKeyboard" - GOTO finishednonexec - END IF - - IF a3u$ = "$VIRTUALKEYBOARD:OFF" THEN - 'Deprecated; does nothing. - layout$ = SCase$("$VirtualKeyboard:Off") - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Deprecated feature", "$VirtualKeyboard" - GOTO finishednonexec - END IF - - IF a3u$ = "$DEBUG" THEN - layout$ = SCase$("$Debug") - IF NoIDEMode THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "$Debug", "$Debug features only work from the IDE" - END IF - GOTO finishednonexec - END IF - - IF a3u$ = "$CHECKING:OFF" THEN - layout$ = SCase$("$Checking:Off") - NoChecks = 1 - IF vWatchOn <> 0 AND NoIDEMode = 0 AND inclevel = 0 THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "$Debug", "$Debug features won't work in $Checking:Off blocks" - END IF - GOTO finishednonexec - END IF - - IF a3u$ = "$CHECKING:ON" THEN - layout$ = SCase$("$Checking:On") - NoChecks = 0 - GOTO finishednonexec - END IF - - IF a3u$ = "$CONSOLE" THEN - layout$ = SCase$("$Console") - Console = 1 - GOTO finishednonexec - END IF - - IF a3u$ = "$CONSOLE:ONLY" THEN - layout$ = SCase$("$Console:Only") - DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) = DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) OR 1 - Console = 1 - IF prepass = 0 THEN - IF NoChecks = 0 THEN PRINT #12, "do{" - PRINT #12, "sub__dest(func__console());" - PRINT #12, "sub__source(func__console());" - GOTO finishedline2 - ELSE - GOTO finishednonexec - END IF - END IF - - IF a3u$ = "$ASSERTS" THEN - layout$ = SCase$("$Asserts") - Asserts = 1 - GOTO finishednonexec - END IF - - IF a3u$ = "$ASSERTS:CONSOLE" THEN - layout$ = SCase$("$Asserts:Console") - Asserts = 1 - Console = 1 - GOTO finishednonexec - END IF - - IF a3u$ = "$SCREENHIDE" THEN - layout$ = SCase$("$ScreenHide") - ScreenHide = 1 - GOTO finishednonexec - END IF - IF a3u$ = "$SCREENSHOW" THEN - layout$ = SCase$("$ScreenShow") - ScreenHide = 0 - GOTO finishednonexec - END IF - - IF a3u$ = "$RESIZE:OFF" THEN - layout$ = SCase$("$Resize:Off") - Resize = 0: Resize_Scale = 0 - GOTO finishednonexec - END IF - IF a3u$ = "$RESIZE:ON" THEN - layout$ = SCase$("$Resize:On") - Resize = 1: Resize_Scale = 0 - GOTO finishednonexec - END IF - - IF a3u$ = "$RESIZE:STRETCH" THEN - layout$ = SCase$("$Resize:Stretch") - Resize = 1: Resize_Scale = 1 - GOTO finishednonexec - END IF - IF a3u$ = "$RESIZE:SMOOTH" THEN - layout$ = SCase$("$Resize:Smooth") - Resize = 1: Resize_Scale = 2 - GOTO finishednonexec - END IF - - IF LEFT$(a3u$, 12) = "$VERSIONINFO" THEN - 'Embed version info into the final binary (Windows only) - FirstDelimiter = INSTR(a3u$, ":") - SecondDelimiter = INSTR(FirstDelimiter + 1, a3u$, "=") - IF FirstDelimiter = 0 OR SecondDelimiter = 0 OR SecondDelimiter = FirstDelimiter + 1 THEN - a$ = "Expected $VERSIONINFO:key=value": GOTO errmes - END IF - - VersionInfoKey$ = LTRIM$(RTRIM$(MID$(a3u$, FirstDelimiter + 1, SecondDelimiter - FirstDelimiter - 1))) - VersionInfoValue$ = StrReplace$(LTRIM$(RTRIM$(MID$(a3$, SecondDelimiter + 1))), CHR$(34), "'") - - SELECT CASE VersionInfoKey$ - CASE "FILEVERSION#" - GOSUB ValidateVersion - viFileVersionNum$ = VersionInfoValue$ - IF viFileVersion$ = "" THEN viFileVersion$ = viFileVersionNum$ - layout$ = SCase$("$VersionInfo:FILEVERSION#=") + VersionInfoValue$ - CASE "PRODUCTVERSION#" - GOSUB ValidateVersion - viProductVersionNum$ = VersionInfoValue$ - IF viProductVersion$ = "" THEN viProductVersion$ = viProductVersionNum$ - layout$ = SCase$("$VersionInfo:PRODUCTVERSION#=") + VersionInfoValue$ - CASE "COMPANYNAME" - viCompanyName$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "CompanyName=" + VersionInfoValue$ - CASE "FILEDESCRIPTION" - viFileDescription$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "FileDescription=" + VersionInfoValue$ - CASE "FILEVERSION" - viFileVersion$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "FileVersion=" + VersionInfoValue$ - CASE "INTERNALNAME" - viInternalName$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "InternalName=" + VersionInfoValue$ - CASE "LEGALCOPYRIGHT" - viLegalCopyright$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "LegalCopyright=" + VersionInfoValue$ - CASE "LEGALTRADEMARKS" - viLegalTrademarks$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "LegalTrademarks=" + VersionInfoValue$ - CASE "ORIGINALFILENAME" - viOriginalFilename$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "OriginalFilename=" + VersionInfoValue$ - CASE "PRODUCTNAME" - viProductName$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "ProductName=" + VersionInfoValue$ - CASE "PRODUCTVERSION" - viProductVersion$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "ProductVersion=" + VersionInfoValue$ - CASE "COMMENTS" - viComments$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "Comments=" + VersionInfoValue$ - CASE "WEB" - viWeb$ = VersionInfoValue$ - layout$ = SCase$("$VersionInfo:") + "Web=" + VersionInfoValue$ - CASE ELSE - a$ = "Invalid key. (Use FILEVERSION#, PRODUCTVERSION#, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Comments or Web)" - GOTO errmes - END SELECT - - VersionInfoSet = -1 - - GOTO finishednonexec - - ValidateVersion: - 'Check if only numbers and commas (4 comma-separated values) - IF LEN(VersionInfoValue$) = 0 THEN a$ = "Expected $VERSIONINFO:" + VersionInfoKey$ + "=#,#,#,# (4 comma-separated numeric values: major, minor, revision and build)": GOTO errmes - viCommas = 0 - FOR i = 1 TO LEN(VersionInfoValue$) - IF ASC(VersionInfoValue$, i) = 44 THEN viCommas = viCommas + 1 - IF INSTR("0123456789,", MID$(VersionInfoValue$, i, 1)) = 0 OR (i = LEN(VersionInfoValue$) AND viCommas <> 3) OR RIGHT$(VersionInfoValue$, 1) = "," THEN - a$ = "Expected $VERSIONINFO:" + VersionInfoKey$ + "=#,#,#,# (4 comma-separated numeric values: major, minor, revision and build)": GOTO errmes - END IF - NEXT - RETURN - END IF - - IF LEFT$(a3u$, 8) = "$EXEICON" THEN - 'Basic syntax check. Multi-platform. - IF ExeIconSet THEN a$ = "$EXEICON already defined": GOTO errmes - FirstDelimiter = INSTR(a3u$, "'") - IF FirstDelimiter = 0 THEN - a$ = "Expected $EXEICON:'filename'": GOTO errmes - ELSE - SecondDelimiter = INSTR(FirstDelimiter + 1, a3u$, "'") - IF SecondDelimiter = 0 THEN a$ = "Expected $EXEICON:'filename'": GOTO errmes - END IF - ExeIconFile$ = RTRIM$(LTRIM$(MID$(a3$, FirstDelimiter + 1, SecondDelimiter - FirstDelimiter - 1))) - IF LEN(ExeIconFile$) = 0 THEN a$ = "Expected $EXEICON:'filename'": GOTO errmes - layout$ = SCase$("$ExeIcon:'") + ExeIconFile$ + "'" + MID$(a3$, SecondDelimiter + 1) - - IconPath$ = "" - IF LEFT$(ExeIconFile$, 2) = "./" OR LEFT$(ExeIconFile$, 2) = ".\" THEN - 'Relative to source file's folder - IF NoIDEMode THEN - IconPath$ = path.source$ - IF LEN(IconPath$) > 0 AND RIGHT$(IconPath$, 1) <> pathsep$ THEN IconPath$ = IconPath$ + pathsep$ - ELSE - IF LEN(ideprogname) THEN IconPath$ = idepath$ + pathsep$ - END IF - - ExeIconFile$ = IconPath$ + MID$(ExeIconFile$, 3) - ELSEIF INSTR(ExeIconFile$, "/") OR INSTR(ExeIconFile$, "\") THEN - FOR i = LEN(ExeIconFile$) TO 1 STEP -1 - IF MID$(ExeIconFile$, i, 1) = "/" OR MID$(ExeIconFile$, i, 1) = "\" THEN - IconPath$ = LEFT$(ExeIconFile$, i) - ExeIconFileOnly$ = MID$(ExeIconFile$, i + 1) - - IF _DIREXISTS(IconPath$) = 0 THEN a$ = "File '" + ExeIconFileOnly$ + "' not found": GOTO errmes - - currentdir$ = _CWD$ - CHDIR IconPath$ - IconPath$ = _CWD$ - CHDIR currentdir$ - - ExeIconFile$ = IconPath$ + pathsep$ + ExeIconFileOnly$ - EXIT FOR - END IF - NEXT - END IF - - IF _FILEEXISTS(ExeIconFile$) = 0 THEN a$ = "File '" + ExeIconFile$ + "' not found": GOTO errmes - - ExeIconSet = linenumber - SetDependency DEPENDENCY_ICON - IF NoChecks = 0 THEN PRINT #12, "do{" - PRINT #12, "sub__icon(NULL,NULL,0);" - GOTO finishedline2 - END IF - - END IF 'QB64 Metacommands - - IF ExecLevel(ExecCounter) THEN - layoutdone = 0 - GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping - END IF - - - linedataoffset = DataOffset - - entireline$ = lineformat(a3$): IF LEN(entireline$) = 0 THEN GOTO finishednonexec - IF Error_Happened THEN GOTO errmes - u$ = UCASE$(entireline$) - - newif = 0 - - 'Convert "CASE ELSE" to "CASE C-EL" to avoid confusing compiler - 'note: CASE does not have to begin on a new line - s = 1 - i = INSTR(s, u$, "CASE" + sp + "ELSE") - DO WHILE i - skip = 0 - IF i <> 1 THEN - IF MID$(u$, i - 1, 1) <> sp THEN skip = 1 - END IF - IF i <> LEN(u$) - 8 THEN - IF MID$(u$, i + 9, 1) <> sp THEN skip = 1 - END IF - IF skip = 0 THEN - MID$(entireline$, i) = "CASE" + sp + "C-EL" - u$ = UCASE$(entireline$) - END IF - s = i + 9 - i = INSTR(s, u$, "CASE" + sp + "ELSE") - LOOP - - n = numelements(entireline$) - - 'line number? - a = ASC(entireline$) - IF (a >= 48 AND a <= 57) OR a = 46 THEN 'numeric - label$ = getelement(entireline$, 1) - IF validlabel(label$) THEN - - IF closedmain <> 0 AND subfunc = "" THEN a$ = "Labels cannot be placed between SUB/FUNCTIONs": GOTO errmes - - v = HashFind(label$, HASHFLAG_LABEL, ignore, r) - addlabchk100: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - IF Labels(r).State = 1 THEN a$ = "Duplicate label (" + RTRIM$(Labels(r).cn) + ")": GOTO errmes - 'aquire state 0 types - tlayout$ = RTRIM$(Labels(r).cn) - GOTO addlabaq100 - END IF 'same scope - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO addlabchk100 - END IF - - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd label$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - addlabaq100: - Labels(r).State = 1 - Labels(r).Data_Offset = linedataoffset - - layout$ = tlayout$ - PRINT #12, "LABEL_" + label$ + ":;" - - - IF INSTR(label$, "p") THEN MID$(label$, INSTR(label$, "p"), 1) = "." - IF RIGHT$(label$, 1) = "d" OR RIGHT$(label$, 1) = "s" THEN label$ = LEFT$(label$, LEN(label$) - 1) - PRINT #12, "last_line=" + label$ + ";" - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - inclinenump$ = "," + str2$(inclinenumber(inclevel)) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) - END IF - IF NoChecks = 0 THEN - IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" - PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}" - END IF - IF n = 1 THEN GOTO finishednonexec - entireline$ = getelements(entireline$, 2, n): u$ = UCASE$(entireline$): n = n - 1 - 'note: fall through, numeric labels can be followed by alphanumeric label - END IF 'validlabel - END IF 'numeric - 'it wasn't a line number - - 'label? - 'note: ignores possibility that this could be a single command SUB/FUNCTION (as in QBASIC?) - IF n >= 2 THEN - x2 = INSTR(entireline$, sp + ":") - IF x2 THEN - IF x2 = LEN(entireline$) - 1 THEN x3 = x2 + 1 ELSE x3 = x2 + 2 - a$ = LEFT$(entireline$, x2 - 1) - - CreatingLabel = 1 - IF validlabel(a$) THEN - - IF validname(a$) = 0 THEN a$ = "Invalid name": GOTO errmes - - IF closedmain <> 0 AND subfunc = "" THEN a$ = "Labels cannot be placed between SUB/FUNCTIONs": GOTO errmes - - v = HashFind(a$, HASHFLAG_LABEL, ignore, r) - addlabchk: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - IF Labels(r).State = 1 THEN a$ = "Duplicate label (" + RTRIM$(Labels(r).cn) + ")": GOTO errmes - 'aquire state 0 types - tlayout$ = RTRIM$(Labels(r).cn) - GOTO addlabaq - END IF 'same scope - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO addlabchk - END IF - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - addlabaq: - Labels(r).State = 1 - Labels(r).Data_Offset = linedataoffset - Labels(r).SourceLineNumber = linenumber - - IF LEN(layout$) THEN layout$ = layout$ + sp + tlayout$ + ":" ELSE layout$ = tlayout$ + ":" - - PRINT #12, "LABEL_" + a$ + ":;" - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - inclinenump$ = "," + str2$(inclinenumber(inclevel)) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) - END IF - IF NoChecks = 0 THEN - IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" - PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}" - END IF - entireline$ = RIGHT$(entireline$, LEN(entireline$) - x3): u$ = UCASE$(entireline$) - n = numelements(entireline$): IF n = 0 THEN GOTO finishednonexec - END IF 'valid - END IF 'includes sp+":" - END IF 'n>=2 - - 'remove leading ":" - DO WHILE ASC(u$) = 58 '":" - IF LEN(layout$) THEN layout$ = layout$ + sp2 + ":" ELSE layout$ = ":" - IF LEN(u$) = 1 THEN GOTO finishednonexec - entireline$ = getelements(entireline$, 2, n): u$ = UCASE$(entireline$): n = n - 1 - LOOP - - 'ELSE at the beginning of a line - IF ASC(u$) = 69 THEN '"E" - - e1$ = getelement(u$, 1) - - IF e1$ = "ELSE" THEN - a$ = "ELSE" - IF n > 1 THEN continuelinefrom = 2 - GOTO gotcommand - END IF - - IF e1$ = "ELSEIF" THEN - IF n < 3 THEN a$ = "Expected ... THEN": GOTO errmes - IF getelement(u$, n) = "THEN" THEN a$ = entireline$: GOTO gotcommand - FOR i = 3 TO n - 1 - IF getelement(u$, i) = "THEN" THEN - a$ = getelements(entireline$, 1, i) - continuelinefrom = i + 1 - GOTO gotcommand - END IF - NEXT - a$ = "Expected THEN": GOTO errmes - END IF - - END IF '"E" - - start = 1 - - GOTO skipcontinit - - contline: - - n = numelements(entireline$) - u$ = UCASE$(entireline$) - - skipcontinit: - - 'jargon: - 'lineelseused - counts how many line ELSEs can POSSIBLY follow - 'endifs - how many C++ endifs "}" need to be added at the end of the line - 'lineelseused - counts the number of indwelling ELSE statements on a line - 'impliedendif - stops autoformat from adding "END IF" - - a$ = "" - - FOR i = start TO n - e$ = getelement(u$, i) - - - IF e$ = ":" THEN - IF i = start THEN - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp2 + ":" ELSE layout$ = ":" - IF i <> n THEN continuelinefrom = i + 1 - GOTO finishednonexec - END IF - IF i <> n THEN continuelinefrom = i - GOTO gotcommand - END IF - - - 'begin scanning an 'IF' statement - IF e$ = "IF" AND a$ = "" THEN newif = 1 - - - IF e$ = "THEN" OR (e$ = "GOTO" AND newif = 1) THEN - IF newif = 0 THEN a$ = "THEN without IF": GOTO errmes - newif = 0 - IF lineelseused > 0 THEN lineelseused = lineelseused - 1 - IF e$ = "GOTO" THEN - IF i = n THEN a$ = "Expected IF expression GOTO label": GOTO errmes - i = i - 1 - END IF - a$ = a$ + sp + e$ '+"THEN"/"GOTO" - IF i <> n THEN continuelinefrom = i + 1: endifs = endifs + 1 - GOTO gotcommand - END IF - - - IF e$ = "ELSE" THEN - - IF start = i THEN - IF lineelseused >= 1 THEN - 'note: more than one else used (in a row) on this line, so close first if with an 'END IF' first - 'note: parses 'END IF' then (after continuelinefrom) parses 'ELSE' - 'consider the following: (square brackets make reading easier) - 'eg. if a=1 then [if b=2 then c=2 else d=2] else e=3 - impliedendif = 1: a$ = "END" + sp + "IF" - endifs = endifs - 1 - continuelinefrom = i - lineelseused = lineelseused - 1 - GOTO gotcommand - END IF - 'follow up previously encountered 'ELSE' by applying 'ELSE' - a$ = "ELSE": continuelinefrom = i + 1 - lineelseused = lineelseused + 1 - GOTO gotcommand - END IF 'start=i - - 'apply everything up to (but not including) 'ELSE' - continuelinefrom = i - GOTO gotcommand - END IF '"ELSE" - - - e$ = getelement(entireline$, i): IF a$ = "" THEN a$ = e$ ELSE a$ = a$ + sp + e$ - NEXT - - - 'we're reached the end of the line - IF endifs > 0 THEN - endifs = endifs - 1 - impliedendif = 1: entireline$ = entireline$ + sp + ":" + sp + "END" + sp + "IF": n = n + 3 - i = i + 1 'skip the ":" (i is now equal to n+2) - continuelinefrom = i - GOTO gotcommand - END IF - - - gotcommand: - - dynscope = 0 - - ca$ = a$ - a$ = eleucase$(ca$) '***REVISE THIS SECTION LATER*** - - - layoutdone = 0 - - linefragment = a$ - IF Debug THEN PRINT #9, a$ - n = numelements(a$) - IF n = 0 THEN GOTO finishednonexec - - 'convert non-UDT dimensioned periods to _046_ - IF INSTR(ca$, sp + "." + sp) THEN - a3$ = getelement(ca$, 1) - except = 0 - aa$ = a3$ + sp 'rebuilt a$ (always has a trailing spacer) - lastfuse = -1 - FOR x = 2 TO n - a2$ = getelement(ca$, x) - IF except = 1 THEN except = 2: GOTO udtperiod 'skip element name - IF a2$ = "." AND x <> n THEN - IF except = 2 THEN except = 1: GOTO udtperiod 'sub-element of UDT - - IF a3$ = ")" THEN - 'assume it was something like typevar(???).x and treat as a UDT - except = 1 - GOTO udtperiod - END IF - - 'find an ID of that type - try = findid(UCASE$(a3$)) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF ((id.t AND ISUDT) <> 0) OR ((id.arraytype AND ISUDT) <> 0) THEN - except = 1 - GOTO udtperiod - END IF - IF try = 2 THEN findanotherid = 1: try = findid(UCASE$(a3$)) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - 'not a udt; fuse lhs & rhs with _046_ - IF isalpha(ASC(a3$)) = 0 AND lastfuse <> x - 2 THEN a$ = "Invalid '.'": GOTO errmes - aa$ = LEFT$(aa$, LEN(aa$) - 1) + fix046$ - lastfuse = x - GOTO periodfused - END IF '"." - except = 0 - udtperiod: - aa$ = aa$ + a2$ + sp - periodfused: - a3$ = a2$ - NEXT - a$ = LEFT$(aa$, LEN(aa$) - 1) - ca$ = a$ - a$ = eleucase$(ca$) - n = numelements(a$) - END IF - - arrayprocessinghappened = 0 - - firstelement$ = getelement(a$, 1) - secondelement$ = getelement(a$, 2) - thirdelement$ = getelement(a$, 3) - - 'non-executable section - - IF n = 1 THEN - IF firstelement$ = "'" THEN layoutdone = 1: GOTO finishednonexec 'nop - END IF - - IF n <= 2 THEN - IF firstelement$ = "DATA" THEN - l$ = SCase$("Data") - IF n = 2 THEN - - e$ = SPACE$((LEN(secondelement$) - 1) \ 2) - FOR x = 1 TO LEN(e$) - v1 = ASC(secondelement$, x * 2) - v2 = ASC(secondelement$, x * 2 + 1) - IF v1 < 65 THEN v1 = v1 - 48 ELSE v1 = v1 - 55 - IF v2 < 65 THEN v2 = v2 - 48 ELSE v2 = v2 - 55 - ASC(e$, x) = v1 + v2 * 16 - NEXT - l$ = l$ + sp + e$ - END IF 'n=2 - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - - GOTO finishednonexec - END IF - END IF - - - - 'declare library - IF declaringlibrary THEN - - IF firstelement$ = "END" THEN - IF n <> 2 OR secondelement$ <> "DECLARE" THEN a$ = "Expected END DECLARE": GOTO errmes - declaringlibrary = 0 - l$ = SCase$("End" + sp + "Declare") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec - END IF 'end declare - - declaringlibrary = 2 - - IF firstelement$ = "SUB" OR firstelement$ = "FUNCTION" THEN - GOTO declaresubfunc2 - END IF - - a$ = "Expected SUB/FUNCTION definition or END DECLARE": GOTO errmes - END IF 'declaringlibrary - - 'check TYPE declarations (created on prepass) - IF definingtype THEN - - IF firstelement$ = "END" THEN - IF n <> 2 OR secondelement$ <> "TYPE" THEN a$ = "Expected END TYPE": GOTO errmes - definingtype = 0 - l$ = SCase$("End" + sp + "Type") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec - END IF - - 'IF n < 3 THEN definingtypeerror = linenumber: a$ = "Expected element-name AS type or AS type element-list": GOTO errmes - IF n < 3 THEN a$ = "Expected element-name AS type or AS type element-list": GOTO errmes - definingtype = 2 - IF firstelement$ = "AS" THEN - l$ = SCase$("As") - t$ = "" - wordsInTypeName = 0 - DO - nextElement$ = getelement$(a$, 2 + wordsInTypeName) - IF nextElement$ = "," THEN - 'element-list - wordsInTypeName = wordsInTypeName - 2 - EXIT DO - END IF - - wordsInTypeName = wordsInTypeName + 1 - IF wordsInTypeName = n - 2 THEN - 'single element in line - wordsInTypeName = wordsInTypeName - 1 - EXIT DO - END IF - LOOP - - t$ = getelements$(a$, 2, 2 + wordsInTypeName) - typ = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF typ = 0 THEN a$ = "Undefined type": GOTO errmes - IF typ AND ISUDT THEN - IF UCASE$(RTRIM$(t$)) = "MEM" AND RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND qb64prefix_set = 1 THEN - t$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) - ELSE - t$ = RTRIM$(udtxcname(typ AND 511)) - END IF - l$ = l$ + sp + t$ - ELSE - l$ = l$ + sp + SCase2$(t$) - END IF - - 'Now add each variable: - FOR i = 3 + wordsInTypeName TO n - thisElement$ = getelement$(ca$, i) - IF thisElement$ = "," THEN - l$ = l$ + thisElement$ - ELSE - l$ = l$ + sp + thisElement$ - END IF - NEXT - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - ELSE - l$ = getelement(ca$, 1) + sp + SCase$("As") - t$ = getelements$(a$, 3, n) - typ = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF typ = 0 THEN a$ = "Undefined type": GOTO errmes - IF typ AND ISUDT THEN - IF UCASE$(RTRIM$(t$)) = "MEM" AND RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND qb64prefix_set = 1 THEN - t$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) - ELSE - t$ = RTRIM$(udtxcname(typ AND 511)) - END IF - l$ = l$ + sp + t$ - ELSE - l$ = l$ + sp + SCase2$(t$) - END IF - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - END IF - GOTO finishednonexec - - END IF 'defining type - - IF firstelement$ = "TYPE" THEN - IF n <> 2 THEN a$ = "Expected TYPE type-name": GOTO errmes - l$ = SCase$("Type") + sp + getelement(ca$, 2) - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - definingtype = 1 - definingtypeerror = linenumber - GOTO finishednonexec - END IF - - 'skip DECLARE SUB/FUNCTION - IF n >= 1 THEN - IF firstelement$ = "DECLARE" THEN - - IF secondelement$ = "LIBRARY" OR secondelement$ = "DYNAMIC" OR secondelement$ = "CUSTOMTYPE" OR secondelement$ = "STATIC" THEN - - declaringlibrary = 1 - dynamiclibrary = 0 - customtypelibrary = 0 - indirectlibrary = 0 - staticlinkedlibrary = 0 - - x = 3 - l$ = SCase$("Declare" + sp + "Library") - - IF secondelement$ = "DYNAMIC" THEN - e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - dynamiclibrary = 1 - x = 4 - l$ = SCase$("Declare" + sp + "Dynamic" + sp + "Library") - IF n = 3 THEN a$ = "Expected DECLARE DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - indirectlibrary = 1 - END IF - - IF secondelement$ = "CUSTOMTYPE" THEN - e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected CUSTOMTYPE LIBRARY": GOTO errmes - customtypelibrary = 1 - x = 4 - l$ = SCase$("Declare" + sp + "CustomType" + sp + "Library") - indirectlibrary = 1 - END IF - - IF secondelement$ = "STATIC" THEN - e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected STATIC LIBRARY": GOTO errmes - x = 4 - l$ = SCase$("Declare" + sp + "Static" + sp + "Library") - staticlinkedlibrary = 1 - END IF - - sfdeclare = 0: sfheader = 0 - - IF n >= x THEN - - sfdeclare = 1 - - addlibrary: - - libname$ = "" - headername$ = "" - - - 'assume library name in double quotes follows - 'assume library is in main qb64 folder - x$ = getelement$(ca$, x) - IF ASC(x$) <> 34 THEN a$ = "Expected LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - x$ = RIGHT$(x$, LEN(x$) - 1) - z = INSTR(x$, CHR$(34)) - IF z = 0 THEN a$ = "Expected LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - x$ = LEFT$(x$, z - 1) - - IF dynamiclibrary <> 0 AND LEN(x$) = 0 THEN a$ = "Expected DECLARE DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - IF customtypelibrary <> 0 AND LEN(x$) = 0 THEN a$ = "Expected DECLARE CUSTOMTYPE LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes - - - - - - - - - - - - - - 'convert '\\' to '\' - WHILE INSTR(x$, "\\") - z = INSTR(x$, "\\") - x$ = LEFT$(x$, z - 1) + RIGHT$(x$, LEN(x$) - z) - WEND - - autoformat_x$ = x$ 'used for autolayout purposes - - 'Remove version number from library name - 'Eg. libname:1.0 becomes libname <-> 1.0 which later becomes libname.so.1.0 - v$ = "" - striplibver: - FOR z = LEN(x$) TO 1 STEP -1 - a = ASC(x$, z) - IF a = ASC_BACKSLASH OR a = ASC_FORWARDSLASH THEN EXIT FOR - IF a = ASC_FULLSTOP OR a = ASC_COLON THEN - IF isuinteger(RIGHT$(x$, LEN(x$) - z)) THEN - IF LEN(v$) THEN v$ = RIGHT$(x$, LEN(x$) - z) + "." + v$ ELSE v$ = RIGHT$(x$, LEN(x$) - z) - x$ = LEFT$(x$, z - 1) - IF a = ASC_COLON THEN EXIT FOR - GOTO striplibver - ELSE - EXIT FOR - END IF - END IF - NEXT - libver$ = v$ - - - IF os$ = "WIN" THEN - 'convert forward-slashes to back-slashes - DO WHILE INSTR(x$, "/") - z = INSTR(x$, "/") - x$ = LEFT$(x$, z - 1) + "\" + RIGHT$(x$, LEN(x$) - z) - LOOP - END IF - - IF os$ = "LNX" THEN - 'convert any back-slashes to forward-slashes - DO WHILE INSTR(x$, "\") - z = INSTR(x$, "\") - x$ = LEFT$(x$, z - 1) + "/" + RIGHT$(x$, LEN(x$) - z) - LOOP - END IF - - 'Separate path from name - libpath$ = "" - FOR z = LEN(x$) TO 1 STEP -1 - a = ASC(x$, z) - IF a = 47 OR a = 92 THEN '\ or / - libpath$ = LEFT$(x$, z) - x$ = RIGHT$(x$, LEN(x$) - z) - EXIT FOR - END IF - NEXT - - 'Accept ./ and .\ as a reference to the source file - 'folder, replacing it with the actual full path, if available - IF libpath$ = "./" OR libpath$ = ".\" THEN - libpath$ = "" - IF NoIDEMode THEN - libpath$ = path.source$ - IF LEN(libpath$) > 0 AND RIGHT$(libpath$, 1) <> pathsep$ THEN libpath$ = libpath$ + pathsep$ - ELSE - IF LEN(ideprogname) THEN libpath$ = idepath$ + pathsep$ - END IF - END IF - - 'Create a path which can be used for inline code (uses \\ instead of \) - libpath_inline$ = "" - FOR z = 1 TO LEN(libpath$) - a = ASC(libpath$, z) - libpath_inline$ = libpath_inline$ + CHR$(a) - IF a = 92 THEN libpath_inline$ = libpath_inline$ + "\" - NEXT - - IF LEN(x$) THEN - IF dynamiclibrary = 0 THEN - 'Static library - - IF os$ = "WIN" THEN - 'check for .lib - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + x$ + ".lib") THEN - libname$ = libpath$ + x$ + ".lib" - inlinelibname$ = libpath_inline$ + x$ + ".lib" - END IF - END IF - 'check for .a - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + x$ + ".a") THEN - libname$ = libpath$ + x$ + ".a" - inlinelibname$ = libpath_inline$ + x$ + ".a" - END IF - END IF - 'check for .o - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + x$ + ".o") THEN - libname$ = libpath$ + x$ + ".o" - inlinelibname$ = libpath_inline$ + x$ + ".o" - END IF - END IF - 'check for .lib - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(x$ + ".lib") THEN - libname$ = x$ + ".lib" - inlinelibname$ = x$ + ".lib" - END IF - END IF - 'check for .a - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(x$ + ".a") THEN - libname$ = x$ + ".a" - inlinelibname$ = x$ + ".a" - END IF - END IF - 'check for .o - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(x$ + ".o") THEN - libname$ = x$ + ".o" - inlinelibname$ = x$ + ".o" - END IF - END IF - END IF 'Windows - - IF os$ = "LNX" THEN - IF staticlinkedlibrary = 0 THEN - - IF MacOSX THEN 'dylib support - 'check for .dylib (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = libpath$ + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".dylib") THEN - libname$ = libpath$ + "lib" + x$ + ".dylib" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".dylib" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - END IF - - 'check for .so (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so." + libver$ - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so") THEN - libname$ = libpath$ + "lib" + x$ + ".so" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - END IF - 'check for .a (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".a") THEN - libname$ = libpath$ + "lib" + x$ + ".a" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".a" - END IF - END IF - 'check for .o (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".o") THEN - libname$ = libpath$ + "lib" + x$ + ".o" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".o" - END IF - END IF - IF staticlinkedlibrary = 0 THEN - 'check for .so (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " - END IF - END IF - END IF - 'check for .a (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".a") THEN - libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".a" - inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".a" - END IF - END IF - IF staticlinkedlibrary = 0 THEN - - IF MacOSX THEN 'dylib support - 'check for .dylib (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".dylib") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".dylib" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".dylib" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - END IF - - 'check for .so (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so" - IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - END IF - 'check for .a (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".a") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".a" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".a" - END IF - END IF - '--------------------------(without path)------------------------------ - IF staticlinkedlibrary = 0 THEN - - IF MacOSX THEN 'dylib support - 'check for .dylib (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "lib" + x$ + "." + libver$ + ".dylib" - mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".dylib") THEN - libname$ = "lib" + x$ + ".dylib" - inlinelibname$ = "lib" + x$ + ".dylib" - mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - END IF - - 'check for .so (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".so." + libver$) THEN - libname$ = "lib" + x$ + ".so." + libver$ - inlinelibname$ = "lib" + x$ + ".so." + libver$ - mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".so") THEN - libname$ = "lib" + x$ + ".so" - inlinelibname$ = "lib" + x$ + ".so" - mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " - END IF - END IF - END IF - 'check for .a (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".a") THEN - libname$ = "lib" + x$ + ".a" - inlinelibname$ = "lib" + x$ + ".a" - END IF - END IF - 'check for .o (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".o") THEN - libname$ = "lib" + x$ + ".o" - inlinelibname$ = "lib" + x$ + ".o" - END IF - END IF - IF staticlinkedlibrary = 0 THEN - 'check for .so (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ - mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib64/" + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so" - mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " - END IF - END IF - END IF - 'check for .a (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".a") THEN - libname$ = "/usr/lib64/" + "lib" + x$ + ".a" - inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".a" - END IF - END IF - IF staticlinkedlibrary = 0 THEN - - IF MacOSX THEN 'dylib support - 'check for .dylib (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".dylib") THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".dylib" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".dylib" - mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - END IF - - 'check for .so (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so" - mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - END IF - 'check for .a (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".a") THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".a" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".a" - mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " - END IF - END IF - END IF 'Linux - - - 'check for header - IF LEN(headername$) = 0 THEN - IF os$ = "WIN" THEN - IF _FILEEXISTS(libpath$ + x$ + ".h") THEN - headername$ = libpath_inline$ + x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS(libpath$ + x$ + ".hpp") THEN - headername$ = libpath_inline$ + x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - '--------------------------(without path)------------------------------ - IF _FILEEXISTS(x$ + ".h") THEN - headername$ = x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS(x$ + ".hpp") THEN - headername$ = x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - END IF 'Windows - - IF os$ = "LNX" THEN - IF _FILEEXISTS(libpath$ + x$ + ".h") THEN - headername$ = libpath_inline$ + x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS(libpath$ + x$ + ".hpp") THEN - headername$ = libpath_inline$ + x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS("/usr/include/" + libpath$ + x$ + ".h") THEN - headername$ = "/usr/include/" + libpath_inline$ + x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS("/usr/include/" + libpath$ + x$ + ".hpp") THEN - headername$ = "/usr/include/" + libpath_inline$ + x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - '--------------------------(without path)------------------------------ - IF _FILEEXISTS(x$ + ".h") THEN - headername$ = x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS(x$ + ".hpp") THEN - headername$ = x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS("/usr/include/" + x$ + ".h") THEN - headername$ = "/usr/include/" + x$ + ".h" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - IF _FILEEXISTS("/usr/include/" + x$ + ".hpp") THEN - headername$ = "/usr/include/" + x$ + ".hpp" - IF customtypelibrary = 0 THEN sfdeclare = 0 - sfheader = 1 - GOTO GotHeader - END IF - END IF 'Linux - - GotHeader: - END IF - - ELSE - 'dynamic library - - IF os$ = "WIN" THEN - 'check for .dll (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + x$ + ".dll") THEN - libname$ = libpath$ + x$ + ".dll" - inlinelibname$ = libpath_inline$ + x$ + ".dll" - END IF - END IF - 'check for .dll (system32) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(ENVIRON$("SYSTEMROOT") + "\System32\" + libpath$ + x$ + ".dll") THEN - libname$ = libpath$ + x$ + ".dll" - inlinelibname$ = libpath_inline$ + x$ + ".dll" - END IF - END IF - '--------------------------(without path)------------------------------ - 'check for .dll (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(x$ + ".dll") THEN - libname$ = x$ + ".dll" - inlinelibname$ = x$ + ".dll" - END IF - END IF - 'check for .dll (system32) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(ENVIRON$("SYSTEMROOT") + "\System32\" + x$ + ".dll") THEN - libname$ = x$ + ".dll" - inlinelibname$ = x$ + ".dll" - END IF - END IF - END IF 'Windows - - IF os$ = "LNX" THEN - 'Note: STATIC libraries (.a/.o) cannot be loaded as dynamic objects - - - IF MacOSX THEN 'dylib support - 'check for .dylib (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = libpath$ + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" - IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".dylib") THEN - libname$ = libpath$ + "lib" + x$ + ".dylib" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".dylib" - IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - END IF - - 'check for .so (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so." + libver$ - IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so") THEN - libname$ = libpath$ + "lib" + x$ + ".so" - inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so" - IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - 'check for .so (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so" - END IF - END IF - - IF MacOSX THEN 'dylib support - 'check for .dylib (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".dylib") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".dylib" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".dylib" - END IF - END IF - END IF - - 'check for .so (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so" - END IF - END IF - '--------------------------(without path)------------------------------ - IF MacOSX THEN 'dylib support - 'check for .dylib (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "lib" + x$ + "." + libver$ + ".dylib" - libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".dylib") THEN - libname$ = "lib" + x$ + ".dylib" - inlinelibname$ = "lib" + x$ + ".dylib" - libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - END IF - - 'check for .so (direct) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".so." + libver$) THEN - libname$ = "lib" + x$ + ".so." + libver$ - inlinelibname$ = "lib" + x$ + ".so." + libver$ - libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("lib" + x$ + ".so") THEN - libname$ = "lib" + x$ + ".so" - inlinelibname$ = "lib" + x$ + ".so" - libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ - END IF - END IF - 'check for .so (usr/lib64) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib64/" + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so" - END IF - END IF - - IF MacOSX THEN 'dylib support - 'check for .dylib (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib") THEN - libname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".dylib") THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".dylib" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".dylib" - END IF - END IF - END IF - - 'check for .so (usr/lib) - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so." + libver$) THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ - END IF - END IF - IF LEN(libname$) = 0 THEN - IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so") THEN - libname$ = "/usr/lib/" + "lib" + x$ + ".so" - inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so" - END IF - END IF - END IF 'Linux - - END IF 'Dynamic - - 'library found? - IF dynamiclibrary <> 0 AND LEN(libname$) = 0 THEN a$ = "DYNAMIC LIBRARY not found": GOTO errmes - IF LEN(libname$) = 0 AND LEN(headername$) = 0 THEN a$ = "LIBRARY not found": GOTO errmes - - '***actual method should cull redundant header and library entries*** - - IF dynamiclibrary = 0 THEN - - 'static - IF LEN(libname$) THEN - IF os$ = "WIN" THEN - IF MID$(libname$, 2, 1) = ":" OR LEFT$(libname$, 1) = "\" THEN - mylib$ = mylib$ + " " + libname$ + " " - ELSE - mylib$ = mylib$ + " ..\..\" + libname$ + " " - END IF - END IF - IF os$ = "LNX" THEN - IF LEFT$(libname$, 1) = "/" THEN - mylib$ = mylib$ + " " + libname$ + " " - ELSE - mylib$ = mylib$ + " ../../" + libname$ + " " - END IF - END IF - - END IF - - ELSE - - 'dynamic - IF LEN(headername$) = 0 THEN 'no header - - IF subfuncn THEN - f = FREEFILE - OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f - ELSE - f = 13 - END IF - - 'make name a C-appropriate variable name - 'by converting everything except numbers and - 'letters to underscores - x2$ = x$ - FOR x2 = 1 TO LEN(x2$) - IF ASC(x2$, x2) < 48 THEN ASC(x2$, x2) = 95 - IF ASC(x2$, x2) > 57 AND ASC(x2$, x2) < 65 THEN ASC(x2$, x2) = 95 - IF ASC(x2$, x2) > 90 AND ASC(x2$, x2) < 97 THEN ASC(x2$, x2) = 95 - IF ASC(x2$, x2) > 122 THEN ASC(x2$, x2) = 95 - NEXT - DLLname$ = x2$ - - IF sfdeclare THEN - - IF os$ = "WIN" THEN - PRINT #17, "HINSTANCE DLL_" + x2$ + "=NULL;" - PRINT #f, "if (!DLL_" + x2$ + "){" - PRINT #f, "DLL_" + x2$ + "=LoadLibrary(" + CHR$(34) + inlinelibname$ + CHR$(34) + ");" - PRINT #f, "if (!DLL_" + x2$ + ") error(259);" - PRINT #f, "}" - END IF - - IF os$ = "LNX" THEN - PRINT #17, "void *DLL_" + x2$ + "=NULL;" - PRINT #f, "if (!DLL_" + x2$ + "){" - PRINT #f, "DLL_" + x2$ + "=dlopen(" + CHR$(34) + inlinelibname$ + CHR$(34) + ",RTLD_LAZY);" - PRINT #f, "if (!DLL_" + x2$ + ") error(259);" - PRINT #f, "}" - END IF - - - END IF - - IF subfuncn THEN CLOSE #f - - END IF 'no header - - END IF 'dynamiclibrary - - IF LEN(headername$) THEN - IF os$ = "WIN" THEN - IF MID$(headername$, 2, 1) = ":" OR LEFT$(headername$, 1) = "\" THEN - PRINT #17, "#include " + CHR$(34) + headername$ + CHR$(34) - ELSE - PRINT #17, "#include " + CHR$(34) + "..\\..\\" + headername$ + CHR$(34) - END IF - END IF - IF os$ = "LNX" THEN - - IF LEFT$(headername$, 1) = "/" THEN - PRINT #17, "#include " + CHR$(34) + headername$ + CHR$(34) - ELSE - PRINT #17, "#include " + CHR$(34) + "../../" + headername$ + CHR$(34) - END IF - - END IF - END IF - - END IF - - l$ = l$ + sp + CHR$(34) + autoformat_x$ + CHR$(34) - - IF n > x THEN - IF dynamiclibrary THEN a$ = "Cannot specify multiple DYNAMIC LIBRARY names in a single DECLARE statement": GOTO errmes - x = x + 1: x2$ = getelement$(a$, x): IF x2$ <> "," THEN a$ = "Expected ,": GOTO errmes - l$ = l$ + sp2 + "," - x = x + 1: IF x > n THEN a$ = "Expected , ...": GOTO errmes - GOTO addlibrary - END IF - - END IF 'n>=x - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec - END IF - - GOTO finishednonexec 'note: no layout required - END IF - END IF - - 'begin SUB/FUNCTION - IF n >= 1 THEN - dynamiclibrary = 0 - declaresubfunc2: - sf = 0 - IF firstelement$ = "FUNCTION" THEN sf = 1 - IF firstelement$ = "SUB" THEN sf = 2 - IF sf THEN - - IF declaringlibrary = 0 THEN - IF LEN(subfunc) THEN a$ = "Expected END SUB/FUNCTION before " + firstelement$: GOTO errmes - END IF - - IF n = 1 THEN a$ = "Expected name after SUB/FUNCTION": GOTO errmes - e$ = getelement$(ca$, 2) - symbol$ = removesymbol$(e$) '$,%,etc. - IF Error_Happened THEN GOTO errmes - IF sf = 2 AND symbol$ <> "" THEN a$ = "Type symbols after a SUB name are invalid": GOTO errmes - try = findid(e$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = sf THEN GOTO createsf - IF try = 2 THEN findanotherid = 1: try = findid(e$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - a$ = "Unregistered SUB/FUNCTION encountered": GOTO errmes - createsf: - IF UCASE$(e$) = "_GL" THEN e$ = "_GL" - IF firstelement$ = "SUB" THEN - l$ = SCase$("Sub") + sp + e$ + symbol$ - ELSE - l$ = SCase$("Function") + sp + e$ + symbol$ - END IF - id2 = id - targetid = currentid - - 'check for ALIAS - aliasname$ = RTRIM$(id.cn) - IF n > 2 THEN - ee$ = getelement$(a$, 3) - IF ee$ = "ALIAS" THEN - IF declaringlibrary = 0 THEN a$ = "ALIAS can only be used with DECLARE LIBRARY": GOTO errmes - IF n = 3 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes - ee$ = getelement$(ca$, 4) - - 'strip string content (optional) - IF LEFT$(ee$, 1) = CHR$(34) THEN - ee$ = RIGHT$(ee$, LEN(ee$) - 1) - x = INSTR(ee$, CHR$(34)): IF x = 0 THEN a$ = "Expected " + CHR$(34): GOTO errmes - ee$ = LEFT$(ee$, x - 1) - l$ = l$ + sp + SCase$("Alias") + sp + CHR_QUOTE + ee$ + CHR_QUOTE - ELSE - l$ = l$ + sp + SCase$("Alias") + sp + ee$ - END IF - - 'strip fix046$ (created by unquoted periods) - DO WHILE INSTR(ee$, fix046$) - x = INSTR(ee$, fix046$): ee$ = LEFT$(ee$, x - 1) + "." + RIGHT$(ee$, LEN(ee$) - x + 1 - LEN(fix046$)) - LOOP - aliasname$ = ee$ - 'remove ALIAS section from line - IF n <= 4 THEN a$ = getelements(a$, 1, 2) - IF n >= 5 THEN a$ = getelements(a$, 1, 2) + sp + getelements(a$, 5, n) - IF n <= 4 THEN ca$ = getelements(ca$, 1, 2) - IF n >= 5 THEN ca$ = getelements(ca$, 1, 2) + sp + getelements(ca$, 5, n) - n = n - 2 - END IF - END IF - - IF declaringlibrary THEN GOTO declibjmp1 - - - IF closedmain = 0 THEN closemain - - 'check for open controls (copy #2) - IF controllevel <> 0 AND controltype(controllevel) <> 6 THEN 'It's OK for subs to be inside $IF blocks - a$ = "Unidentified open control block" - SELECT CASE controltype(controllevel) - CASE 1: a$ = "IF without END IF" - CASE 2: a$ = "FOR without NEXT" - CASE 3, 4: a$ = "DO without LOOP" - CASE 5: a$ = "WHILE without WEND" - CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" - END SELECT - linenumber = controlref(controllevel) - GOTO errmes - END IF - - IF ideindentsubs THEN - controllevel = controllevel + 1 - controltype(controllevel) = 32 - controlref(controllevel) = linenumber - END IF - - subfunc = RTRIM$(id.callname) 'SUB_..." - IF id.subfunc = 1 THEN subfuncoriginalname$ = "FUNCTION " ELSE subfuncoriginalname$ = "SUB " - subfuncoriginalname$ = subfuncoriginalname$ + RTRIM$(id.cn) - subfuncn = subfuncn + 1 - closedsubfunc = 0 - subfuncid = targetid - - subfuncret$ = "" - - CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #13 - CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #19 - CLOSE #15: OPEN tmpdir$ + "ret" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #15 - PRINT #15, "if (next_return_point){" - PRINT #15, "next_return_point--;" - PRINT #15, "switch(return_point[next_return_point]){" - PRINT #15, "case 0:" - PRINT #15, "error(3);" 'return without gosub! - PRINT #15, "break;" - defdatahandle = 13 - - declibjmp1: - - IF declaringlibrary THEN - IF sfdeclare = 0 AND indirectlibrary = 0 THEN - CLOSE #17 - OPEN tmpdir$ + "regsf_ignore.txt" FOR OUTPUT AS #17 - END IF - IF sfdeclare = 1 AND customtypelibrary = 0 AND dynamiclibrary = 0 AND indirectlibrary = 0 THEN - PRINT #17, "#include " + CHR$(34) + "externtype" + str2(ResolveStaticFunctions + 1) + ".txt" + CHR$(34) - fh = FREEFILE: OPEN tmpdir$ + "externtype" + str2(ResolveStaticFunctions + 1) + ".txt" FOR OUTPUT AS #fh: CLOSE #fh - END IF - END IF - - - - - IF sf = 1 THEN - rettyp = id.ret - t$ = typ2ctyp$(id.ret, "") - IF Error_Happened THEN GOTO errmes - IF t$ = "qbs" THEN t$ = "qbs*" - - IF declaringlibrary THEN - IF rettyp AND ISSTRING THEN - t$ = "char*" - END IF - END IF - - IF declaringlibrary <> 0 AND dynamiclibrary <> 0 THEN - IF os$ = "WIN" THEN - PRINT #17, "typedef " + t$ + " (CALLBACK* DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; - END IF - IF os$ = "LNX" THEN - PRINT #17, "typedef " + t$ + " (*DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; - END IF - ELSEIF declaringlibrary <> 0 AND customtypelibrary <> 0 THEN - PRINT #17, "typedef " + t$ + " CUSTOMCALL_" + removecast$(RTRIM$(id.callname)) + "("; - ELSE - PRINT #17, t$ + " " + removecast$(RTRIM$(id.callname)) + "("; - END IF - IF declaringlibrary THEN GOTO declibjmp2 - PRINT #12, t$ + " " + removecast$(RTRIM$(id.callname)) + "("; - - 'create variable to return result - 'if type wasn't specified, define it - IF symbol$ = "" THEN - a = ASC(UCASE$(e$)): IF a = 95 THEN a = 91 - a = a - 64 'so A=1, Z=27 and _=28 - symbol$ = defineextaz(a) - END IF - reginternalvariable = 1 - ignore = dim2(e$, symbol$, 0, "") - IF Error_Happened THEN GOTO errmes - reginternalvariable = 0 - 'the following line stops the return variable from being free'd before being returned - CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #19 - 'create return - IF (rettyp AND ISSTRING) THEN - r$ = refer$(str2$(currentid), id.t, 1) - IF Error_Happened THEN GOTO errmes - subfuncret$ = subfuncret$ + "qbs_maketmp(" + r$ + ");" - subfuncret$ = subfuncret$ + "return " + r$ + ";" - ELSE - r$ = refer$(str2$(currentid), id.t, 0) - IF Error_Happened THEN GOTO errmes - subfuncret$ = "return " + r$ + ";" - END IF - ELSE - - IF declaringlibrary <> 0 AND dynamiclibrary <> 0 THEN - IF os$ = "WIN" THEN - PRINT #17, "typedef void (CALLBACK* DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; - END IF - IF os$ = "LNX" THEN - PRINT #17, "typedef void (*DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; - END IF - ELSEIF declaringlibrary <> 0 AND customtypelibrary <> 0 THEN - PRINT #17, "typedef void CUSTOMCALL_" + removecast$(RTRIM$(id.callname)) + "("; - ELSE - PRINT #17, "void " + removecast$(RTRIM$(id.callname)) + "("; - END IF - IF declaringlibrary THEN GOTO declibjmp2 - PRINT #12, "void " + removecast$(RTRIM$(id.callname)) + "("; - END IF - declibjmp2: - - addstatic2layout = 0 - staticsf = 0 - e$ = getelement$(a$, n) - IF e$ = "STATIC" THEN - IF declaringlibrary THEN a$ = "STATIC cannot be used in a library declaration": GOTO errmes - addstatic2layout = 1 - staticsf = 2 - a$ = LEFT$(a$, LEN(a$) - 7): n = n - 1 'remove STATIC - END IF - - 'check items to pass - params = 0 - AllowLocalName = 1 - IF n > 2 THEN - e$ = getelement$(a$, 3) - IF e$ <> "(" THEN a$ = "Expected (": GOTO errmes - e$ = getelement$(a$, n) - IF e$ <> ")" THEN a$ = "Expected )": GOTO errmes - l$ = l$ + sp + "(" - IF n = 4 THEN GOTO nosfparams2 - IF n < 4 THEN a$ = "Expected ( ... )": GOTO errmes - B = 0 - a2$ = "" - FOR i = 4 TO n - 1 - e$ = getelement$(ca$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN B = B - 1 - IF e$ = "," AND B = 0 THEN - IF i = n - 1 THEN a$ = "Expected , ... )": GOTO errmes - getlastparam2: - IF a2$ = "" THEN a$ = "Expected ... ,": GOTO errmes - a2$ = LEFT$(a2$, LEN(a2$) - 1) - 'possible format: [BYVAL]a[%][(1)][AS][type] - params = params + 1 - glinkid = targetid - glinkarg = params - - - - IF params > 1 THEN - PRINT #17, ","; - - IF declaringlibrary = 0 THEN - PRINT #12, ","; - END IF - - END IF - n2 = numelements(a2$) - array = 0 - t2$ = "" - e$ = getelement$(a2$, 1) - - byvalue = 0 - IF UCASE$(e$) = "BYVAL" THEN - IF declaringlibrary = 0 THEN a$ = "BYVAL can only be used with DECLARE LIBRARY": GOTO errmes - byvalue = 1: a2$ = RIGHT$(a2$, LEN(a2$) - 6) - IF RIGHT$(l$, 1) = "(" THEN l$ = l$ + sp2 + SCase$("ByVal") ELSE l$ = l$ + sp + SCase$("Byval") - n2 = numelements(a2$): e$ = getelement$(a2$, 1) - END IF - - IF RIGHT$(l$, 1) = "(" THEN l$ = l$ + sp2 + e$ ELSE l$ = l$ + sp + e$ - - n2$ = e$ - dimmethod = 0 - - - symbol2$ = removesymbol$(n2$) - IF validname(n2$) = 0 THEN a$ = "Invalid name": GOTO errmes - - IF Error_Happened THEN GOTO errmes - IF symbol2$ <> "" THEN dimmethod = 1 - m = 0 - FOR i2 = 2 TO n2 - e$ = getelement$(a2$, i2) - IF e$ = "(" THEN - IF m <> 0 THEN a$ = "Syntax error - too many opening brackets": GOTO errmes - m = 1 - array = 1 - l$ = l$ + sp2 + "(" - GOTO gotaa2 - END IF - IF e$ = ")" THEN - IF m <> 1 THEN a$ = "Syntax error - closing bracket without opening bracket": GOTO errmes - m = 2 - l$ = l$ + sp2 + ")" - GOTO gotaa2 - END IF - IF UCASE$(e$) = "AS" THEN - IF m <> 0 AND m <> 2 THEN a$ = "Syntax error - check your brackets": GOTO errmes - m = 3 - l$ = l$ + sp + SCase$("As") - GOTO gotaa2 - END IF - IF m = 1 THEN l$ = l$ + sp + e$: GOTO gotaa2 'ignore contents of option bracket telling how many dimensions (add to layout as is) - IF m <> 3 THEN a$ = "Syntax error - check your brackets": GOTO errmes - IF t2$ = "" THEN t2$ = e$ ELSE t2$ = t2$ + " " + e$ - gotaa2: - NEXT i2 - IF m = 1 THEN a$ = "Syntax error - check your brackets": GOTO errmes - IF symbol2$ <> "" AND t2$ <> "" THEN a$ = "Syntax error - check parameter types": GOTO errmes - - - IF LEN(t2$) THEN 'add type-name after AS - t2$ = UCASE$(t2$) - t3$ = t2$ - typ = typname2typ(t3$) - IF Error_Happened THEN GOTO errmes - IF typ = 0 THEN a$ = "Undefined type": GOTO errmes - IF typ AND ISUDT THEN - IF RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND UCASE$(t3$) = "MEM" AND qb64prefix_set = 1 THEN - t3$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) - ELSE - t3$ = RTRIM$(udtxcname(typ AND 511)) - END IF - l$ = l$ + sp + t3$ - ELSE - FOR t3i = 1 TO LEN(t3$) - IF ASC(t3$, t3i) = 32 THEN ASC(t3$, t3i) = ASC(sp) - NEXT - t3$ = SCase2$(t3$) - l$ = l$ + sp + t3$ - END IF - END IF - - IF t2$ = "" THEN t2$ = symbol2$ - IF t2$ = "" THEN - IF LEFT$(n2$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n2$)) - 64 - t2$ = defineaz(v) - dimmethod = 1 - END IF - - - - - IF array = 1 THEN - IF declaringlibrary THEN a$ = "Arrays cannot be passed to a library": GOTO errmes - dimsfarray = 1 - 'note: id2.nele is currently 0 - nelereq = ASC(MID$(id2.nelereq, params, 1)) - IF nelereq THEN - nele = nelereq - MID$(id2.nele, params, 1) = CHR$(nele) - - ids(targetid) = id2 - - ignore = dim2(n2$, t2$, dimmethod, str2$(nele)) - IF Error_Happened THEN GOTO errmes - ELSE - nele = 1 - MID$(id2.nele, params, 1) = CHR$(nele) - - ids(targetid) = id2 - - ignore = dim2(n2$, t2$, dimmethod, "?") - IF Error_Happened THEN GOTO errmes - END IF - - dimsfarray = 0 - r$ = refer$(str2$(currentid), id.t, 1) - IF Error_Happened THEN GOTO errmes - PRINT #17, "ptrszint*" + r$; - PRINT #12, "ptrszint*" + r$; - ELSE - - IF declaringlibrary THEN - 'is it a udt? - FOR xx = 1 TO lasttype - IF t2$ = RTRIM$(udtxname(xx)) THEN - PRINT #17, "void*" - GOTO decudt - ELSEIF RTRIM$(udtxname(xx)) = "_MEM" AND t2$ = "MEM" AND qb64prefix_set = 1 THEN - PRINT #17, "void*" - GOTO decudt - END IF - NEXT - t$ = typ2ctyp$(0, t2$) - - IF Error_Happened THEN GOTO errmes - IF t$ = "qbs" THEN - t$ = "char*" - IF byvalue = 1 THEN a$ = "STRINGs cannot be passed using BYVAL": GOTO errmes - byvalue = 1 'use t$ as is - END IF - IF byvalue THEN PRINT #17, t$; ELSE PRINT #17, t$ + "*"; - decudt: - GOTO declibjmp3 - END IF - - dimsfarray = 1 - ignore = dim2(n2$, t2$, dimmethod, "") - IF Error_Happened THEN GOTO errmes - - - dimsfarray = 0 - t$ = "" - typ = id.t 'the typ of the ID created by dim2 - - t$ = typ2ctyp$(typ, "") - IF Error_Happened THEN GOTO errmes - - - - IF t$ = "" THEN a$ = "Cannot find C type to return array data": GOTO errmes - 'searchpoint - 'get the name of the variable - r$ = refer$(str2$(currentid), id.t, 1) - IF Error_Happened THEN GOTO errmes - PRINT #17, t$ + "*" + r$; - PRINT #12, t$ + "*" + r$; - IF t$ = "qbs" THEN - u$ = str2$(uniquenumber) - PRINT #13, "qbs*oldstr" + u$ + "=NULL;" - PRINT #13, "if(" + r$ + "->tmp||" + r$ + "->fixed||" + r$ + "->readonly){" - PRINT #13, "oldstr" + u$ + "=" + r$ + ";" - - PRINT #13, "if (oldstr" + u$ + "->cmem_descriptor){" - PRINT #13, r$ + "=qbs_new_cmem(oldstr" + u$ + "->len,0);" - PRINT #13, "}else{" - PRINT #13, r$ + "=qbs_new(oldstr" + u$ + "->len,0);" - PRINT #13, "}" - - PRINT #13, "memcpy(" + r$ + "->chr,oldstr" + u$ + "->chr,oldstr" + u$ + "->len);" - PRINT #13, "}" - - PRINT #19, "if(oldstr" + u$ + "){" - PRINT #19, "if(oldstr" + u$ + "->fixed)qbs_set(oldstr" + u$ + "," + r$ + ");" - PRINT #19, "qbs_free(" + r$ + ");" - PRINT #19, "}" - END IF - END IF - declibjmp3: - IF i <> n - 1 THEN l$ = l$ + sp2 + "," - - a2$ = "" - ELSE - a2$ = a2$ + e$ + sp - IF i = n - 1 THEN GOTO getlastparam2 - END IF - NEXT i - nosfparams2: - l$ = l$ + sp2 + ")" - END IF 'n>2 - AllowLocalName = 0 - - IF addstatic2layout THEN l$ = l$ + sp + SCase$("Static") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - - PRINT #17, ");" - - IF declaringlibrary THEN GOTO declibjmp4 - - PRINT #12, "){" - PRINT #12, "qbs *tqbs;" - PRINT #12, "ptrszint tmp_long;" - PRINT #12, "int32 tmp_fileno;" - PRINT #12, "uint32 qbs_tmp_base=qbs_tmp_list_nexti;" - PRINT #12, "uint8 *tmp_mem_static_pointer=mem_static_pointer;" - PRINT #12, "uint32 tmp_cmem_sp=cmem_sp;" - PRINT #12, "#include " + CHR$(34) + "data" + str2$(subfuncn) + ".txt" + CHR$(34) - - 'create new _MEM lock for this scope - PRINT #12, "mem_lock *sf_mem_lock;" 'MUST not be static for recursion reasons - PRINT #12, "new_mem_lock();" - PRINT #12, "sf_mem_lock=mem_lock_tmp;" - PRINT #12, "sf_mem_lock->type=3;" - - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL+ 1 ;" - IF subfunc <> "SUB_VWATCH" THEN - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = "(" + thisincname$ + "," + STR$(inclinenumber(inclevel)) + ") " - END IF - - PRINT #12, "qbs_set(__STRING_VWATCH_SUBNAME,qbs_new_txt_len(" + CHR$(34) + inclinenump$ + subfuncoriginalname$ + CHR$(34) + "," + str2$(LEN(inclinenump$ + subfuncoriginalname$)) + "));" - PRINT #12, "qbs_cleanup(qbs_tmp_base,0);" - PRINT #12, "qbs_set(__STRING_VWATCH_INTERNALSUBNAME,qbs_new_txt_len(" + CHR$(34) + subfunc + CHR$(34) + "," + str2$(LEN(subfunc)) + "));" - PRINT #12, "qbs_cleanup(qbs_tmp_base,0);" - PRINT #12, "*__LONG_VWATCH_LINENUMBER=-2; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - END IF - - PRINT #12, "if (new_error) goto exit_subfunc;" - - 'statementn = statementn + 1 - 'if nochecks=0 then PRINT #12, "S_" + str2$(statementn) + ":;" - - dimstatic = staticsf - - declibjmp4: - - IF declaringlibrary THEN - - IF customtypelibrary THEN - - callname$ = removecast$(RTRIM$(id2.callname)) - - PRINT #17, "CUSTOMCALL_" + callname$ + " *" + callname$ + "=NULL;" - - IF subfuncn THEN - f = FREEFILE - OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f - ELSE - f = 13 - END IF - - - PRINT #f, callname$ + "=(CUSTOMCALL_" + callname$ + "*)&" + aliasname$ + ";" - - IF subfuncn THEN CLOSE #f - - 'if no header exists to make the external function available, the function definition must be found - IF sfheader = 0 AND sfdeclare <> 0 THEN - ResolveStaticFunctions = ResolveStaticFunctions + 1 - 'expand array if necessary - IF ResolveStaticFunctions > UBOUND(ResolveStaticFunction_Name) THEN - REDIM _PRESERVE ResolveStaticFunction_Name(1 TO ResolveStaticFunctions + 100) AS STRING - REDIM _PRESERVE ResolveStaticFunction_File(1 TO ResolveStaticFunctions + 100) AS STRING - REDIM _PRESERVE ResolveStaticFunction_Method(1 TO ResolveStaticFunctions + 100) AS LONG - END IF - ResolveStaticFunction_File(ResolveStaticFunctions) = libname$ - ResolveStaticFunction_Name(ResolveStaticFunctions) = aliasname$ - ResolveStaticFunction_Method(ResolveStaticFunctions) = 1 - END IF 'sfheader=0 - - END IF - - IF dynamiclibrary THEN - IF sfdeclare THEN - - PRINT #17, "DLLCALL_" + removecast$(RTRIM$(id2.callname)) + " " + removecast$(RTRIM$(id2.callname)) + "=NULL;" - - IF subfuncn THEN - f = FREEFILE - OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f - ELSE - f = 13 - END IF - - PRINT #f, "if (!" + removecast$(RTRIM$(id2.callname)) + "){" - IF os$ = "WIN" THEN - PRINT #f, removecast$(RTRIM$(id2.callname)) + "=(DLLCALL_" + removecast$(RTRIM$(id2.callname)) + ")GetProcAddress(DLL_" + DLLname$ + "," + CHR$(34) + aliasname$ + CHR$(34) + ");" - PRINT #f, "if (!" + removecast$(RTRIM$(id2.callname)) + ") error(260);" - END IF - IF os$ = "LNX" THEN - PRINT #f, removecast$(RTRIM$(id2.callname)) + "=(DLLCALL_" + removecast$(RTRIM$(id2.callname)) + ")dlsym(DLL_" + DLLname$ + "," + CHR$(34) + aliasname$ + CHR$(34) + ");" - PRINT #f, "if (dlerror()) error(260);" - END IF - PRINT #f, "}" - - IF subfuncn THEN CLOSE #f - - END IF 'sfdeclare - END IF 'dynamic - - IF sfdeclare = 1 AND customtypelibrary = 0 AND dynamiclibrary = 0 AND indirectlibrary = 0 THEN - ResolveStaticFunctions = ResolveStaticFunctions + 1 - 'expand array if necessary - IF ResolveStaticFunctions > UBOUND(ResolveStaticFunction_Name) THEN - REDIM _PRESERVE ResolveStaticFunction_Name(1 TO ResolveStaticFunctions + 100) AS STRING - REDIM _PRESERVE ResolveStaticFunction_File(1 TO ResolveStaticFunctions + 100) AS STRING - REDIM _PRESERVE ResolveStaticFunction_Method(1 TO ResolveStaticFunctions + 100) AS LONG - END IF - ResolveStaticFunction_File(ResolveStaticFunctions) = libname$ - ResolveStaticFunction_Name(ResolveStaticFunctions) = aliasname$ - ResolveStaticFunction_Method(ResolveStaticFunctions) = 2 - END IF - - IF sfdeclare = 0 AND indirectlibrary = 0 THEN - CLOSE #17 - OPEN tmpdir$ + "regsf.txt" FOR APPEND AS #17 - END IF - - END IF 'declaring library - - GOTO finishednonexec - END IF - END IF - - 'END SUB/FUNCTION - IF n = 2 THEN - IF firstelement$ = "END" THEN - sf = 0 - IF secondelement$ = "FUNCTION" THEN sf = 1 - IF secondelement$ = "SUB" THEN sf = 2 - IF sf THEN - - IF LEN(subfunc) = 0 THEN a$ = "END " + secondelement$ + " without " + secondelement$: GOTO errmes - - 'check for open controls (copy #3) - IF controllevel <> 0 AND controltype(controllevel) <> 6 AND controltype(controllevel) <> 32 THEN 'It's OK for subs to be inside $IF blocks - a$ = "Unidentified open control block" - SELECT CASE controltype(controllevel) - CASE 1: a$ = "IF without END IF" - CASE 2: a$ = "FOR without NEXT" - CASE 3, 4: a$ = "DO without LOOP" - CASE 5: a$ = "WHILE without WEND" - CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" - END SELECT - linenumber = controlref(controllevel) - GOTO errmes - END IF - - IF controltype(controllevel) = 32 AND ideindentsubs THEN - controltype(controllevel) = 0 - controllevel = controllevel - 1 - END IF - - IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = SCase$("Sub") ELSE secondelement$ = SCase$("Function") - l$ = SCase$("End") + sp + secondelement$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - - IF vWatchOn = 1 THEN - vWatchVariable "", 1 - END IF - - staticarraylist = "": staticarraylistn = 0 'remove previously listed arrays - dimstatic = 0 - PRINT #12, "exit_subfunc:;" - IF vWatchOn = 1 THEN - IF NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - vWatchAddLabel 0, -1 - END IF - PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" - - IF inclinenumber(inclevel) = 0 AND firstLineNumberLabelvWatch > 0 THEN - PRINT #12, "goto VWATCH_SKIPSETNEXTLINE;" - PRINT #12, "VWATCH_SETNEXTLINE:;" - PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" - FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch - WHILE i > LEN(vWatchUsedLabels) - vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) - vWatchUsedSkipLabels = vWatchUsedSkipLabels + SPACE$(1000) - WEND - IF ASC(vWatchUsedLabels, i) = 1 THEN - PRINT #12, " case " + str2$(i) + ":" - PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" - PRINT #12, " break;" - END IF - NEXT - PRINT #12, " default:" - PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" - PRINT #12, " goto VWATCH_SETNEXTLINE;" - PRINT #12, "}" - - PRINT #12, "VWATCH_SKIPLINE:;" - PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" - FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch - IF ASC(vWatchUsedSkipLabels, i) = 1 THEN - PRINT #12, " case -" + str2$(i) + ":" - PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" - PRINT #12, " break;" - END IF - NEXT - PRINT #12, "}" - - PRINT #12, "VWATCH_SKIPSETNEXTLINE:;" - END IF - firstLineNumberLabelvWatch = 0 - END IF - - 'release _MEM lock for this scope - PRINT #12, "free_mem_lock(sf_mem_lock);" - - PRINT #12, "#include " + CHR$(34) + "free" + str2$(subfuncn) + ".txt" + CHR$(34) - PRINT #12, "if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;" - PRINT #12, "cmem_sp=tmp_cmem_sp;" - IF subfuncret$ <> "" THEN PRINT #12, subfuncret$ - - PRINT #12, "}" 'skeleton sub - 'ret???.txt - PRINT #15, "}" 'end case - PRINT #15, "}" - PRINT #15, "error(3);" 'no valid return possible - subfunc = "" - closedsubfunc = -1 - - 'unshare temp. shared variables - FOR i = 1 TO idn - IF ids(i).share AND 2 THEN ids(i).share = ids(i).share - 2 - NEXT - - FOR i = 1 TO revertmaymusthaven - x = revertmaymusthave(i) - SWAP ids(x).musthave, ids(x).mayhave - NEXT - revertmaymusthaven = 0 - - 'undeclare constants in sub/function's scope - 'constlast = constlastshared - GOTO finishednonexec - - END IF - END IF - END IF - - - - IF n >= 1 AND firstelement$ = "CONST" THEN - l$ = SCase$("Const") - 'DEF... do not change type, the expression is stored in a suitable type - 'based on its value if type isn't forced/specified - IF n < 3 THEN a$ = "Expected CONST name = value/expression": GOTO errmes - i = 2 - - constdefpending: - pending = 0 - - n$ = getelement$(ca$, i): i = i + 1 - l$ = l$ + sp + n$ + sp + "=" - typeoverride = 0 - s$ = removesymbol$(n$) - IF Error_Happened THEN GOTO errmes - IF s$ <> "" THEN - typeoverride = typname2typ(s$) - IF Error_Happened THEN GOTO errmes - IF typeoverride AND ISFIXEDLENGTH THEN a$ = "Invalid constant type": GOTO errmes - IF typeoverride = 0 THEN a$ = "Invalid constant type": GOTO errmes - END IF - - IF getelement$(a$, i) <> "=" THEN a$ = "Expected =": GOTO errmes - i = i + 1 - - 'get expression - e$ = "" - B = 0 - FOR i2 = i TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN - pending = 1 - i = i2 + 1 - IF i > n - 2 THEN a$ = "Expected CONST ... , name = value/expression": GOTO errmes - EXIT FOR - END IF - IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - NEXT - - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - - 'Note: Actual CONST definition handled in prepass - - 'Set CONST as defined - hashname$ = n$ - hashchkflags = HASHFLAG_CONSTANT - hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF constsubfunc(hashresref) = subfuncn THEN constdefined(hashresref) = 1: EXIT DO - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - - IF pending THEN l$ = l$ + sp2 + ",": GOTO constdefpending - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - - GOTO finishednonexec - END IF - - predefine: - IF n >= 2 THEN - asreq = 0 - IF firstelement$ = "DEFINT" THEN l$ = SCase$("DefInt"): a$ = a$ + sp + "AS" + sp + "INTEGER": n = n + 2: GOTO definetype - IF firstelement$ = "DEFLNG" THEN l$ = SCase$("DefLng"): a$ = a$ + sp + "AS" + sp + "LONG": n = n + 2: GOTO definetype - IF firstelement$ = "DEFSNG" THEN l$ = SCase$("DefSng"): a$ = a$ + sp + "AS" + sp + "SINGLE": n = n + 2: GOTO definetype - IF firstelement$ = "DEFDBL" THEN l$ = SCase$("DefDbl"): a$ = a$ + sp + "AS" + sp + "DOUBLE": n = n + 2: GOTO definetype - IF firstelement$ = "DEFSTR" THEN l$ = SCase$("DefStr"): a$ = a$ + sp + "AS" + sp + "STRING": n = n + 2: GOTO definetype - IF firstelement$ = "_DEFINE" OR (firstelement$ = "DEFINE" AND qb64prefix_set = 1) THEN - asreq = 1 - IF firstelement$ = "_DEFINE" THEN l$ = SCase$("_Define") ELSE l$ = SCase$("Define") - definetype: - 'get type from rhs - typ$ = "" - typ2$ = "" - t$ = "" - FOR i = n TO 2 STEP -1 - t$ = getelement$(a$, i) - IF t$ = "AS" THEN EXIT FOR - typ$ = t$ + " " + typ$ - typ2$ = t$ + sp + typ2$ - NEXT - typ$ = RTRIM$(typ$) - IF t$ <> "AS" THEN a$ = qb64prefix$ + "DEFINE: Expected ... AS ...": GOTO errmes - IF i = n OR i = 2 THEN a$ = qb64prefix$ + "DEFINE: Expected ... AS ...": GOTO errmes - - - n = i - 1 - 'the data is from element 2 to element n - i = 2 - 1 - definenext: - 'expects an alphabet letter or underscore - i = i + 1: e$ = getelement$(a$, i): E = ASC(UCASE$(e$)) - IF LEN(e$) > 1 THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes - IF E <> 95 AND (E > 90 OR E < 65) THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes - IF E = 95 THEN E = 27 ELSE E = E - 64 - defineaz(E) = typ$ - defineextaz(E) = type2symbol(typ$) - IF Error_Happened THEN GOTO errmes - firste = E - l$ = l$ + sp + e$ - - IF i = n THEN - IF predefining = 1 THEN GOTO predefined - IF asreq THEN l$ = l$ + sp + SCase$("As") + sp + typ2$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec - END IF - - 'expects "-" or "," - i = i + 1: e$ = getelement$(a$, i) - IF e$ <> "-" AND e$ <> "," THEN a$ = qb64prefix$ + "DEFINE: Expected - or ,": GOTO errmes - IF e$ = "-" THEN - l$ = l$ + sp2 + "-" - IF i = n THEN a$ = qb64prefix$ + "DEFINE: Syntax incomplete": GOTO errmes - 'expects an alphabet letter or underscore - i = i + 1: e$ = getelement$(a$, i): E = ASC(UCASE$(e$)) - IF LEN(e$) > 1 THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes - IF E <> 95 AND (E > 90 OR E < 65) THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes - IF E = 95 THEN E = 27 ELSE E = E - 64 - IF firste > E THEN SWAP E, firste - FOR e2 = firste TO E - defineaz(e2) = typ$ - defineextaz(e2) = type2symbol(typ$) - IF Error_Happened THEN GOTO errmes - NEXT - l$ = l$ + sp2 + e$ - IF i = n THEN - IF predefining = 1 THEN GOTO predefined - IF asreq THEN l$ = l$ + sp + SCase$("As") + sp + typ2$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec - END IF - 'expects "," - i = i + 1: e$ = getelement$(a$, i) - IF e$ <> "," THEN a$ = qb64prefix$ + "DEFINE: Expected ,": GOTO errmes - END IF - l$ = l$ + sp2 + "," - GOTO definenext - END IF '_DEFINE - END IF '2 - IF predefining = 1 THEN GOTO predefined - - IF closedmain <> 0 AND subfunc = "" THEN a$ = "Statement cannot be placed between SUB/FUNCTIONs": GOTO errmes - - 'executable section: - - statementn = statementn + 1 - - - IF n >= 1 THEN - IF firstelement$ = "NEXT" THEN - - l$ = SCase$("Next") - IF n = 1 THEN GOTO simplenext - v$ = "" - FOR i = 2 TO n - a2$ = getelement(ca$, i) - - IF a2$ = "," THEN - - lastnextele: - e$ = fixoperationorder(v$) - IF Error_Happened THEN GOTO errmes - IF LEN(l$) = 4 THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN - getid VAL(e$) - IF Error_Happened THEN GOTO errmes - IF (id.t AND ISPOINTER) THEN - IF (id.t AND ISSTRING) = 0 THEN - IF (id.t AND ISOFFSETINBITS) = 0 THEN - IF (id.t AND ISARRAY) = 0 THEN - GOTO fornextfoundvar2 - END IF - END IF - END IF - END IF - END IF - a$ = "Unsupported variable after NEXT": GOTO errmes - fornextfoundvar2: - simplenext: - IF controltype(controllevel) <> 2 THEN a$ = "NEXT without FOR": GOTO errmes - IF n <> 1 AND controlvalue(controllevel) <> currentid THEN a$ = "Incorrect variable after NEXT": GOTO errmes - PRINT #12, "fornext_continue_" + str2$(controlid(controllevel)) + ":;" - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - PRINT #12, "}" - PRINT #12, "fornext_exit_" + str2$(controlid(controllevel)) + ":;" - controllevel = controllevel - 1 - IF n = 1 THEN EXIT FOR - v$ = "" - - ELSE - - IF LEN(v$) THEN v$ = v$ + sp + a2$ ELSE v$ = a2$ - IF i = n THEN GOTO lastnextele - - END IF - - NEXT - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec '***no error causing code, event checking done by FOR*** - END IF - END IF - - - - IF n >= 1 THEN - IF firstelement$ = "WHILE" THEN - IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - controllevel = controllevel + 1 - controlref(controllevel) = linenumber - controltype(controllevel) = 5 - controlid(controllevel) = uniquenumber - IF n >= 2 THEN - e$ = fixoperationorder(getelements$(ca$, 2, n)) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("While") + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" - IF (typ AND ISSTRING) THEN a$ = "WHILE ERROR! Cannot accept a STRING type.": GOTO errmes - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - PRINT #12, "while((" + e$ + ")||new_error){" - ELSE - a$ = "WHILE ERROR! Expected expression after WHILE.": GOTO errmes - END IF - - GOTO finishedline - END IF - END IF - - IF n = 1 THEN - IF firstelement$ = "WEND" THEN - - - IF controltype(controllevel) <> 5 THEN a$ = "WEND without WHILE": GOTO errmes - PRINT #12, "ww_continue_" + str2$(controlid(controllevel)) + ":;" - PRINT #12, "}" - PRINT #12, "ww_exit_" + str2$(controlid(controllevel)) + ":;" - controllevel = controllevel - 1 - l$ = SCase$("Wend") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec '***no error causing code, event checking done by WHILE*** - END IF - END IF - - - - - - IF n >= 1 THEN - IF firstelement$ = "DO" THEN - IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - controllevel = controllevel + 1 - controlref(controllevel) = linenumber - l$ = SCase$("Do") - IF n >= 2 THEN - whileuntil = 0 - IF secondelement$ = "WHILE" THEN whileuntil = 1: l$ = l$ + sp + SCase$("While") - IF secondelement$ = "UNTIL" THEN whileuntil = 2: l$ = l$ + sp + SCase$("Until") - IF whileuntil = 0 THEN a$ = "DO ERROR! Expected WHILE or UNTIL after DO.": GOTO errmes - IF whileuntil > 0 AND n = 2 THEN a$ = "Condition expected after WHILE/UNTIL": GOTO errmes - e$ = fixoperationorder(getelements$(ca$, 3, n)) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" - IF (typ AND ISSTRING) THEN a$ = "DO ERROR! Cannot accept a STRING type.": GOTO errmes - IF whileuntil = 1 THEN PRINT #12, "while((" + e$ + ")||new_error){" ELSE PRINT #12, "while((!(" + e$ + "))||new_error){" - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - controltype(controllevel) = 4 - ELSE - controltype(controllevel) = 3 - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - ELSE - PRINT #12, "do{" - END IF - END IF - controlid(controllevel) = uniquenumber - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - - IF n >= 1 THEN - IF firstelement$ = "LOOP" THEN - l$ = SCase$("Loop") - IF controltype(controllevel) <> 3 AND controltype(controllevel) <> 4 THEN a$ = "PROGRAM FLOW ERROR!": GOTO errmes - IF n >= 2 THEN - IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - IF controltype(controllevel) = 4 THEN a$ = "PROGRAM FLOW ERROR!": GOTO errmes - whileuntil = 0 - IF secondelement$ = "WHILE" THEN whileuntil = 1: l$ = l$ + sp + SCase$("While") - IF secondelement$ = "UNTIL" THEN whileuntil = 2: l$ = l$ + sp + SCase$("Until") - IF whileuntil = 0 THEN a$ = "LOOP ERROR! Expected WHILE or UNTIL after LOOP.": GOTO errmes - IF whileuntil > 0 AND n = 2 THEN a$ = "Condition expected after WHILE/UNTIL": GOTO errmes - e$ = fixoperationorder(getelements$(ca$, 3, n)) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" - IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes - PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - IF whileuntil = 1 THEN PRINT #12, "}while((" + e$ + ")&&(!new_error));" ELSE PRINT #12, "}while((!(" + e$ + "))&&(!new_error));" - ELSE - PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" - - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - - IF controltype(controllevel) = 4 THEN - PRINT #12, "}" - ELSE - PRINT #12, "}while(1);" 'infinite loop! - END IF - END IF - PRINT #12, "dl_exit_" + str2$(controlid(controllevel)) + ":;" - controllevel = controllevel - 1 - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - IF n = 1 THEN GOTO finishednonexec '***no error causing code, event checking done by DO*** - GOTO finishedline - END IF - END IF - - - - - - - - - - IF n >= 1 THEN - IF firstelement$ = "FOR" THEN - IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - - l$ = SCase$("For") - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - controllevel = controllevel + 1 - controlref(controllevel) = linenumber - controltype(controllevel) = 2 - controlid(controllevel) = uniquenumber - - v$ = "" - startvalue$ = "" - p3$ = "1": stepused = 0 - p2$ = "" - mode = 0 - E = 0 - FOR i = 2 TO n - e$ = getelement$(a$, i) - IF e$ = "=" THEN - IF mode <> 0 THEN E = 1: EXIT FOR - mode = 1 - v$ = getelements$(ca$, 2, i - 1) - equpos = i - END IF - IF e$ = "TO" THEN - IF mode <> 1 THEN E = 1: EXIT FOR - mode = 2 - startvalue$ = getelements$(ca$, equpos + 1, i - 1) - topos = i - END IF - IF e$ = "STEP" THEN - IF mode <> 2 THEN E = 1: EXIT FOR - mode = 3 - stepused = 1 - p2$ = getelements$(ca$, topos + 1, i - 1) - p3$ = getelements$(ca$, i + 1, n) - EXIT FOR - END IF - NEXT - IF mode < 2 THEN E = 1 - IF p2$ = "" THEN p2$ = getelements$(ca$, topos + 1, n) - IF LEN(v$) = 0 OR LEN(startvalue$) = 0 OR LEN(p2$) = 0 THEN E = 1 - IF E <> 0 AND mode < 3 THEN a$ = "Expected FOR name = start TO end": GOTO errmes - IF E THEN a$ = "Expected FOR name = start TO end STEP increment": GOTO errmes - - e$ = fixoperationorder(v$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN - getid VAL(e$) - IF Error_Happened THEN GOTO errmes - IF (id.t AND ISPOINTER) THEN - IF (id.t AND ISSTRING) = 0 THEN - IF (id.t AND ISOFFSETINBITS) = 0 THEN - IF (id.t AND ISARRAY) = 0 THEN - GOTO fornextfoundvar - END IF - END IF - END IF - END IF - END IF - a$ = "Unsupported variable used in FOR statement": GOTO errmes - fornextfoundvar: - controlvalue(controllevel) = currentid - v$ = e$ - - 'find C++ datatype to match variable - 'markup to cater for greater range/accuracy - ctype$ = "" - ctyp = typ - ISPOINTER - bits = typ AND 511 - IF (typ AND ISFLOAT) THEN - IF bits = 32 THEN ctype$ = "double": ctyp = 64& + ISFLOAT - IF bits = 64 THEN ctype$ = "long double": ctyp = 256& + ISFLOAT - IF bits = 256 THEN ctype$ = "long double": ctyp = 256& + ISFLOAT - ELSE - IF bits = 8 THEN ctype$ = "int16": ctyp = 16& - IF bits = 16 THEN ctype$ = "int32": ctyp = 32& - IF bits = 32 THEN ctype$ = "int64": ctyp = 64& - IF bits = 64 THEN ctype$ = "int64": ctyp = 64& - END IF - IF ctype$ = "" THEN a$ = "Unsupported variable used in FOR statement": GOTO errmes - u$ = str2(uniquenumber) - - IF subfunc = "" THEN - PRINT #13, "static " + ctype$ + " fornext_value" + u$ + ";" - PRINT #13, "static " + ctype$ + " fornext_finalvalue" + u$ + ";" - PRINT #13, "static " + ctype$ + " fornext_step" + u$ + ";" - PRINT #13, "static uint8 fornext_step_negative" + u$ + ";" - ELSE - PRINT #13, ctype$ + " fornext_value" + u$ + ";" - PRINT #13, ctype$ + " fornext_finalvalue" + u$ + ";" - PRINT #13, ctype$ + " fornext_step" + u$ + ";" - PRINT #13, "uint8 fornext_step_negative" + u$ + ";" - END IF - - 'calculate start - e$ = fixoperationorder$(startvalue$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + "=" + sp + tlayout$ - e$ = evaluatetotyp$(e$, ctyp) - IF Error_Happened THEN GOTO errmes - PRINT #12, "fornext_value" + u$ + "=" + e$ + ";" - - 'final - e$ = fixoperationorder$(p2$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + SCase$("To") + sp + tlayout$ - e$ = evaluatetotyp(e$, ctyp) - IF Error_Happened THEN GOTO errmes - PRINT #12, "fornext_finalvalue" + u$ + "=" + e$ + ";" - - 'step - e$ = fixoperationorder$(p3$) - IF Error_Happened THEN GOTO errmes - IF stepused = 1 THEN l$ = l$ + sp + SCase$("Step") + sp + tlayout$ - e$ = evaluatetotyp(e$, ctyp) - IF Error_Happened THEN GOTO errmes - - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - - PRINT #12, "fornext_step" + u$ + "=" + e$ + ";" - PRINT #12, "if (fornext_step" + u$ + "<0) fornext_step_negative" + u$ + "=1; else fornext_step_negative" + u$ + "=0;" - - PRINT #12, "if (new_error) goto fornext_error" + u$ + ";" - PRINT #12, "goto fornext_entrylabel" + u$ + ";" - PRINT #12, "while(1){" - typbak = typ - PRINT #12, "fornext_value" + u$ + "=fornext_step" + u$ + "+(" + refer$(v$, typ, 0) + ");" - IF Error_Happened THEN GOTO errmes - typ = typbak - PRINT #12, "fornext_entrylabel" + u$ + ":" - setrefer v$, typ, "fornext_value" + u$, 1 - IF Error_Happened THEN GOTO errmes - PRINT #12, "if (fornext_step_negative" + u$ + "){" - PRINT #12, "if (fornext_value" + u$ + "fornext_finalvalue" + u$ + ") break;" - PRINT #12, "}" - PRINT #12, "fornext_error" + u$ + ":;" - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - - GOTO finishedline - END IF - END IF - - - IF n = 1 THEN - IF firstelement$ = "ELSE" THEN - - 'Routine to add error checking for ELSE so we'll no longer be able to do things like the following: - 'IF x = 1 THEN - ' SELECT CASE s - ' CASE 1 - ' END SELECT ELSE y = 2 - 'END IF - 'Notice the ELSE with the SELECT CASE? Before this patch, commands like those were considered valid QB64 code. - temp$ = UCASE$(LTRIM$(RTRIM$(wholeline))) - 'IF NoIDEMode THEN - DO WHILE INSTR(temp$, CHR$(9)) - ASC(temp$, INSTR(temp$, CHR$(9))) = 32 - LOOP - 'END IF - goodelse = 0 'a check to see if it's a good else - IF LEFT$(temp$, 2) = "IF" THEN goodelse = -1: GOTO skipelsecheck 'If we have an IF, the else is probably good - IF LEFT$(temp$, 4) = "ELSE" THEN goodelse = -1: GOTO skipelsecheck 'If it's an else by itself,then we'll call it good too at this point and let the rest of the syntax checking check for us - DO - spacelocation = INSTR(temp$, " ") - IF spacelocation THEN temp$ = LEFT$(temp$, spacelocation - 1) + MID$(temp$, spacelocation + 1) - LOOP UNTIL spacelocation = 0 - IF INSTR(temp$, ":ELSE") OR INSTR(temp$, ":IF") THEN goodelse = -1: GOTO skipelsecheck 'I personally don't like the idea of a :ELSE statement, but this checks for that and validates it as well. YUCK! (I suppose this might be useful if there's a label where the ELSE is, like thisline: ELSE - count = 0 - DO - count = count + 1 - SELECT CASE MID$(temp$, count, 1) - CASE IS = "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ":" - CASE ELSE: EXIT DO - END SELECT - LOOP UNTIL count >= LEN(temp$) - IF MID$(temp$, count, 4) = "ELSE" OR MID$(temp$, count, 2) = "IF" THEN goodelse = -1 'We only had numbers before our else - IF NOT goodelse THEN a$ = "Invalid Syntax for ELSE": GOTO errmes - skipelsecheck: - 'End of ELSE Error checking - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 1 THEN - IF controlstate(controllevel) = 2 THEN a$ = "IF-THEN already contains an ELSE statement": GOTO errmes - PRINT #12, "}else{" - controlstate(controllevel) = 2 - IF lineelseused = 0 THEN lhscontrollevel = lhscontrollevel - 1 - l$ = SCase$("Else") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec '***no error causing code, event checking done by IF*** - END IF - NEXT - a$ = "ELSE without IF": GOTO errmes - END IF - END IF - - IF n >= 3 THEN - IF firstelement$ = "ELSEIF" THEN - IF NoChecks = 0 THEN - PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - END IF - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 1 THEN - IF controlstate(controllevel) = 2 THEN a$ = "ELSEIF invalid after ELSE": GOTO errmes - controlstate(controllevel) = 1 - controlvalue(controllevel) = controlvalue(controllevel) + 1 - e$ = getelement$(a$, n) - IF e$ <> "THEN" THEN a$ = "Expected ELSEIF expression THEN": GOTO errmes - PRINT #12, "}else{" - e$ = fixoperationorder$(getelements$(ca$, 2, n - 1)) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("ElseIf") + sp + tlayout$ + sp + SCase$("Then") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF typ AND ISSTRING THEN - a$ = "Expected ELSEIF LEN(stringexpression) THEN": GOTO errmes - END IF - IF stringprocessinghappened THEN - PRINT #12, "if (" + cleanupstringprocessingcall$ + e$ + ")){" - ELSE - PRINT #12, "if (" + e$ + "){" - END IF - lhscontrollevel = lhscontrollevel - 1 - GOTO finishedline - END IF - NEXT - a$ = "ELSEIF without IF": GOTO errmes - END IF - END IF - - IF n >= 3 THEN - IF firstelement$ = "IF" THEN - IF NoChecks = 0 THEN - PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - END IF - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - e$ = getelement(a$, n) - iftype = 0 - IF e$ = "THEN" THEN iftype = 1 - IF e$ = "GOTO" THEN iftype = 2 - IF iftype = 0 THEN a$ = "Expected IF expression THEN/GOTO": GOTO errmes - - controllevel = controllevel + 1 - controlref(controllevel) = linenumber - controltype(controllevel) = 1 - controlvalue(controllevel) = 0 'number of extra closing } required at END IF - controlstate(controllevel) = 0 - - e$ = fixoperationorder$(getelements(ca$, 2, n - 1)) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("If") + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - - IF typ AND ISSTRING THEN - a$ = "Expected IF LEN(stringexpression) THEN": GOTO errmes - END IF - - IF stringprocessinghappened THEN - PRINT #12, "if ((" + cleanupstringprocessingcall$ + e$ + "))||new_error){" - ELSE - PRINT #12, "if ((" + e$ + ")||new_error){" - END IF - - IF iftype = 1 THEN l$ = l$ + sp + SCase$("Then") 'note: 'GOTO' will be added when iftype=2 - layoutdone = 1: IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - - IF iftype = 2 THEN 'IF ... GOTO - GOTO finishedline - END IF - - THENGOTO = 1 'possible: IF a=1 THEN 10 - GOTO finishedline2 - END IF - END IF - - 'ENDIF - IF n = 1 AND getelement(a$, 1) = "ENDIF" THEN - IF controltype(controllevel) <> 1 THEN a$ = "END IF without IF": GOTO errmes - layoutdone = 1 - IF impliedendif = 0 THEN - l$ = SCase$("End If") - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - END IF - - PRINT #12, "}" - FOR i = 1 TO controlvalue(controllevel) - PRINT #12, "}" - NEXT - controllevel = controllevel - 1 - GOTO finishednonexec '***no error causing code, event checking done by IF*** - END IF - - - 'END IF - IF n = 2 THEN - IF getelement(a$, 1) = "END" AND getelement(a$, 2) = "IF" THEN - - - IF controltype(controllevel) <> 1 THEN a$ = "END IF without IF": GOTO errmes - layoutdone = 1 - IF impliedendif = 0 THEN - l$ = SCase$("End" + sp + "If") - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - END IF - - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - - PRINT #12, "}" - FOR i = 1 TO controlvalue(controllevel) - PRINT #12, "}" - NEXT - controllevel = controllevel - 1 - GOTO finishednonexec '***no error causing code, event checking done by IF*** - END IF - END IF - - - - 'SELECT CASE - IF n >= 1 THEN - IF firstelement$ = "SELECT" THEN - IF NoChecks = 0 THEN - PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - END IF - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - SelectCaseCounter = SelectCaseCounter + 1 - IF UBOUND(EveryCaseSet) <= SelectCaseCounter THEN REDIM _PRESERVE EveryCaseSet(SelectCaseCounter) - IF UBOUND(SelectCaseHasCaseBlock) <= SelectCaseCounter THEN REDIM _PRESERVE SelectCaseHasCaseBlock(SelectCaseCounter) - SelectCaseHasCaseBlock(SelectCaseCounter) = 0 - IF secondelement$ = "EVERYCASE" THEN - EveryCaseSet(SelectCaseCounter) = -1 - IF n = 2 THEN a$ = "Expected SELECT CASE expression": GOTO errmes - e$ = fixoperationorder(getelements$(ca$, 3, n)) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Select EveryCase ") + tlayout$ - ELSE - EveryCaseSet(SelectCaseCounter) = 0 - IF n = 1 OR secondelement$ <> "CASE" THEN a$ = "Expected CASE or EVERYCASE": GOTO errmes - IF n = 2 THEN a$ = "Expected SELECT CASE expression": GOTO errmes - e$ = fixoperationorder(getelements$(ca$, 3, n)) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Select Case ") + tlayout$ - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - u = uniquenumber - - controllevel = controllevel + 1 - controlvalue(controllevel) = 0 'id - - t$ = "" - IF (typ AND ISSTRING) THEN - t = 0 - IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN - controlvalue(controllevel) = VAL(e$) - ELSE - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - PRINT #13, "static qbs *sc_" + str2$(u) + "=qbs_new(0,0);" - PRINT #12, "qbs_set(sc_" + str2$(u) + "," + e$ + ");" - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - END IF - - ELSE - - IF (typ AND ISFLOAT) THEN - - IF (typ AND 511) > 64 THEN t = 3: t$ = "long double" - IF (typ AND 511) = 32 THEN t = 4: t$ = "float" - IF (typ AND 511) = 64 THEN t = 5: t$ = "double" - IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN - controlvalue(controllevel) = VAL(e$) - ELSE - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - - PRINT #13, "static " + t$ + " sc_" + str2$(u) + ";" - PRINT #12, "sc_" + str2$(u) + "=" + e$ + ";" - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - END IF - - ELSE - - 'non-float - t = 1: t$ = "int64" - IF (typ AND ISUNSIGNED) THEN - IF (typ AND 511) <= 32 THEN t = 7: t$ = "uint32" - IF (typ AND 511) > 32 THEN t = 2: t$ = "uint64" - ELSE - IF (typ AND 511) <= 32 THEN t = 6: t$ = "int32" - IF (typ AND 511) > 32 THEN t = 1: t$ = "int64" - END IF - IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN - controlvalue(controllevel) = VAL(e$) - ELSE - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - PRINT #13, "static " + t$ + " sc_" + str2$(u) + ";" - PRINT #12, "sc_" + str2$(u) + "=" + e$ + ";" - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - END IF - - END IF - END IF - - - - controlref(controllevel) = linenumber - controltype(controllevel) = 10 + t - controlid(controllevel) = u - IF EveryCaseSet(SelectCaseCounter) THEN PRINT #13, "int32 sc_" + str2$(controlid(controllevel)) + "_var;" - IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_var=0;" - GOTO finishedline - END IF - END IF - - - 'END SELECT - IF n = 2 THEN - IF firstelement$ = "END" AND secondelement$ = "SELECT" THEN - 'complete current case if necessary - '18=CASE (awaiting END SELECT/CASE/CASE ELSE) - '19=CASE ELSE (awaiting END SELECT) - IF controltype(controllevel) = 18 THEN - everycasenewcase = everycasenewcase + 1 - PRINT #12, "sc_ec_" + str2$(everycasenewcase) + "_end:;" - controllevel = controllevel - 1 - IF EveryCaseSet(SelectCaseCounter) = 0 THEN PRINT #12, "goto sc_" + str2$(controlid(controllevel)) + "_end;" - PRINT #12, "}" - END IF - IF controltype(controllevel) = 19 THEN - controllevel = controllevel - 1 - IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "} /* End of SELECT EVERYCASE ELSE */" - END IF - - PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_end:;" - IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes - - IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - - IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - 'warn user of empty SELECT CASE block - IF NOT IgnoreWarnings THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "empty SELECT CASE block", "" - END IF - END IF - - controllevel = controllevel - 1 - SelectCaseCounter = SelectCaseCounter - 1 - l$ = SCase$("End" + sp + "Select") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec '***no error causing code, event checking done by SELECT CASE*** - END IF - END IF - - 'prevents code from being placed before 'CASE condition' in a SELECT CASE block - IF n >= 1 AND firstelement$ <> "CASE" AND SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN - a$ = "Expected CASE expression": GOTO errmes - END IF - - - 'CASE - IF n >= 1 THEN - IF firstelement$ = "CASE" THEN - - l$ = SCase$("Case") - 'complete current case if necessary - '18=CASE (awaiting END SELECT/CASE/CASE ELSE) - '19=CASE ELSE (awaiting END SELECT) - IF controltype(controllevel) = 19 THEN a$ = "Expected END SELECT": GOTO errmes - IF controltype(controllevel) = 18 THEN - lhscontrollevel = lhscontrollevel - 1 - controllevel = controllevel - 1 - everycasenewcase = everycasenewcase + 1 - PRINT #12, "sc_ec_" + str2$(everycasenewcase) + "_end:;" - IF EveryCaseSet(SelectCaseCounter) = 0 THEN - PRINT #12, "goto sc_" + str2$(controlid(controllevel)) + "_end;" - ELSE - PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_var=-1;" - END IF - PRINT #12, "}" - 'following line fixes problem related to RESUME after error - 'statementn = statementn + 1 - 'if nochecks=0 then PRINT #12, "S_" + str2$(statementn) + ":;" - END IF - - IF controltype(controllevel) <> 6 AND (controltype(controllevel) < 10 OR controltype(controllevel) > 17) THEN a$ = "CASE without SELECT CASE": GOTO errmes - IF n = 1 THEN a$ = "Expected CASE expression": GOTO errmes - SelectCaseHasCaseBlock(SelectCaseCounter) = -1 - - - 'upgrade: - '#1: variables can be referred to directly by storing an id in 'controlref' - ' (but not if part of an array etc.) - 'DIM controlvalue(1000) AS LONG - '#2: more types will be available - ' +SINGLE - ' +DOUBLE - ' -LONG DOUBLE - ' +INT32 - ' +UINT32 - '14=SELECT CASE float ... - '15=SELECT CASE double - '16=SELECT CASE int32 - '17=SELECT CASE uint32 - - '10=SELECT CASE qbs (awaiting END SELECT/CASE) - '11=SELECT CASE int64 (awaiting END SELECT/CASE) - '12=SELECT CASE uint64 (awaiting END SELECT/CASE) - '13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) - '14=SELECT CASE float ... - '15=SELECT CASE double - '16=SELECT CASE int32 - '17=SELECT CASE uint32 - - ' bits = targettyp AND 511 - ' IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" - ' IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" - ' IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" - - - t = controltype(controllevel) - 10 - 'get required type cast, and float options - flt = 0 - IF t = 0 THEN tc$ = "" - IF t = 1 THEN tc$ = "" - IF t = 2 THEN tc$ = "" - IF t = 3 THEN tc$ = "": flt = 1 - IF t = 4 THEN tc$ = "(float)": flt = 1 - IF t = 5 THEN tc$ = "(double)": flt = 1 - IF t = 6 THEN tc$ = "" - IF t = 7 THEN tc$ = "" - - n$ = "sc_" + str2$(controlid(controllevel)) - cv = controlvalue(controllevel) - IF cv THEN - n$ = refer$(str2$(cv), 0, 0) - IF Error_Happened THEN GOTO errmes - END IF - - 'CASE ELSE - IF n = 2 THEN - IF getelement$(a$, 2) = "C-EL" THEN - IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "if (sc_" + str2$(controlid(controllevel)) + "_var==0) {" - controllevel = controllevel + 1: controltype(controllevel) = 19 - controlref(controllevel) = controlref(controllevel - 1) - l$ = l$ + sp + SCase$("Else") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishednonexec '***no error causing code, event checking done by SELECT CASE*** - END IF - END IF - - IF NoChecks = 0 THEN - PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - END IF - END IF - - - - f12$ = "" - - nexp = 0 - B = 0 - e$ = "" - FOR i = 2 TO n - e2$ = getelement$(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF i = n THEN e$ = e$ + sp + e2$ - IF i = n OR (e2$ = "," AND B = 0) THEN - IF nexp <> 0 THEN l$ = l$ + sp2 + ",": f12$ = f12$ + "||" - IF e$ = "" THEN a$ = "Expected expression": GOTO errmes - e$ = RIGHT$(e$, LEN(e$) - 1) - - - - 'TYPE 1? ... TO ... - n2 = numelements(e$) - b2 = 0 - el$ = "": er$ = "" - usedto = 0 - FOR i2 = 1 TO n2 - e3$ = getelement$(e$, i2) - IF e3$ = "(" THEN b2 = b2 + 1 - IF e3$ = ")" THEN b2 = b2 - 1 - IF b2 = 0 AND UCASE$(e3$) = "TO" THEN - usedto = 1 - ELSE - IF usedto = 0 THEN el$ = el$ + sp + e3$ ELSE er$ = er$ + sp + e3$ - END IF - NEXT - IF usedto = 1 THEN - IF el$ = "" OR er$ = "" THEN a$ = "Expected expression TO expression": GOTO errmes - el$ = RIGHT$(el$, LEN(el$) - 1): er$ = RIGHT$(er$, LEN(er$) - 1) - 'evaluate each side - FOR i2 = 1 TO 2 - IF i2 = 1 THEN e$ = el$ ELSE e$ = er$ - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - IF i2 = 1 THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + SCase$("To") + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF t = 0 THEN - IF (typ AND ISSTRING) = 0 THEN a$ = "Expected string expression": GOTO errmes - IF i2 = 1 THEN f12$ = f12$ + "(qbs_greaterorequal(" + n$ + "," + e$ + ")&&qbs_lessorequal(" + n$ + "," - IF i2 = 2 THEN f12$ = f12$ + e$ + "))" - ELSE - IF (typ AND ISSTRING) THEN a$ = "Expected numeric expression": GOTO errmes - 'round to integer? - IF (typ AND ISFLOAT) THEN - IF t = 1 THEN e$ = "qbr(" + e$ + ")" - IF t = 2 THEN e$ = "qbr_longdouble_to_uint64(" + e$ + ")" - IF t = 6 OR t = 7 THEN e$ = "qbr_double_to_long(" + e$ + ")" - END IF - 'cast result? - IF LEN(tc$) THEN e$ = tc$ + "(" + e$ + ")" - IF i2 = 1 THEN f12$ = f12$ + "((" + n$ + ">=(" + e$ + "))&&(" + n$ + "<=(" - IF i2 = 2 THEN f12$ = f12$ + e$ + ")))" - END IF - NEXT - GOTO addedexp - END IF - - '10=SELECT CASE qbs (awaiting END SELECT/CASE) - '11=SELECT CASE int64 (awaiting END SELECT/CASE) - '12=SELECT CASE uint64 (awaiting END SELECT/CASE) - '13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) - '14=SELECT CASE float ... - '15=SELECT CASE double - '16=SELECT CASE int32 - '17=SELECT CASE uint32 - - ' bits = targettyp AND 511 - ' IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" - ' IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" - ' IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" - - - - - - - o$ = "==" 'used by type 3 - - 'TYPE 2? - x$ = getelement$(e$, 1) - IF isoperator(x$) THEN 'non-standard usage correction - IF x$ = "=" OR x$ = "<>" OR x$ = ">" OR x$ = "<" OR x$ = ">=" OR x$ = "<=" THEN - e$ = "IS" + sp + e$ - x$ = "IS" - END IF - END IF - IF UCASE$(x$) = "IS" THEN - n2 = numelements(e$) - IF n2 < 3 THEN a$ = "Expected IS =,<>,>,<,>=,<= expression": GOTO errmes - o$ = getelement$(e$, 2) - o2$ = o$ - o = 0 - IF o$ = "=" THEN o$ = "==": o = 1 - IF o$ = "<>" THEN o$ = "!=": o = 1 - IF o$ = ">" THEN o = 1 - IF o$ = "<" THEN o = 1 - IF o$ = ">=" THEN o = 1 - IF o$ = "<=" THEN o = 1 - IF o <> 1 THEN a$ = "Expected IS =,<>,>,<,>=,<= expression": GOTO errmes - l$ = l$ + sp + SCase$("Is") + sp + o2$ - e$ = getelements$(e$, 3, n2) - 'fall through to type 3 using modified e$ & o$ - END IF - - 'TYPE 3? simple expression - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - IF t = 0 THEN - 'string comparison - IF (typ AND ISSTRING) = 0 THEN a$ = "Expected string expression": GOTO errmes - IF o$ = "==" THEN o$ = "qbs_equal" - IF o$ = "!=" THEN o$ = "qbs_notequal" - IF o$ = ">" THEN o$ = "qbs_greaterthan" - IF o$ = "<" THEN o$ = "qbs_lessthan" - IF o$ = ">=" THEN o$ = "qbs_greaterorequal" - IF o$ = "<=" THEN o$ = "qbs_lessorequal" - f12$ = f12$ + o$ + "(" + n$ + "," + e$ + ")" - ELSE - 'numeric - IF (typ AND ISSTRING) THEN a$ = "Expected numeric expression": GOTO errmes - 'round to integer? - IF (typ AND ISFLOAT) THEN - IF t = 1 THEN e$ = "qbr(" + e$ + ")" - IF t = 2 THEN e$ = "qbr_longdouble_to_uint64(" + e$ + ")" - IF t = 6 OR t = 7 THEN e$ = "qbr_double_to_long(" + e$ + ")" - END IF - 'cast result? - IF LEN(tc$) THEN e$ = tc$ + "(" + e$ + ")" - f12$ = f12$ + "(" + n$ + o$ + "(" + e$ + "))" - END IF - - addedexp: - e$ = "" - nexp = nexp + 1 - ELSE - e$ = e$ + sp + e2$ - END IF - NEXT - - IF stringprocessinghappened THEN - PRINT #12, "if ((" + cleanupstringprocessingcall$ + f12$ + "))||new_error){" - ELSE - PRINT #12, "if ((" + f12$ + ")||new_error){" - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - controllevel = controllevel + 1 - controlref(controllevel) = controlref(controllevel - 1) - controltype(controllevel) = 18 - GOTO finishedline - END IF - END IF - - - - - - - - - - - - - 'static scope commands: - - IF NoChecks = 0 THEN - IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - ELSE - PRINT #12, "do{" - END IF - 'PRINT #12, "S_" + str2$(statementn) + ":;" - END IF - - - IF n > 1 THEN - IF firstelement$ = "PALETTE" THEN - IF secondelement$ = "USING" THEN - l$ = SCase$("Palette" + sp + "Using" + sp) - IF n < 3 THEN a$ = "Expected PALETTE USING array-name": GOTO errmes - 'check array - e$ = getelement$(ca$, 3) - IF FindArray(e$) THEN - IF Error_Happened THEN GOTO errmes - z = 1 - t = id.arraytype - IF (t AND 511) <> 16 AND (t AND 511) <> 32 THEN z = 0 - IF t AND ISFLOAT THEN z = 0 - IF t AND ISOFFSETINBITS THEN z = 0 - IF t AND ISSTRING THEN z = 0 - IF t AND ISUDT THEN z = 0 - IF t AND ISUNSIGNED THEN z = 0 - IF z = 0 THEN a$ = "Array must be of type INTEGER or LONG": GOTO errmes - bits = t AND 511 - GOTO pu_gotarray - END IF - IF Error_Happened THEN GOTO errmes - a$ = "Expected PALETTE USING array-name": GOTO errmes - pu_gotarray: - 'add () if index not specified - IF n = 3 THEN - e$ = e$ + sp + "(" + sp + ")" - ELSE - IF n = 4 OR getelement$(a$, 4) <> "(" OR getelement$(a$, n) <> ")" THEN a$ = "Expected PALETTE USING array-name(...)": GOTO errmes - e$ = e$ + sp + getelements$(ca$, 4, n) - END IF - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - e$ = evaluatetotyp(e$, -2) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_paletteusing(" + e$ + "," + str2(bits) + ");" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF 'using - END IF 'palette - END IF 'n>1 - - - IF firstelement$ = "KEY" THEN - IF n = 1 THEN a$ = "Expected KEY ...": GOTO errmes - l$ = SCase$("KEY") + sp - IF secondelement$ = "OFF" THEN - IF n > 2 THEN a$ = "Expected KEY OFF only": GOTO errmes - l$ = l$ + SCase$("Off"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - PRINT #12, "key_off();" - GOTO finishedline - END IF - IF secondelement$ = "ON" THEN - IF n > 2 THEN a$ = "Expected KEY ON only": GOTO errmes - l$ = l$ + SCase$("On"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - PRINT #12, "key_on();" - GOTO finishedline - END IF - IF secondelement$ = "LIST" THEN - IF n > 2 THEN a$ = "Expected KEY LIST only": GOTO errmes - l$ = l$ + SCase$("List"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - PRINT #12, "key_list();" - GOTO finishedline - END IF - 'search for comma to indicate assignment - B = 0: e$ = "" - FOR i = 2 TO n - e2$ = getelement(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN - i = i + 1: GOTO key_assignment - END IF - IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ - NEXT - 'assume KEY(x) ON/OFF/STOP and handle as a sub - GOTO key_fallthrough - key_assignment: - 'KEY x, "string" - 'index - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + "," + sp - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "key_assign(" + e$ + ","; - 'string - e$ = getelements$(ca$, i, n) - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - e$ = evaluatetotyp(e$, ISSTRING) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ");" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF 'KEY - key_fallthrough: - - - - - IF firstelement$ = "FIELD" THEN - - 'get filenumber - B = 0: e$ = "" - FOR i = 2 TO n - e2$ = getelement(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN - i = i + 1: GOTO fieldgotfn - END IF - IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ - NEXT - GOTO fielderror - fieldgotfn: - IF e$ = "#" OR LEN(e$) = 0 THEN GOTO fielderror - IF LEFT$(e$, 2) = "#" + sp THEN e$ = RIGHT$(e$, LEN(e$) - 2): l$ = SCase$("Field") + sp + "#" + sp2 ELSE l$ = SCase$("Field") + sp - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + "," + sp - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "field_new(" + e$ + ");" - - fieldnext: - - 'get fieldwidth - IF i > n THEN GOTO fielderror - B = 0: e$ = "" - FOR i = i TO n - e2$ = getelement(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF UCASE$(e2$) = "AS" AND B = 0 THEN - i = i + 1: GOTO fieldgotfw - END IF - IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ - NEXT - GOTO fielderror - fieldgotfw: - IF LEN(e$) = 0 THEN GOTO fielderror - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp + SCase$("As") + sp - sizee$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - - 'get variable name - IF i > n THEN GOTO fielderror - B = 0: e$ = "" - FOR i = i TO n - e2$ = getelement(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF (i = n OR e2$ = ",") AND B = 0 THEN - IF e2$ = "," THEN i = i - 1 - IF i = n THEN - IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ - END IF - GOTO fieldgotfname - END IF - IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ - NEXT - GOTO fielderror - fieldgotfname: - IF LEN(e$) = 0 THEN GOTO fielderror - 'evaluate it to check it is a STRING - e$ = fixoperationorder(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF (typ AND ISSTRING) = 0 THEN GOTO fielderror - IF typ AND ISFIXEDLENGTH THEN a$ = "Fixed length strings cannot be used in a FIELD statement": GOTO errmes - IF (typ AND ISREFERENCE) = 0 THEN GOTO fielderror - e$ = refer(e$, typ, 0) - IF Error_Happened THEN GOTO errmes - PRINT #12, "field_add(" + e$ + "," + sizee$ + ");" - - IF i < n THEN - i = i + 1 - e$ = getelement(a$, i) - IF e$ <> "," THEN a$ = "Expected ,": GOTO errmes - l$ = l$ + sp2 + "," + sp - i = i + 1 - GOTO fieldnext - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - - fielderror: a$ = "Expected FIELD #filenumber, characters AS variable$, ...": GOTO errmes - END IF - - - - - - '1=IF (awaiting END IF) - '2=FOR (awaiting NEXT) - '3=DO (awaiting LOOP [UNTIL|WHILE param]) - '4=DO WHILE/UNTIL (awaiting LOOP) - '5=WHILE (awaiting WEND) - - IF n = 2 THEN - IF firstelement$ = "EXIT" THEN - - l$ = SCase$("Exit") + sp - - IF secondelement$ = "DO" THEN - 'scan backwards until previous control level reached - l$ = l$ + SCase$("Do") - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 3 OR t = 4 THEN - PRINT #12, "goto dl_exit_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = "EXIT DO without DO": GOTO errmes - END IF - - IF secondelement$ = "FOR" THEN - 'scan backwards until previous control level reached - l$ = l$ + SCase$("For") - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 2 THEN - PRINT #12, "goto fornext_exit_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = "EXIT FOR without FOR": GOTO errmes - END IF - - IF secondelement$ = "WHILE" THEN - 'scan backwards until previous control level reached - l$ = l$ + SCase$("While") - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 5 THEN - PRINT #12, "goto ww_exit_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = "EXIT WHILE without WHILE": GOTO errmes - END IF - - IF secondelement$ = "SELECT" THEN - 'scan backwards until previous control level reached - l$ = l$ + SCase$("Select") - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 18 OR t = 19 THEN 'CASE/CASE ELSE - PRINT #12, "goto sc_" + str2$(controlid(i - 1)) + "_end;" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = "EXIT SELECT without SELECT": GOTO errmes - END IF - - IF secondelement$ = "CASE" THEN - 'scan backwards until previous control level reached - l$ = l$ + SCase$("Case") - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 18 THEN 'CASE - PRINT #12, "goto sc_ec_" + str2$(everycasenewcase + 1) + "_end;" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - ELSEIF t = 19 THEN 'CASE ELSE - PRINT #12, "goto sc_" + str2$(controlid(i - 1)) + "_end;" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = "EXIT CASE without CASE": GOTO errmes - END IF - - END IF - END IF - - - - - - - - - IF n >= 2 THEN - IF firstelement$ = "ON" AND secondelement$ = "STRIG" THEN - DEPENDENCY(DEPENDENCY_DEVICEINPUT) = 1 - i = 3 - IF i > n THEN a$ = "Expected (": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes - l$ = SCase$("On" + sp + "Strig" + sp2 + "(") - IF i > n THEN a$ = "Expected ...": GOTO errmes - B = 0 - x = 0 - e2$ = "" - e3$ = "" - FOR i = i TO n - e$ = getelement$(ca$, i) - a = ASC(e$) - IF a = 40 THEN B = B + 1 - IF a = 41 THEN B = B - 1 - IF B = -1 THEN GOTO onstriggotarg - IF a = 44 AND B = 0 THEN - x = x + 1 - IF x > 1 THEN a$ = "Expected )": GOTO errmes - IF e2$ = "" THEN a$ = "Expected ... ,": GOTO errmes - e3$ = e2$ - e2$ = "" - ELSE - IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ - END IF - NEXT - a$ = "Expected )": GOTO errmes - onstriggotarg: - IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes - PRINT #12, "onstrig_setup("; - - 'sort scanned results - IF LEN(e3$) THEN - optI$ = e3$ - optController$ = e2$ - optPassed$ = "1" - ELSE - optI$ = e2$ - optController$ = "0" - optPassed$ = "0" - END IF - - 'i - e$ = fixoperationorder$(optI$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + tlayout$ - e$ = evaluatetotyp(e$, 32&): IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ","; - - 'controller , passed - IF optPassed$ = "1" THEN - e$ = fixoperationorder$(optController$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluatetotyp(e$, 32&): IF Error_Happened THEN GOTO errmes - ELSE - e$ = optController$ - END IF - PRINT #12, e$ + "," + optPassed$ + ","; - - l$ = l$ + sp2 + ")" + sp 'close brackets - - i = i + 1 - IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes - a2$ = getelement$(a$, i): i = i + 1 - onstrigid = onstrigid + 1 - PRINT #12, str2$(onstrigid) + ","; - - IF a2$ = "GOSUB" THEN - IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - - PRINT #12, "0);" - - IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk60z: - IF v THEN - s = Labels(r).Scope - IF s = 0 OR s = -1 THEN 'main scope? - IF s = -1 THEN Labels(r).Scope = 0 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Scope_Restriction = subfuncn - Labels(r).Error_Line = linenumber - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk60z - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = 0 - Labels(r).Error_Line = linenumber - Labels(r).Scope_Restriction = subfuncn - END IF 'x - l$ = l$ + SCase$("GoSub") + sp + tlayout$ - - PRINT #30, "if(strig_event_id==" + str2$(onstrigid) + ")goto LABEL_" + a2$ + ";" - - PRINT #29, "case " + str2$(onstrigid) + ":" - PRINT #29, "strig_event_occurred++;" - PRINT #29, "strig_event_id=" + str2$(onstrigid) + ";" - PRINT #29, "strig_event_occurred++;" - PRINT #29, "return_point[next_return_point++]=0;" - PRINT #29, "if (next_return_point>=return_points) more_return_points();" - PRINT #29, "QBMAIN(NULL);" - PRINT #29, "break;" - - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - - ELSE - - 'establish whether sub a2$ exists using try - x = 0 - try = findid(a2$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = 2 THEN x = 1: EXIT DO - IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes - - l$ = l$ + RTRIM$(id.cn) - - PRINT #29, "case " + str2$(onstrigid) + ":" - PRINT #29, RTRIM$(id.callname) + "("; - - IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes - - IF i > n THEN - - IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes - PRINT #12, "0);" - PRINT #29, ");" - - ELSE - - IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes - - t = CVL(id.arg) - B = t AND 511 - IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes - IF B = 8 THEN ct$ = "int8" - IF B = 16 THEN ct$ = "int16" - IF B = 32 THEN ct$ = "int32" - IF B = 64 THEN ct$ = "int64" - IF t AND ISOFFSET THEN ct$ = "ptrszint" - IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ - PRINT #29, "(" + ct$ + "*)&i64);" - - e$ = getelements$(ca$, i, n) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ");" - - END IF - - PRINT #29, "break;" - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - END IF - - END IF - END IF - - - - - - - - - - - - - IF n >= 2 THEN - IF firstelement$ = "ON" AND secondelement$ = "TIMER" THEN - i = 3 - IF i > n THEN a$ = "Expected (": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes - l$ = SCase$("On" + sp + "Timer" + sp2 + "(") - IF i > n THEN a$ = "Expected ...": GOTO errmes - B = 0 - x = 0 - e2$ = "" - e3$ = "" - FOR i = i TO n - e$ = getelement$(ca$, i) - a = ASC(e$) - IF a = 40 THEN B = B + 1 - IF a = 41 THEN B = B - 1 - IF B = -1 THEN GOTO ontimgotarg - IF a = 44 AND B = 0 THEN - x = x + 1 - IF x > 1 THEN a$ = "Expected )": GOTO errmes - IF e2$ = "" THEN a$ = "Expected ... ,": GOTO errmes - e3$ = e2$ - e2$ = "" - ELSE - IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ - END IF - NEXT - a$ = "Expected )": GOTO errmes - ontimgotarg: - IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes - PRINT #12, "ontimer_setup("; - 'i - IF LEN(e3$) THEN - e$ = fixoperationorder$(e3$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + tlayout$ + "," + sp - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ","; - ELSE - PRINT #12, "0,"; - l$ = l$ + sp2 - END IF - 'sec - e$ = fixoperationorder$(e2$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + ")" + sp - e$ = evaluatetotyp(e$, DOUBLETYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ","; - i = i + 1 - IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes - a2$ = getelement$(a$, i): i = i + 1 - ontimerid = ontimerid + 1 - PRINT #12, str2$(ontimerid) + ","; - - IF a2$ = "GOSUB" THEN - IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - - PRINT #12, "0);" - - IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk60: - IF v THEN - s = Labels(r).Scope - IF s = 0 OR s = -1 THEN 'main scope? - IF s = -1 THEN Labels(r).Scope = 0 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Scope_Restriction = subfuncn - Labels(r).Error_Line = linenumber - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk60 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = 0 - Labels(r).Error_Line = linenumber - Labels(r).Scope_Restriction = subfuncn - END IF 'x - l$ = l$ + SCase$("GoSub") + sp + tlayout$ - - PRINT #25, "if(timer_event_id==" + str2$(ontimerid) + ")goto LABEL_" + a2$ + ";" - - PRINT #24, "case " + str2$(ontimerid) + ":" - PRINT #24, "timer_event_occurred++;" - PRINT #24, "timer_event_id=" + str2$(ontimerid) + ";" - PRINT #24, "timer_event_occurred++;" - PRINT #24, "return_point[next_return_point++]=0;" - PRINT #24, "if (next_return_point>=return_points) more_return_points();" - PRINT #24, "QBMAIN(NULL);" - PRINT #24, "break;" - - - - 'call validlabel (to validate the label) [see goto] - 'increment ontimerid - 'use ontimerid to generate the jumper routine - 'etc. - - - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - ELSE - - 'establish whether sub a2$ exists using try - x = 0 - try = findid(a2$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = 2 THEN x = 1: EXIT DO - IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes - - l$ = l$ + RTRIM$(id.cn) - - PRINT #24, "case " + str2$(ontimerid) + ":" - PRINT #24, RTRIM$(id.callname) + "("; - - IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes - - IF i > n THEN - - IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes - PRINT #12, "0);" - PRINT #24, ");" - - ELSE - - IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes - - t = CVL(id.arg) - B = t AND 511 - IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes - IF B = 8 THEN ct$ = "int8" - IF B = 16 THEN ct$ = "int16" - IF B = 32 THEN ct$ = "int32" - IF B = 64 THEN ct$ = "int64" - IF t AND ISOFFSET THEN ct$ = "ptrszint" - IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ - PRINT #24, "(" + ct$ + "*)&i64);" - - e$ = getelements$(ca$, i, n) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ");" - - END IF - - PRINT #24, "break;" - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - END IF - - END IF - END IF - - - - - IF n >= 2 THEN - IF firstelement$ = "ON" AND secondelement$ = "KEY" THEN - i = 3 - IF i > n THEN a$ = "Expected (": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes - l$ = SCase$("On" + sp + "Key" + sp2 + "(") - IF i > n THEN a$ = "Expected ...": GOTO errmes - B = 0 - x = 0 - e2$ = "" - FOR i = i TO n - e$ = getelement$(ca$, i) - a = ASC(e$) - - - IF a = 40 THEN B = B + 1 - IF a = 41 THEN B = B - 1 - IF B = -1 THEN EXIT FOR - IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ - NEXT - IF i = n + 1 THEN a$ = "Expected )": GOTO errmes - IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes - - e$ = fixoperationorder$(e2$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + ")" + sp - e$ = evaluatetotyp(e$, DOUBLETYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - PRINT #12, "onkey_setup(" + e$ + ","; - - i = i + 1 - IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes - a2$ = getelement$(a$, i): i = i + 1 - onkeyid = onkeyid + 1 - PRINT #12, str2$(onkeyid) + ","; - - IF a2$ = "GOSUB" THEN - IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes - a2$ = getelement$(ca$, i): i = i + 1 - - PRINT #12, "0);" - - IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk61: - IF v THEN - s = Labels(r).Scope - IF s = 0 OR s = -1 THEN 'main scope? - IF s = -1 THEN Labels(r).Scope = 0 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Scope_Restriction = subfuncn - Labels(r).Error_Line = linenumber - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk61 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = 0 - Labels(r).Error_Line = linenumber - Labels(r).Scope_Restriction = subfuncn - END IF 'x - l$ = l$ + SCase$("GoSub") + sp + tlayout$ - - PRINT #28, "if(key_event_id==" + str2$(onkeyid) + ")goto LABEL_" + a2$ + ";" - - PRINT #27, "case " + str2$(onkeyid) + ":" - PRINT #27, "key_event_occurred++;" - PRINT #27, "key_event_id=" + str2$(onkeyid) + ";" - PRINT #27, "key_event_occurred++;" - PRINT #27, "return_point[next_return_point++]=0;" - PRINT #27, "if (next_return_point>=return_points) more_return_points();" - PRINT #27, "QBMAIN(NULL);" - PRINT #27, "break;" - - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - ELSE - - 'establish whether sub a2$ exists using try - x = 0 - try = findid(a2$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = 2 THEN x = 1: EXIT DO - IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes - - l$ = l$ + RTRIM$(id.cn) - - PRINT #27, "case " + str2$(onkeyid) + ":" - PRINT #27, RTRIM$(id.callname) + "("; - - IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes - - IF i > n THEN - - IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes - PRINT #12, "0);" - PRINT #27, ");" - - ELSE - - IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes - - t = CVL(id.arg) - B = t AND 511 - IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes - IF B = 8 THEN ct$ = "int8" - IF B = 16 THEN ct$ = "int16" - IF B = 32 THEN ct$ = "int32" - IF B = 64 THEN ct$ = "int64" - IF t AND ISOFFSET THEN ct$ = "ptrszint" - IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ - PRINT #27, "(" + ct$ + "*)&i64);" - - e$ = getelements$(ca$, i, n) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - PRINT #12, e$ + ");" - - END IF - - PRINT #27, "break;" - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - layoutdone = 1 - GOTO finishedline - END IF - - END IF - END IF - - - - - - - - - - - - - - - - - - - - - - - - - - - - 'SHARED (SUB) - IF n >= 1 THEN - IF firstelement$ = "SHARED" THEN - IF n = 1 THEN a$ = "Expected SHARED ...": GOTO errmes - i = 2 - IF subfuncn = 0 THEN a$ = "SHARED must be used within a SUB/FUNCTION": GOTO errmes - - - - l$ = SCase$("Shared") - subfuncshr: - - 'get variable name - n$ = getelement$(ca$, i): i = i + 1 - - IF n$ = "" THEN a$ = "Expected SHARED variable-name or SHARED AS type variable-list": GOTO errmes - - IF UCASE$(n$) <> "AS" THEN - 'traditional dim syntax for SHARED - newSharedSyntax = 0 - s$ = removesymbol(n$) - IF Error_Happened THEN GOTO errmes - l2$ = s$ 'either symbol or nothing - - 'array? - a = 0 - IF getelement$(a$, i) = "(" THEN - IF getelement$(a$, i + 1) <> ")" THEN a$ = "Expected ()": GOTO errmes - i = i + 2 - a = 1 - l2$ = l2$ + sp2 + "(" + sp2 + ")" - END IF - - method = 1 - - 'specific type? - t$ = "" - ts$ = "" - t3$ = "" - IF getelement$(a$, i) = "AS" THEN - l2$ = l2$ + sp + SCase$("As") - getshrtyp: - i = i + 1 - t2$ = getelement$(a$, i) - IF t2$ <> "," AND t2$ <> "" THEN - IF t$ = "" THEN t$ = t2$ ELSE t$ = t$ + " " + t2$ - IF t3$ = "" THEN t3$ = t2$ ELSE t3$ = t3$ + sp + t2$ - GOTO getshrtyp - END IF - IF t$ = "" THEN a$ = "Expected AS type": GOTO errmes - - t = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF t AND ISINCONVENTIONALMEMORY THEN t = t - ISINCONVENTIONALMEMORY - IF t AND ISPOINTER THEN t = t - ISPOINTER - IF t AND ISREFERENCE THEN t = t - ISREFERENCE - tsize = typname2typsize - method = 0 - IF (t AND ISUDT) = 0 THEN - ts$ = type2symbol$(t$) - l2$ = l2$ + sp + SCase2$(t3$) - ELSE - t3$ = RTRIM$(udtxcname(t AND 511)) - IF RTRIM$(udtxcname(t AND 511)) = "_MEM" AND UCASE$(t$) = "MEM" AND qb64prefix_set = 1 THEN - t3$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) - END IF - l2$ = l2$ + sp + t3$ - END IF - IF Error_Happened THEN GOTO errmes - - END IF 'as - - IF LEN(s$) <> 0 AND LEN(t$) <> 0 THEN a$ = "Expected symbol or AS type after variable name": GOTO errmes - - 'no symbol of type specified, apply default - IF s$ = "" AND t$ = "" THEN - IF LEFT$(n$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n$)) - 64 - s$ = defineextaz(v) - END IF - - NormalSharedBlock: - 'switch to main module - oldsubfunc$ = subfunc$ - subfunc$ = "" - defdatahandle = 18 - CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 - CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 - - 'use 'try' to locate the variable (if it already exists) - n2$ = n$ + s$ + ts$ 'note: either ts$ or s$ will exist unless it is a UDT - try = findid(n2$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF a THEN - 'an array - - IF id.arraytype THEN - IF LEN(t$) = 0 THEN GOTO shrfound - t2 = id.arraytype: t2size = id.tsize - IF t2 AND ISINCONVENTIONALMEMORY THEN t2 = t2 - ISINCONVENTIONALMEMORY - IF t2 AND ISPOINTER THEN t2 = t2 - ISPOINTER - IF t2 AND ISREFERENCE THEN t2 = t2 - ISREFERENCE - IF t = t2 AND tsize = t2size THEN GOTO shrfound - END IF - - ELSE - 'not an array - - IF id.t THEN - IF LEN(t$) = 0 THEN GOTO shrfound - t2 = id.t: t2size = id.tsize - IF t2 AND ISINCONVENTIONALMEMORY THEN t2 = t2 - ISINCONVENTIONALMEMORY - IF t2 AND ISPOINTER THEN t2 = t2 - ISPOINTER - IF t2 AND ISREFERENCE THEN t2 = t2 - ISREFERENCE - - IF Debug THEN PRINT #9, "SHARED:comparing:"; t; t2, tsize; t2size - - IF t = t2 AND tsize = t2size THEN GOTO shrfound - END IF - - END IF - - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - 'unknown variable - IF a THEN a$ = "Array '" + n$ + "' not defined": GOTO errmes - 'create variable - IF LEN(s$) THEN typ$ = s$ ELSE typ$ = t$ - IF optionexplicit THEN a$ = "Variable '" + n$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": GOTO errmes - bypassNextVariable = -1 - retval = dim2(n$, typ$, method, "") - manageVariableList "", vWatchNewVariable$, 0, 2 - IF Error_Happened THEN GOTO errmes - 'note: variable created! - - shrfound: - IF newSharedSyntax = 0 THEN - l$ = l$ + sp + RTRIM$(id.cn) + l2$ - ELSE - IF sharedAsLayoutAdded = 0 THEN - sharedAsLayoutAdded = -1 - l$ = l$ + l2$ + sp$ + RTRIM$(id.cn) + l3$ - ELSE - l$ = l$ + sp$ + RTRIM$(id.cn) + l3$ - END IF - END IF - - ids(currentid).share = ids(currentid).share OR 2 'set as temporarily shared - - 'method must apply to the current sub/function regardless of how the variable was defined in 'main' - lmay = LEN(RTRIM$(id.mayhave)): lmust = LEN(RTRIM$(id.musthave)) - IF lmay <> 0 OR lmust <> 0 THEN - IF (method = 1 AND lmust = 0) OR (method = 0 AND lmay = 0) THEN - revertmaymusthaven = revertmaymusthaven + 1 - revertmaymusthave(revertmaymusthaven) = currentid - SWAP ids(currentid).musthave, ids(currentid).mayhave - END IF - END IF - - 'switch back to sub/func - subfunc$ = oldsubfunc$ - defdatahandle = 13 - CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR APPEND AS #13 - CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR APPEND AS #19 - - IF newSharedSyntax THEN RETURN - - IF getelement$(a$, i) = "," THEN i = i + 1: l$ = l$ + sp2 + ",": GOTO subfuncshr - IF getelement$(a$, i) <> "" THEN a$ = "Expected ,": GOTO errmes - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - ELSE - 'new dim syntax for SHARED! - i = i - 1 'relocate back to "AS" - - 'estabilish the data type: - t$ = "" - ts$ = "" - t3$ = "" - n$ = "" - previousElement$ = "" - l2$ = sp + SCase$("As") - sharedAsLayoutAdded = 0 - getshrtyp2: - i = i + 1 - t2$ = getelement$(a$, i) - IF t2$ <> "," AND t2$ <> "(" AND t2$ <> "" THEN - 'get first variable name - n$ = getelement$(ca$, i) - - IF LEN(previousElement$) THEN - IF t$ = "" THEN t$ = previousElement$ ELSE t$ = t$ + " " + previousElement$ - IF t3$ = "" THEN t3$ = previousElement$ ELSE t3$ = t3$ + sp + previousElement$ - END IF - previousElement$ = t2$ - GOTO getshrtyp2 - END IF - IF t$ = "" THEN a$ = "Expected SHARED AS type variable-list or SHARED variable-name AS type": GOTO errmes - - t = typname2typ(t$) - IF Error_Happened THEN GOTO errmes - IF t AND ISINCONVENTIONALMEMORY THEN t = t - ISINCONVENTIONALMEMORY - IF t AND ISPOINTER THEN t = t - ISPOINTER - IF t AND ISREFERENCE THEN t = t - ISREFERENCE - tsize = typname2typsize - method = 0 - IF (t AND ISUDT) = 0 THEN - ts$ = type2symbol$(t$) - l2$ = l2$ + sp + SCase2$(t3$) - ELSE - t3$ = RTRIM$(udtxcname(t AND 511)) - IF RTRIM$(udtxcname(t AND 511)) = "_MEM" AND UCASE$(t$) = "MEM" AND qb64prefix_set = 1 THEN - t3$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) - END IF - l2$ = l2$ + sp + t3$ - END IF - IF Error_Happened THEN GOTO errmes - - subfuncshr2: - s$ = removesymbol(n$) - IF Error_Happened THEN GOTO errmes - IF s$ <> "" THEN - a$ = "Cannot use type symbol with SHARED AS type variable-list (" + s$ + ")" - GOTO errmes - END IF - - 'array? - a = 0 - l3$ = "" - IF getelement$(a$, i) = "(" THEN - IF getelement$(a$, i + 1) <> ")" THEN a$ = "Expected ()": GOTO errmes - i = i + 2 - a = 1 - l3$ = sp2 + "(" + sp2 + ")" - END IF - - newSharedSyntax = -1 - GOSUB NormalSharedBlock - newSharedSyntax = 0 - - IF getelement$(a$, i) = "," THEN - i = i + 1 - l$ = l$ + sp2 + "," - - 'get next variable name - n$ = getelement$(ca$, i): i = i + 1 - GOTO subfuncshr2 - END IF - IF getelement$(a$, i) <> "" THEN a$ = "Expected ,": GOTO errmes - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - END IF - - 'EXIT SUB/FUNCTION - IF n = 2 THEN - IF firstelement$ = "EXIT" THEN - sf = 0 - IF secondelement$ = "FUNCTION" THEN sf = 1 - IF secondelement$ = "SUB" THEN sf = 2 - IF sf THEN - - IF LEN(subfunc) = 0 THEN a$ = "EXIT " + secondelement$ + " must be used within a " + secondelement$: GOTO errmes - - PRINT #12, "goto exit_subfunc;" - IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = SCase$("Sub") ELSE secondelement$ = SCase$("Function") - l$ = SCase$("Exit") + sp + secondelement$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - END IF - - - '_ECHO checking - IF firstelement$ = "_ECHO" OR (firstelement$ = "ECHO" AND qb64prefix_set = 1) THEN - IF Console = 0 THEN - a$ = qb64prefix$ + "ECHO requires $CONSOLE or $CONSOLE:ONLY to be set first": GOTO errmes - END IF - END IF - - - 'ASC statement (fully inline) - IF n >= 1 THEN - IF firstelement$ = "ASC" THEN - IF getelement$(a$, 2) <> "(" THEN a$ = "Expected ( after ASC": GOTO errmes - - 'calculate 3 parts - useposition = 0 - part = 1 - i = 3 - a3$ = "" - stringvariable$ = "" - position$ = "" - B = 0 - DO - - IF i > n THEN 'got part 3 - IF part <> 3 OR LEN(a3$) = 0 THEN a$ = "Expected ASC ( ... , ... ) = ...": GOTO errmes - expression$ = a3$ - EXIT DO - END IF - - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - - IF B = -1 THEN - - IF part = 1 THEN 'eg. ASC(a$)=65 - IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected =": GOTO errmes - stringvariable$ = a3$ - position$ = "1" - part = 3: a3$ = "": i = i + 1: GOTO ascgotpart - END IF - - IF part = 2 THEN 'eg. ASC(a$,i)=65 - IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected =": GOTO errmes - useposition = 1 - position$ = a3$ - part = 3: a3$ = "": i = i + 1: GOTO ascgotpart - END IF - - 'fall through, already in part 3 - - END IF - - IF a2$ = "," AND B = 0 THEN - IF part = 1 THEN stringvariable$ = a3$: part = 2: a3$ = "": GOTO ascgotpart - END IF - - IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ - ascgotpart: - i = i + 1 - LOOP - IF LEN(stringvariable$) = 0 OR LEN(position$) = 0 THEN a$ = "Expected ASC ( ... , ... ) = ...": GOTO errmes - - 'validate stringvariable$ - stringvariable$ = fixoperationorder$(stringvariable$) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Asc") + sp2 + "(" + sp2 + tlayout$ - - e$ = evaluate(stringvariable$, sourcetyp) - IF Error_Happened THEN GOTO errmes - IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "Expected ASC ( string-variable , ...": GOTO errmes - stringvariable$ = evaluatetotyp(stringvariable$, ISSTRING) - IF Error_Happened THEN GOTO errmes - - - - IF position$ = "1" THEN - IF useposition THEN l$ = l$ + sp2 + "," + sp + "1" + sp2 + ")" + sp + "=" ELSE l$ = l$ + sp2 + ")" + sp + "=" - - PRINT #12, "tqbs=" + stringvariable$ + "; if (!new_error){" - e$ = fixoperationorder$(expression$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "tmp_long=" + e$ + "; if (!new_error){" - PRINT #12, "if (tqbs->len){tqbs->chr[0]=tmp_long;}else{error(5);}" - PRINT #12, "}}" - - ELSE - - PRINT #12, "tqbs=" + stringvariable$ + "; if (!new_error){" - e$ = fixoperationorder$(position$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ + sp2 + ")" + sp + "=" - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "tmp_fileno=" + e$ + "; if (!new_error){" - e$ = fixoperationorder$(expression$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - e$ = evaluatetotyp(e$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "tmp_long=" + e$ + "; if (!new_error){" - PRINT #12, "if ((tmp_fileno>0)&&(tmp_fileno<=tqbs->len)){tqbs->chr[tmp_fileno-1]=tmp_long;}else{error(5);}" - PRINT #12, "}}}" - - END IF - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - - - - - 'MID$ statement - IF n >= 1 THEN - IF firstelement$ = "MID$" THEN - IF getelement$(a$, 2) <> "(" THEN a$ = "Expected ( after MID$": GOTO errmes - 'calculate 4 parts - length$ = "" - part = 1 - i = 3 - a3$ = "" - stringvariable$ = "" - start$ = "" - B = 0 - DO - IF i > n THEN - IF part <> 4 OR a3$ = "" THEN a$ = "Expected MID$(...)=...": GOTO errmes - stringexpression$ = a3$ - EXIT DO - END IF - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF B = -1 THEN - IF part = 2 THEN - IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected = after )": GOTO errmes - start$ = a3$: part = 4: a3$ = "": i = i + 1: GOTO midgotpart - END IF - IF part = 3 THEN - IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected = after )": GOTO errmes - IF a3$ = "" THEN a$ = "Omit , before ) if omitting length in MID$ statement": GOTO errmes - length$ = a3$: part = 4: a3$ = "": i = i + 1: GOTO midgotpart - END IF - END IF - IF a2$ = "," AND B = 0 THEN - IF part = 1 THEN stringvariable$ = a3$: part = 2: a3$ = "": GOTO midgotpart - IF part = 2 THEN start$ = a3$: part = 3: a3$ = "": GOTO midgotpart - END IF - IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ - midgotpart: - i = i + 1 - LOOP - IF stringvariable$ = "" THEN a$ = "Syntax error - first parameter must be a string variable/array-element": GOTO errmes - IF start$ = "" THEN a$ = "Syntax error - second parameter not optional": GOTO errmes - 'check if it is a valid source string - stringvariable$ = fixoperationorder$(stringvariable$) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Mid$") + sp2 + "(" + sp2 + tlayout$ - e$ = evaluate(stringvariable$, sourcetyp) - IF Error_Happened THEN GOTO errmes - IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "MID$ expects a string variable/array-element as its first argument": GOTO errmes - stringvariable$ = evaluatetotyp(stringvariable$, ISSTRING) - IF Error_Happened THEN GOTO errmes - - start$ = fixoperationorder$(start$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - start$ = evaluatetotyp((start$), 32&) - - stringexpression$ = fixoperationorder$(stringexpression$) - IF Error_Happened THEN GOTO errmes - l2$ = tlayout$ - stringexpression$ = evaluatetotyp(stringexpression$, ISSTRING) - IF Error_Happened THEN GOTO errmes - - IF LEN(length$) THEN - length$ = fixoperationorder$(length$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - length$ = evaluatetotyp(length$, 32&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_mid(" + stringvariable$ + "," + start$ + "," + length$ + "," + stringexpression$ + ",1);" - ELSE - PRINT #12, "sub_mid(" + stringvariable$ + "," + start$ + ",0," + stringexpression$ + ",0);" - END IF - - l$ = l$ + sp2 + ")" + sp + "=" + sp + l2$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - - - IF n >= 2 THEN - IF firstelement$ = "ERASE" THEN - i = 2 - l$ = SCase$("Erase") - erasenextarray: - var$ = getelement$(ca$, i) - x$ = var$: ls$ = removesymbol(x$) - IF Error_Happened THEN GOTO errmes - - IF FindArray(var$) THEN - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + RTRIM$(id.cn) + ls$ - 'erase the array - clearerase: - n$ = RTRIM$(id.callname) - bytesperelement$ = str2((id.arraytype AND 511) \ 8) - IF id.arraytype AND ISSTRING THEN bytesperelement$ = str2(id.tsize) - IF id.arraytype AND ISOFFSETINBITS THEN bytesperelement$ = str2((id.arraytype AND 511)) + "/8+1" - IF id.arraytype AND ISUDT THEN - bytesperelement$ = str2(udtxsize(id.arraytype AND 511) \ 8) - END IF - PRINT #12, "if (" + n$ + "[2]&1){" 'array is defined - PRINT #12, "if (" + n$ + "[2]&2){" 'array is static - IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN - PRINT #12, "tmp_long="; - FOR i2 = 1 TO ABS(id.arrayelements) - IF i2 <> 1 THEN PRINT #12, "*"; - PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; - NEXT - PRINT #12, ";" - PRINT #12, "while(tmp_long--){" - PRINT #12, "((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))->len=0;" - PRINT #12, "}" - ELSE - 'numeric - 'clear array - PRINT #12, "memset((void*)(" + n$ + "[0]),0,"; - FOR i2 = 1 TO ABS(id.arrayelements) - IF i2 <> 1 THEN PRINT #12, "*"; - PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; - NEXT - PRINT #12, "*" + bytesperelement$ + ");" - END IF - PRINT #12, "}else{" 'array is dynamic - '1. free memory & any allocated strings - IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN - 'free strings - PRINT #12, "tmp_long="; - FOR i2 = 1 TO ABS(id.arrayelements) - IF i2 <> 1 THEN PRINT #12, "*"; - PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; - NEXT - PRINT #12, ";" - PRINT #12, "while(tmp_long--){" - PRINT #12, "qbs_free((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]));" - PRINT #12, "}" - 'free memory - PRINT #12, "free((void*)(" + n$ + "[0]));" - ELSE - 'free memory - PRINT #12, "if (" + n$ + "[2]&4){" 'cmem array - PRINT #12, "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" - PRINT #12, "}else{" 'non-cmem array - PRINT #12, "free((void*)(" + n$ + "[0]));" - PRINT #12, "}" - END IF - '2. set array (and its elements) as undefined - PRINT #12, n$ + "[2]^=1;" 'remove defined flag, keeping other flags (such as cmem) - 'set dimensions as undefined - FOR i2 = 1 TO ABS(id.arrayelements) - B = i2 * 4 - PRINT #12, n$ + "[" + str2(B) + "]=2147483647;" 'base - PRINT #12, n$ + "[" + str2(B + 1) + "]=0;" 'num. index - PRINT #12, n$ + "[" + str2(B + 2) + "]=0;" 'multiplier - NEXT - IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN - PRINT #12, n$ + "[0]=(ptrszint)¬hingstring;" - ELSE - PRINT #12, n$ + "[0]=(ptrszint)nothingvalue;" - END IF - PRINT #12, "}" 'static/dynamic - PRINT #12, "}" 'array is defined - IF clearerasereturn = 1 THEN clearerasereturn = 0: GOTO clearerasereturned - GOTO erasedarray - END IF - IF Error_Happened THEN GOTO errmes - a$ = "Undefined array passed to ERASE": GOTO errmes - - erasedarray: - IF i < n THEN - i = i + 1: n$ = getelement$(a$, i): IF n$ <> "," THEN a$ = "Expected ,": GOTO errmes - l$ = l$ + sp2 + "," - i = i + 1: IF i > n THEN a$ = "Expected , ...": GOTO errmes - GOTO erasenextarray - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - - - 'DIM/REDIM/STATIC - IF n >= 2 THEN - dimoption = 0: redimoption = 0: commonoption = 0 - IF firstelement$ = "DIM" THEN l$ = SCase$("Dim"): dimoption = 1 - IF firstelement$ = "REDIM" THEN - l$ = SCase$("ReDim") - dimoption = 2: redimoption = 1 - IF secondelement$ = "_PRESERVE" OR (secondelement$ = "PRESERVE" AND qb64prefix_set = 1) THEN - redimoption = 2 - IF secondelement$ = "_PRESERVE" THEN - l$ = l$ + sp + SCase$("_Preserve") - ELSE - l$ = l$ + sp + SCase$("Preserve") - END IF - IF n = 2 THEN a$ = "Expected REDIM " + qb64prefix$ + "PRESERVE ...": GOTO errmes - END IF - END IF - IF firstelement$ = "STATIC" THEN l$ = SCase$("Static"): dimoption = 3 - IF firstelement$ = "COMMON" THEN l$ = SCase$("Common"): dimoption = 1: commonoption = 1 - IF dimoption THEN - - IF dimoption = 3 AND subfuncn = 0 THEN a$ = "STATIC must be used within a SUB/FUNCTION": GOTO errmes - IF commonoption = 1 AND subfuncn <> 0 THEN a$ = "COMMON cannot be used within a SUB/FUNCTION": GOTO errmes - - i = 2 - IF redimoption = 2 THEN i = 3 - - IF dimoption <> 3 THEN 'shared cannot be static - a2$ = getelement(a$, i) - IF a2$ = "SHARED" THEN - IF subfuncn <> 0 THEN a$ = "DIM/REDIM SHARED invalid within a SUB/FUNCTION": GOTO errmes - dimshared = 1 - i = i + 1 - l$ = l$ + sp + SCase$("Shared") - END IF - END IF - - IF dimoption = 3 THEN dimstatic = 1: AllowLocalName = 1 - - 'look for new dim syntax: DIM AS variabletype var1, var2, etc.... - e$ = getelement$(a$, i) - IF e$ <> "AS" THEN - 'no "AS", so this is the traditional dim syntax - dimnext: - newDimSyntax = 0 - notype = 0 - listarray = 0 - - - 'old chain code - 'chaincommonarray=0 - - varname$ = getelement(ca$, i): i = i + 1 - IF varname$ = "" THEN a$ = "Expected " + firstelement$ + " variable-name or " + firstelement$ + " AS type variable-list": GOTO errmes - - 'get the next element - IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 - - 'check if next element is a ( to create an array - elements$ = "" - - IF e$ = "(" THEN - B = 1 - FOR i = i TO n - e$ = getelement(ca$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN B = B - 1 - IF B = 0 THEN EXIT FOR - IF LEN(elements$) THEN elements$ = elements$ + sp + e$ ELSE elements$ = e$ - NEXT - IF B <> 0 THEN a$ = "Expected )": GOTO errmes - i = i + 1 'set i to point to the next element - - IF commonoption THEN elements$ = "?" - - - IF Debug THEN PRINT #9, "DIM2:array:elements$:[" + elements$ + "]" - - 'arrayname() means list array to it will automatically be static when it is formally dimensioned later - 'note: listed arrays are always created in dynamic memory, but their contents are not erased - ' this differs from static arrays from SUB...STATIC and the unique QB64 method -> STATIC arrayname(100) - IF dimoption = 3 THEN 'STATIC used - IF LEN(elements$) = 0 THEN 'nothing between brackets - listarray = 1 'add to static list - END IF - END IF - - 'last element was ")" - 'get next element - IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 - END IF 'e$="(" - d$ = e$ - - dimmethod = 0 - - appendname$ = "" 'the symbol to append to name returned by dim2 - appendtype$ = "" 'eg. sp+AS+spINTEGER - dim2typepassback$ = "" - - 'does varname have an appended symbol? - s$ = removesymbol$(varname$) - IF Error_Happened THEN GOTO errmes - IF validname(varname$) = 0 THEN a$ = "Invalid variable name": GOTO errmes - - IF s$ <> "" THEN - typ$ = s$ - dimmethod = 1 - appendname$ = typ$ - GOTO dimgottyp - END IF - - IF d$ = "AS" THEN - appendtype$ = sp + SCase$("As") - typ$ = "" - FOR i = i TO n - d$ = getelement(a$, i) - IF d$ = "," THEN i = i + 1: EXIT FOR - typ$ = typ$ + d$ + " " - appendtype$ = appendtype$ + sp + d$ - d$ = "" - NEXT - appendtype$ = SCase2$(appendtype$) 'capitalise default types (udt override this later if necessary) - typ$ = RTRIM$(typ$) - GOTO dimgottyp - END IF - - 'auto-define type based on name - notype = 1 - IF LEFT$(varname$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(varname$)) - 64 - typ$ = defineaz(v) - dimmethod = 1 - GOTO dimgottyp - - dimgottyp: - IF d$ <> "" AND d$ <> "," THEN a$ = "DIM: Expected ,": GOTO errmes - - 'In QBASIC, if no type info is given it can refer to an expeicit/formally defined array - IF notype <> 0 AND dimoption <> 3 AND dimoption <> 1 THEN 'not DIM or STATIC which only create new content - IF LEN(elements$) THEN 'an array - IF FindArray(varname$) THEN - IF LEN(RTRIM$(id.mayhave)) THEN 'explict/formally defined - typ$ = id2fulltypename$ 'adopt type - dimmethod = 0 'set as formally defined - END IF - END IF - END IF - END IF - - NormalDimBlock: - IF dimoption = 3 AND LEN(elements$) THEN 'eg. STATIC a(100) - 'does a conflicting array exist? (use findarray) if so again this should lead to duplicate definition - typ2$ = symbol2fulltypename$(typ$) - t = typname2typ(typ2$): ts = typname2typsize - 'try name without any extension - IF FindArray(varname$) THEN 'name without any symbol - IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static - IF LEN(RTRIM$(id.musthave)) THEN - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes - END IF - END IF - ELSE - IF dimmethod = 0 THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes 'explicit over explicit - ELSE - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes - END IF - END IF - END IF - END IF - END IF - END IF - 'add extension (if possible) - IF (t AND ISUDT) = 0 THEN - s2$ = type2symbol$(typ2$) - IF Error_Happened THEN GOTO errmes - IF FindArray(varname$ + s2$) THEN - IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static - IF LEN(RTRIM$(id.musthave)) THEN - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes - END IF - END IF - ELSE - IF dimmethod = 0 THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes 'explicit over explicit - ELSE - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes - END IF - END IF - END IF - END IF - END IF - END IF - END IF 'not a UDT - END IF - - IF listarray THEN 'eg. STATIC a() - 'note: list is cleared by END SUB/FUNCTION - - 'is a conflicting array already listed? if so this should cause a duplicate definition error - 'check for conflict within list: - xi = 1 - FOR x = 1 TO staticarraylistn - varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 - typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 - 'check if they are similar - IF UCASE$(varname$) = UCASE$(varname2$) THEN - IF dimmethod2 = 1 THEN - 'old using symbol - IF symbol2fulltypename$(typ$) = typ2$ THEN a$ = "Name already in use (" + varname$ + ")": GOTO errmes - ELSE - 'old using AS - IF dimmethod = 0 THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes - ELSE - IF symbol2fulltypename$(typ$) = typ2$ THEN a$ = "Name already in use (" + varname$ + ")": GOTO errmes - END IF - END IF - END IF - NEXT - - 'does a conflicting array exist? (use findarray) if so again this should lead to duplicate definition - typ2$ = symbol2fulltypename$(typ$) - t = typname2typ(typ2$): ts = typname2typsize - 'try name without any extension - IF FindArray(varname$) THEN 'name without any symbol - IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static - IF LEN(RTRIM$(id.musthave)) THEN - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes - END IF - END IF - ELSE - IF dimmethod = 0 THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes 'explicit over explicit - ELSE - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + ")": GOTO errmes - END IF - END IF - END IF - END IF - END IF - END IF - 'add extension (if possible) - IF (t AND ISUDT) = 0 THEN - s2$ = type2symbol$(typ2$) - IF Error_Happened THEN GOTO errmes - IF FindArray(varname$ + s2$) THEN - IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static - IF LEN(RTRIM$(id.musthave)) THEN - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes - END IF - END IF - ELSE - IF dimmethod = 0 THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes 'explicit over explicit - ELSE - 'if types match then fail - IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN - IF ts = id.tsize THEN - a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes - END IF - END IF - END IF - END IF - END IF - END IF - END IF 'not a UDT - - 'note: static list arrays cannot be created until they are formally [or informally] (RE)DIM'd later - IF LEN(staticarraylist) THEN staticarraylist = staticarraylist + sp - staticarraylist = staticarraylist + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) - IF Error_Happened THEN GOTO errmes - staticarraylistn = staticarraylistn + 1 - l$ = l$ + sp + varname$ + appendname$ + sp2 + "(" + sp2 + ")" + appendtype$ - 'note: none of the following code is run, dim2 call is also skipped - - ELSE - - olddimstatic = dimstatic - - 'check if varname is on the static list - IF LEN(elements$) THEN 'it's an array - IF subfuncn THEN 'it's in a sub/function - xi = 1 - FOR x = 1 TO staticarraylistn - varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 - typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 - 'check if they are similar - IF UCASE$(varname$) = UCASE$(varname2$) THEN - IF symbol2fulltypename$(typ$) = typ2$ THEN - IF Error_Happened THEN GOTO errmes - IF dimmethod = dimmethod2 THEN - 'match found! - varname$ = varname2$ - dimstatic = 3 - IF dimoption = 3 THEN a$ = "Array already listed as STATIC": GOTO errmes - END IF - END IF 'typ - END IF 'varname - NEXT - END IF - END IF - - 'COMMON exception - 'note: COMMON alone does not imply SHARED - ' if either(or both) COMMON & later DIM have SHARED, variable becomes shared - IF commonoption THEN - IF LEN(elements$) THEN - - 'add array to list - IF LEN(commonarraylist) THEN commonarraylist = commonarraylist + sp - 'note: dimmethod distinguishes between a%(...) vs a(...) AS INTEGER - commonarraylist = commonarraylist + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) + sp + str2(dimshared) - IF Error_Happened THEN GOTO errmes - commonarraylistn = commonarraylistn + 1 - IF Debug THEN PRINT #9, "common listed:" + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) + sp + str2(dimshared) - IF Error_Happened THEN GOTO errmes - - x = 0 - - v$ = varname$ - IF dimmethod = 1 THEN v$ = v$ + typ$ - try = findid(v$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.arraytype THEN - - t = typname2typ(typ$) - IF Error_Happened THEN GOTO errmes - s = typname2typsize - match = 1 - 'note: dimmethod 2 is already matched - IF dimmethod = 0 THEN - t2 = id.arraytype - s2 = id.tsize - IF (t AND ISFLOAT) <> (t2 AND ISFLOAT) THEN match = 0 - IF (t AND ISUNSIGNED) <> (t2 AND ISUNSIGNED) THEN match = 0 - IF (t AND ISSTRING) <> (t2 AND ISSTRING) THEN match = 0 - IF (t AND ISFIXEDLENGTH) <> (t2 AND ISFIXEDLENGTH) THEN match = 0 - IF (t AND ISOFFSETINBITS) <> (t2 AND ISOFFSETINBITS) THEN match = 0 - IF (t AND ISUDT) <> (t2 AND ISUDT) THEN match = 0 - IF (t AND 511) <> (t2 AND 511) THEN match = 0 - IF s <> s2 THEN match = 0 - 'check for implicit/explicit declaration match - oldmethod = 0: IF LEN(RTRIM$(id.musthave)) THEN oldmethod = 1 - IF oldmethod <> dimmethod THEN match = 0 - END IF - - IF match THEN - x = currentid - IF dimshared THEN ids(x).share = 1 'share if necessary - tlayout$ = RTRIM$(id.cn) + sp + "(" + sp2 + ")" - - IF dimmethod = 0 THEN - IF t AND ISUDT THEN - dim2typepassback$ = RTRIM$(udtxcname(t AND 511)) - IF UCASE$(typ$) = "MEM" AND qb64prefix_set = 1 AND RTRIM$(udtxcname(t AND 511)) = "_MEM" THEN - dim2typepassback$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) - END IF - ELSE - dim2typepassback$ = typ$ - DO WHILE INSTR(dim2typepassback$, " ") - ASC(dim2typepassback$, INSTR(dim2typepassback$, " ")) = ASC(sp) - LOOP - dim2typepassback$ = SCase2$(dim2typepassback$) - END IF - END IF 'method 0 - - EXIT DO - END IF 'match - - END IF 'arraytype - IF try = 2 THEN findanotherid = 1: try = findid(v$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - - IF x = 0 THEN x = idn + 1 - - 'note: the following code only adds include directives, everything else is defered - OPEN tmpdir$ + "chain.txt" FOR APPEND AS #22 - 'include directive - PRINT #22, "#include " + CHR$(34) + "chain" + str2$(x) + ".txt" + CHR$(34) - CLOSE #22 - 'create/clear include file - OPEN tmpdir$ + "chain" + str2$(x) + ".txt" FOR OUTPUT AS #22: CLOSE #22 - - OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #22 - 'include directive - PRINT #22, "#include " + CHR$(34) + "inpchain" + str2$(x) + ".txt" + CHR$(34) - CLOSE #22 - 'create/clear include file - OPEN tmpdir$ + "inpchain" + str2$(x) + ".txt" FOR OUTPUT AS #22: CLOSE #22 - - 'note: elements$="?" - IF x <> idn + 1 THEN GOTO skipdim 'array already exists - GOTO dimcommonarray - - END IF - END IF - - 'is varname on common list? - '****** - IF LEN(elements$) THEN 'it's an array - IF subfuncn = 0 THEN 'not in a sub/function - - IF Debug THEN PRINT #9, "common checking:" + varname$ - - xi = 1 - FOR x = 1 TO commonarraylistn - varname2$ = getelement$(commonarraylist, xi): xi = xi + 1 - typ2$ = getelement$(commonarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - IF Debug THEN PRINT #9, "common checking against:" + varname2$ + sp + typ2$ + sp + str2(dimmethod2) + sp + str2(dimshared2) - 'check if they are similar - IF varname$ = varname2$ THEN - IF symbol2fulltypename$(typ$) = typ2$ THEN - IF Error_Happened THEN GOTO errmes - IF dimmethod = dimmethod2 THEN - - 'match found! - 'enforce shared status (if necessary) - IF dimshared2 THEN dimshared = dimshared OR 2 'temp force SHARED - - 'old chain code - 'chaincommonarray=x - - END IF 'method - END IF 'typ - END IF 'varname - NEXT - END IF - END IF - - dimcommonarray: - retval = dim2(varname$, typ$, dimmethod, elements$) - IF Error_Happened THEN GOTO errmes - skipdim: - IF dimshared >= 2 THEN dimshared = dimshared - 2 - - 'non-array COMMON variable - IF commonoption <> 0 AND LEN(elements$) = 0 THEN - - 'CHAIN.TXT (save) - - use_global_byte_elements = 1 - - 'switch output from main.txt to chain.txt - CLOSE #12 - OPEN tmpdir$ + "chain.txt" FOR APPEND AS #12 - l2$ = tlayout$ - - PRINT #12, "int32val=1;" 'simple variable - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - t = id.t - bits = t AND 511 - IF t AND ISUDT THEN bits = udtxsize(t AND 511) - IF t AND ISSTRING THEN - IF t AND ISFIXEDLENGTH THEN - bits = id.tsize * 8 - ELSE - PRINT #12, "int64val=__STRING_" + RTRIM$(id.n) + "->len*8;" - bits = 0 - END IF - END IF - - IF bits THEN - PRINT #12, "int64val=" + str2$(bits) + ";" 'size in bits - END IF - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - - 'put the variable - e$ = RTRIM$(id.n) - - IF (t AND ISUDT) = 0 THEN - IF t AND ISFIXEDLENGTH THEN - e$ = e$ + "$" + str2$(id.tsize) - ELSE - e$ = e$ + typevalue2symbol$(t) - IF Error_Happened THEN GOTO errmes - END IF - END IF - e$ = evaluatetotyp(fixoperationorder$(e$), -4) - IF Error_Happened THEN GOTO errmes - - PRINT #12, "sub_put(FF,NULL," + e$ + ",0);" - - tlayout$ = l2$ - 'revert output to main.txt - CLOSE #12 - OPEN tmpdir$ + "main.txt" FOR APPEND AS #12 - - - 'INPCHAIN.TXT (load) - - 'switch output from main.txt to chain.txt - CLOSE #12 - OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #12 - l2$ = tlayout$ - - - PRINT #12, "if (int32val==1){" - 'get the size in bits - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - '***assume correct size*** - - e$ = RTRIM$(id.n) - t = id.t - IF (t AND ISUDT) = 0 THEN - IF t AND ISFIXEDLENGTH THEN - e$ = e$ + "$" + str2$(id.tsize) - ELSE - e$ = e$ + typevalue2symbol$(t) - IF Error_Happened THEN GOTO errmes - END IF - END IF - - IF t AND ISSTRING THEN - IF (t AND ISFIXEDLENGTH) = 0 THEN - PRINT #12, "tqbs=qbs_new(int64val>>3,1);" - PRINT #12, "qbs_set(__STRING_" + RTRIM$(id.n) + ",tqbs);" - 'now that the string is the correct size, the following GET command will work correctly... - END IF - END IF - - e$ = evaluatetotyp(fixoperationorder$(e$), -4) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_get(FF,NULL," + e$ + ",0);" - - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" 'get next command - PRINT #12, "}" - - tlayout$ = l2$ - 'revert output to main.txt - CLOSE #12 - OPEN tmpdir$ + "main.txt" FOR APPEND AS #12 - - use_global_byte_elements = 0 - - END IF - - commonarraylisted: - - IF LEN(appendtype$) > 0 AND newDimSyntax = -1 THEN - IF LEN(dim2typepassback$) THEN appendtype$ = sp + SCase$("As") + sp + dim2typepassback$ - IF newDimSyntaxTypePassBack = 0 THEN - newDimSyntaxTypePassBack = -1 - l$ = l$ + appendtype$ - END IF - END IF - - n2 = numelements(tlayout$) - l$ = l$ + sp + getelement$(tlayout$, 1) + appendname$ - IF n2 > 1 THEN - l$ = l$ + sp2 + getelements$(tlayout$, 2, n2) - END IF - - IF LEN(appendtype$) > 0 AND newDimSyntax = 0 THEN - IF LEN(dim2typepassback$) THEN appendtype$ = sp + SCase$("As") + sp + dim2typepassback$ - l$ = l$ + appendtype$ - END IF - - 'modify first element name to include symbol - - dimstatic = olddimstatic - - END IF 'listarray=0 - - IF newDimSyntax THEN RETURN - - IF d$ = "," THEN l$ = l$ + sp2 + ",": GOTO dimnext - - dimoption = 0 - dimshared = 0 - redimoption = 0 - IF dimstatic = 1 THEN dimstatic = 0 - AllowLocalName = 0 - - layoutdone = 1 - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - - GOTO finishedline - ELSE - 'yes, this is the new dim syntax. - i = i + 1 'skip "AS" - newDimSyntaxTypePassBack = 0 - - 'estabilish the data type: - appendname$ = "" - appendtype$ = sp + SCase$("As") - typ$ = "" - varname$ = "" - previousElement$ = "" - FOR i = i TO n - d$ = getelement(a$, i) - IF d$ = "," OR d$ = "(" THEN EXIT FOR - varname$ = getelement(ca$, i) - IF LEN(previousElement$) THEN - typ$ = typ$ + previousElement$ + " " - appendtype$ = appendtype$ + sp + previousElement$ - END IF - previousElement$ = d$ - d$ = "" - NEXT - appendtype$ = SCase2$(appendtype$) 'capitalise default types (udt override this later if necessary) - typ$ = RTRIM$(typ$) - - dimnext2: - notype = 0 - listarray = 0 - - IF typ$ = "" OR varname$ = "" THEN a$ = "Expected " + firstelement$ + " AS type variable-list or " + firstelement$ + " variable-name AS type": GOTO errmes - - 'get the next element - IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 - - 'check if next element is a ( to create an array - elements$ = "" - - IF e$ = "(" THEN - B = 1 - FOR i = i TO n - e$ = getelement(ca$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN B = B - 1 - IF B = 0 THEN EXIT FOR - IF LEN(elements$) THEN elements$ = elements$ + sp + e$ ELSE elements$ = e$ - NEXT - IF B <> 0 THEN a$ = "Expected )": GOTO errmes - i = i + 1 'set i to point to the next element - - IF commonoption THEN elements$ = "?" - - - IF Debug THEN PRINT #9, "DIM2:array:elements$:[" + elements$ + "]" - - 'arrayname() means list array to it will automatically be static when it is formally dimensioned later - 'note: listed arrays are always created in dynamic memory, but their contents are not erased - ' this differs from static arrays from SUB...STATIC and the unique QB64 method -> STATIC arrayname(100) - IF dimoption = 3 THEN 'STATIC used - IF LEN(elements$) = 0 THEN 'nothing between brackets - listarray = 1 'add to static list - END IF - END IF - - 'last element was ")" - 'get next element - IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 - END IF 'e$="(" - d$ = e$ - - dimmethod = 0 - - dim2typepassback$ = "" - - 'does varname have an appended symbol? - s$ = removesymbol$(varname$) - IF Error_Happened THEN GOTO errmes - IF validname(varname$) = 0 THEN a$ = "Invalid variable name": GOTO errmes - - IF s$ <> "" THEN - a$ = "Cannot use type symbol with " + firstelement$ + " AS type variable-list (" + s$ + ")" - GOTO errmes - END IF - - IF d$ <> "" AND d$ <> "," THEN a$ = "DIM: Expected ,": GOTO errmes - - newDimSyntax = -1 - GOSUB NormalDimBlock - newDimSyntax = 0 - - IF d$ = "," THEN - l$ = l$ + sp2 + "," - varname$ = getelement(ca$, i): i = i + 1 - GOTO dimnext2 - END IF - - dimoption = 0 - dimshared = 0 - redimoption = 0 - IF dimstatic = 1 THEN dimstatic = 0 - AllowLocalName = 0 - - layoutdone = 1 - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - - GOTO finishedline - END IF - END IF - END IF - - - - - - - - - - - - 'THEN [GOTO] linenumber? - IF THENGOTO = 1 THEN - IF n = 1 THEN - l$ = "" - a = ASC(LEFT$(firstelement$, 1)) - IF a = 46 OR (a >= 48 AND a <= 57) THEN a2$ = ca$: GOTO THENGOTO - END IF - END IF - - 'goto - IF n = 2 THEN - IF getelement$(a$, 1) = "GOTO" THEN - l$ = SCase$("GoTo") - a2$ = getelement$(ca$, 2) - THENGOTO: - IF validlabel(a2$) = 0 THEN a$ = "Invalid label!": GOTO errmes - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk2: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk2 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - Labels(r).Error_Line = linenumber - END IF 'x - - IF LEN(l$) THEN l$ = l$ + sp + tlayout$ ELSE l$ = tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - PRINT #12, "goto LABEL_" + a2$ + ";" - GOTO finishedline - END IF - END IF - - IF n = 1 THEN - IF firstelement$ = "_CONTINUE" OR (firstelement$ = "CONTINUE" AND qb64prefix_set = 1) THEN - IF firstelement$ = "_CONTINUE" THEN l$ = SCase$("_Continue") ELSE l$ = SCase$("Continue") - 'scan backwards until previous control level reached - FOR i = controllevel TO 1 STEP -1 - t = controltype(i) - IF t = 2 THEN 'for...next - PRINT #12, "goto fornext_continue_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - ELSEIF t = 3 OR t = 4 THEN 'do...loop - PRINT #12, "goto dl_continue_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - ELSEIF t = 5 THEN 'while...wend - PRINT #12, "goto ww_continue_" + str2$(controlid(i)) + ";" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - NEXT - a$ = qb64prefix$ + "CONTINUE outside DO..LOOP/FOR..NEXT/WHILE..WEND block": GOTO errmes - END IF - END IF - - IF firstelement$ = "CHAIN" THEN - IF vWatchOn THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $Debug mode", "CHAIN" - END IF - END IF - - IF firstelement$ = "RUN" THEN 'RUN - IF vWatchOn THEN - addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $Debug mode", "RUN" - END IF - l$ = SCase$("Run") - IF n = 1 THEN - 'no parameters - PRINT #12, "sub_run_init();" 'note: called first to free up screen-locked image handles - PRINT #12, "sub_clear(NULL,NULL,NULL,NULL);" 'use functionality of CLEAR - IF LEN(subfunc$) THEN - PRINT #12, "QBMAIN(NULL);" - ELSE - PRINT #12, "goto S_0;" - END IF - ELSE - 'parameter passed - e$ = getelements$(ca$, 2, n) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l2$ = tlayout$ - ignore$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - IF n = 2 AND ((typ AND ISSTRING) = 0) THEN - 'assume it's a label or line number - lbl$ = getelement$(ca$, 2) - IF validlabel(lbl$) = 0 THEN a$ = "Invalid label!": GOTO errmes 'invalid label - - v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk501: - IF v THEN - s = Labels(r).Scope - IF s = 0 OR s = -1 THEN 'main scope? - IF s = -1 THEN Labels(r).Scope = 0 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Scope_Restriction = subfuncn - Labels(r).Error_Line = linenumber - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk501 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd lbl$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = 0 - Labels(r).Error_Line = linenumber - Labels(r).Scope_Restriction = subfuncn - END IF 'x - - l$ = l$ + sp + tlayout$ - PRINT #12, "sub_run_init();" 'note: called first to free up screen-locked image handles - PRINT #12, "sub_clear(NULL,NULL,NULL,NULL);" 'use functionality of CLEAR - IF LEN(subfunc$) THEN - PRINT #21, "if (run_from_line==" + str2(nextrunlineindex) + "){run_from_line=0;goto LABEL_" + lbl$ + ";}" - PRINT #12, "run_from_line=" + str2(nextrunlineindex) + ";" - nextrunlineindex = nextrunlineindex + 1 - PRINT #12, "QBMAIN(NULL);" - ELSE - PRINT #12, "goto LABEL_" + lbl$ + ";" - END IF - ELSE - 'assume it's a string containing a filename to execute - e$ = evaluatetotyp(e$, ISSTRING) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_run(" + e$ + ");" - l$ = l$ + sp + l2$ - END IF 'isstring - END IF 'n=1 - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF 'run - - - - - - IF firstelement$ = "END" THEN - l$ = SCase$("End") - IF n > 1 THEN - e$ = getelements$(ca$, 2, n) - e$ = fixoperationorder$(e$): IF Error_Happened THEN GOTO errmes - l2$ = tlayout$ - e$ = evaluatetotyp(e$, ISINTEGER64): IF Error_Happened THEN GOTO errmes - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - inclinenump$ = "," + str2$(inclinenumber(inclevel)) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) - END IF - IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" - PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors) - PRINT #12, "exit_code=" + e$ + ";" - l$ = l$ + sp + l2$ - END IF - xend - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - - IF firstelement$ = "SYSTEM" THEN - l$ = SCase$("System") - IF n > 1 THEN - e$ = getelements$(ca$, 2, n) - e$ = fixoperationorder$(e$): IF Error_Happened THEN GOTO errmes - l2$ = tlayout$ - e$ = evaluatetotyp(e$, ISINTEGER64): IF Error_Happened THEN GOTO errmes - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - inclinenump$ = "," + str2$(inclinenumber(inclevel)) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) - END IF - IF vWatchOn = 1 AND NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" - PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors) - PRINT #12, "exit_code=" + e$ + ";" - l$ = l$ + sp + l2$ - END IF - - - IF vWatchOn = 1 THEN - IF inclinenumber(inclevel) = 0 THEN - vWatchAddLabel linenumber, 0 - END IF - PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - PRINT #12, "if (sub_gl_called) error(271);" - PRINT #12, "close_program=1;" - PRINT #12, "end();" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - - IF n >= 1 THEN - IF firstelement$ = "STOP" THEN - l$ = SCase$("Stop") - IF n > 1 THEN - e$ = getelements$(ca$, 2, n) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Stop") + sp + tlayout$ - e$ = evaluatetotyp(e$, 64) - IF Error_Happened THEN GOTO errmes - 'note: this value is currently ignored but evaluated for checking reasons - END IF - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - IF vWatchOn = 1 AND NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - vWatchAddLabel linenumber, 0 - ELSE - PRINT #12, "close_program=1;" - PRINT #12, "end();" - END IF - GOTO finishedline - END IF - END IF - - IF n = 2 THEN - IF firstelement$ = "GOSUB" THEN - xgosub ca$ - IF Error_Happened THEN GOTO errmes - 'note: layout implemented in xgosub - GOTO finishedline - END IF - END IF - - IF n >= 1 THEN - IF firstelement$ = "RETURN" THEN - IF n = 1 THEN - PRINT #12, "#include " + CHR$(34) + "ret" + str2$(subfuncn) + ".txt" + CHR$(34) - l$ = SCase$("Return") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - ELSE - 'label/linenumber follows - IF subfuncn <> 0 THEN a$ = "RETURN linelabel/linenumber invalid within a SUB/FUNCTION": GOTO errmes - IF n > 2 THEN a$ = "Expected linelabel/linenumber after RETURN": GOTO errmes - PRINT #12, "if (!next_return_point) error(3);" 'check return point available - PRINT #12, "next_return_point--;" 'destroy return point - a2$ = getelement$(ca$, 2) - IF validlabel(a2$) = 0 THEN a$ = "Invalid label!": GOTO errmes - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk505: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk505 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - Labels(r).Error_Line = linenumber - END IF 'x - - PRINT #12, "goto LABEL_" + a2$ + ";" - l$ = SCase$("Return") + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - END IF - - IF n >= 1 THEN - IF firstelement$ = "RESUME" THEN - l$ = SCase$("Resume") - IF n = 1 THEN - resumeprev: - - - PRINT #12, "if (!error_handling){error(20);}else{error_retry=1; qbevent=1; error_handling=0; error_err=0; return;}" - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - IF n > 2 THEN a$ = "Too many parameters": GOTO errmes - s$ = getelement$(ca$, 2) - IF UCASE$(s$) = "NEXT" THEN - - - PRINT #12, "if (!error_handling){error(20);}else{error_handling=0; error_err=0; return;}" - - l$ = l$ + sp + SCase$("Next") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - IF s$ = "0" THEN l$ = l$ + sp + "0": GOTO resumeprev - IF validlabel(s$) = 0 THEN a$ = "Invalid label passed to RESUME": GOTO errmes - - v = HashFind(s$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk506: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk506 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd s$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - Labels(r).Error_Line = linenumber - END IF 'x - - l$ = l$ + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - PRINT #12, "if (!error_handling){error(20);}else{error_handling=0; error_err=0; goto LABEL_" + s$ + ";}" - GOTO finishedline - END IF - END IF - - IF n = 4 THEN - IF getelements(a$, 1, 3) = "ON" + sp + "ERROR" + sp + "GOTO" THEN - l$ = SCase$("On" + sp + "Error" + sp + "GoTo") - lbl$ = getelement$(ca$, 4) - IF lbl$ = "0" THEN - PRINT #12, "error_goto_line=0;" - l$ = l$ + sp + "0" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - IF validlabel(lbl$) = 0 THEN a$ = "Invalid label": GOTO errmes - - v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk6: - IF v THEN - s = Labels(r).Scope - IF s = 0 OR s = -1 THEN 'main scope? - IF s = -1 THEN Labels(r).Scope = 0 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Scope_Restriction = subfuncn - Labels(r).Error_Line = linenumber - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk6 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd lbl$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = 0 - Labels(r).Error_Line = linenumber - Labels(r).Scope_Restriction = subfuncn - END IF 'x - - - l$ = l$ + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - errorlabels = errorlabels + 1 - PRINT #12, "error_goto_line=" + str2(errorlabels) + ";" - PRINT #14, "if (error_goto_line==" + str2(errorlabels) + "){error_handling=1; goto LABEL_" + lbl$ + ";}" - GOTO finishedline - END IF - END IF - - IF n >= 1 THEN - IF firstelement$ = "RESTORE" THEN - l$ = SCase$("Restore") - IF n = 1 THEN - PRINT #12, "data_offset=0;" - ELSE - IF n > 2 THEN a$ = "Syntax error - too many parameters (expected RESTORE label/line number)": GOTO errmes - lbl$ = getelement$(ca$, 2) - IF validlabel(lbl$) = 0 THEN a$ = "Invalid label": GOTO errmes - - 'rule: a RESTORE label has no scope, therefore, only one instance of that label may exist - 'how: enforced by a post check for duplicates - v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) - x = 1 - IF v THEN 'already defined - x = 0 - tlayout$ = RTRIM$(Labels(r).cn) - Labels(r).Data_Referenced = 1 'make sure the data referenced flag is set - IF Labels(r).Error_Line = 0 THEN Labels(r).Error_Line = linenumber - END IF - IF x THEN - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd lbl$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = -1 'modifyable scope - Labels(r).Error_Line = linenumber - Labels(r).Data_Referenced = 1 - END IF 'x - - l$ = l$ + sp + tlayout$ - PRINT #12, "data_offset=data_at_LABEL_" + lbl$ + ";" - END IF - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - - - - 'ON ... GOTO/GOSUB - IF n >= 1 THEN - IF firstelement$ = "ON" THEN - xongotogosub a$, ca$, n - IF Error_Happened THEN GOTO errmes - GOTO finishedline - END IF - END IF - - - '(_MEM) _MEMPUT _MEMGET - IF n >= 1 THEN - IF firstelement$ = "_MEMGET" OR (firstelement$ = "MEMGET" AND qb64prefix_set = 1) THEN - 'get expressions - e$ = "" - B = 0 - ne = 0 - FOR i2 = 2 TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN - ne = ne + 1 - IF ne = 1 THEN blk$ = e$: e$ = "" - IF ne = 2 THEN offs$ = e$: e$ = "" - IF ne = 3 THEN a$ = "Syntax error - too many parameters (Expected " + qb64prefix$ + "MEMGET mem-reference, offset, variable)": GOTO errmes - ELSE - IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - END IF - NEXT - var$ = e$ - IF e$ = "" OR ne <> 2 THEN a$ = "Expected " + qb64prefix$ + "MEMGET mem-reference, offset, variable": GOTO errmes - - IF firstelement$ = "_MEMGET" THEN l$ = SCase$("_MemGet") + sp ELSE l$ = SCase$("MemGet") + sp - - e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - - test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes - IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes - blkoffs$ = evaluatetotyp(e$, -6) - - ' IF typ AND ISREFERENCE THEN e$ = refer(e$, typ, 0) - - - 'PRINT #12, blkoffs$ '??? - - e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes - offs$ = e$ - 'PRINT #12, e$ '??? - - e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes - varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes - - - 'PRINT #12, varoffs$ '??? - 'PRINT #12, varsize$ '??? - - 'what do we do next - 'need to know offset of variable and its size - - 'known sizes will be handled by designated command casts, otherwise use memmove - s = 0 - IF varsize$ = "1" THEN s = 1: st$ = "int8" - IF varsize$ = "2" THEN s = 2: st$ = "int16" - IF varsize$ = "4" THEN s = 4: st$ = "int32" - IF varsize$ = "8" THEN s = 8: st$ = "int64" - - IF NoChecks THEN - 'fast version: - IF s THEN - PRINT #12, "*(" + st$ + "*)" + varoffs$ + "=*(" + st$ + "*)(" + offs$ + ");" - ELSE - PRINT #12, "memmove(" + varoffs$ + ",(void*)" + offs$ + "," + varsize$ + ");" - END IF - ELSE - 'safe version: - PRINT #12, "tmp_long=" + offs$ + ";" - 'is mem block init? - PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" - 'are region and id valid? - PRINT #12, "if (" - PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" - PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" - PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" - 'diagnose error - PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" - PRINT #12, "}else{" - IF s THEN - PRINT #12, "*(" + st$ + "*)" + varoffs$ + "=*(" + st$ + "*)tmp_long;" - ELSE - PRINT #12, "memmove(" + varoffs$ + ",(void*)tmp_long," + varsize$ + ");" - END IF - PRINT #12, "}" - PRINT #12, "}else error(309);" - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - - END IF - END IF - - - - - IF n >= 1 THEN - IF firstelement$ = "_MEMPUT" OR (firstelement$ = "MEMPUT" AND qb64prefix_set = 1) THEN - 'get expressions - typ$ = "" - e$ = "" - B = 0 - ne = 0 - FOR i2 = 2 TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF (e2$ = "," OR UCASE$(e2$) = "AS") AND B = 0 THEN - ne = ne + 1 - IF ne = 1 THEN blk$ = e$: e$ = "" - IF ne = 2 THEN offs$ = e$: e$ = "" - IF ne = 3 THEN var$ = e$: e$ = "" - IF (UCASE$(e2$) = "AS" AND ne <> 3) OR (ne = 3 AND UCASE$(e2$) <> "AS") OR ne = 4 THEN a$ = "Expected _MEMPUT mem-reference,offset,variable|value[AS type]": GOTO errmes - ELSE - IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - END IF - NEXT - IF ne < 2 OR e$ = "" THEN a$ = "Expected " + qb64prefix$ + "MEMPUT mem-reference, offset, variable|value[AS type]": GOTO errmes - IF ne = 2 THEN var$ = e$ ELSE typ$ = UCASE$(e$) - - IF firstelement$ = "_MEMPUT" THEN l$ = SCase$("_MemPut") + sp ELSE l$ = SCase$("MemPut") + sp - - e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - - test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes - IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes - blkoffs$ = evaluatetotyp(e$, -6) - - e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes - offs$ = e$ - - IF ne = 2 THEN - e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - - test$ = evaluate(e$, t): IF Error_Happened THEN GOTO errmes - IF (t AND ISREFERENCE) = 0 AND (t AND ISSTRING) THEN - PRINT #12, "g_tmp_str=" + test$ + ";" - varsize$ = "g_tmp_str->len" - varoffs$ = "g_tmp_str->chr" - ELSE - varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes - varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes - END IF - - 'known sizes will be handled by designated command casts, otherwise use memmove - s = 0 - IF varsize$ = "1" THEN s = 1: st$ = "int8" - IF varsize$ = "2" THEN s = 2: st$ = "int16" - IF varsize$ = "4" THEN s = 4: st$ = "int32" - IF varsize$ = "8" THEN s = 8: st$ = "int64" - - IF NoChecks THEN - 'fast version: - IF s THEN - PRINT #12, "*(" + st$ + "*)(" + offs$ + ")=*(" + st$ + "*)" + varoffs$ + ";" - ELSE - PRINT #12, "memmove((void*)" + offs$ + "," + varoffs$ + "," + varsize$ + ");" - END IF - ELSE - 'safe version: - PRINT #12, "tmp_long=" + offs$ + ";" - 'is mem block init? - PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" - 'are region and id valid? - PRINT #12, "if (" - PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" - PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" - PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" - 'diagnose error - PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" - PRINT #12, "}else{" - IF s THEN - PRINT #12, "*(" + st$ + "*)tmp_long=*(" + st$ + "*)" + varoffs$ + ";" - ELSE - PRINT #12, "memmove((void*)tmp_long," + varoffs$ + "," + varsize$ + ");" - END IF - PRINT #12, "}" - PRINT #12, "}else error(309);" - END IF - - ELSE - - '... AS type method - 'FUNCTION typname2typ& (t2$) - 'typname2typsize = 0 'the default - t = typname2typ(typ$) - IF t = 0 THEN a$ = "Invalid type": GOTO errmes - IF (t AND ISOFFSETINBITS) <> 0 OR (t AND ISUDT) <> 0 OR (t AND ISSTRING) THEN a$ = qb64prefix$ + "MEMPUT requires numeric type": GOTO errmes - IF (t AND ISPOINTER) THEN t = t - ISPOINTER - 'attempt conversion... - e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ + sp + SCase$("As") + sp + typ$ - e$ = evaluatetotyp(e$, t): IF Error_Happened THEN GOTO errmes - st$ = typ2ctyp$(t, "") - varsize$ = str2((t AND 511) \ 8) - IF NoChecks THEN - 'fast version: - PRINT #12, "*(" + st$ + "*)(" + offs$ + ")=" + e$ + ";" - ELSE - 'safe version: - PRINT #12, "tmp_long=" + offs$ + ";" - 'is mem block init? - PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" - 'are region and id valid? - PRINT #12, "if (" - PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" - PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" - PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" - 'diagnose error - PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" - PRINT #12, "}else{" - PRINT #12, "*(" + st$ + "*)tmp_long=" + e$ + ";" - PRINT #12, "}" - PRINT #12, "}else error(309);" - END IF - - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - - END IF - END IF - - - - - - IF n >= 1 THEN - IF firstelement$ = "_MEMFILL" OR (firstelement$ = "MEMFILL" AND qb64prefix_set = 1) THEN - 'get expressions - typ$ = "" - e$ = "" - B = 0 - ne = 0 - FOR i2 = 2 TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF (e2$ = "," OR UCASE$(e2$) = "AS") AND B = 0 THEN - ne = ne + 1 - IF ne = 1 THEN blk$ = e$: e$ = "" - IF ne = 2 THEN offs$ = e$: e$ = "" - IF ne = 3 THEN bytes$ = e$: e$ = "" - IF ne = 4 THEN var$ = e$: e$ = "" - IF (UCASE$(e2$) = "AS" AND ne <> 4) OR (ne = 4 AND UCASE$(e2$) <> "AS") OR ne = 5 THEN a$ = "Expected _MEMFILL mem-reference,offset,bytes,variable|value[AS type]": GOTO errmes - ELSE - IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - END IF - NEXT - IF ne < 3 OR e$ = "" THEN a$ = "Expected " + qb64prefix$ + "MEMFILL mem-reference, offset, bytes, variable|value[AS type]": GOTO errmes - IF ne = 3 THEN var$ = e$ ELSE typ$ = UCASE$(e$) - - IF firstelement$ = "_MEMFILL" THEN l$ = SCase$("_MemFill") + sp ELSE l$ = SCase$("MemFill") + sp - - e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - - test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes - IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes - blkoffs$ = evaluatetotyp(e$, -6) - - e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes - offs$ = e$ - - e$ = fixoperationorder$(bytes$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes - bytes$ = e$ - - IF ne = 3 THEN 'no AS - e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - test$ = evaluate(e$, t) - IF (t AND ISREFERENCE) = 0 AND (t AND ISSTRING) THEN - PRINT #12, "tmp_long=(ptrszint)" + test$ + ";" - varsize$ = "((qbs*)tmp_long)->len" - varoffs$ = "((qbs*)tmp_long)->chr" - ELSE - varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes - varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes - END IF - - IF NoChecks THEN - PRINT #12, "sub__memfill_nochecks(" + offs$ + "," + bytes$ + ",(ptrszint)" + varoffs$ + "," + varsize$ + ");" - ELSE - PRINT #12, "sub__memfill((mem_block*)" + blkoffs$ + "," + offs$ + "," + bytes$ + ",(ptrszint)" + varoffs$ + "," + varsize$ + ");" - END IF - - ELSE - - '... AS type method - t = typname2typ(typ$) - IF t = 0 THEN a$ = "Invalid type": GOTO errmes - IF (t AND ISOFFSETINBITS) <> 0 OR (t AND ISUDT) <> 0 OR (t AND ISSTRING) THEN a$ = qb64prefix$ + "MEMFILL requires numeric type": GOTO errmes - IF (t AND ISPOINTER) THEN t = t - ISPOINTER - 'attempt conversion... - e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ + sp + SCase$("As") + sp + typ$ - e$ = evaluatetotyp(e$, t): IF Error_Happened THEN GOTO errmes - - c$ = "sub__memfill_" - IF NoChecks THEN c$ = "sub__memfill_nochecks_" - IF t AND ISOFFSET THEN - c$ = c$ + "OFFSET" - ELSE - IF t AND ISFLOAT THEN - IF (t AND 511) = 32 THEN c$ = c$ + "SINGLE" - IF (t AND 511) = 64 THEN c$ = c$ + "DOUBLE" - IF (t AND 511) = 256 THEN c$ = c$ + "FLOAT" 'padded variable - ELSE - c$ = c$ + str2((t AND 511) \ 8) - END IF - END IF - c$ = c$ + "(" - IF NoChecks = 0 THEN c$ = c$ + "(mem_block*)" + blkoffs$ + "," - PRINT #12, c$ + offs$ + "," + bytes$ + "," + e$ + ");" - END IF - - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - - END IF - END IF - - - - - - - - - - - - - - 'note: ABSOLUTE cannot be used without CALL - cispecial = 0 - IF n > 1 THEN - IF firstelement$ = "INTERRUPT" OR firstelement$ = "INTERRUPTX" THEN - a$ = "CALL" + sp + firstelement$ + sp + "(" + sp + getelements$(a$, 2, n) + sp + ")" - ca$ = "CALL" + sp + firstelement$ + sp + "(" + sp + getelements$(ca$, 2, n) + sp + ")" - n = n + 3 - firstelement$ = "CALL" - cispecial = 1 - 'fall through - END IF - END IF - - usecall = 0 - IF firstelement$ = "CALL" THEN - usecall = 1 - IF n = 1 THEN a$ = "Expected CALL sub-name [(...)]": GOTO errmes - cn$ = getelement$(ca$, 2): n$ = UCASE$(cn$) - - IF n > 2 THEN - - IF n <= 4 THEN a$ = "Expected CALL sub-name (...)": GOTO errmes - IF getelement$(a$, 3) <> "(" OR getelement$(a$, n) <> ")" THEN a$ = "Expected CALL sub-name (...)": GOTO errmes - a$ = n$ + sp + getelements$(a$, 4, n - 1) - ca$ = cn$ + sp + getelements$(ca$, 4, n - 1) - - - IF n$ = "INTERRUPT" OR n$ = "INTERRUPTX" THEN 'assume CALL INTERRUPT[X] request - 'print "CI: call interrupt command reached":sleep 1 - IF n$ = "INTERRUPT" THEN PRINT #12, "call_interrupt("; ELSE PRINT #12, "call_interruptx("; - argn = 0 - n = numelements(a$) - B = 0 - e$ = "" - FOR i = 2 TO n - e2$ = getelement$(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF (e2$ = "," AND B = 0) OR i = n THEN - IF i = n THEN - IF e$ = "" THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - END IF - argn = argn + 1 - IF argn = 1 THEN 'interrupt number - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = SCase$("Call") + sp + n$ + sp2 + "(" + sp2 + tlayout$ - IF cispecial = 1 THEN l$ = n$ + sp + tlayout$ - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN GOTO errmes - 'print "CI: evaluated interrupt number as ["+e$+"]":sleep 1 - PRINT #12, e$; - END IF - IF argn = 2 OR argn = 3 THEN 'inregs, outregs - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e2$ = e$ - e$ = evaluatetotyp(e$, -2) 'offset+size - IF Error_Happened THEN GOTO errmes - 'print "CI: evaluated in/out regs ["+e2$+"] as ["+e$+"]":sleep 1 - PRINT #12, "," + e$; - END IF - e$ = "" - ELSE - IF e$ = "" THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ - END IF - NEXT - IF argn <> 3 THEN a$ = "Expected CALL INTERRUPT (interrupt-no, inregs, outregs)": GOTO errmes - PRINT #12, ");" - IF cispecial = 0 THEN l$ = l$ + sp2 + ")" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - 'print "CI: done":sleep 1 - GOTO finishedline - END IF 'call interrupt - - - - - - - - - 'call to CALL ABSOLUTE beyond reasonable doubt - IF n$ = "ABSOLUTE" THEN - l$ = SCase$("Call" + sp + "Absolute" + sp2 + "(" + sp2) - argn = 0 - n = numelements(a$) - B = 0 - e$ = "" - FOR i = 2 TO n - e2$ = getelement$(ca$, i) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF (e2$ = "," AND B = 0) OR i = n THEN - IF i < n THEN - IF e$ = "" THEN a$ = "Expected expression before , or )": GOTO errmes - '1. variable or value? - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + "," + sp - ignore$ = evaluate(e$, typ) - IF Error_Happened THEN GOTO errmes - - IF (typ AND ISPOINTER) <> 0 AND (typ AND ISREFERENCE) <> 0 THEN - - 'assume standard variable - 'assume not string/array/udt/etc - e$ = "VARPTR" + sp + "(" + sp + e$ + sp + ")" - e$ = evaluatetotyp(e$, UINTEGERTYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - - ELSE - - 'assume not string - 'single, double or integer64? - IF typ AND ISFLOAT THEN - IF (typ AND 511) = 32 THEN - e$ = evaluatetotyp(e$, SINGLETYPE - ISPOINTER) - IF Error_Happened THEN GOTO errmes - v$ = "pass" + str2$(uniquenumber) - PRINT #defdatahandle, "float *" + v$ + "=NULL;" - PRINT #13, "if(" + v$ + "==NULL){" - PRINT #13, "cmem_sp-=4;" - PRINT #13, v$ + "=(float*)(dblock+cmem_sp);" - PRINT #13, "if (cmem_sp2 - - a$ = n$ - ca$ = cn$ - usecall = 2 - - END IF 'n>2 - - n = numelements(a$) - firstelement$ = getelement$(a$, 1) - - 'valid SUB name - validsub = 0 - findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) - try = findid(firstelement$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = 2 THEN validsub = 1: EXIT DO - IF try = 2 THEN - findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) - findanotherid = 1 - try = findid(firstelement$) - IF Error_Happened THEN GOTO errmes - ELSE - try = 0 - END IF - LOOP - IF validsub = 0 THEN a$ = "Expected CALL sub-name [(...)]": GOTO errmes - END IF - - 'sub? - IF n >= 1 THEN - - IF firstelement$ = "?" THEN firstelement$ = "PRINT" - - findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) - try = findid(firstelement$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.subfunc = 2 THEN - - 'check symbol - s$ = removesymbol$(firstelement$ + "") - IF Error_Happened THEN GOTO errmes - IF ASC(id.musthave) = 36 THEN '="$" - IF s$ <> "$" THEN GOTO notsubcall 'missing musthave "$" - ELSE - IF LEN(s$) THEN GOTO notsubcall 'unrequired symbol added - END IF - 'check for variable assignment - IF n > 1 THEN - IF ASC(id.specialformat) <> 61 THEN '<>"=" - IF ASC(getelement$(a$, 2)) = 61 THEN GOTO notsubcall 'assignment, not sub call - END IF - END IF - 'check for array assignment - IF n > 2 THEN - IF firstelement$ <> "PRINT" AND firstelement$ <> "LPRINT" THEN - IF getelement$(a$, 2) = "(" THEN - B = 1 - FOR i = 3 TO n - e$ = getelement$(a$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN - B = B - 1 - IF B = 0 THEN - IF i = n THEN EXIT FOR - IF getelement$(a$, i + 1) = "=" THEN GOTO notsubcall - END IF - END IF - NEXT - END IF - END IF - END IF - - - 'generate error on driect _GL call - IF firstelement$ = "_GL" THEN - a$ = "Cannot call SUB _GL directly": GOTO errmes - END IF - - IF firstelement$ = "VWATCH" THEN - a$ = "Cannot call SUB VWATCH directly": GOTO errmes - END IF - - IF firstelement$ = "OPEN" THEN - 'gwbasic or qbasic version? - B = 0 - FOR x = 2 TO n - a2$ = getelement$(a$, x) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF a2$ = "FOR" OR a2$ = "AS" THEN EXIT FOR 'qb style open verified - IF B = 0 AND a2$ = "," THEN 'the gwbasic version includes a comma after the first string expression - findanotherid = 1 - try = findid(firstelement$) 'id of sub_open_gwbasic - IF Error_Happened THEN GOTO errmes - EXIT FOR - END IF - NEXT - END IF - - - 'IF findid(firstelement$) THEN - 'IF id.subfunc = 2 THEN - - - IF firstelement$ = "CLOSE" OR firstelement$ = "RESET" THEN - IF firstelement$ = "RESET" THEN - IF n > 1 THEN a$ = "Syntax error - RESET takes no parameters": GOTO errmes - l$ = SCase$("Reset") - ELSE - l$ = SCase$("Close") - END IF - - IF n = 1 THEN - PRINT #12, "sub_close(NULL,0);" 'closes all files - ELSE - l$ = l$ + sp - B = 0 - s = 0 - a3$ = "" - FOR x = 2 TO n - a2$ = getelement$(ca$, x) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF a2$ = "#" AND B = 0 THEN - IF s = 0 THEN s = 1 ELSE a$ = "Unexpected #": GOTO errmes - l$ = l$ + "#" + sp2 - GOTO closenexta - END IF - - IF a2$ = "," AND B = 0 THEN - IF s = 2 THEN - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ + sp2 + "," + sp - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_close(" + e$ + ",1);" - a3$ = "" - s = 0 - GOTO closenexta - ELSE - a$ = "Expected expression before ,": GOTO errmes - END IF - END IF - - s = 2 - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - - closenexta: - NEXT - - IF s = 2 THEN - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + tlayout$ - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_close(" + e$ + ",1);" - ELSE - l$ = LEFT$(l$, LEN(l$) - 1) - END IF - - END IF - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF 'close - - - - - - - - - - - - - - - - - 'data, restore, read - IF firstelement$ = "READ" THEN 'file input - xread ca$, n - IF Error_Happened THEN GOTO errmes - 'note: layout done in xread sub - GOTO finishedline - END IF 'read - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - lineinput = 0 - IF n >= 2 THEN - IF firstelement$ = "LINE" AND secondelement$ = "INPUT" THEN - lineinput = 1 - a$ = RIGHT$(a$, LEN(a$) - 5): ca$ = RIGHT$(ca$, LEN(ca$) - 5): n = n - 1 'remove "LINE" - firstelement$ = "INPUT" - END IF - END IF - - IF firstelement$ = "INPUT" THEN 'file input - IF n > 1 THEN - IF getelement$(a$, 2) = "#" THEN - l$ = SCase$("Input") + sp + "#": IF lineinput THEN l$ = SCase$("Line") + sp + l$ - - u$ = str2$(uniquenumber) - 'which file? - IF n = 2 THEN a$ = "Expected # ... , ...": GOTO errmes - a3$ = "" - B = 0 - FOR i = 3 TO n - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF a2$ = "," AND B = 0 THEN - IF a3$ = "" THEN a$ = "Expected # ... , ...": GOTO errmes - GOTO inputgotfn - END IF - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - NEXT - inputgotfn: - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + tlayout$ - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN GOTO errmes - PRINT #12, "tmp_fileno=" + e$ + ";" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - i = i + 1 - IF i > n THEN a$ = "Expected , ...": GOTO errmes - a3$ = "" - B = 0 - FOR i = i TO n - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF i = n THEN - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - a2$ = ",": B = 0 - END IF - IF a2$ = "," AND B = 0 THEN - IF a3$ = "" THEN a$ = "Expected , ...": GOTO errmes - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp2 + "," + sp + tlayout$ - e$ = evaluate(e$, t) - IF Error_Happened THEN GOTO errmes - IF (t AND ISREFERENCE) = 0 THEN a$ = "Expected variable-name": GOTO errmes - IF (t AND ISSTRING) THEN - e$ = refer(e$, t, 0) - IF Error_Happened THEN GOTO errmes - IF lineinput THEN - PRINT #12, "sub_file_line_input_string(tmp_fileno," + e$ + ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - ELSE - PRINT #12, "sub_file_input_string(tmp_fileno," + e$ + ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - END IF - stringprocessinghappened = 1 - ELSE - IF lineinput THEN a$ = "Expected string-variable": GOTO errmes - - 'numeric variable - IF (t AND ISFLOAT) <> 0 OR (t AND 511) <> 64 THEN - IF (t AND ISOFFSETINBITS) THEN - setrefer e$, t, "((int64)func_file_input_float(tmp_fileno," + str2(t) + "))", 1 - IF Error_Happened THEN GOTO errmes - ELSE - setrefer e$, t, "func_file_input_float(tmp_fileno," + str2(t) + ")", 1 - IF Error_Happened THEN GOTO errmes - END IF - ELSE - IF t AND ISUNSIGNED THEN - setrefer e$, t, "func_file_input_uint64(tmp_fileno)", 1 - IF Error_Happened THEN GOTO errmes - ELSE - setrefer e$, t, "func_file_input_int64(tmp_fileno)", 1 - IF Error_Happened THEN GOTO errmes - END IF - END IF - - PRINT #12, "if (new_error) goto skip" + u$ + ";" - - END IF - IF i = n THEN EXIT FOR - IF lineinput THEN a$ = "Too many variables": GOTO errmes - a3$ = "": a2$ = "" - END IF - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - NEXT - PRINT #12, "skip" + u$ + ":" - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - END IF - END IF 'input# - - - IF firstelement$ = "INPUT" THEN - l$ = SCase$("Input"): IF lineinput THEN l$ = SCase$("Line") + sp + l$ - commaneeded = 0 - i = 2 - - newline = 1: IF getelement$(a$, i) = ";" THEN newline = 0: i = i + 1: l$ = l$ + sp + ";" - - a2$ = getelement$(ca$, i) - IF LEFT$(a2$, 1) = CHR$(34) THEN - e$ = fixoperationorder$(a2$): l$ = l$ + sp + tlayout$ - IF Error_Happened THEN GOTO errmes - PRINT #12, "qbs_print(qbs_new_txt_len(" + a2$ + "),0);" - i = i + 1 - 'MUST be followed by a ; or , - a2$ = getelement$(ca$, i) - i = i + 1 - l$ = l$ + sp2 + a2$ - IF a2$ = ";" THEN - IF lineinput THEN GOTO finishedpromptstring - PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "? " + CHR$(34) + "),0);" - GOTO finishedpromptstring - END IF - IF a2$ = "," THEN - GOTO finishedpromptstring - END IF - a$ = "Syntax error - Reference: INPUT [;] " + CHR$(34) + "[Question or statement text]" + CHR$(34) + "{,|;} variable[, ...] or INPUT ; variable[, ...]": GOTO errmes - END IF - 'there was no promptstring, so print a ? - IF lineinput = 0 THEN PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "? " + CHR$(34) + "),0);" - finishedpromptstring: - numvar = 0 - FOR i = i TO n - IF commaneeded = 1 THEN - a2$ = getelement$(ca$, i) - IF a2$ <> "," THEN a$ = "Syntax error - comma expected": GOTO errmes - ELSE - - B = 0 - e$ = "" - FOR i2 = i TO n - e2$ = getelement$(ca$, i2) - IF e2$ = "(" THEN B = B + 1 - IF e2$ = ")" THEN B = B - 1 - IF e2$ = "," AND B = 0 THEN i2 = i2 - 1: EXIT FOR - e$ = e$ + sp + e2$ - NEXT - i = i2: IF i > n THEN i = n - IF e$ = "" THEN a$ = "Expected variable": GOTO errmes - e$ = RIGHT$(e$, LEN(e$) - 1) - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$: IF i <> n THEN l$ = l$ + sp2 + "," - e$ = evaluate(e$, t) - IF Error_Happened THEN GOTO errmes - IF (t AND ISREFERENCE) = 0 THEN a$ = "Expected variable": GOTO errmes - - IF (t AND ISSTRING) THEN - e$ = refer(e$, t, 0) - IF Error_Happened THEN GOTO errmes - numvar = numvar + 1 - IF lineinput THEN - PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=ISSTRING+512;" - ELSE - PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=ISSTRING;" - END IF - PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + e$ + ";" - GOTO gotinputvar - END IF - - IF lineinput THEN a$ = "Expected string variable": GOTO errmes - IF (t AND ISARRAY) THEN - IF (t AND ISOFFSETINBITS) THEN - a$ = "INPUT cannot handle BIT array elements": GOTO errmes - END IF - END IF - e$ = "&(" + refer(e$, t, 0) + ")" - IF Error_Happened THEN GOTO errmes - - 'remove assumed/unnecessary flags - IF (t AND ISPOINTER) THEN t = t - ISPOINTER - IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY - IF (t AND ISREFERENCE) THEN t = t - ISREFERENCE - - 'IF (t AND ISOFFSETINBITS) THEN - 'numvar = numvar + 1 - 'consider storing the bit offset in unused bits of t - 'PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=" + str2(t) + ";" - 'PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + refer(ref$, typ, 1) + ";" - 'GOTO gotinputvar - 'END IF - - 'assume it is a regular variable - numvar = numvar + 1 - PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=" + str2$(t) + ";" - PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + e$ + ";" - GOTO gotinputvar - - END IF - gotinputvar: - commaneeded = commaneeded + 1: IF commaneeded = 2 THEN commaneeded = 0 - NEXT - IF numvar = 0 THEN a$ = "Syntax error - Reference: INPUT [;] " + CHR$(34) + "[Question or statement text]" + CHR$(34) + "{,|;} variable[, ...] or INPUT ; variable[, ...]": GOTO errmes - IF lineinput = 1 AND numvar > 1 THEN a$ = "Too many variables": GOTO errmes - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - PRINT #12, "qbs_input(" + str2(numvar) + "," + str2$(newline) + ");" - PRINT #12, "if (stop_program) end();" - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - PRINT #12, cleanupstringprocessingcall$ + "0);" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - - - - IF firstelement$ = "WRITE" THEN 'file write - IF n > 1 THEN - IF getelement$(a$, 2) = "#" THEN - xfilewrite ca$, n - IF Error_Happened THEN GOTO errmes - GOTO finishedline - END IF '# - END IF 'n>1 - END IF '"write" - - IF firstelement$ = "WRITE" THEN 'write - xwrite ca$, n - IF Error_Happened THEN GOTO errmes - GOTO finishedline - END IF '"write" - - IF firstelement$ = "PRINT" THEN 'file print - IF n > 1 THEN - IF getelement$(a$, 2) = "#" THEN - xfileprint a$, ca$, n - IF Error_Happened THEN GOTO errmes - l$ = tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF '# - END IF 'n>1 - END IF '"print" - - IF firstelement$ = "PRINT" OR firstelement$ = "LPRINT" THEN - IF secondelement$ <> "USING" THEN 'check to see if we need to auto-add semicolons - elementon = 2 - redosemi: - FOR i = elementon TO n - 1 - nextchar$ = getelement$(a$, i + 1) - IF nextchar$ <> ";" AND nextchar$ <> "," AND nextchar$ <> "+" AND nextchar$ <> ")" THEN - temp1$ = getelement$(a$, i) - beginpoint = INSTR(beginpoint, temp1$, CHR$(34)) - endpoint = INSTR(beginpoint + 1, temp1$, CHR$(34) + ",") - IF beginpoint <> 0 AND endpoint <> 0 THEN 'if we have both positions - 'Quote without semicolon check (like PRINT "abc"123) - textlength = endpoint - beginpoint - 1 - textvalue$ = MID$(temp1$, endpoint + 2, LEN(LTRIM$(STR$(textlength)))) - IF VAL(textvalue$) = textlength THEN - insertelements a$, i, ";" - insertelements ca$, i, ";" - n = n + 1 - elementon = i + 2 'just a easy way to reduce redundant calls to the routine - GOTO redosemi - END IF - END IF - IF temp1$ <> "USING" THEN - IF LEFT$(LTRIM$(nextchar$), 1) = CHR$(34) THEN - IF temp1$ <> ";" AND temp1$ <> "," AND temp1$ <> "+" AND temp1$ <> "(" THEN - insertelements a$, i, ";" - insertelements ca$, i, ";" - n = n + 1 - elementon = i + 2 'just a easy way to reduce redundant calls to the routine - GOTO redosemi - END IF - END IF - END IF - END IF - NEXT - END IF - - xprint a$, ca$, n - IF Error_Happened THEN GOTO errmes - l$ = tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - END IF - - - - IF firstelement$ = "CLEAR" THEN - IF subfunc$ <> "" THEN a$ = "CLEAR cannot be used inside a SUB/FUNCTION": GOTO errmes - END IF - - 'LSET/RSET - IF firstelement$ = "LSET" OR firstelement$ = "RSET" THEN - IF n = 1 THEN a$ = "Expected " + firstelement$ + " ...": GOTO errmes - IF firstelement$ = "LSET" THEN l$ = SCase$("LSet") ELSE l$ = SCase$("RSet") - dest$ = "" - source$ = "" - part = 1 - i = 2 - a3$ = "" - B = 0 - DO - IF i > n THEN - IF part <> 2 OR a3$ = "" THEN a$ = "Expected LSET/RSET stringvariable=string": GOTO errmes - source$ = a3$ - EXIT DO - END IF - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN B = B + 1 - IF a2$ = ")" THEN B = B - 1 - IF a2$ = "=" AND B = 0 THEN - IF part = 1 THEN dest$ = a3$: part = 2: a3$ = "": GOTO lrsetgotpart - END IF - IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ - lrsetgotpart: - i = i + 1 - LOOP - IF dest$ = "" THEN a$ = "Expected LSET/RSET stringvariable=string": GOTO errmes - 'check if it is a valid source string - f$ = fixoperationorder$(dest$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ + sp + "=" - e$ = evaluate(f$, sourcetyp) - IF Error_Happened THEN GOTO errmes - IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "LSET/RSET expects a string variable/array-element as its first argument": GOTO errmes - dest$ = evaluatetotyp(f$, ISSTRING) - IF Error_Happened THEN GOTO errmes - source$ = fixoperationorder$(source$) - IF Error_Happened THEN GOTO errmes - l$ = l$ + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - source$ = evaluatetotyp(source$, ISSTRING) - IF Error_Happened THEN GOTO errmes - IF firstelement$ = "LSET" THEN - PRINT #12, "sub_lset(" + dest$ + "," + source$ + ");" - ELSE - PRINT #12, "sub_rset(" + dest$ + "," + source$ + ");" - END IF - GOTO finishedline - END IF - - 'SWAP - IF firstelement$ = "SWAP" THEN - IF n < 4 THEN a$ = "Expected SWAP ... , ...": GOTO errmes - B = 0 - ele = 1 - e1$ = "" - e2$ = "" - FOR i = 2 TO n - e$ = getelement$(ca$, i) - IF e$ = "(" THEN B = B + 1 - IF e$ = ")" THEN B = B - 1 - IF e$ = "," AND B = 0 THEN - IF ele = 2 THEN a$ = "Expected SWAP ... , ...": GOTO errmes - ele = 2 - ELSE - IF ele = 1 THEN e1$ = e1$ + sp + e$ ELSE e2$ = e2$ + sp + e$ - END IF - NEXT - IF e2$ = "" THEN a$ = "Expected SWAP ... , ...": GOTO errmes - e1$ = RIGHT$(e1$, LEN(e1$) - 1): e2$ = RIGHT$(e2$, LEN(e2$) - 1) - - e1$ = fixoperationorder(e1$) - IF Error_Happened THEN GOTO errmes - e1l$ = tlayout$ - e2$ = fixoperationorder(e2$) - IF Error_Happened THEN GOTO errmes - e2l$ = tlayout$ - e1$ = evaluate(e1$, e1typ): e2$ = evaluate(e2$, e2typ) - IF Error_Happened THEN GOTO errmes - IF (e1typ AND ISREFERENCE) = 0 OR (e2typ AND ISREFERENCE) = 0 THEN a$ = "Expected variable": GOTO errmes - - layoutdone = 1 - l$ = SCase$("Swap") + sp + e1l$ + sp2 + "," + sp + e2l$ - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - - 'swap strings? - IF (e1typ AND ISSTRING) THEN - IF (e2typ AND ISSTRING) = 0 THEN a$ = "Type mismatch": GOTO errmes - e1$ = refer(e1$, e1typ, 0): e2$ = refer(e2$, e2typ, 0) - IF Error_Happened THEN GOTO errmes - PRINT #12, "swap_string(" + e1$ + "," + e2$ + ");" - GOTO finishedline - END IF - - 'swap UDT? - 'note: entire UDTs, unlike thier elements cannot be swapped like standard variables - ' as UDT sizes may vary, and to avoid a malloc operation, QB64 should allocate a buffer - ' in global.txt for the purpose of swapping each UDT type - - IF e1typ AND ISUDT THEN - a$ = e1$ - 'retrieve ID - i = INSTR(a$, sp3) - IF i THEN - idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) - getid idnumber - IF Error_Happened THEN GOTO errmes - u = VAL(a$) - i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) - i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) - n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" - IF E = 0 THEN 'not an element of UDT u - lhsscope$ = scope$ - e$ = e2$: t2 = e2typ - IF (t2 AND ISUDT) = 0 THEN a$ = "Expected SWAP with similar user defined type": GOTO errmes - idnumber2 = VAL(e$) - getid idnumber2 - IF Error_Happened THEN GOTO errmes - n2$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n2$ = "ARRAY_" + n2$ + "[0]" - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): u2 = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): e2 = VAL(e$) - - i = INSTR(e$, sp3): o2$ = RIGHT$(e$, LEN(e$) - i) - 'WARNING: u2 may need minor modifications based on e to see if they are the same - IF u <> u2 OR e2 <> 0 THEN a$ = "Expected SWAP with similar user defined type": GOTO errmes - dst$ = "(((char*)" + lhsscope$ + n$ + ")+(" + o$ + "))" - src$ = "(((char*)" + scope$ + n2$ + ")+(" + o2$ + "))" - B = udtxsize(u) \ 8 - siz$ = str2$(B) - IF B = 1 THEN PRINT #12, "swap_8(" + src$ + "," + dst$ + ");" - IF B = 2 THEN PRINT #12, "swap_16(" + src$ + "," + dst$ + ");" - IF B = 4 THEN PRINT #12, "swap_32(" + src$ + "," + dst$ + ");" - IF B = 8 THEN PRINT #12, "swap_64(" + src$ + "," + dst$ + ");" - IF B <> 1 AND B <> 2 AND B <> 4 AND B <> 8 THEN PRINT #12, "swap_block(" + src$ + "," + dst$ + "," + siz$ + ");" - GOTO finishedline - END IF 'e=0 - END IF 'i - END IF 'isudt - - 'cull irrelavent flags to make comparison possible - e1typc = e1typ - IF e1typc AND ISPOINTER THEN e1typc = e1typc - ISPOINTER - IF e1typc AND ISINCONVENTIONALMEMORY THEN e1typc = e1typc - ISINCONVENTIONALMEMORY - IF e1typc AND ISARRAY THEN e1typc = e1typc - ISARRAY - IF e1typc AND ISUNSIGNED THEN e1typc = e1typc - ISUNSIGNED - IF e1typc AND ISUDT THEN e1typc = e1typc - ISUDT - e2typc = e2typ - IF e2typc AND ISPOINTER THEN e2typc = e2typc - ISPOINTER - IF e2typc AND ISINCONVENTIONALMEMORY THEN e2typc = e2typc - ISINCONVENTIONALMEMORY - IF e2typc AND ISARRAY THEN e2typc = e2typc - ISARRAY - IF e2typc AND ISUNSIGNED THEN e2typc = e2typc - ISUNSIGNED - IF e2typc AND ISUDT THEN e2typc = e2typc - ISUDT - IF e1typc <> e2typc THEN a$ = "Type mismatch": GOTO errmes - t = e1typ - IF t AND ISOFFSETINBITS THEN a$ = "Cannot SWAP bit-length variables": GOTO errmes - B = t AND 511 - t$ = str2$(B): IF B > 64 THEN t$ = "longdouble" - PRINT #12, "swap_" + t$ + "(&" + refer(e1$, e1typ, 0) + ",&" + refer(e2$, e2typ, 0) + ");" - IF Error_Happened THEN GOTO errmes - GOTO finishedline - END IF - - IF firstelement$ = "OPTION" THEN - IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" - IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" - IF n = 1 THEN a$ = "Expected OPTION BASE" + e$: GOTO errmes - e$ = getelement$(a$, 2) - SELECT CASE e$ - CASE "BASE" - l$ = getelement$(a$, 3) - IF l$ <> "0" AND l$ <> "1" THEN a$ = "Expected OPTION BASE 0 or 1": GOTO errmes - IF l$ = "1" THEN optionbase = 1 ELSE optionbase = 0 - l$ = SCase$("Option" + sp + "Base") + sp + l$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - CASE "EXPLICIT", "_EXPLICIT" - IF e$ = "EXPLICIT" AND qb64prefix$ = "_" THEN - IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" - IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" - a$ = "Expected OPTION BASE" + e$: GOTO errmes - END IF - - opex_desiredState = -1 - IF optionexplicit = 0 THEN - IF opex_recompileAttempts = 0 THEN - opex_recompileAttempts = opex_recompileAttempts + 1 - GOTO do_recompile - END IF - END IF - - l$ = SCase$("Option") + sp - IF e$ = "EXPLICIT" THEN l$ = l$ + SCase$("Explicit") ELSE l$ = l$ + SCase$("_Explicit") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - CASE "EXPLICITARRAY", "_EXPLICITARRAY" - IF e$ = "EXPLICITARRAY" AND qb64prefix$ = "_" THEN - IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" - IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" - a$ = "Expected OPTION BASE" + e$: GOTO errmes - END IF - - opexarray_desiredState = -1 - IF optionexplicitarray = 0 THEN - IF opexarray_recompileAttempts = 0 THEN - opexarray_recompileAttempts = opexarray_recompileAttempts + 1 - GOTO do_recompile - END IF - END IF - - l$ = SCase$("Option") + sp - IF e$ = "EXPLICITARRAY" THEN l$ = l$ + SCase$("ExplicitArray") ELSE l$ = l$ + SCase$("_ExplicitArray") - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - GOTO finishedline - CASE ELSE - IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" - IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" - a$ = "Expected OPTION BASE" + e$: GOTO errmes - END SELECT - END IF - - 'any other "unique" subs can be processed above - - id2 = id - - targetid = currentid - - IF RTRIM$(id2.callname) = "sub_stub" THEN a$ = "Command not implemented": GOTO errmes - - IF n > 1 THEN - IF id2.args = 0 THEN a$ = "SUB does not require any arguments": GOTO errmes - END IF - - SetDependency id2.Dependency - - seperateargs_error = 0 - passedneeded = seperateargs(getelements(a$, 2, n), getelements(ca$, 2, n), passed&) - IF seperateargs_error THEN a$ = seperateargs_error_message: GOTO errmes - - 'backup args to local string array space before calling evaluate - FOR i = 1 TO OptMax: separgs2(i) = "": NEXT 'save space! - FOR i = 1 TO OptMax + 1: separgslayout2(i) = "": NEXT - FOR i = 1 TO id2.args: separgs2(i) = separgs(i): NEXT - FOR i = 1 TO id2.args + 1: separgslayout2(i) = separgslayout(i): NEXT - - - - IF Debug THEN - PRINT #9, "separgs:": FOR i = 1 TO id2.args: PRINT #9, i, separgs2(i): NEXT - PRINT #9, "separgslayout:": FOR i = 1 TO id2.args + 1: PRINT #9, i, separgslayout2(i): NEXT - END IF - - - - 'note: seperateargs finds the arguments to pass and sets passed& as necessary - ' FIXOPERTIONORDER is not called on these args yet - ' what we need it to do is build a second array of layout info at the same time - ' ref:DIM SHARED separgslayout(100) AS STRING - ' the above array stores what layout info (if any) goes BEFORE the arg in question - ' it has one extra index which is the arg after - - IF usecall THEN - IF id.internal_subfunc THEN - IF usecall = 1 THEN l$ = SCase$("Call") + sp + SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp2 + "(" + sp2 - IF usecall = 2 THEN l$ = SCase$("Call") + sp + SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp 'sp at end for easy parsing - ELSE - IF usecall = 1 THEN l$ = SCase$("Call") + sp + RTRIM$(id.cn) + RTRIM$(id.musthave) + sp2 + "(" + sp2 - IF usecall = 2 THEN l$ = SCase$("Call") + sp + RTRIM$(id.cn) + RTRIM$(id.musthave) + sp 'sp at end for easy parsing - END IF - ELSE - IF id.internal_subfunc THEN - l$ = SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp - ELSE - l$ = RTRIM$(id.cn) + RTRIM$(id.musthave) + sp - END IF - END IF - - subcall$ = RTRIM$(id.callname) + "(" - addedlayout = 0 - - fieldcall = 0 - 'GET/PUT field exception - IF RTRIM$(id2.callname) = "sub_get" OR RTRIM$(id2.callname) = "sub_put" THEN - IF passed AND 2 THEN - 'regular GET/PUT call with variable provided - passed = passed - 2 'for complience with existing methods, remove 'passed' flag for the passing of a variable - ELSE - 'FIELD GET/PUT call with variable omited - IF RTRIM$(id2.callname) = "sub_get" THEN - fieldcall = 1 - subcall$ = "field_get(" - ELSE - fieldcall = 2 - subcall$ = "field_put(" - END IF - END IF - END IF 'field exception - - IF RTRIM$(id2.callname) = "sub_timer" OR RTRIM$(id2.callname) = "sub_key" THEN 'spacing exception - IF usecall = 0 THEN - l$ = LEFT$(l$, LEN(l$) - 1) + sp2 - END IF - END IF - - FOR i = 1 TO id2.args - targettyp = CVL(MID$(id2.arg, -3 + i * 4, 4)) - nele = ASC(MID$(id2.nele, i, 1)) - nelereq = ASC(MID$(id2.nelereq, i, 1)) - - addlayout = 1 'omits option values in layout (eg. BINARY="2") - convertspacing = 0 'if an 'equation' is next, it will be preceeded by a space - x$ = separgslayout2$(i) - DO WHILE LEN(x$) - x = ASC(x$) - IF x THEN - convertspacing = 0 - x2$ = MID$(x$, 2, x) - x$ = RIGHT$(x$, LEN(x$) - x - 1) - - s = 0 - an = 0 - x3$ = RIGHT$(l$, 1) - IF x3$ = sp THEN s = 1 - IF x3$ = sp2 THEN - s = 2 - IF alphanumeric(ASC(RIGHT$(l$, 2))) THEN an = 1 - ELSE - IF alphanumeric(ASC(x3$)) THEN an = 1 - END IF - s1 = s - - IF alphanumeric(ASC(x2$)) THEN convertspacing = 1 - - - IF x2$ = "LPRINT" THEN - - 'x2$="LPRINT" - 'x$=CHR$(0) - 'x3$=[sp] from WIDTH[sp] - 'therefore... - 's=1 - 'an=0 - 'convertspacing=1 - - - 'if debug=1 then - 'print #9,"LPRINT:" - 'print #9,s - 'print #9,an - 'print #9,l$ - 'print #9,x2$ - 'end if - - END IF - - - - - IF (an = 1 OR addedlayout = 1) AND alphanumeric(ASC(x2$)) <> 0 THEN - - - - s = 1 'force space - x2$ = x2$ + sp2 - GOTO customlaychar - END IF - - IF x2$ = "=" THEN - s = 1 - x2$ = x2$ + sp - GOTO customlaychar - END IF - - IF x2$ = "#" THEN - s = 1 - x2$ = x2$ + sp2 - GOTO customlaychar - END IF - - IF x2$ = "," THEN x2$ = x2$ + sp: GOTO customlaychar - - - IF x$ = CHR$(0) THEN 'substitution - IF x2$ = "STEP" THEN x2$ = x2$ + sp2: GOTO customlaychar - x2$ = x2$ + sp: GOTO customlaychar - END IF - - 'default solution sp2+?+sp2 - x2$ = x2$ + sp2 - - - - - - customlaychar: - IF s = 0 THEN s = 2 - IF s <> s1 THEN - IF s1 THEN l$ = LEFT$(l$, LEN(l$) - 1) - IF s = 1 THEN l$ = l$ + sp - IF s = 2 THEN l$ = l$ + sp2 - END IF - - IF (RTRIM$(id2.callname) = "sub_timer" OR RTRIM$(id2.callname) = "sub_key") AND i = id2.args THEN 'spacing exception - IF x2$ <> ")" + sp2 THEN - l$ = LEFT$(l$, LEN(l$) - 1) + sp - END IF - END IF - - l$ = l$ + x2$ - - ELSE - addlayout = 0 - x$ = RIGHT$(x$, LEN(x$) - 1) - END IF - addedlayout = 0 - LOOP - - - - '---better sub syntax checking begins here--- - - - - IF targettyp = -3 THEN - IF separgs2(i) = "N-LL" THEN a$ = "Expected array name": GOTO errmes - 'names of numeric arrays have ( ) automatically appended (nothing else) - e$ = separgs2(i) - - IF INSTR(e$, sp) = 0 THEN 'one element only - try_string$ = e$ - try = findid(try_string$) - IF Error_Happened THEN GOTO errmes - DO - IF try THEN - IF id.arraytype THEN - IF (id.arraytype AND ISSTRING) = 0 THEN - e$ = e$ + sp + "(" + sp + ")" - EXIT DO - END IF - END IF - '--- - IF try = 2 THEN findanotherid = 1: try = findid(try_string$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - END IF 'if try - IF try = 0 THEN 'add symbol? - IF LEN(removesymbol$(try_string$)) = 0 THEN - IF Error_Happened THEN GOTO errmes - a = ASC(try_string$) - IF a >= 97 AND a <= 122 THEN a = a - 32 - IF a = 95 THEN a = 91 - a = a - 64 - IF LEN(defineextaz(a)) THEN try_string$ = try_string$ + defineextaz(a): try = findid(try_string$) - IF Error_Happened THEN GOTO errmes - END IF - END IF 'try=0 - LOOP UNTIL try = 0 - END IF 'one element only - - - - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp - IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 - e$ = evaluatetotyp(e$, -2) - IF Error_Happened THEN GOTO errmes - GOTO sete - END IF '-3 - - - IF targettyp = -2 THEN - e$ = fixoperationorder$(e$) - IF Error_Happened THEN GOTO errmes - IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp - IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 - e$ = evaluatetotyp(e$, -2) - IF Error_Happened THEN GOTO errmes - GOTO sete - END IF '-2 - - IF targettyp = -4 THEN - - IF fieldcall THEN - i = id2.args + 1 - EXIT FOR - END IF - - IF separgs2(i) = "N-LL" THEN a$ = "Expected variable name/array element": GOTO errmes - e$ = fixoperationorder$(separgs2(i)) - IF Error_Happened THEN GOTO errmes - IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp - IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 - - 'GET/PUT RANDOM-ACCESS override - IF firstelement$ = "GET" OR firstelement$ = "PUT" THEN - e2$ = e$ 'backup - e$ = evaluate(e$, sourcetyp) - IF Error_Happened THEN GOTO errmes - IF (sourcetyp AND ISSTRING) THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - 'replace name of sub to call - subcall$ = RIGHT$(subcall$, LEN(subcall$) - 7) 'delete original name - 'note: GET2 & PUT2 take differing input, following code is correct - IF firstelement$ = "GET" THEN - subcall$ = "sub_get2" + subcall$ - e$ = refer(e$, sourcetyp, 0) 'pass a qbs pointer instead - IF Error_Happened THEN GOTO errmes - GOTO sete - ELSE - subcall$ = "sub_put2" + subcall$ - 'no goto sete required, fall through - END IF - END IF - END IF - e$ = e2$ 'restore - END IF 'override - - e$ = evaluatetotyp(e$, -4) - IF Error_Happened THEN GOTO errmes - GOTO sete - END IF '-4 - - IF separgs2(i) = "N-LL" THEN - e$ = "NULL" - ELSE - - e2$ = fixoperationorder$(separgs2(i)) - IF Error_Happened THEN GOTO errmes - IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp - IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 - - e$ = evaluate(e2$, sourcetyp) - IF Error_Happened THEN GOTO errmes - - IF sourcetyp AND ISOFFSET THEN - IF (targettyp AND ISOFFSET) = 0 THEN - IF id2.internal_subfunc = 0 THEN a$ = "Cannot convert _OFFSET type to other types": GOTO errmes - END IF - END IF - - IF RTRIM$(id2.callname) = "sub_paint" THEN - IF i = 3 THEN - IF (sourcetyp AND ISSTRING) THEN - targettyp = ISSTRING - END IF - END IF - END IF - - IF LEFT$(separgs2(i), 2) = "(" + sp THEN dereference = 1 ELSE dereference = 0 - - 'pass by reference - IF (targettyp AND ISPOINTER) THEN - IF dereference = 0 THEN 'check deferencing wasn't used - - 'note: array pointer - IF (targettyp AND ISARRAY) THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN a$ = "Expected arrayname()": GOTO errmes - IF (sourcetyp AND ISARRAY) = 0 THEN a$ = "Expected arrayname()": GOTO errmes - IF Debug THEN PRINT #9, "sub:array reference:[" + e$ + "]" - - 'check arrays are of same type - targettyp2 = targettyp: sourcetyp2 = sourcetyp - targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) - sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) - IF sourcetyp2 <> targettyp2 THEN a$ = "Incorrect array type passed to sub": GOTO errmes - - 'check arrayname was followed by '()' - IF targettyp AND ISUDT THEN - IF Debug THEN PRINT #9, "sub:array reference:udt reference:[" + e$ + "]" - 'get UDT info - udtrefid = VAL(e$) - getid udtrefid - IF Error_Happened THEN GOTO errmes - udtrefi = INSTR(e$, sp3) 'end of id - udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u - udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) - udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e - udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) - o$ = RIGHT$(e$, LEN(e$) - udtrefi3) - 'note: most of the UDT info above is not required - IF LEFT$(o$, 4) <> "(0)*" THEN a$ = "Expected arrayname()": GOTO errmes - ELSE - IF RIGHT$(e$, 2) <> sp3 + "0" THEN a$ = "Expected arrayname()": GOTO errmes - END IF - - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) - getid idnum - IF Error_Happened THEN GOTO errmes - - IF targettyp AND ISFIXEDLENGTH THEN - targettypsize = CVL(MID$(id2.argsize, i * 4 - 4 + 1, 4)) - IF id.tsize <> targettypsize THEN a$ = "Incorrect array type passed to sub": GOTO errmes - END IF - - IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - recompile = 1 - END IF - END IF - - IF id.linkid = 0 THEN - 'if id.linkid is 0, it means the number of array elements is definietly - 'known of the array being passed, this is not some "fake"/unknown array. - 'using the numer of array elements of a fake array would be dangerous! - - - IF nelereq = 0 THEN - 'only continue if the number of array elements required is unknown - 'and it needs to be set - - IF id.arrayelements > 0 THEN '2009 - - nelereq = id.arrayelements - MID$(id2.nelereq, i, 1) = CHR$(nelereq) - - END IF - - 'print rtrim$(id2.n)+">nelereq=";nelereq - - ids(targetid) = id2 - - ELSE - - 'the number of array elements required is known AND - 'the number of elements in the array to be passed is known - - IF id.arrayelements <> nelereq THEN a$ = "Passing arrays with a differing number of elements to a SUB/FUNCTION is not supported": GOTO errmes - - - END IF - END IF - - e$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN GOTO errmes - GOTO sete - - END IF 'target is an array - - 'note: not an array... - 'target is not an array - - IF (targettyp AND ISSTRING) = 0 THEN - IF (sourcetyp AND ISREFERENCE) THEN - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp - - targettyp2 = targettyp: sourcetyp2 = sourcetyp - - 'get info about source/target - arr = 0: IF (sourcetyp2 AND ISARRAY) THEN arr = 1 - passudtelement = 0: IF (targettyp2 AND ISUDT) = 0 AND (sourcetyp2 AND ISUDT) <> 0 THEN passudtelement = 1: sourcetyp2 = sourcetyp2 - ISUDT - - 'remove flags irrelevant for comparison... ISPOINTER,ISREFERENCE,ISINCONVENTIONALMEMORY,ISARRAY - targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) - sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) - - 'compare types - IF sourcetyp2 = targettyp2 THEN - - IF sourcetyp AND ISUDT THEN - 'udt/udt array - - 'get info - udtrefid = VAL(e$) - getid udtrefid - IF Error_Happened THEN GOTO errmes - udtrefi = INSTR(e$, sp3) 'end of id - udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u - udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) - udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e - udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) - o$ = RIGHT$(e$, LEN(e$) - udtrefi3) - 'note: most of the UDT info above is not required - - IF arr THEN - n$ = scope$ + "ARRAY_UDT_" + RTRIM$(id.n) + "[0]" - ELSE - n$ = scope$ + "UDT_" + RTRIM$(id.n) - END IF - - e$ = "(void*)( ((char*)(" + n$ + ")) + (" + o$ + ") )" - - 'convert void* to target type* - IF passudtelement THEN e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ - IF Error_Happened THEN GOTO errmes - - ELSE - 'not a udt - IF arr THEN - IF (sourcetyp2 AND ISOFFSETINBITS) THEN a$ = "Cannot pass BIT array offsets": GOTO errmes - e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" - IF Error_Happened THEN GOTO errmes - ELSE - e$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN GOTO errmes - END IF - - 'note: signed/unsigned mismatch requires casting - IF (sourcetyp AND ISUNSIGNED) <> (targettyp AND ISUNSIGNED) THEN - e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ - IF Error_Happened THEN GOTO errmes - END IF - - END IF 'udt? - - IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - recompile = 1 - END IF - END IF - - GOTO sete - END IF 'similar - END IF 'reference - ELSE 'not a string - 'its a string - IF (sourcetyp AND ISREFERENCE) THEN - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp - IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - recompile = 1 - END IF - END IF - END IF 'reference - END IF 'its a string - - END IF 'dereference check - END IF 'target is a pointer - - 'note: Target is not a pointer... - - 'String-numeric mismatch? - IF targettyp AND ISSTRING THEN - IF (sourcetyp AND ISSTRING) = 0 THEN - nth = i - IF ids(targetid).args = 1 THEN a$ = "String required for sub": GOTO errmes - a$ = str_nth$(nth) + " sub argument requires a string": GOTO errmes - END IF - END IF - IF (targettyp AND ISSTRING) = 0 THEN - IF sourcetyp AND ISSTRING THEN - nth = i - IF ids(targetid).args = 1 THEN a$ = "Number required for sub": GOTO errmes - a$ = str_nth$(nth) + " sub argument requires a number": GOTO errmes - END IF - END IF - - 'change to "non-pointer" value - IF (sourcetyp AND ISREFERENCE) THEN - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN GOTO errmes - END IF - - IF explicitreference = 0 THEN - IF targettyp AND ISUDT THEN - nth = i - IF qb64prefix_set AND udtxcname(targettyp AND 511) = "_MEM" THEN - x$ = "'" + MID$(RTRIM$(udtxcname(targettyp AND 511)), 2) + "'" - ELSE - x$ = "'" + RTRIM$(udtxcname(targettyp AND 511)) + "'" - END IF - IF ids(targetid).args = 1 THEN a$ = "TYPE " + x$ + " required for sub": GOTO errmes - a$ = str_nth$(nth) + " sub argument requires TYPE " + x$: GOTO errmes - END IF - ELSE - IF sourcetyp AND ISUDT THEN a$ = "Number required for sub": GOTO errmes - END IF - - 'round to integer if required - IF (sourcetyp AND ISFLOAT) THEN - IF (targettyp AND ISFLOAT) = 0 THEN - '**32 rounding fix - bits = targettyp AND 511 - IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" - IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" - IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" - END IF - END IF - - IF (targettyp AND ISPOINTER) THEN 'pointer required - IF (targettyp AND ISSTRING) THEN GOTO sete 'no changes required - t$ = typ2ctyp$(targettyp, "") - IF Error_Happened THEN GOTO errmes - v$ = "pass" + str2$(uniquenumber) - 'assume numeric type - IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? - bytesreq = ((targettyp AND 511) + 7) \ 8 - PRINT #defdatahandle, t$ + " *" + v$ + "=NULL;" - PRINT #13, "if(" + v$ + "==NULL){" - PRINT #13, "cmem_sp-=" + str2(bytesreq) + ";" - PRINT #13, v$ + "=(" + t$ + "*)(dblock+cmem_sp);" - PRINT #13, "if (cmem_spchr" - END IF - - IF LTRIM$(RTRIM$(e$)) = "0" THEN e$ = "NULL" - - END IF - - IF i <> 1 THEN subcall$ = subcall$ + "," - subcall$ = subcall$ + e$ - NEXT - - 'note: i=id.args+1 - x$ = separgslayout2$(i) - DO WHILE LEN(x$) - x = ASC(x$) - IF x THEN - x2$ = MID$(x$, 2, x) - x$ = RIGHT$(x$, LEN(x$) - x - 1) - - s = 0 - an = 0 - x3$ = RIGHT$(l$, 1) - IF x3$ = sp THEN s = 1 - IF x3$ = sp2 THEN - s = 2 - IF alphanumeric(ASC(RIGHT$(l$, 2))) THEN an = 1 - 'if asc(right$(l$,2))=34 then an=1 - ELSE - IF alphanumeric(ASC(x3$)) THEN an = 1 - 'if asc(x3$)=34 then an=1 - END IF - s1 = s - - IF (an = 1 OR addedlayout = 1) AND alphanumeric(ASC(x2$)) <> 0 THEN - s = 1 'force space - x2$ = x2$ + sp2 - GOTO customlaychar2 - END IF - - IF x2$ = "=" THEN - s = 1 - x2$ = x2$ + sp - GOTO customlaychar2 - END IF - - IF x2$ = "#" THEN - s = 1 - x2$ = x2$ + sp2 - GOTO customlaychar2 - END IF - - IF x2$ = "," THEN x2$ = x2$ + sp: GOTO customlaychar2 - - IF x$ = CHR$(0) THEN 'substitution - IF x2$ = "STEP" THEN x2$ = SCase$("Step") + sp2: GOTO customlaychar2 - x2$ = x2$ + sp: GOTO customlaychar2 - END IF - - 'default solution sp2+?+sp2 - x2$ = x2$ + sp2 - customlaychar2: - IF s = 0 THEN s = 2 - IF s <> s1 THEN - IF s1 THEN l$ = LEFT$(l$, LEN(l$) - 1) - IF s = 1 THEN l$ = l$ + sp - IF s = 2 THEN l$ = l$ + sp2 - END IF - l$ = l$ + x2$ - - ELSE - addlayout = 0 - x$ = RIGHT$(x$, LEN(x$) - 1) - END IF - addedlayout = 0 - LOOP - - - - - - - IF passedneeded THEN - subcall$ = subcall$ + "," + str2$(passed&) - END IF - subcall$ = subcall$ + ");" - - IF firstelement$ = "SLEEP" THEN - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - END IF - - PRINT #12, subcall$ - - IF firstelement$ = "SLEEP" THEN - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - END IF - - subcall$ = "" - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - - layoutdone = 1 - x$ = RIGHT$(l$, 1): IF x$ = sp OR x$ = sp2 THEN l$ = LEFT$(l$, LEN(l$) - 1) - IF usecall = 1 THEN l$ = l$ + sp2 + ")" - IF Debug THEN PRINT #9, "SUB layout:[" + l$ + "]" - IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ - GOTO finishedline - - - END IF - - IF try = 2 THEN - findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) - findanotherid = 1 - try = findid(firstelement$) - IF Error_Happened THEN GOTO errmes - ELSE - try = 0 - END IF - LOOP - - END IF - - notsubcall: - - IF n >= 1 THEN - IF firstelement$ = "LET" THEN - IF n = 1 THEN a$ = "Syntax error - Reference: LET variable = expression (tip: LET is entirely optional)": GOTO errmes - ca$ = RIGHT$(ca$, LEN(ca$) - 4) - n = n - 1 - l$ = SCase$("Let") - IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - 'note: layoutdone=1 will be set later - GOTO letused - END IF - END IF - - 'LET ???=??? - IF n >= 3 THEN - IF INSTR(a$, sp + "=" + sp) THEN - letused: - assign ca$, n - IF Error_Happened THEN GOTO errmes - layoutdone = 1 - IF LEN(layout$) = 0 THEN layout$ = tlayout$ ELSE layout$ = layout$ + sp + tlayout$ - GOTO finishedline - END IF - END IF '>=3 - IF RIGHT$(a$, 2) = sp + "=" THEN a$ = "Expected ... = expression": GOTO errmes - - 'Syntax error - a$ = "Syntax error": GOTO errmes - - finishedline: - THENGOTO = 0 - finishedline2: - - IF inputfunctioncalled THEN - inputfunctioncalled = 0 - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - END IF - - IF arrayprocessinghappened = 1 THEN arrayprocessinghappened = 0 - - inclinenump$ = "" - IF inclinenumber(inclevel) THEN - inclinenump$ = "," + str2$(inclinenumber(inclevel)) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) - END IF - IF NoChecks = 0 THEN - IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" - IF dynscope THEN - dynscope = 0 - PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");if(r)goto S_" + str2$(statementn) + ";}" - ELSE - PRINT #12, "if(!qbevent)break;" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}while(r);" - END IF - END IF - - finishednonexec: - - firstLine = 0 - - IF layoutdone = 0 THEN layoutok = 0 'invalidate layout if not handled - - IF continuelinefrom = 0 THEN 'note: manager #2 requires this condition - - 'Include Manager #2 '*** - IF LEN(addmetainclude$) THEN - - IF inclevel = 0 THEN - 'backup line formatting - layoutcomment_backup$ = layoutcomment$ - layoutok_backup = layoutok - layout_backup$ = layout$ - END IF - - a$ = addmetainclude$: addmetainclude$ = "" 'read/clear message - - IF inclevel = 0 THEN - includingFromRoot = 0 - forceIncludingFile = 0 - forceInclude: - IF forceIncludeFromRoot$ <> "" THEN - a$ = forceIncludeFromRoot$ - forceIncludeFromRoot$ = "" - forceIncludingFile = 1 - includingFromRoot = 1 - END IF - END IF - - IF inclevel = 100 THEN a$ = "Too many indwelling INCLUDE files": GOTO errmes - '1. Verify file exists (location is either (a)relative to source file or (b)absolute) - fh = 99 + inclevel + 1 - - firstTryMethod = 1 - IF includingFromRoot <> 0 AND inclevel = 0 THEN firstTryMethod = 2 - FOR try = firstTryMethod TO 2 'if including file from root, do not attempt including from relative location - IF try = 1 THEN - IF inclevel = 0 THEN - IF idemode THEN p$ = idepath$ + pathsep$ ELSE p$ = getfilepath$(sourcefile$) - ELSE - p$ = getfilepath$(incname(inclevel)) - END IF - f$ = p$ + a$ - END IF - IF try = 2 THEN f$ = a$ - IF _FILEEXISTS(f$) THEN - qberrorhappened = -2 '*** - OPEN f$ FOR BINARY AS #fh - qberrorhappened2: '*** - IF qberrorhappened = -2 THEN EXIT FOR '*** - END IF - qberrorhappened = 0 - NEXT - IF qberrorhappened <> -2 THEN qberrorhappened = 0: a$ = "File " + a$ + " not found": GOTO errmes - inclevel = inclevel + 1: incname$(inclevel) = f$: inclinenumber(inclevel) = 0 - END IF 'fall through to next section... - '-------------------- - DO WHILE inclevel - fh = 99 + inclevel - '2. Feed next line - IF EOF(fh) = 0 THEN - LINE INPUT #fh, x$ - a3$ = x$ - continuelinefrom = 0 - inclinenumber(inclevel) = inclinenumber(inclevel) + 1 - 'create extended error string 'incerror$' - errorLineInInclude = inclinenumber(inclevel) - e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" - IF inclevel > 1 THEN - e$ = e$ + " (through " - FOR x = 1 TO inclevel - 1 STEP 1 - e$ = e$ + incname$(x) - IF x < inclevel - 1 THEN 'a sep is req - IF x = inclevel - 2 THEN - e$ = e$ + " then " - ELSE - e$ = e$ + ", " - END IF - END IF - NEXT - e$ = e$ + ")" - END IF - incerror$ = e$ - linenumber = linenumber - 1 'lower official linenumber to counter later increment - IF idemode THEN sendc$ = CHR$(10) + a3$: GOTO sendcommand 'passback - GOTO includeline - END IF - '3. Close & return control - CLOSE #fh - inclevel = inclevel - 1 - IF inclevel = 0 THEN - IF forceIncludingFile = 1 THEN - forceIncludingFile = 0 - GOTO forceIncludeCompleted - END IF - 'restore line formatting - layoutok = layoutok_backup - layout$ = layout_backup$ - layoutcomment$ = layoutcomment_backup$ - END IF - LOOP 'fall through to next section... - '(end manager) - - - - END IF 'continuelinefrom=0 - - - IF Debug THEN - PRINT #9, "[layout check]" - PRINT #9, "[" + layoutoriginal$ + "]" - PRINT #9, "[" + layout$ + "]" - PRINT #9, layoutok - PRINT #9, "[end layout check]" - END IF - - - - - IF idemode THEN - IF continuelinefrom <> 0 THEN GOTO ide4 'continue processing other commands on line - - IF LEN(layoutcomment$) THEN - IF LEN(layout$) THEN layout$ = layout$ + sp + layoutcomment$ ELSE layout$ = layoutcomment$ - END IF - - IF layoutok = 0 THEN - layout$ = layoutoriginal$ - ELSE - - 'reverse '046' changes present in autolayout - 'replace fix046$ with . - i = INSTR(layout$, fix046$) - DO WHILE i - layout$ = LEFT$(layout$, i - 1) + "." + RIGHT$(layout$, LEN(layout$) - (i + LEN(fix046$) - 1)) - i = INSTR(layout$, fix046$) - LOOP - - END IF - x = lhscontrollevel: IF controllevel < lhscontrollevel THEN x = controllevel - IF definingtype = 2 THEN x = x + 1 - IF definingtype > 0 THEN definingtype = 2 - IF declaringlibrary = 2 THEN x = x + 1 - IF declaringlibrary > 0 THEN declaringlibrary = 2 - layout$ = SPACE$(x) + layout$ - IF linecontinuation THEN layout$ = "" - - GOTO ideret4 'return control to IDE - END IF - - 'layout is not currently used by the compiler (as appose to the IDE), if it was it would be used here - skipide4: -LOOP - -'add final line -IF lastLineReturn = 0 THEN - lastLineReturn = 1 - lastLine = 1 - wholeline$ = "" - GOTO mainpassLastLine -END IF - -ide5: -linenumber = 0 - -IF closedmain = 0 THEN closemain - -IF definingtype THEN linenumber = definingtypeerror: a$ = "TYPE without END TYPE": GOTO errmes - -'check for open controls (copy #1) -IF controllevel THEN - a$ = "Unidentified open control block" - SELECT CASE controltype(controllevel) - CASE 1: a$ = "IF without END IF" - CASE 2: a$ = "FOR without NEXT" - CASE 3, 4: a$ = "DO without LOOP" - CASE 5: a$ = "WHILE without WEND" - CASE 6: a$ = "$IF without $END IF" - CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" - CASE 32: a$ = "SUB/FUNCTION without END SUB/FUNCTION" - END SELECT - linenumber = controlref(controllevel) - GOTO errmes -END IF - -IF ideindentsubs = 0 THEN - IF LEN(subfunc) THEN a$ = "SUB/FUNCTION without END SUB/FUNCTION": GOTO errmes -END IF - -'close the error handler (cannot be put in 'closemain' because subs/functions can also add error jumps to this file) -PRINT #14, "exit(99);" 'in theory this line should never be run! -PRINT #14, "}" 'close error jump handler - -'create CLEAR method "CLEAR" -CLOSE #12 'close code handle -OPEN tmpdir$ + "clear.txt" FOR OUTPUT AS #12 'direct code to clear.txt - -FOR i = 1 TO idn - - IF ids(i).staticscope THEN 'static scope? - subfunc = RTRIM$(ids(i).insubfunc) 'set static scope - GOTO clearstaticscope - END IF - - a = ASC(ids(i).insubfunc) - IF a = 0 OR a = 32 THEN 'global scope? - subfunc = "" 'set global scope - clearstaticscope: - - IF ids(i).arraytype THEN 'an array - getid i - IF Error_Happened THEN GOTO errmes - IF id.arrayelements = -1 THEN GOTO clearerasereturned 'cannot erase non-existant array - IF INSTR(vWatchVariableExclusions$, "@" + RTRIM$(id.callname) + "@") > 0 THEN - GOTO clearerasereturned - END IF - clearerasereturn = 1: GOTO clearerase - END IF 'array - - IF ids(i).t THEN 'non-array variable - getid i - IF Error_Happened THEN GOTO errmes - bytes$ = variablesize$(-1) - IF Error_Happened THEN GOTO errmes - 'create a reference - typ = id.t + ISREFERENCE - IF typ AND ISUDT THEN - e$ = str2(i) + sp3 + str2(typ AND 511) + sp3 + "0" + sp3 + "0" - ELSE - e$ = str2(i) - END IF - e$ = refer$(e$, typ, 1) - IF Error_Happened THEN GOTO errmes - IF typ AND ISSTRING THEN - IF typ AND ISFIXEDLENGTH THEN - PRINT #12, "memset((void*)(" + e$ + "->chr),0," + bytes$ + ");" - GOTO cleared - ELSE - IF INSTR(vWatchVariableExclusions$, "@" + e$ + "@") = 0 AND LEFT$(e$, 12) <> "_SUB_VWATCH_" THEN - PRINT #12, e$ + "->len=0;" - END IF - GOTO cleared - END IF - END IF - IF typ AND ISUDT THEN - IF udtxvariable(typ AND 511) THEN - 'this next procedure resets values of UDT variables with variable-length strings - clear_udt_with_varstrings e$, typ AND 511, 12, 0 - ELSE - PRINT #12, "memset((void*)" + e$ + ",0," + bytes$ + ");" - END IF - ELSE - IF INSTR(vWatchVariableExclusions$, "@" + e$ + "@") = 0 AND LEFT$(e$, 12) <> "_SUB_VWATCH_" THEN - PRINT #12, "*" + e$ + "=0;" - END IF - END IF - GOTO cleared - END IF 'non-array variable - - END IF 'scope - - cleared: - clearerasereturned: -NEXT -CLOSE #12 - -IF Debug THEN - PRINT #9, "finished making program!" - PRINT #9, "recompile="; recompile -END IF - -'Set cmem flags for subs/functions requiring data passed in cmem -FOR i = 1 TO idn - IF cmemlist(i) THEN 'must be in cmem - - getid i - IF Error_Happened THEN GOTO errmes - - IF Debug THEN PRINT #9, "recompiling cmem sf! checking:"; RTRIM$(id.n) - - IF id.sfid THEN 'it is an argument of a sub/function - - IF Debug THEN PRINT #9, "recompiling cmem sf! It's a sub/func arg!" - - i2 = id.sfid - x = id.sfarg - - IF Debug THEN PRINT #9, "recompiling cmem sf! values:"; i2; x - - 'check if cmem flag is set, if not then set it & force recompile - IF MID$(sfcmemargs(i2), x, 1) <> CHR$(1) THEN - MID$(sfcmemargs(i2), x, 1) = CHR$(1) - - - IF Debug THEN PRINT #9, "recompiling cmem sf! setting:"; i2; x - - - recompile = 1 - END IF - END IF - END IF -NEXT i - -unresolved = 0 -FOR i = 1 TO idn - getid i - IF Error_Happened THEN GOTO errmes - - IF Debug THEN PRINT #9, "checking id named:"; id.n - - IF id.subfunc THEN - FOR i2 = 1 TO id.args - t = CVL(MID$(id.arg, i2 * 4 - 3, 4)) - IF t > 0 THEN - IF (t AND ISPOINTER) THEN - IF (t AND ISARRAY) THEN - - IF Debug THEN PRINT #9, "checking argument "; i2; " of "; id.args - - nele = ASC(MID$(id.nele, i2, 1)) - nelereq = ASC(MID$(id.nelereq, i2, 1)) - - IF Debug THEN PRINT #9, "nele="; nele - IF Debug THEN PRINT #9, "nelereq="; nelereq - - IF nele <> nelereq THEN - - IF Debug THEN PRINT #9, "mismatch detected!" - - unresolved = unresolved + 1 - sflistn = sflistn + 1 - sfidlist(sflistn) = i - sfarglist(sflistn) = i2 - sfelelist(sflistn) = nelereq '0 means still unknown - END IF - END IF - END IF - END IF - NEXT - END IF -NEXT - -'is recompilation required to resolve this? -IF unresolved > 0 THEN - IF lastunresolved = -1 THEN - 'first pass - recompile = 1 - IF Debug THEN - PRINT #9, "recompiling to resolve array elements (first time)" - PRINT #9, "sflistn="; sflistn - PRINT #9, "oldsflistn="; oldsflistn - END IF - ELSE - 'not first pass - IF unresolved < lastunresolved THEN - recompile = 1 - IF Debug THEN - PRINT #9, "recompiling to resolve array elements (not first time)" - PRINT #9, "sflistn="; sflistn - PRINT #9, "oldsflistn="; oldsflistn - END IF - END IF - END IF -END IF 'unresolved -lastunresolved = unresolved - -'IDEA! -'have a flag to record if anything gets resolved in a pass -'if not then it's time to stop -'the problem is the same amount of new problems may be created by a -'resolve as those that get fixed -'also/or.. could it be that previous fixes are overridden in a recompile -' by a new fix? if so, it would give these effects - - - -'could recompilation resolve this? -'IF sflistn <> -1 THEN -'IF sflistn <> oldsflistn THEN -'recompile = 1 -' -'if debug then -'print #9,"recompile set to 1 to resolve array elements" -'print #9,"sflistn=";sflistn -'print #9,"oldsflistn=";oldsflistn -'end if -' -'END IF -'END IF - -IF Debug THEN PRINT #9, "Beginning COMMON array list check..." -xi = 1 -FOR x = 1 TO commonarraylistn - varname$ = getelement$(commonarraylist, xi): xi = xi + 1 - typ$ = getelement$(commonarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - 'find the array ID (try method) - t = typname2typ(typ$) - IF Error_Happened THEN GOTO errmes - IF (t AND ISUDT) = 0 THEN varname$ = varname$ + type2symbol$(typ$) - IF Error_Happened THEN GOTO errmes - - IF Debug THEN PRINT #9, "Checking for array '" + varname$ + "'..." - - try = findid(varname$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.arraytype THEN GOTO foundcommonarray2 - IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - foundcommonarray2: - - IF Debug THEN PRINT #9, "Found array '" + varname$ + "!" - - IF id.arrayelements = -1 THEN - IF arrayelementslist(currentid) <> 0 THEN recompile = 1 - IF Debug THEN PRINT #9, "Recompiling to resolve elements of:" + varname$ - END IF -NEXT -IF Debug THEN PRINT #9, "Finished COMMON array list check!" - -IF vWatchDesiredState <> vWatchOn THEN - vWatchRecompileAttempts = vWatchRecompileAttempts + 1 - recompile = 1 -END IF - -IF recompile THEN - do_recompile: - IF Debug THEN PRINT #9, "Recompile required!" - recompile = 0 - IF idemode THEN iderecompile = 1 - FOR closeall = 1 TO 255: CLOSE closeall: NEXT - OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock - GOTO recompile -END IF - -IF Debug THEN PRINT #9, "Beginning label check..." -FOR r = 1 TO nLabels - - IF Labels(r).Scope_Restriction THEN - a$ = RTRIM$(Labels(r).cn) - ignore = validlabel(a$) - v = HashFind(a$, HASHFLAG_LABEL, ignore, r2) - addlabchk7: - IF v THEN - IF Labels(r2).Scope = Labels(r).Scope_Restriction THEN - linenumber = Labels(r).Error_Line: a$ = "Common label within a SUB/FUNCTION": GOTO errmes - END IF - IF v = 2 THEN v = HashFindCont(ignore, r2): GOTO addlabchk7 - END IF 'v - END IF 'restriction - - 'check for undefined labels - IF Labels(r).State = 0 THEN - - IF INSTR(PossibleSubNameLabels$, sp + UCASE$(RTRIM$(Labels(r).cn)) + sp) THEN - IF INSTR(SubNameLabels$, sp + UCASE$(RTRIM$(Labels(r).cn)) + sp) = 0 THEN 'not already added - SubNameLabels$ = SubNameLabels$ + UCASE$(RTRIM$(Labels(r).cn)) + sp - IF Debug THEN PRINT #9, "Recompiling to resolve label:"; RTRIM$(Labels(r).cn) - GOTO do_recompile - END IF - END IF - - linenumber = Labels(r).Error_Line: a$ = "Label '" + RTRIM$(Labels(r).cn) + "' not defined": GOTO errmes - END IF - - - IF Labels(r).Data_Referenced THEN - - 'check for ambiguous RESTORE reference - x = 0 - a$ = RTRIM$(Labels(r).cn) - ignore = validlabel(a$) - v = HashFind(a$, HASHFLAG_LABEL, ignore, r2) - addlabchk4: - IF v THEN - x = x + 1 - IF v = 2 THEN v = HashFindCont(ignore, r2): GOTO addlabchk4 - END IF 'v - IF x <> 1 THEN linenumber = Labels(r).Error_Line: a$ = "Ambiguous DATA label": GOTO errmes - - 'add global data offset variable - PRINT #18, "ptrszint data_at_LABEL_" + a$ + "=" + str2(Labels(r).Data_Offset) + ";" - - END IF 'data referenced - -NEXT -IF Debug THEN PRINT #9, "Finished check!" - - -'if targettyp=-4 or targettyp=-5 then '? -> byte_element(offset,element size in bytes) -' IF (sourcetyp AND ISREFERENCE) = 0 THEN a$ = "Expected variable name/array element": GOTO errmes - - -'create include files for COMMON arrays - -CLOSE #12 - -'return to 'main' -subfunc$ = "" -defdatahandle = 18 -CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 -CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 - -IF Console THEN - PRINT #18, "int32 console=1;" -ELSE - PRINT #18, "int32 console=0;" -END IF - -IF ScreenHide THEN - PRINT #18, "int32 screen_hide_startup=1;" -ELSE - PRINT #18, "int32 screen_hide_startup=0;" -END IF - -IF Asserts THEN - PRINT #18, "int32 asserts=1;" -ELSE - PRINT #18, "int32 asserts=0;" -END IF - -IF vWatchOn THEN - PRINT #18, "int32 vwatch=-1;" -ELSE - PRINT #18, "int32 vwatch=0;" -END IF - -fh = FREEFILE -OPEN tmpdir$ + "dyninfo.txt" FOR APPEND AS #fh -IF Resize THEN - PRINT #fh, "ScreenResize=1;" -END IF -IF Resize_Scale THEN - PRINT #fh, "ScreenResizeScale=" + str2(Resize_Scale) + ";" -END IF -CLOSE #fh - -IF vWatchOn = 1 THEN - vWatchVariable "", 1 -END IF - - -'DATA_finalize -PRINT #18, "ptrszint data_size=" + str2(DataOffset) + ";" -IF DataOffset = 0 THEN - - PRINT #18, "uint8 *data=(uint8*)calloc(1,1);" - -ELSE - - IF inline_DATA = 0 THEN - IF os$ = "WIN" THEN - IF OS_BITS = 32 THEN - x$ = CHR$(0): PUT #16, , x$ - PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #18, "extern char *binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - PRINT #18, "}" - PRINT #18, "uint8 *data=(uint8*)&binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - ELSE - x$ = CHR$(0): PUT #16, , x$ - PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #18, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - PRINT #18, "}" - PRINT #18, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - END IF - END IF - IF os$ = "LNX" THEN - x$ = CHR$(0): PUT #16, , x$ - PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #18, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - PRINT #18, "}" - PRINT #18, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - END IF - ELSE - 'inline data - CLOSE #16 - ff = FREEFILE - OPEN tmpdir$ + "data.bin" FOR BINARY AS #ff - x$ = SPACE$(LOF(ff)) - GET #ff, , x$ - CLOSE #ff - x2$ = "uint8 inline_data[]={" - FOR i = 1 TO LEN(x$) - x2$ = x2$ + inlinedatastr$(ASC(x$, i)) - NEXT - x2$ = x2$ + "0};" - PRINT #18, x2$ - PRINT #18, "uint8 *data=&inline_data[0];" - x$ = "": x2$ = "" - END IF -END IF - -IF Debug THEN PRINT #9, "Beginning generation of code for saving/sharing common array data..." -use_global_byte_elements = 1 -ncommontmp = 0 -xi = 1 -FOR x = 1 TO commonarraylistn - varname$ = getelement$(commonarraylist, xi): xi = xi + 1 - typ$ = getelement$(commonarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 - - 'find the array ID (try method) - purevarname$ = varname$ - t = typname2typ(typ$) - IF Error_Happened THEN GOTO errmes - IF (t AND ISUDT) = 0 THEN varname$ = varname$ + type2symbol$(typ$) - IF Error_Happened THEN GOTO errmes - try = findid(varname$) - IF Error_Happened THEN GOTO errmes - DO WHILE try - IF id.arraytype THEN GOTO foundcommonarray - IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 - IF Error_Happened THEN GOTO errmes - LOOP - a$ = "COMMON array unlocatable": GOTO errmes 'should never happen - foundcommonarray: - IF Debug THEN PRINT #9, "Found common array '" + varname$ + "'!" - - i = currentid - arraytype = id.arraytype - arrayelements = id.arrayelements - e$ = RTRIM$(id.n) - IF (t AND ISUDT) = 0 THEN e$ = e$ + typevalue2symbol$(t) - IF Error_Happened THEN GOTO errmes - n$ = e$ - n2$ = RTRIM$(id.callname) - tsize = id.tsize - - 'select command - command = 3 'fixed length elements - IF t AND ISSTRING THEN - IF (t AND ISFIXEDLENGTH) = 0 THEN - command = 4 'var-len elements - END IF - END IF - - - 'if... - 'i) array elements are still undefined (ie. arrayelements=-1) pass the input content along - ' if any existed or an array-placeholder - 'ii) if the array's elements were defined, any input content would have been loaded so the - ' array (in whatever state it currently is) should be passed. If it is currently erased - ' then it should be passed as a placeholder - - IF arrayelements = -1 THEN - - 'load array (copies the array, if any, into a buffer for later) - - - - OPEN tmpdir$ + "inpchain" + str2$(i) + ".txt" FOR OUTPUT AS #12 - PRINT #12, "if (int32val==2){" 'array place-holder - 'create buffer to store array as-is in global.txt - x$ = str2$(uniquenumber) - x1$ = "chainarraybuf" + x$ - x2$ = "chainarraybufsiz" + x$ - PRINT #18, "static uint8 *" + x1$ + "=(uint8*)malloc(1);" - PRINT #18, "static int64 " + x2$ + "=0;" - 'read next command - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - IF command = 3 THEN PRINT #12, "if (int32val==3){" 'fixed-length-element array - IF command = 4 THEN PRINT #12, "if (int32val==4){" 'var-length-element array - PRINT #12, x2$ + "+=4; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int32*)(" + x1$ + "+" + x2$ + "-4)=int32val;" - - IF command = 3 THEN - 'read size in bits of one element, convert it to bytes - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val;" - PRINT #12, "bytes=int64val>>3;" - END IF 'com=3 - - IF command = 4 THEN PRINT #12, "bytes=1;" 'bytes used to calculate number of elements - - 'read number of dimensions - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - PRINT #12, x2$ + "+=4; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int32*)(" + x1$ + "+" + x2$ + "-4)=int32val;" - - 'read size of dimensions & calculate the size of the array in bytes - PRINT #12, "while(int32val--){" - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" 'lbound - PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val;" - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" 'ubound - PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val2;" - PRINT #12, "bytes*=(int64val2-int64val+1);" - PRINT #12, "}" - - IF command = 3 THEN - 'read the array data - PRINT #12, x2$ + "+=bytes; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + ");" - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)(" + x1$ + "+" + x2$ + "-bytes),bytes," + NewByteElement$ + "),0);" - END IF 'com=3 - - IF command = 4 THEN - PRINT #12, "bytei=0;" - PRINT #12, "while(bytei>3); " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + ");" - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)(" + x1$ + "+" + x2$ + "-(int64val>>3)),(int64val>>3)," + NewByteElement$ + "),0);" - PRINT #12, "bytei++;" - PRINT #12, "}" - END IF - - 'get next command - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - PRINT #12, "}" 'command=3 or 4 - - PRINT #12, "}" 'array place-holder - CLOSE #12 - - - 'save array (saves the buffered data, if any, for later) - - OPEN tmpdir$ + "chain" + str2$(i) + ".txt" FOR OUTPUT AS #12 - PRINT #12, "int32val=2;" 'placeholder - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)" + x1$ + "," + x2$ + "," + NewByteElement$ + "),0);" - CLOSE #12 - - - - - ELSE - 'note: arrayelements<>-1 - - 'load array - - OPEN tmpdir$ + "inpchain" + str2$(i) + ".txt" FOR OUTPUT AS #12 - - PRINT #12, "if (int32val==2){" 'array place-holder - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - IF command = 3 THEN PRINT #12, "if (int32val==3){" 'fixed-length-element array - IF command = 4 THEN PRINT #12, "if (int32val==4){" 'var-length-element array - - IF command = 3 THEN - 'get size in bits - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - '***assume correct*** - END IF - - 'get number of elements - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - '***assume correct*** - - e$ = "" - IF command = 4 THEN PRINT #12, "bytes=1;" 'bytes counts the number of total elements - FOR x2 = 1 TO arrayelements - - 'create 'secret' variables to assist in passing common arrays - IF x2 > ncommontmp THEN - ncommontmp = ncommontmp + 1 - - IF Debug THEN PRINT #9, "Calling DIM2(...)..." - IF Error_Happened THEN GOTO errmes - retval = dim2("___RESERVED_COMMON_LBOUND" + str2$(ncommontmp), "_INTEGER64", 0, "") - IF Error_Happened THEN GOTO errmes - retval = dim2("___RESERVED_COMMON_UBOUND" + str2$(ncommontmp), "_INTEGER64", 0, "") - IF Error_Happened THEN GOTO errmes - IF Debug THEN PRINT #9, "Finished calling DIM2(...)!" - IF Error_Happened THEN GOTO errmes - - - END IF - - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - PRINT #12, "*__INTEGER64____RESERVED_COMMON_LBOUND" + str2$(x2) + "=int64val;" - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" - PRINT #12, "*__INTEGER64____RESERVED_COMMON_UBOUND" + str2$(x2) + "=int64val2;" - IF command = 4 THEN PRINT #12, "bytes*=(int64val2-int64val+1);" - IF x2 > 1 THEN e$ = e$ + sp + "," + sp - e$ = e$ + "___RESERVED_COMMON_LBOUND" + str2$(x2) + sp + "TO" + sp + "___RESERVED_COMMON_UBOUND" + str2$(x2) - NEXT - - IF Debug THEN PRINT #9, "Calling DIM2(" + purevarname$ + "," + typ$ + ",0," + e$ + ")..." - IF Error_Happened THEN GOTO errmes - 'Note: purevarname$ is simply varname$ without the type symbol after it - redimoption = 1 - retval = dim2(purevarname$, typ$, 0, e$) - IF Error_Happened THEN GOTO errmes - redimoption = 0 - IF Debug THEN PRINT #9, "Finished calling DIM2(" + purevarname$ + "," + typ$ + ",0," + e$ + ")!" - IF Error_Happened THEN GOTO errmes - - IF command = 3 THEN - 'use get to load in the array data - varname$ = varname$ + sp + "(" + sp + ")" - e$ = evaluatetotyp(fixoperationorder$(varname$), -4) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_get(FF,NULL," + e$ + ",0);" - END IF - - IF command = 4 THEN - PRINT #12, "bytei=0;" - PRINT #12, "while(bytei>3,1));" 'change string size - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)tqbs->chr,int64val>>3," + NewByteElement$ + "),0);" 'get size - PRINT #12, "bytei++;" - PRINT #12, "}" - END IF - - 'get next command - PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - PRINT #12, "}" - PRINT #12, "}" - CLOSE #12 - - 'save array - - OPEN tmpdir$ + "chain" + str2$(i) + ".txt" FOR OUTPUT AS #12 - - PRINT #12, "int32val=2;" 'placeholder - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - PRINT #12, "if (" + n2$ + "[2]&1){" 'don't add unless defined - - IF command = 3 THEN PRINT #12, "int32val=3;" - IF command = 4 THEN PRINT #12, "int32val=4;" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - IF command = 3 THEN - 'size of each element in bits - bits = t AND 511 - IF t AND ISUDT THEN bits = udtxsize(t AND 511) - IF t AND ISSTRING THEN bits = tsize * 8 - PRINT #12, "int64val=" + str2$(bits) + ";" 'size in bits - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - END IF 'com=3 - - PRINT #12, "int32val=" + str2$(arrayelements) + ";" 'number of dimensions - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" - - IF command = 3 THEN - - FOR x2 = 1 TO arrayelements - 'simulate calls to lbound/ubound - e$ = "LBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" - e$ = evaluatetotyp(fixoperationorder$(e$), 64) - IF Error_Happened THEN GOTO errmes - PRINT #12, "int64val=" + e$ + ";" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - e$ = "UBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" - e$ = evaluatetotyp(fixoperationorder$(e$), 64) - IF Error_Happened THEN GOTO errmes - PRINT #12, "int64val=" + e$ + ";" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - NEXT - - 'array data - e$ = evaluatetotyp(fixoperationorder$(n$ + sp + "(" + sp + ")"), -4) - IF Error_Happened THEN GOTO errmes - PRINT #12, "sub_put(FF,NULL," + e$ + ",0);" - - END IF 'com=3 - - IF command = 4 THEN - - 'store LBOUND/UBOUND values and calculate number of total elements/strings - PRINT #12, "bytes=1;" 'note: bytes is actually the total number of elements - FOR x2 = 1 TO arrayelements - e$ = "LBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" - e$ = evaluatetotyp(fixoperationorder$(e$), 64) - IF Error_Happened THEN GOTO errmes - PRINT #12, "int64val=" + e$ + ";" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" - e$ = "UBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" - e$ = evaluatetotyp(fixoperationorder$(e$), 64) - IF Error_Happened THEN GOTO errmes - PRINT #12, "int64val2=" + e$ + ";" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" - PRINT #12, "bytes*=(int64val2-int64val+1);" - NEXT - - PRINT #12, "bytei=0;" - PRINT #12, "while(byteilen; int64val<<=3;" - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" 'size of element - PRINT #12, "sub_put(FF,NULL,byte_element((uint64)tqbs->chr,tqbs->len," + NewByteElement$ + "),0);" 'element data - PRINT #12, "bytei++;" - PRINT #12, "}" - - END IF 'com=4 - - PRINT #12, "}" 'don't add unless defined - - CLOSE #12 - - - - - 'if chaincommonarray then - 'l2$=tlayout$ - 'x=chaincommonarray - ' - ''chain???.txt - 'open tmpdir$ + "chain" + str2$(x) + ".txt" for append as #22 - 'if lof(22) then close #22: goto chaindone 'only add this once - ''***assume non-var-len-string array*** - 'print #22,"int32val=3;" 'non-var-len-element array - 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" - 't=id.arraytype - ''***check for UDT size if necessary*** - ''***check for string length if necessary*** - 'bits=t and 511 - 'print #22,"int64val="+str2$(bits)+";" 'size in bits - 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" - 'print #22,"int32val="+str2$(id.arrayelements)+";" 'number of elements - 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" - 'e$=rtrim$(id.n) - 'if (t and ISUDT)=0 then e$=e$+typevalue2symbol$(t) - 'n$=e$ - 'for x2=1 to id.arrayelements - ''simulate calls to lbound/ubound - 'e$="LBOUND"+sp+"("+sp+n$+sp+","+sp+str2$(x2)+sp+")" - 'e$=evaluatetotyp(fixoperationorder$(e$),64) - 'print #22,"int64val="+e$+";"'LBOUND - 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" - 'e$="UBOUND"+sp+"("+sp+n$+sp+","+sp+str2$(x2)+sp+")" - 'e$=evaluatetotyp(fixoperationorder$(e$),64) - 'print #22,"int64val="+e$+";"'LBOUND - 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" - 'next - ''add array data - 'e$=evaluatetotyp(fixoperationorder$(n$+sp+"("+sp+")"),-4) - 'print #22,"sub_put(FF,NULL,"+e$+",0);" - 'close #22 - ' - ''inpchain???.txt - 'open tmpdir$ + "chain" + str2$(x) + ".txt" for append as #22 - 'print #22,"if (int32val==1){" 'common declaration of an array - 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" - 'print #22,"if (int32val==3){" 'fixed-length-element array - ' - 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" - ''***assume size correct and continue*** - ' - ''get number of elements - 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" - ' - ''call dim2 and tell it to redim an array - ' - ''*********this should happen BEFORE the array (above) is actually dimensioned, - ''*********where the common() declaration is - ' - ''****although, if you never reference the array............. - ''****ARGH! you can access an undimmed array just like in a sub/function - ' - ' - ' - ' - 'print #22,"}" - 'print #22,"}" - 'close #22 - ' - 'chaindone: - 'tlayout$=l2$ - 'end if 'chaincommonarray - - - - - 'OPEN tmpdir$ + "chain.txt" FOR APPEND AS #22 - ''include directive - 'print #22, "#include " + CHR$(34) + "chain" + str2$(x) + ".txt" + CHR$(34) - 'close #22 - ''create/clear include file - 'open tmpdir$ + "chain" + str2$(x) + ".txt" for output as #22:close #22 - ' - 'OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #22 - ''include directive - 'print #22, "#include " + CHR$(34) + "inpchain" + str2$(x) + ".txt" + CHR$(34) - 'close #22 - ''create/clear include file - 'open tmpdir$ + "inpchain" + str2$(x) + ".txt" for output as #22:close #22 - - - - - - - END IF 'id.arrayelements=-1 - -NEXT -use_global_byte_elements = 0 -IF Debug THEN PRINT #9, "Finished generation of code for saving/sharing common array data!" - - -FOR closeall = 1 TO 255: CLOSE closeall: NEXT -OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock - -compilelog$ = tmpdir$ + "compilelog.txt" - -OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log - -IF idemode = 0 AND NOT QuietMode THEN - IF ConsoleMode THEN - PRINT "[" + STRING$(maxprogresswidth, ".") + "] 100%" - ELSE - LOCATE , 1 - PRINT STRING$(maxprogresswidth, 219) + " 100%" - END IF -END IF - -IF NOT IgnoreWarnings THEN - totalUnusedVariables = 0 - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).used = 0 THEN - totalUnusedVariables = totalUnusedVariables + 1 - END IF - NEXT - - IF totalUnusedVariables > 0 THEN - maxVarNameLen = 0 - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).used = 0 THEN - IF LEN(usedVariableList(i).name) > maxVarNameLen THEN maxVarNameLen = LEN(usedVariableList(i).name) - END IF - NEXT - - header$ = "unused variable" 's (" + LTRIM$(STR$(totalUnusedVariables)) + ")" - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).used = 0 THEN - addWarning usedVariableList(i).linenumber, usedVariableList(i).includeLevel, usedVariableList(i).includedLine, usedVariableList(i).includedFile, header$, usedVariableList(i).name + SPACE$((maxVarNameLen + 1) - LEN(usedVariableList(i).name)) + " " + usedVariableList(i).varType - END IF - NEXT - END IF -END IF - -IF idemode THEN GOTO ideret5 -ide6: - -IF idemode = 0 AND No_C_Compile_Mode = 0 THEN - IF NOT QuietMode THEN - PRINT - IF os$ = "LNX" THEN - PRINT "Compiling C++ code into executable..." - ELSE - PRINT "Compiling C++ code into EXE..." - END IF - END IF - IF LEN(outputfile_cmd$) THEN - 'resolve relative path for output file - path.out$ = getfilepath$(outputfile_cmd$) - f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1) - file$ = RemoveFileExtension$(f$) - IF LEN(path.out$) THEN - IF _DIREXISTS(path.out$) = 0 THEN - PRINT - PRINT "Can't create output executable - path not found: " + path.out$ - IF ConsoleMode THEN SYSTEM 1 - END 1 - END IF - currentdir$ = _CWD$ - CHDIR path.out$ - path.out$ = _CWD$ - CHDIR currentdir$ - IF RIGHT$(path.out$, 1) <> pathsep$ THEN path.out$ = path.out$ + pathsep$ - path.exe$ = path.out$ - SaveExeWithSource = -1 'Override the global setting if an output file was specified - END IF - END IF - t.path.exe$ = path.exe$ - IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN - E = 0 - ON ERROR GOTO qberror_test - KILL path.exe$ + file$ + extension$ - ON ERROR GOTO qberror - IF E = 1 THEN - a$ = "CANNOT CREATE " + CHR$(34) + file$ + extension$ + CHR$(34) + " BECAUSE THE FILE IS ALREADY IN USE!": GOTO errmes - END IF - END IF - path.exe$ = t.path.exe$ -END IF - -IF ExeIconSet THEN - linenumber = ExeIconSet 'on error, this allows reporting the linenumber where $EXEICON was used - wholeline = " $EXEICON:'" + ExeIconFile$ + "'" - - ' Copy icon file into temp directory with known name - ' This solves the problem of the resource file needing an absolute path - ON ERROR GOTO qberror_test - - DIM errNo AS LONG - errNo = CopyFile&(ExeIconFile$, tmpdir$ + "icon.ico") - IF errNo <> 0 THEN a$ = "Error copying " + QuotedFilename$(ExeIconFile$) + " to temp directory": GOTO errmes - - ON ERROR GOTO qberror -END IF - -IF VersionInfoSet THEN - manifest = FREEFILE - OPEN tmpdir$ + file$ + extension$ + ".manifest" FOR OUTPUT AS #manifest - PRINT #manifest, "" - PRINT #manifest, "" - PRINT #manifest, "" - PRINT #manifest, "" + viFileDescription$ + "" - PRINT #manifest, "" - PRINT #manifest, " " - PRINT #manifest, " " - PRINT #manifest, " " - PRINT #manifest, "" - PRINT #manifest, "" - CLOSE #manifest - - manifestembed = FREEFILE - OPEN tmpdir$ + "manifest.h" FOR OUTPUT AS #manifestembed - PRINT #manifestembed, "#ifndef RESOURCE_H" - PRINT #manifestembed, "#define RESOURCE_H" - PRINT #manifestembed, "#ifdef __cplusplus" - PRINT #manifestembed, "extern " + AddQuotes$("C") + " {" - PRINT #manifestembed, "#endif" - PRINT #manifestembed, "#ifdef __cplusplus" - PRINT #manifestembed, "}" - PRINT #manifestembed, "#endif" - PRINT #manifestembed, "#endif /* RESOURCE_H */" - PRINT #manifestembed, "#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 /*Defined manifest file*/" - PRINT #manifestembed, "#define RT_MANIFEST 24" - CLOSE #manifestembed -END IF - -IF VersionInfoSet OR ExeIconSet THEN - iconfilehandle = FREEFILE - OPEN tmpdir$ + "icon.rc" FOR OUTPUT AS #iconfilehandle - - IF ExeIconSet THEN - PRINT #iconfilehandle, "0 ICON " + AddQuotes$("icon.ico") - END IF - - IF VersionInfoSet THEN - PRINT #iconfilehandle, "" - PRINT #iconfilehandle, "#include " + AddQuotes$("manifest.h") - PRINT #iconfilehandle, "" - PRINT #iconfilehandle, "CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST " + AddQuotes$(file$ + extension$ + ".manifest") - PRINT #iconfilehandle, "" - PRINT #iconfilehandle, "1 VERSIONINFO" - IF LEN(viFileVersionNum$) THEN PRINT #iconfilehandle, "FILEVERSION "; viFileVersionNum$ - IF LEN(viProductVersionNum$) THEN PRINT #iconfilehandle, "PRODUCTVERSION "; viProductVersionNum$ - PRINT #iconfilehandle, "BEGIN" - PRINT #iconfilehandle, " BLOCK " + AddQuotes$("StringFileInfo") - PRINT #iconfilehandle, " BEGIN" - PRINT #iconfilehandle, " BLOCK " + AddQuotes$("040904E4") - PRINT #iconfilehandle, " BEGIN" - PRINT #iconfilehandle, " VALUE " + AddQuotes$("CompanyName") + "," + AddQuotes$(viCompanyName$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("FileDescription") + "," + AddQuotes$(viFileDescription$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("FileVersion") + "," + AddQuotes$(viFileVersion$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("InternalName") + "," + AddQuotes$(viInternalName$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("LegalCopyright") + "," + AddQuotes$(viLegalCopyright$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("LegalTrademarks") + "," + AddQuotes$(viLegalTrademarks$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("OriginalFilename") + "," + AddQuotes$(viOriginalFilename$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("ProductName") + "," + AddQuotes$(viProductName$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("ProductVersion") + "," + AddQuotes$(viProductVersion$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("Comments") + "," + AddQuotes$(viComments$ + "\0") - PRINT #iconfilehandle, " VALUE " + AddQuotes$("Web") + "," + AddQuotes$(viWeb$ + "\0") - PRINT #iconfilehandle, " END" - PRINT #iconfilehandle, " END" - PRINT #iconfilehandle, " BLOCK " + AddQuotes$("VarFileInfo") - PRINT #iconfilehandle, " BEGIN" - PRINT #iconfilehandle, " VALUE " + AddQuotes$("Translation") + ", 0x409, 0x04E4" - PRINT #iconfilehandle, " END" - PRINT #iconfilehandle, "END" - CLOSE #iconfilehandle - END IF -END IF - -'Update dependencies - -o$ = LCASE$(os$) -win = 0: IF os$ = "WIN" THEN win = 1 -lnx = 0: IF os$ = "LNX" THEN lnx = 1 -mac = 0: IF MacOSX THEN mac = 1: o$ = "osx" -ver$ = Version$ 'eg. "0.123" -libs$ = "" -makedeps$ = "" -make$ = GetMakeExecutable$ - -localpath$ = "internal\c\" - - -IF DEPENDENCY(DEPENDENCY_GL) THEN makedeps$ = makedeps$ + " DEP_GL=y" -IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENIMAGE=y" -IF DEPENDENCY(DEPENDENCY_IMAGE_CODEC) THEN makedeps$ = makedeps$ + " DEP_IMAGE_CODEC=y" -IF DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) THEN makedeps$ = makedeps$ + " DEP_CONSOLE_ONLY=y" -IF DEPENDENCY(DEPENDENCY_SOCKETS) THEN makedeps$ = makedeps$ + " DEP_SOCKETS=y" -IF DEPENDENCY(DEPENDENCY_PRINTER) THEN makedeps$ = makedeps$ + " DEP_PRINTER=y" -IF DEPENDENCY(DEPENDENCY_ICON) THEN makedeps$ = makedeps$ + " DEP_ICON=y" -IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENIMAGE=y" -IF DEPENDENCY(DEPENDENCY_LOADFONT) THEN makedeps$ = makedeps$ + " DEP_FONT=y" -IF DEPENDENCY(DEPENDENCY_DEVICEINPUT) THEN makedeps$ = makedeps$ + " DEP_DEVICEINPUT=y" -IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) THEN makedeps$ = makedeps$ + " DEP_AUDIO_DECODE=y" -IF DEPENDENCY(DEPENDENCY_AUDIO_CONVERSION) THEN makedeps$ = makedeps$ + " DEP_AUDIO_CONVERSION=y" -IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) THEN makedeps$ = makedeps$ + " DEP_AUDIO_DECODE=y" -IF DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN makedeps$ = makedeps$ + " DEP_AUDIO_OUT=y" -IF DEPENDENCY(DEPENDENCY_ZLIB) THEN makedeps$ = makedeps$ + " DEP_ZLIB=y" -IF inline_DATA = 0 AND DataOffset THEN makedeps$ = makedeps$ + " DEP_DATA=y" -IF Console THEN makedeps$ = makedeps$ + " DEP_CONSOLE=y" -IF ExeIconSet OR VersionInfoSet THEN makedeps$ = makedeps$ + " DEP_ICON_RC=y" - -IF tempfolderindex > 1 THEN makedeps$ = makedeps$ + " TEMP_ID=" + str2$(tempfolderindex) - -CxxFlagsExtra$ = ExtraCppFlags -CxxLibsExtra$ = ExtraLinkerFlags - -' If debugging then use `-Og` rather than `-O2` -IF OptimizeCppProgram THEN - IF Include_GDB_Debugging_Info THEN - CxxFlagsExtra$ = CxxFlagsExtra$ + " -Og" - ELSE - CxxFlagsExtra$ = CxxFlagsExtra$ + " -O2" - END IF -ELSE - IF Include_GDB_Debugging_Info THEN - CxxFlagsExtra$ = CxxFlagsExtra$ + " -g" - END IF -END IF - -CxxLibsExtra$ = CxxLibsExtra$ + " " + mylib$ + " " + mylibopt$ - -' Make and the shell don't like certain characters in the file name, so we -' escape them to get them to handle them properly -escapedExe$ = StrReplace$(path.exe$ + file$ + extension$, " ", "\ ") -escapedExe$ = StrReplace$(escapedExe$, "$", "$$") - -makeline$ = make$ + makedeps$ + " EXE=" + AddQuotes$(escapedExe$) -makeline$ = makeline$ + " " + AddQuotes$("CXXFLAGS_EXTRA=" + CxxFlagsExtra$) -makeline$ = makeline$ + " " + AddQuotes$("CFLAGS_EXTRA=" + CxxFlagsExtra$) -makeline$ = makeline$ + " " + AddQuotes$("CXXLIBS_EXTRA=" + CxxLibsExtra$) -makeline$ = makeline$ + " -j" + AddQuotes$(str2$(MaxParallelProcesses)) - -IF NOT StripDebugSymbols THEN - makeline$ = makeline$ + " STRIP_SYMBOLS=n" -END IF - -IF os$ = "WIN" THEN - - makeline$ = makeline$ + " OS=win" - - 'resolve static function definitions and add to global.txt - FOR x = 1 TO ResolveStaticFunctions - IF LEN(ResolveStaticFunction_File(x)) THEN - - n = 0 - SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " --demangle -g >internal\temp\nm_output.txt" - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) + "(" - OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname+LEFTBRACKET - x1 = INSTR(a$, s$) - IF x1 THEN - IF ResolveStaticFunction_Method(x) = 1 THEN - x1 = x1 + 1 - x2 = INSTR(x1, a$, ")") - fh2 = FREEFILE - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" - CLOSE #fh2 - END IF - n = n + 1 - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - - IF n = 0 THEN 'attempt to locate simple function name without brackets - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) - OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname - x1 = INSTR(a$, s$) - IF RIGHT$(a$, LEN(s$)) = s$ THEN - fh2 = FREEFILE - IF ResolveStaticFunction_Method(x) = 1 THEN - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #fh2, "extern void " + s$ + "(void);" - PRINT #fh2, "}" - ELSE - OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " - END IF - CLOSE #fh2 - n = n + 1 - EXIT DO - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - END IF - - IF n = 0 THEN 'a C++ dynamic object library? - SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " -D --demangle -g >.\internal\temp\nm_output_dynamic.txt" - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) + "(" - OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname+LEFTBRACKET - x1 = INSTR(a$, s$) - IF x1 THEN - IF ResolveStaticFunction_Method(x) = 1 THEN - x1 = x1 + 1 - x2 = INSTR(x1, a$, ")") - fh2 = FREEFILE - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" - CLOSE #fh2 - END IF - n = n + 1 - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - END IF - - IF n = 0 THEN 'a C dynamic object library? - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) - OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname - x1 = INSTR(a$, s$) - IF RIGHT$(a$, LEN(s$)) = s$ THEN - fh2 = FREEFILE - IF ResolveStaticFunction_Method(x) = 1 THEN - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #fh2, "extern void " + s$ + "(void);" - PRINT #fh2, "}" - ELSE - OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " - END IF - CLOSE #fh2 - n = n + 1 - EXIT DO - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - IF n = 0 THEN a$ = "Could not find sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - END IF - - END IF - NEXT - - IF No_C_Compile_Mode = 0 THEN - SHELL _HIDE "cmd /c " + makeline$ + " 1>> " + compilelog$ + " 2>&1" - - IF idemode THEN - 'Restore fg/bg colors - dummy = DarkenFGBG(0) - END IF - END IF - - ffh = FREEFILE - OPEN tmpdir$ + "debug_win.bat" FOR OUTPUT AS #ffh - PRINT #ffh, "@echo off" - PRINT #ffh, "cd %0\..\" - PRINT #ffh, "cd ../.." - PRINT #ffh, "echo C++ Debugging: " + file$ + extension$ + " using gdb.exe" - PRINT #ffh, "echo Debugger commands:" - PRINT #ffh, "echo After the debugger launches type 'run' to start your program" - PRINT #ffh, "echo After your program crashes type 'list' to find where the problem is and fix/report it" - PRINT #ffh, "echo Type 'quit' to exit" - PRINT #ffh, "echo (the GDB debugger has many other useful commands, this advice is for beginners)" - PRINT #ffh, "pause" - PRINT #ffh, "internal\c\c_compiler\bin\gdb.exe " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) - PRINT #ffh, "pause" - CLOSE ffh -END IF - -IF os$ = "LNX" THEN - - IF INSTR(_OS$, "[MACOSX]") THEN - makeline$ = makeline$ + " OS=osx" - ELSE - makeline$ = makeline$ + " OS=lnx" - END IF - - FOR x = 1 TO ResolveStaticFunctions - IF LEN(ResolveStaticFunction_File(x)) THEN - - n = 0 - IF MacOSX = 0 THEN SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " --demangle -g >./internal/temp/nm_output.txt 2>./internal/temp/nm_error.txt" - IF MacOSX THEN SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " >./internal/temp/nm_output.txt 2>./internal/temp/nm_error.txt" - - IF MacOSX = 0 THEN 'C++ name demangling not supported in MacOSX - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) + "(" - OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname+LEFTBRACKET - x1 = INSTR(a$, s$) - IF x1 THEN - IF ResolveStaticFunction_Method(x) = 1 THEN - x1 = x1 + 1 - x2 = INSTR(x1, a$, ")") - fh2 = FREEFILE - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" - CLOSE #fh2 - END IF - n = n + 1 - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - END IF 'macosx=0 - - IF n = 0 THEN 'attempt to locate simple function name without brackets - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x): s2$ = s$ - IF MacOSX THEN s$ = " _" + ResolveStaticFunction_Name(x) 'search for C mangled name - OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname - x1 = INSTR(a$, s$) - IF RIGHT$(a$, LEN(s$)) = s$ THEN - fh2 = FREEFILE - IF ResolveStaticFunction_Method(x) = 1 THEN - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #fh2, "extern void " + s2$ + "(void);" - PRINT #fh2, "}" - ELSE - OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " - END IF - CLOSE #fh2 - n = n + 1 - EXIT DO - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - END IF - - IF n = 0 THEN 'a C++ dynamic object library? - IF MacOSX THEN GOTO macosx_libfind_failed - SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " -D --demangle -g >./internal/temp/nm_output_dynamic.txt 2>./internal/temp/nm_error.txt" - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) + "(" - OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname+LEFTBRACKET - x1 = INSTR(a$, s$) - IF x1 THEN - IF ResolveStaticFunction_Method(x) = 1 THEN - x1 = x1 + 1 - x2 = INSTR(x1, a$, ")") - fh2 = FREEFILE - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" - CLOSE #fh2 - END IF - n = n + 1 - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - END IF - - IF n = 0 THEN 'a C dynamic object library? - fh = FREEFILE - s$ = " " + ResolveStaticFunction_Name(x) - OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh - DO UNTIL EOF(fh) - LINE INPUT #fh, a$ - IF LEN(a$) THEN - 'search for SPACE+functionname - x1 = INSTR(a$, s$) - IF RIGHT$(a$, LEN(s$)) = s$ THEN - fh2 = FREEFILE - IF ResolveStaticFunction_Method(x) = 1 THEN - OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - PRINT #fh2, "extern void " + s$ + "(void);" - PRINT #fh2, "}" - ELSE - OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 - PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " - END IF - CLOSE #fh2 - n = n + 1 - EXIT DO - END IF 'x1 - END IF '<>"" - LOOP - CLOSE #fh - macosx_libfind_failed: - IF n = 0 THEN a$ = "Could not find sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes - END IF - - END IF - NEXT - - IF INSTR(_OS$, "[MACOSX]") THEN - - ffh = FREEFILE - OPEN tmpdir$ + "recompile_osx.command" FOR OUTPUT AS #ffh - PRINT #ffh, "cd " + CHR_QUOTE + "$(dirname " + CHR_QUOTE + "$0" + CHR_QUOTE + ")" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "Recompiling..." + CHR_QUOTE + CHR$(10); - PRINT #ffh, "cd ../c" + CHR$(10); - PRINT #ffh, makeline$ + CHR$(10); - PRINT #ffh, "read -p " + CHR_QUOTE + "Press ENTER to exit..." + CHR_QUOTE + CHR$(10); - CLOSE ffh - SHELL _HIDE "chmod +x " + tmpdir$ + "recompile_osx.command" - - ffh = FREEFILE - OPEN tmpdir$ + "debug_osx.command" FOR OUTPUT AS #ffh - PRINT #ffh, "cd " + CHR_QUOTE + "$(dirname " + CHR_QUOTE + "$0" + CHR_QUOTE + ")" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "Pause()" + CHR$(10); - PRINT #ffh, "{" + CHR$(10); - PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); - PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); - PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); - PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); - PRINT #ffh, "}" + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "C++ Debugging: " + file$ + extension$ + " using GDB" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "Debugger commands:" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "After the debugger launches type 'run' to start your program" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "After your program crashes type 'list' to find where the problem is and fix/report it" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "(the GDB debugger has many other useful commands, this advice is for beginners)" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "gdb " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) + CHR$(10); - PRINT #ffh, "Pause" + CHR$(10); - CLOSE ffh - SHELL _HIDE "chmod +x " + tmpdir$ + "debug_osx.command" - - ELSE - - ffh = FREEFILE - OPEN tmpdir$ + "recompile_lnx.sh" FOR OUTPUT AS #ffh - PRINT #ffh, "#!/bin/sh" + CHR$(10); - PRINT #ffh, "Pause()" + CHR$(10); - PRINT #ffh, "{" + CHR$(10); - PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); - PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); - PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); - PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); - PRINT #ffh, "}" + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "Recompiling..." + CHR_QUOTE + CHR$(10); - PRINT #ffh, "cd ../c" + CHR$(10); - PRINT #ffh, makeline$ + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "Press ENTER to exit..." + CHR_QUOTE + CHR$(10); - PRINT #ffh, "Pause" + CHR$(10); - CLOSE ffh - SHELL _HIDE "chmod +x " + tmpdir$ + "recompile_lnx.sh" - - ffh = FREEFILE - OPEN tmpdir$ + "debug_lnx.sh" FOR OUTPUT AS #ffh - PRINT #ffh, "#!/bin/sh" + CHR$(10); - PRINT #ffh, "Pause()" + CHR$(10); - PRINT #ffh, "{" + CHR$(10); - PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); - PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); - PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); - PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); - PRINT #ffh, "}" + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "C++ Debugging: " + file$ + extension$ + " using GDB" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "Debugger commands:" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "After the debugger launches type 'run' to start your program" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "After your program crashes type 'list' to find where the problem is and fix/report it" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "echo " + CHR_QUOTE + "(the GDB debugger has many other useful commands, this advice is for beginners)" + CHR_QUOTE + CHR$(10); - PRINT #ffh, "gdb " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) + CHR$(10); - PRINT #ffh, "Pause" + CHR$(10); - CLOSE ffh - SHELL _HIDE "chmod +x " + tmpdir$ + "debug_lnx.sh" - - END IF - - IF No_C_Compile_Mode = 0 THEN - SHELL _HIDE makeline$ + " 1>> " + compilelog$ + " 2>&1" - IF idemode THEN - 'Restore fg/bg colors - dummy = DarkenFGBG(0) - END IF - END IF - - IF INSTR(_OS$, "[MACOSX]") THEN - ff = FREEFILE - IF path.exe$ = "./" OR path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = "" - OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff - PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34); - PRINT #ff, CHR$(10); - PRINT #ff, "./" + file$ + extension$ + " &"; - PRINT #ff, CHR$(10); - PRINT #ff, "osascript -e 'tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to close (every window whose name contains " + CHR$(34) + file$ + extension$ + "_start.command" + CHR$(34) + ")' &"; - PRINT #ff, CHR$(10); - PRINT #ff, "osascript -e 'if (count the windows of application " + CHR$(34) + "Terminal" + CHR$(34) + ") is 0 then tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to quit' &"; - PRINT #ff, CHR$(10); - PRINT #ff, "exit"; - PRINT #ff, CHR$(10); - CLOSE #ff - SHELL _HIDE "chmod +x " + path.exe$ + file$ + extension$ + "_start.command" - END IF - -END IF - -IF No_C_Compile_Mode THEN compfailed = 0: GOTO No_C_Compile -IF path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = "" -IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN - compfailed = 0 - lastBinaryGenerated$ = path.exe$ + file$ + extension$ -ELSE - compfailed = 1 'detect compilation failure -END IF - -IF compfailed THEN - IF idemode THEN - idemessage$ = "C++ Compilation failed " + CHR$(0) + "(Check " + _TRIM$(compilelog$) + ")" - GOTO ideerror - END IF - IF compfailed THEN - PRINT "ERROR: C++ compilation failed." - PRINT "Check " + compilelog$ + " for details." - END IF -ELSE - IF idemode = 0 AND NOT QuietMode THEN PRINT "Output: "; lastBinaryGenerated$ -END IF - -Skip_Build: - - - -IF idemode THEN GOTO ideret6 - -No_C_Compile: - -IF (compfailed <> 0 OR warningsissued <> 0) AND ConsoleMode = 0 THEN END 1 -IF compfailed <> 0 THEN SYSTEM 1 -SYSTEM 0 - -qberror_test: -E = 1 -RESUME NEXT - -qberror: -'_CONSOLE ON -'_ECHO "A QB error has occurred (and you have compiled in debugging support)." -'_ECHO "Some key information (qb64.bas):" -'_ECHO "Error" + STR$(ERR) -'_ECHO "Description: " + _ERRORMESSAGE$ -'_ECHO "Line" + STR$(_ERRORLINE) -'IF _INCLERRORLINE THEN -' _ECHO "Included line" + STR$(_INCLERRORLINE) -' _ECHO "Included file " + _INCLERRORFILE$ -'END IF -'_ECHO "" -'_ECHO "Loaded source file details:" -'_ECHO "ideerror =" + STR$(ideerror) + "; qberrorhappened =" + STR$(qberrorhappened) + "; qberrorhappenedvalue =" + STR$(qberrorhappenedvalue) + "; linenumber =" + STR$(linenumber) -'_ECHO "ca$ = {" + ca$ + "}, idecommand$ = {" + idecommand$ + "}" -'_ECHO "linefragment = {" + linefragment+ "}" - -IF Debug THEN 'A more in-your-face error handler - IF ConsoleMode THEN - PRINT - ELSE - _AUTODISPLAY - SCREEN _NEWIMAGE(80, 25, 0), , 0, 0 - COLOR 7, 0 - END IF - _CONTROLCHR OFF - PRINT "A QB error has occurred (and you have compiled in debugging support)." - PRINT "Some key information (qb64.bas):" - PRINT "Error"; ERR - PRINT "Description: "; _ERRORMESSAGE$ - PRINT "Line"; _ERRORLINE - IF _INCLERRORLINE THEN - PRINT "Included line"; _INCLERRORLINE - PRINT "Included file "; _INCLERRORFILE$ - END IF - PRINT - PRINT "Loaded source file details:" - PRINT "ideerror ="; ideerror; "qberrorhappened ="; qberrorhappened; "qberrorhappenedvalue ="; qberrorhappenedvalue; "linenumber ="; linenumber - PRINT "ca$ = {"; ca$; "}, idecommand$ = {"; idecommand$; "}" - PRINT "linefragment = {"; linefragment; "}" - END -END IF - -IF ideerror THEN 'error happened inside the IDE - fh = FREEFILE - OPEN "internal\temp\ideerror.txt" FOR APPEND AS #fh - PRINT #fh, DATE$; TIME$; "--------------------" - PRINT #fh, ERR - PRINT #fh, _ERRORMESSAGE$ - PRINT #fh, _ERRORLINE - PRINT #fh, _INCLERRORLINE - PRINT #fh, _INCLERRORFILE$ - CLOSE #fh - sendc$ = CHR$(255) 'a runtime error has occurred - RESUME sendcommand 'allow IDE to handle error recovery -END IF - -qberrorhappenedvalue = qberrorhappened -qberrorhappened = 1 - -IF Debug THEN PRINT #9, "QB ERROR!" -IF Debug THEN PRINT #9, "ERR="; ERR -IF Debug THEN PRINT #9, "ERL="; ERL - -IF idemode AND qberrorhappenedvalue >= 0 THEN - 'real qb error occurred - ideerrorline = linenumber - idemessage$ = "Compiler error (check for syntax errors) (" + _ERRORMESSAGE$ + ":" - IF ERR THEN idemessage$ = idemessage$ + str2$(ERR) + "-" - IF _ERRORLINE THEN idemessage$ = idemessage$ + str2$(_ERRORLINE) - IF _INCLERRORLINE THEN idemessage$ = idemessage$ + "-" + _INCLERRORFILE$ + "-" + str2$(_INCLERRORLINE) - idemessage$ = idemessage$ + ")" - IF inclevel > 0 THEN idemessage$ = idemessage$ + incerror$ - RESUME ideerror -END IF - -IF qberrorhappenedvalue >= 0 THEN - a$ = "UNEXPECTED INTERNAL COMPILER ERROR!": GOTO errmes 'internal comiler error -END IF - - -qberrorcode = ERR -qberrorline = ERL -IF qberrorhappenedvalue = -1 THEN RESUME qberrorhappened1 -IF qberrorhappenedvalue = -2 THEN RESUME qberrorhappened2 -IF qberrorhappenedvalue = -3 THEN RESUME qberrorhappened3 -END - -errmes: 'set a$ to message -IF Error_Happened THEN a$ = Error_Message: Error_Happened = 0 -layout$ = "": layoutok = 0 'invalidate layout - -IF forceIncludingFile THEN 'If we're to the point where we're adding the automatic QB64 includes, we don't need to report the $INCLUDE information - IF INSTR(a$, "END SUB/FUNCTION before") THEN a$ = "SUB without END SUB" 'Just a simple rewrite of the error message to be less confusing for SUB/FUNCTIONs -ELSE 'We want to let the user know which module the error occurred in - IF inclevel > 0 THEN a$ = a$ + incerror$ -END IF - -IF idemode THEN - ideerrorline = linenumber - idemessage$ = a$ - GOTO ideerror 'infinitely preferable to RESUME -END IF -'non-ide mode output -PRINT -IF NOT MonochromeLoggingMode THEN - IF INSTR(_OS$, "WIN") THEN - COLOR 4 - ELSE - COLOR 9 - END IF -END IF -PRINT a$ -IF NOT MonochromeLoggingMode THEN COLOR 7 -FOR i = 1 TO LEN(linefragment) - IF MID$(linefragment, i, 1) = sp$ THEN MID$(linefragment, i, 1) = " " -NEXT -FOR i = 1 TO LEN(wholeline) - IF MID$(wholeline, i, 1) = sp$ THEN MID$(wholeline, i, 1) = " " -NEXT -PRINT "Caused by (or after):" + linefragment -IF NOT MonochromeLoggingMode THEN COLOR 8 -PRINT "LINE "; -IF NOT MonochromeLoggingMode THEN COLOR 15 -PRINT str2(linenumber) + ":"; -IF NOT MonochromeLoggingMode THEN COLOR 7 -PRINT wholeline - -IF ConsoleMode THEN SYSTEM 1 -END 1 - -FUNCTION ParseCMDLineArgs$ () - 'Recall that COMMAND$ is a concatenation of argv[] elements, so we don't have - 'to worry about more than one space between things (unless they used quotes, - 'in which case they're simply asking for trouble). - FOR i = 1 TO _COMMANDCOUNT - token$ = COMMAND$(i) - IF LCASE$(token$) = "/?" OR LCASE$(token$) = "--help" OR LCASE$(token$) = "/help" THEN token$ = "-?" - SELECT CASE LCASE$(LEFT$(token$, 2)) - CASE "-?" 'Command-line help - _DEST _CONSOLE - IF qb64versionprinted = 0 THEN qb64versionprinted = -1: PRINT "QB64 Compiler V" + Version$ - PRINT - PRINT "Usage: qb64 [switches] " - PRINT - PRINT "Options:" - PRINT " Source file to load" ' '80 columns - PRINT " -c Compile instead of edit" - PRINT " -o Write output executable to " - PRINT " -x Compile instead of edit and output the result to the" - PRINT " console" - PRINT " -w Show warnings" - PRINT " -q Quiet mode (does not inhibit warnings or errors)" - PRINT " -m Do not colorize compiler output (monochrome mode)" - PRINT " -e Enable OPTION _EXPLICIT, making variable declaration" - PRINT " mandatory (per-compilation; doesn't affect the" - PRINT " source file or global settings)" - PRINT " -s[:switch=true/false] View/edit compiler settings" - PRINT " -l: Start the IDE at the specified line number" - PRINT " -p Purge all pre-compiled content first" - PRINT " -z Generate C code without compiling to executable" - PRINT - SYSTEM - CASE "-u" 'Invoke "Update all pages" to populate internal/help files (hidden build option) - Help_Recaching = 2: Help_IgnoreCache = 1 - IF ideupdatehelpbox THEN - _DEST _CONSOLE - PRINT "Update failed: curl not found" - SYSTEM 1 - END IF - SYSTEM - CASE "-c" 'Compile instead of edit - NoIDEMode = 1 - cmdlineswitch = -1 - CASE "-o" 'Specify an output file - IF LEN(COMMAND$(i + 1)) > 0 THEN outputfile_cmd$ = COMMAND$(i + 1): i = i + 1 - cmdlineswitch = -1 - CASE "-x" 'Use the console - ConsoleMode = 1 - NoIDEMode = 1 'Implies -c - cmdlineswitch = -1 - CASE "-w" 'Show warnings - ShowWarnings = -1 - cmdlineswitch = -1 - CASE "-q" 'Quiet mode - QuietMode = -1 - cmdlineswitch = -1 - CASE "-m" 'Monochrome mode - MonochromeLoggingMode = -1 - cmdlineswitch = -1 - CASE "-e" 'Option Explicit - optionexplicit_cmd = -1 - cmdlineswitch = -1 - CASE "-s" 'Settings - settingsMode = -1 - _DEST _CONSOLE - IF qb64versionprinted = 0 THEN qb64versionprinted = -1: PRINT "QB64 Compiler V" + Version$ - SELECT CASE LCASE$(MID$(token$, 3)) - CASE "" - PRINT "debuginfo = "; - IF idedebuginfo THEN PRINT "true" ELSE PRINT "false" - PRINT "exewithsource = "; - IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false" - SYSTEM - CASE ":exewithsource" - PRINT "exewithsource = "; - IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false" - SYSTEM - CASE ":exewithsource=true" - WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "True" - PRINT "exewithsource = true" - SaveExeWithSource = -1 - CASE ":exewithsource=false" - WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "False" - PRINT "exewithsource = false" - SaveExeWithSource = 0 - CASE ":debuginfo" - PRINT "debuginfo = "; - IF idedebuginfo THEN PRINT "true" ELSE PRINT "false" - SYSTEM - CASE ":debuginfo=true" - PRINT "debuginfo = true" - WriteConfigSetting generalSettingsSection$, "DebugInfo", "True" + DebugInfoIniWarning$ - idedebuginfo = -1 - Include_GDB_Debugging_Info = idedebuginfo - PurgeTemporaryBuildFiles (os$), (MacOSX) - CASE ":debuginfo=false" - PRINT "debuginfo = false" - WriteConfigSetting generalSettingsSection$, "DebugInfo", "False" + DebugInfoIniWarning$ - idedebuginfo = 0 - Include_GDB_Debugging_Info = idedebuginfo - PurgeTemporaryBuildFiles (os$), (MacOSX) - CASE ELSE - PRINT "Invalid settings switch: "; token$ - PRINT - PRINT "Valid switches:" - PRINT " -s:debuginfo=true/false (Embed C++ debug info into .EXE)" - PRINT " -s:exewithsource=true/false (Save .EXE in the source folder)" - SYSTEM 1 - END SELECT - _DEST 0 - CASE "-l" 'goto line (ide mode only); -l: - IF MID$(token$, 3, 1) = ":" THEN ideStartAtLine = VAL(MID$(token$, 4)) - cmdlineswitch = -1 - CASE "-p" 'Purge - PurgeTemporaryBuildFiles (os$), (MacOSX) - cmdlineswitch = -1 - CASE "-z" 'Not compiling C code - No_C_Compile_Mode = 1 - ConsoleMode = 1 'Implies -x - NoIDEMode = 1 'Implies -c - cmdlineswitch = -1 - CASE ELSE 'Something we don't recognise, assume it's a filename - IF PassedFileName$ = "" THEN PassedFileName$ = token$ - END SELECT - NEXT i - - IF LEN(PassedFileName$) THEN - ParseCMDLineArgs$ = PassedFileName$ - ELSE - IF cmdlineswitch = 0 AND settingsMode = -1 THEN SYSTEM - END IF -END FUNCTION - -FUNCTION Type2MemTypeValue (t1) - t = 0 - IF t1 AND ISARRAY THEN t = t + 65536 - IF t1 AND ISUDT THEN - IF (t1 AND 511) = 1 THEN - t = t + 4096 '_MEM type - ELSE - t = t + 32768 - END IF - ELSE - IF t1 AND ISSTRING THEN - t = t + 512 'string - ELSE - IF t1 AND ISFLOAT THEN - t = t + 256 'float - ELSE - t = t + 128 'integer - IF t1 AND ISUNSIGNED THEN t = t + 1024 - IF t1 AND ISOFFSET THEN t = t + 8192 'offset type - END IF - t1s = (t1 AND 511) \ 8 - IF t1s = 1 THEN t = t + t1s - IF t1s = 2 THEN t = t + t1s - IF t1s = 4 THEN t = t + t1s - IF t1s = 8 THEN t = t + t1s - IF t1s = 16 THEN t = t + t1s - IF t1s = 32 THEN t = t + t1s - IF t1s = 64 THEN t = t + t1s - END IF - END IF - Type2MemTypeValue = t -END FUNCTION - -'udt is non-zero if this is an array of udt's, to allow examining each udt element -FUNCTION allocarray (n2$, elements$, elementsize, udt) - dimsharedlast = dimshared: dimshared = 0 - - IF autoarray = 1 THEN autoarray = 0: autoary = 1 'clear global value & set local value - - f12$ = "" - - 'changelog: - 'added 4 to [2] to indicate cmem array where appropriate - - e$ = elements$: n$ = n2$ - IF elementsize = -2147483647 THEN stringarray = 1: elementsize = 8 - - IF ASC(e$) = 63 THEN '? - l$ = "(" + sp2 + ")" - undefined = -1 - nume = 1 - IF LEN(e$) = 1 THEN GOTO undefinedarray - undefined = 1 - nume = VAL(RIGHT$(e$, LEN(e$) - 1)) - GOTO undefinedarray - END IF - - - 'work out how many elements there are (critical to later calculations) - nume = 1 - n = numelements(e$) - FOR i = 1 TO n - e2$ = getelement(e$, i) - IF e2$ = "(" THEN b = b + 1 - IF b = 0 AND e2$ = "," THEN nume = nume + 1 - IF e2$ = ")" THEN b = b - 1 - NEXT - IF Debug THEN PRINT #9, "numelements count:"; nume - - descstatic = 0 - IF arraydesc THEN - IF id.arrayelements <> nume THEN - - IF id.arrayelements = -1 THEN 'unknown - IF arrayelementslist(currentid) <> 0 AND nume <> arrayelementslist(currentid) THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION - IF nume = 1 THEN id.arrayelements = 1: ids(currentid).arrayelements = 1 'lucky guess! - arrayelementslist(currentid) = nume - ELSE - Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION - END IF - - END IF - IF id.staticarray THEN descstatic = 1 - END IF - - l$ = "(" + sp2 - - cr$ = CHR$(13) + CHR$(10) - sd$ = "" - constdimensions = 1 - ei = 4 + nume * 4 - 4 - cure = 1 - e3$ = "": e3base$ = "" - FOR i = 1 TO n - e2$ = getelement(e$, i) - IF e2$ = "(" THEN b = b + 1 - IF (e2$ = "," AND b = 0) OR i = n THEN - IF i = n THEN e3$ = e3$ + sp + e2$ - e3$ = RIGHT$(e3$, LEN(e3$) - 1) - IF e3base$ <> "" THEN e3base$ = RIGHT$(e3base$, LEN(e3base$) - 1) - 'PRINT e3base$ + "[TO]" + e3$ - 'set the base - - basegiven = 1 - IF e3base$ = "" THEN e3base$ = str2$(optionbase + 0): basegiven = 0 - constequation = 1 - - e3base$ = fixoperationorder$(e3base$) - IF Error_Happened THEN EXIT FUNCTION - IF basegiven THEN l$ = l$ + tlayout$ + sp + SCase$("To") + sp - e3base$ = evaluatetotyp$(e3base$, 64&) - IF Error_Happened THEN EXIT FUNCTION - - IF constequation = 0 THEN constdimensions = 0 - sd$ = sd$ + n$ + "[" + str2(ei) + "]=" + e3base$ + ";" + cr$ - 'set the number of indexes - constequation = 1 - - e3$ = fixoperationorder$(e3$) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + tlayout$ + sp2 - IF i = n THEN l$ = l$ + ")" ELSE l$ = l$ + "," + sp - e3$ = evaluatetotyp$(e3$, 64&) - IF Error_Happened THEN EXIT FUNCTION - - IF constequation = 0 THEN constdimensions = 0 - ei = ei + 1 - sd$ = sd$ + n$ + "[" + str2(ei) + "]=(" + e3$ + ")-" + n$ + "[" + str2(ei - 1) + "]+1;" + cr$ - ei = ei + 1 - 'calc muliplier - IF cure = 1 THEN - 'set only for the purpose of the calculating correct multipliers - sd$ = sd$ + n$ + "[" + str2(ei) + "]=1;" + cr$ - ELSE - sd$ = sd$ + n$ + "[" + str2(ei) + "]=" + n$ + "[" + str2(ei + 4) + "]*" + n$ + "[" + str2(ei + 3) + "];" + cr$ - END IF - ei = ei + 1 - ei = ei + 1 'skip reserved - ei = ei - 8 - cure = cure + 1 - e3$ = "": e3base$ = "" - GOTO aanexte - END IF - IF e2$ = ")" THEN b = b - 1 - IF UCASE$(e2$) = "TO" AND b = 0 THEN - e3base$ = e3$ - e3$ = "" - ELSE - e3$ = e3$ + sp + e2$ - END IF - aanexte: - NEXT - sd$ = LEFT$(sd$, LEN(sd$) - 2) - - undefinedarray: - - 'calc cmem - cmem = 0 - IF arraydesc = 0 THEN - IF cmemlist(idn + 1) THEN cmem = 1 - ELSE - IF cmemlist(arraydesc) THEN cmem = 1 - END IF - - staticarray = constdimensions - IF subfuncn <> 0 AND dimstatic = 0 THEN staticarray = 0 'arrays in SUBS/FUNCTIONS are DYNAMIC - IF dimstatic = 3 THEN staticarray = 0 'STATIC arrayname() listed arrays keep thier values but are dynamic in memory - IF DynamicMode THEN staticarray = 0 - IF redimoption THEN staticarray = 0 - IF dimoption = 3 THEN staticarray = 0 'STATIC a(100) arrays are still dynamic - - IF arraydesc THEN - IF staticarray = 1 THEN - IF descstatic THEN Give_Error "Cannot redefine a static array!": EXIT FUNCTION - staticarray = 0 - END IF - END IF - - - - - - - bytesperelement$ = str2(elementsize) - IF elementsize < 0 THEN - elementsize = -elementsize - bytesperelement$ = str2(elementsize) + "/8+1" - END IF - - - 'Begin creation of array descriptor (if array has not been defined yet) - IF arraydesc = 0 THEN - PRINT #defdatahandle, "ptrszint *" + n$ + "=NULL;" - PRINT #13, "if (!" + n$ + "){" - PRINT #13, n$ + "=(ptrszint*)mem_static_malloc(" + str2(4 * nume + 4 + 1) + "*ptrsz);" '+1 is for the lock - 'create _MEM lock - PRINT #13, "new_mem_lock();" - PRINT #13, "mem_lock_tmp->type=4;" - PRINT #13, "((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "]=(ptrszint)mem_lock_tmp;" - END IF - - 'generate sizestr$ & elesizestr$ (both are used in various places in following code) - sizestr$ = "" - FOR i = 1 TO nume - IF i <> 1 THEN sizestr$ = sizestr$ + "*" - sizestr$ = sizestr$ + n$ + "[" + str2(i * 4 - 4 + 5) + "]" - NEXT - elesizestr$ = sizestr$ 'elements in entire array - sizestr$ = sizestr$ + "*" + bytesperelement$ 'bytes in entire array - - - - '------------------STATIC ARRAY CREATION-------------------------------- - IF staticarray THEN - 'STATIC memory - PRINT #13, sd$ 'setup new array dimension ranges - 'Example of sd$ for DIM a(10): - '__ARRAY_SINGLE_A[4]= 0 ; - '__ARRAY_SINGLE_A[5]=( 10 )-__ARRAY_SINGLE_A[4]+1; - '__ARRAY_SINGLE_A[6]=1; - IF cmem AND stringarray = 0 THEN - 'Note: A string array's pointers are always stored in 64bit memory - '(static)CONVENTINAL memory - PRINT #13, n$ + "[0]=(ptrszint)cmem_static_pointer;" - 'alloc mem & check if static memory boundry has oversteped dynamic memory boundry - PRINT #13, "if ((cmem_static_pointer+=((" + sizestr$ + ")+15)&-16)>cmem_dynamic_base) error(257);" - '64K check - PRINT #13, "if ((" + sizestr$ + ")>65536) error(257);" - 'clear array - PRINT #13, "memset((void*)(" + n$ + "[0]),0," + sizestr$ + ");" - 'set flags - PRINT #13, n$ + "[2]=1+2+4;" 'init+static+cmem - ELSE - '64BIT MEMORY - PRINT #13, n$ + "[0]=(ptrszint)mem_static_malloc(" + sizestr$ + ");" - IF stringarray THEN - 'Init string pointers in the array - PRINT #13, "tmp_long=" + elesizestr$ + ";" - PRINT #13, "while(tmp_long--){" - IF cmem THEN - PRINT #13, "((uint64*)(" + n$ + "[0]))[tmp_long]=(uint64)qbs_new_cmem(0,0);" - ELSE - PRINT #13, "((uint64*)(" + n$ + "[0]))[tmp_long]=(uint64)qbs_new(0,0);" - END IF - PRINT #13, "}" - ELSE - 'clear array - PRINT #13, "memset((void*)(" + n$ + "[0]),0," + sizestr$ + ");" - END IF - PRINT #13, n$ + "[2]=1+2;" 'init+static - END IF - - IF udt > 0 AND udtxvariable(udt) THEN - PRINT #13, "tmp_long=" + elesizestr$ + ";" - PRINT #13, "while(tmp_long--){" - initialise_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ - PRINT #13, acc$ - PRINT #13, "}" - END IF - - 'Close static array desc - PRINT #13, "}" - allocarray = nume + 65536 - END IF - '------------------END OF STATIC ARRAY CREATION------------------------- - - '------------------DYNAMIC ARRAY CREATION------------------------------- - IF staticarray = 0 THEN - - IF undefined = 0 THEN - - - - 'Generate error if array is static - f12$ = f12$ + CRLF + "if (" + n$ + "[2]&2){" 'static array - f12$ = f12$ + CRLF + "error(10);" 'cannot redefine a static array! - f12$ = f12$ + CRLF + "}else{" - 'Note: Array is either undefined or dynamically defined at this point - - - 'REDIM (not DIM) must be used to redefine an array - IF redimoption = 0 THEN - f12$ = f12$ + CRLF + "if (" + n$ + "[2]&1){" 'array is defined - f12$ = f12$ + CRLF + "if (!error_occurred) error(10);" 'cannot redefine an array without using REDIM! - f12$ = f12$ + CRLF + "}else{" - ELSE - '--------ERASE EXISTING ARRAY IF NECESSARY-------- - - 'IMPORTANT: If array is not going to be preserved, it should be cleared before - ' creating the new array for memory considerations - - 'refresh lock ID (_MEM) - f12$ = f12$ + CRLF + "((mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "])->id=(++mem_lock_id);" - - IF redimoption = 2 THEN - f12$ = f12$ + CRLF + "static int32 preserved_elements;" 'must be put here for scope considerations - END IF - - 'If array is defined, it must be destroyed first - f12$ = f12$ + CRLF + "if (" + n$ + "[2]&1){" 'array is defined - - IF redimoption = 2 THEN - f12$ = f12$ + CRLF + "preserved_elements=" + elesizestr$ + ";" - GOTO skiperase - END IF - - 'Note: pointers to strings must be freed before array can be freed - IF stringarray THEN - f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" - f12$ = f12$ + CRLF + "while(tmp_long--) qbs_free((qbs*)((uint64*)(" + n$ + "[0]))[tmp_long]);" - END IF - 'As must any variable length strings in UDT's - IF udt > 0 AND udtxvariable(udt) THEN - f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" - f12$ = f12$ + CRLF + "while(tmp_long--) {" - free_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ - f12$ = f12$ + acc$ + "}" - END IF - - 'Free array's memory - IF stringarray THEN - 'Note: String arrays are never in cmem - f12$ = f12$ + CRLF + "free((void*)(" + n$ + "[0]));" - ELSE - 'Note: Array may be in cmem! - f12$ = f12$ + CRLF + "if (" + n$ + "[2]&4){" 'array is in cmem - f12$ = f12$ + CRLF + "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" - f12$ = f12$ + CRLF + "}else{" 'not in cmem - f12$ = f12$ + CRLF + "free((void*)(" + n$ + "[0]));" - f12$ = f12$ + CRLF + "}" - END IF - - skiperase: - - f12$ = f12$ + CRLF + "}" 'array was defined - IF redimoption = 2 THEN - f12$ = f12$ + CRLF + "else preserved_elements=0;" 'if array wasn't defined, no elements are preserved - END IF - - - '--------ERASED ARRAY AS NECESSARY-------- - END IF 'redim specified - - - '--------CREATE ARRAY & CLEAN-UP CODE-------- - 'Overwrite existing array dimension sizes/ranges - f12$ = f12$ + CRLF + sd$ - IF stringarray OR ((udt > 0) AND udtxvariable(udt)) THEN - - 'Note: String and variable-length udt arrays are always created in 64bit memory - - IF redimoption = 2 THEN - f12$ = f12$ + CRLF + "if (preserved_elements){" - - f12$ = f12$ + CRLF + "static ptrszint tmp_long2;" - - 'free any qbs strings which will be lost in the realloc - f12$ = f12$ + CRLF + "tmp_long2=" + elesizestr$ + ";" - f12$ = f12$ + CRLF + "if (tmp_long2 0 AND udtxvariable(udt) THEN - PRINT #19, "while(tmp_long--) {" - acc$ = "" - free_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ - PRINT #19, acc$ + "}" - ELSE - PRINT #19, "while(tmp_long--) qbs_free((qbs*)((uint64*)(" + n$ + "[0]))[tmp_long]);" - END IF - PRINT #19, "free((void*)(" + n$ + "[0]));" - PRINT #19, "}" - 'free lock (_MEM) - PRINT #19, "free_mem_lock( (mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "] );" - END IF - - - ELSE 'not string/var-udt array - - '1. Create array - f12$ = f12$ + CRLF + "if (" + n$ + "[2]&4){" 'array will be in cmem - - IF redimoption = 2 THEN - f12$ = f12$ + CRLF + "if (preserved_elements){" - - 'reallocation method - 'backup data - f12$ = f12$ + CRLF + "memcpy(redim_preserve_cmem_buffer,(void*)(" + n$ + "[0]),preserved_elements*" + bytesperelement$ + ");" - 'free old array - f12$ = f12$ + CRLF + "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" - f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" - f12$ = f12$ + CRLF + n$ + "[0]=(ptrszint)cmem_dynamic_malloc(tmp_long*" + bytesperelement$ + ");" - f12$ = f12$ + CRLF + "memcpy((void*)(" + n$ + "[0]),redim_preserve_cmem_buffer,preserved_elements*" + bytesperelement$ + ");" - f12$ = f12$ + CRLF + "if (preserved_elements 0 AND elements <> arrayelementslist(currentid) THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION - IF elements = 1 THEN id2.arrayelements = 1: ids(currentid).arrayelements = 1 'lucky guess - arrayelementslist(currentid) = elements - ELSE - IF elements <> id2.arrayelements THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION - END IF - - curarg = 1 - firsti = 1 - FOR i = 1 TO n - l$ = getelement(a$, i) - IF l$ = "(" THEN b = b + 1 - IF l$ = ")" THEN b = b - 1 - IF (l$ = "," AND b = 0) OR (i = n) THEN - IF i = n THEN - IF l$ = "," THEN Give_Error "Array index missing": EXIT FUNCTION - e$ = evaluatetotyp(getelements$(a$, firsti, i), 64&) - IF Error_Happened THEN EXIT FUNCTION - ELSE - e$ = evaluatetotyp(getelements$(a$, firsti, i - 1), 64&) - IF Error_Happened THEN EXIT FUNCTION - END IF - IF e$ = "" THEN Give_Error "Array index missing": EXIT FUNCTION - argi = (elements - curarg) * 4 + 4 - IF curarg = 1 THEN - IF NoChecks = 0 THEN - r$ = r$ + "array_check((" + e$ + ")-" + n$ + "[" + str2(argi) + "]," + n$ + "[" + str2(argi + 1) + "])+" - ELSE - r$ = r$ + "(" + e$ + ")-" + n$ + "[" + str2(argi) + "]+" - END IF - - ELSE - IF NoChecks = 0 THEN - r$ = r$ + "array_check((" + e$ + ")-" + n$ + "[" + str2(argi) + "]," + n$ + "[" + str2(argi + 1) + "])*" + n$ + "[" + str2(argi + 2) + "]+" - ELSE - r$ = r$ + "((" + e$ + ")-" + n$ + "[" + str2(argi) + "])*" + n$ + "[" + str2(argi + 2) + "]+" - END IF - END IF - firsti = i + 1 - curarg = curarg + 1 - END IF - NEXT - r$ = LEFT$(r$, LEN(r$) - 1) 'remove trailing + - gotarrayindex: - - r$ = idnumber$ + sp3 + r$ - arrayreference$ = r$ - 'PRINT "arrayreference returning:" + r$ - -END FUNCTION - -SUB assign (a$, n) - FOR i = 1 TO n - c = ASC(getelement$(a$, i)) - IF c = 40 THEN b = b + 1 '( - IF c = 41 THEN b = b - 1 ') - IF c = 61 AND b = 0 THEN '= - IF i = 1 THEN Give_Error "Expected ... =": EXIT SUB - IF i = n THEN Give_Error "Expected = ...": EXIT SUB - - a2$ = fixoperationorder(getelements$(a$, 1, i - 1)) - IF Error_Happened THEN EXIT SUB - l$ = tlayout$ + sp + "=" + sp - - 'note: evaluating a2$ will fail if it is setting a function's return value without this check (as the function, not the return-variable) will be found by evaluate) - IF i = 2 THEN 'lhs has only 1 element - try = findid(a2$) - IF Error_Happened THEN EXIT SUB - DO WHILE try - IF id.t THEN - IF subfuncn = id.insubfuncn THEN 'avoid global before local - IF (id.t AND ISUDT) = 0 THEN - makeidrefer a2$, typ - GOTO assignsimplevariable - END IF - END IF - END IF - IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 - IF Error_Happened THEN EXIT SUB - LOOP - END IF - - a2$ = evaluate$(a2$, typ): IF Error_Happened THEN EXIT SUB - assignsimplevariable: - IF (typ AND ISREFERENCE) = 0 THEN Give_Error "Expected variable =": EXIT SUB - setrefer a2$, typ, getelements$(a$, i + 1, n), 0 - IF Error_Happened THEN EXIT SUB - tlayout$ = l$ + tlayout$ - - EXIT SUB - - END IF '=,b=0 - NEXT - Give_Error "Expected =": EXIT SUB -END SUB - -SUB clearid - id = cleariddata -END SUB - -SUB vWatchVariable (this$, action AS _BYTE) - STATIC totalLocalVariables AS LONG, localVariablesList$ - STATIC totalMainModuleVariables AS LONG, mainModuleVariablesList$ - - SELECT CASE action - CASE -1 'reset - totalLocalVariables = 0 - localVariablesList$ = "" - totalMainModuleVariables = 0 - mainModuleVariablesList$ = "" - CASE 0 'add - IF INSTR(vWatchVariableExclusions$, "@" + this$ + "@") > 0 OR LEFT$(this$, 12) = "_SUB_VWATCH_" THEN - EXIT SUB - END IF - - vWatchNewVariable$ = this$ - IF subfunc = "" THEN - totalMainModuleVariables = totalMainModuleVariables + 1 - mainModuleVariablesList$ = mainModuleVariablesList$ + "vwatch_global_vars[" + str2$(totalMainModuleVariables - 1) + "] = &" + this$ + ";" + CRLF - manageVariableList id.cn, this$, totalMainModuleVariables - 1, 0 - ELSE - totalLocalVariables = totalLocalVariables + 1 - localVariablesList$ = localVariablesList$ + "vwatch_local_vars[" + str2$(totalLocalVariables - 1) + "] = &" + this$ + ";" + CRLF - manageVariableList id.cn, this$, totalLocalVariables - 1, 0 - END IF - CASE 1 'dump to data[].txt & reset - IF subfunc = "" THEN - IF totalMainModuleVariables > 0 THEN - PRINT #13, "void *vwatch_local_vars[0];" - PRINT #18, "void *vwatch_global_vars["; totalMainModuleVariables; "];" - PRINT #13, mainModuleVariablesList$ - ELSE - PRINT #13, "void *vwatch_local_vars[0];" - PRINT #18, "void *vwatch_global_vars[0];" - END IF - - mainModuleVariablesList$ = "" - totalMainModuleVariables = 0 - ELSE - IF subfunc <> "SUB_VWATCH" THEN - IF totalLocalVariables > 0 THEN - PRINT #13, "void *vwatch_local_vars["; (totalLocalVariables); "];" - PRINT #13, localVariablesList$ - ELSE - PRINT #13, "void *vwatch_local_vars[0];" - END IF - ELSE - PRINT #13, "void *vwatch_local_vars[0];" - END IF - - localVariablesList$ = "" - totalLocalVariables = 0 - END IF - END SELECT -END SUB - -SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) - STATIC prevLabel AS LONG, prevSkip AS LONG - - IF lastLine = 0 THEN - WHILE this > LEN(vWatchUsedLabels) - vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) - vWatchUsedSkipLabels = vWatchUsedSkipLabels + SPACE$(1000) - WEND - - IF firstLineNumberLabelvWatch = 0 THEN - firstLineNumberLabelvWatch = this - ELSE - IF prevSkip <> prevLabel THEN - ASC(vWatchUsedSkipLabels, prevLabel) = 1 - PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" - prevSkip = prevLabel - END IF - END IF - - IF prevLabel <> this THEN - ASC(vWatchUsedLabels, this) = 1 - PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;" - prevLabel = this - lastLineNumberLabelvWatch = this - END IF - ELSE - IF prevSkip <> prevLabel THEN - ASC(vWatchUsedSkipLabels, prevLabel) = 1 - PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" - prevSkip = prevLabel - END IF - END IF -END SUB - -SUB closemain - xend - - PRINT #12, "return;" - - IF vWatchOn AND firstLineNumberLabelvWatch > 0 THEN - PRINT #12, "VWATCH_SETNEXTLINE:;" - PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" - FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch - IF ASC(vWatchUsedLabels, i) = 1 THEN - PRINT #12, " case " + str2$(i) + ":" - PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" - PRINT #12, " break;" - END IF - NEXT - PRINT #12, " default:" - PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" - PRINT #12, " goto VWATCH_SETNEXTLINE;" - PRINT #12, "}" - - PRINT #12, "VWATCH_SKIPLINE:;" - PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" - FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch - IF ASC(vWatchUsedSkipLabels, i) = 1 THEN - PRINT #12, " case -" + str2$(i) + ":" - PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" - PRINT #12, " break;" - END IF - NEXT - PRINT #12, "}" - - END IF - - PRINT #12, "}" - PRINT #15, "}" 'end case - PRINT #15, "}" - PRINT #15, "error(3);" 'no valid return possible - - closedmain = 1 - firstLineNumberLabelvWatch = 0 -END SUB - -FUNCTION countelements (a$) - n = numelements(a$) - c = 1 - FOR i = 1 TO n - e$ = getelement$(a$, i) - IF e$ = "(" THEN b = b + 1 - IF e$ = ")" THEN b = b - 1 - IF b < 0 THEN Give_Error "Unexpected ) encountered": EXIT FUNCTION - IF e$ = "," AND b = 0 THEN c = c + 1 - NEXT - countelements = c -END FUNCTION - - - -FUNCTION dim2 (varname$, typ2$, method, elements$) - - 'notes: (DO NOT REMOVE THESE IMPORTANT USAGE NOTES) - ' - '(shared)dimsfarray: Creates an ID only (no C++ code) - ' Adds an index/'link' to the sub/function's argument - ' ID.sfid=glinkid - ' ID.sfarg=glinkarg - ' Sets arrayelements=-1 'unknown' (if elements$="?") otherwise val(elements$) - ' ***Does not refer to arrayelementslist()*** - ' - '(argument)method: 0 being created by a DIM name AS type - ' 1 being created by a DIM name+symbol - ' or automatically without the use of DIM - ' - 'elements$="?": (see also dimsfarray for that special case) - ' Checks arrayelementslist() and; - ' if unknown(=0), creates an ID only - ' if known, creates a DYNAMIC array's C++ initialization code so it can be used later - - typ$ = typ2$ - dim2 = 1 'success - - IF Debug THEN PRINT #9, "dim2 called", method - - cvarname$ = varname$ - l$ = cvarname$ - varname$ = UCASE$(varname$) - - IF dimsfarray = 1 THEN f = 0 ELSE f = 1 - - IF dimstatic <> 0 AND dimshared = 0 THEN - 'name will have include the sub/func name in its scope - 'variable/array will be created in main on startup - defdatahandle = 18 'change from 13 to 18(global.txt) - CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 - CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 - END IF - - - scope2$ = module$ + "_" + subfunc$ + "_" - 'Note: when REDIMing a SHARED array in dynamic memory scope2$ must be modified - - IF LEN(typ$) = 0 THEN Give_Error "DIM2: No type specified!": EXIT FUNCTION - - 'UDT - 'is it a udt? - FOR i = 1 TO lasttype - IF typ$ = RTRIM$(udtxname(i)) OR (typ$ = "MEM" AND RTRIM$(udtxname(i)) = "_MEM" AND qb64prefix_set = 1) THEN - dim2typepassback$ = RTRIM$(udtxcname(i)) - IF typ$ = "MEM" AND RTRIM$(udtxname(i)) = "_MEM" THEN - dim2typepassback$ = MID$(RTRIM$(udtxcname(i)), 2) - END IF - - n$ = "UDT_" + varname$ - - 'array of UDTs - IF elements$ <> "" THEN - arraydesc = 0 - IF f = 1 THEN - try = findid(varname$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - bits = udtxsize(i) - IF udtxbytealign(i) THEN - IF bits MOD 8 THEN bits = bits + 8 - (bits MOD 8) - END IF - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, -bits, i) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = UDTTYPE + i - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - id.n = cvarname$ - - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - regid - vWatchVariable n$, 0 - IF Error_Happened THEN EXIT FUNCTION - GOTO dim2exitfunc - END IF - - 'not an array of UDTs - bits = udtxsize(i): bytes = bits \ 8 - IF bits MOD 8 THEN - bytes = bytes + 1 - END IF - n$ = scope2$ + n$ - IF f THEN PRINT #defdatahandle, "void *" + n$ + "=NULL;" - clearid - id.n = cvarname$ - id.t = UDTTYPE + i - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f THEN - PRINT #13, "if(" + n$ + "==NULL){" - PRINT #13, "cmem_sp-=" + str2(bytes) + ";" - PRINT #13, "if (cmem_sp 6 THEN - IF LEFT$(typ$, 9) <> "STRING * " THEN Give_Error "Expected STRING * number/constant": EXIT FUNCTION - - c$ = RIGHT$(typ$, LEN(typ$) - 9) - - 'constant check 2011 - hashfound = 0 - hashname$ = c$ - hashchkflags = HASHFLAG_CONSTANT - hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN - IF constdefined(hashresref) THEN - hashfound = 1 - EXIT DO - END IF - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - IF hashfound THEN - i2 = hashresref - t = consttype(i2) - IF t AND ISSTRING THEN Give_Error "Expected STRING * numeric-constant": EXIT FUNCTION - 'convert value to general formats - IF t AND ISFLOAT THEN - v## = constfloat(i2) - v&& = v## - v~&& = v&& - ELSE - IF t AND ISUNSIGNED THEN - v~&& = constuinteger(i2) - v&& = v~&& - v## = v&& - ELSE - v&& = constinteger(i2) - v## = v&& - v~&& = v&& - END IF - END IF - IF v&& < 1 OR v&& > 9999999999 THEN Give_Error "STRING * out-of-range constant": EXIT FUNCTION - bytes = v&& - dim2typepassback$ = SCase$("String * ") + constcname(i2) - GOTO constantlenstr - END IF - - IF isuinteger(c$) = 0 THEN Give_Error "Number/Constant expected after *": EXIT FUNCTION - IF LEN(c$) > 10 THEN Give_Error "Too many characters in number after *": EXIT FUNCTION - bytes = VAL(c$) - IF bytes = 0 THEN Give_Error "Cannot create a fixed string of length 0": EXIT FUNCTION - constantlenstr: - n$ = "STRING" + str2(bytes) + "_" + varname$ - - 'array of fixed length strings - IF elements$ <> "" THEN - arraydesc = 0 - IF f = 1 THEN - try = findid(varname$ + "$") - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(varname$ + "$") ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, bytes) - 'IF arraydesc THEN goto dim2exitfunc 'id already exists! - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, bytes, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = STRINGTYPE + ISFIXEDLENGTH - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - id.n = cvarname$ - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - id.tsize = bytes - IF method = 0 THEN - id.mayhave = "$" + str2(bytes) - END IF - IF method = 1 THEN - id.musthave = "$" + str2(bytes) - END IF - regid - IF Error_Happened THEN EXIT FUNCTION - vWatchVariable n$, 0 - GOTO dim2exitfunc - END IF - - 'standard fixed length string - n$ = scope2$ + n$ - IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" - IF f THEN PRINT #19, "qbs_free(" + n$ + ");" 'so descriptor can be freed - clearid - id.n = cvarname$ - id.t = STRINGTYPE + ISFIXEDLENGTH - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f THEN PRINT #13, "if(" + n$ + "==NULL){" - IF f THEN PRINT #13, "cmem_sp-=" + str2(bytes) + ";" - IF f THEN PRINT #13, "if (cmem_spchr,0," + str2(bytes) + ");" - IF f THEN PRINT #13, "}" - ELSE - IF f THEN PRINT #13, "if(" + n$ + "==NULL){" - o$ = "(uint8*)mem_static_malloc(" + str2$(bytes) + ")" - IF f THEN PRINT #13, n$ + "=qbs_new_fixed(" + o$ + "," + str2$(bytes) + ",0);" - IF f THEN PRINT #13, "memset(" + n$ + "->chr,0," + str2$(bytes) + ");" - IF f THEN PRINT #13, "}" - END IF - id.tsize = bytes - IF method = 0 THEN - id.mayhave = "$" + str2(bytes) - END IF - IF method = 1 THEN - id.musthave = "$" + str2(bytes) - END IF - id.callname = n$ - regid - vWatchVariable n$, 0 - IF Error_Happened THEN EXIT FUNCTION - GOTO dim2exitfunc - END IF - - 'variable length string processing - n$ = "STRING_" + varname$ - - 'array of variable length strings - IF elements$ <> "" THEN - arraydesc = 0 - IF f = 1 THEN - try = findid(varname$ + "$") - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(varname$ + "$") ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, -2147483647) '-2147483647=STRING - 'IF arraydesc THEN goto dim2exitfunc 'id already exists! - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, -2147483647, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.n = cvarname$ - id.arraytype = STRINGTYPE - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - IF method = 0 THEN - id.mayhave = "$" - END IF - IF method = 1 THEN - id.musthave = "$" - END IF - regid - IF Error_Happened THEN EXIT FUNCTION - vWatchVariable n$, 0 - GOTO dim2exitfunc - END IF - - 'standard variable length string - n$ = scope2$ + n$ - clearid - id.n = cvarname$ - id.t = STRINGTYPE - IF cmemlist(idn + 1) THEN - IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" - IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new_cmem(0,0);" - id.t = id.t + ISINCONVENTIONALMEMORY - ELSE - IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" - IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new(0,0);" - END IF - IF f THEN PRINT #19, "qbs_free(" + n$ + ");" - IF method = 0 THEN - id.mayhave = "$" - END IF - IF method = 1 THEN - id.musthave = "$" - END IF - id.callname = n$ - regid - vWatchVariable n$, 0 - IF Error_Happened THEN EXIT FUNCTION - GOTO dim2exitfunc - END IF - - IF LEFT$(typ$, 4) = "_BIT" OR (LEFT$(typ$, 3) = "BIT" AND qb64prefix_set = 1) THEN - IF (LEFT$(typ$, 4) = "_BIT" AND LEN(typ$) > 4) OR (LEFT$(typ$, 3) = "BIT" AND LEN(typ$) > 3) THEN - IF LEFT$(typ$, 7) <> "_BIT * " AND LEFT$(typ$, 6) <> "BIT * " THEN Give_Error "Expected " + qb64prefix$ + "BIT * number": EXIT FUNCTION - c$ = MID$(typ$, INSTR(typ$, " * ") + 3) - IF isuinteger(c$) = 0 THEN Give_Error "Number expected after *": EXIT FUNCTION - IF LEN(c$) > 2 THEN Give_Error "Cannot create a bit variable of size > 64 bits": EXIT FUNCTION - bits = VAL(c$) - IF bits = 0 THEN Give_Error "Cannot create a bit variable of size 0 bits": EXIT FUNCTION - IF bits > 64 THEN Give_Error "Cannot create a bit variable of size > 64 bits": EXIT FUNCTION - ELSE - bits = 1 - END IF - IF bits <= 32 THEN ct$ = "int32" ELSE ct$ = "int64" - IF unsgn THEN n$ = "U": ct$ = "u" + ct$ - n$ = n$ + "BIT" + str2(bits) + "_" + varname$ - - 'array of bit-length variables - IF elements$ <> "" THEN - IF bits > 63 THEN Give_Error "Cannot create a bit array of size > 63 bits": EXIT FUNCTION - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "`" + str2(bits) - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, -bits) 'passing a negative element size signifies bits not bytes - 'IF arraydesc THEN goto dim2exitfunc 'id already exists! - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, -bits, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.n = cvarname$ - id.arraytype = BITTYPE - 1 + bits - IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - IF method = 0 THEN - IF unsgn THEN id.mayhave = "~`" + str2(bits) ELSE id.mayhave = "`" + str2(bits) - END IF - IF method = 1 THEN - IF unsgn THEN id.musthave = "~`" + str2(bits) ELSE id.musthave = "`" + str2(bits) - END IF - regid - IF Error_Happened THEN EXIT FUNCTION - vWatchVariable n$, 0 - GOTO dim2exitfunc - END IF - 'standard bit-length variable - n$ = scope2$ + n$ - PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - PRINT #13, "if(" + n$ + "==NULL){" - PRINT #13, "cmem_sp-=4;" - PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "%%" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 1) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 1, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = BYTETYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = BYTETYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=1;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "%" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 2, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - - id.arraytype = INTEGERTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = INTEGERTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=2;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "%&" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, OS_BITS \ 8, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = OFFSETTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = OFFSETTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=" + str2(OS_BITS \ 8) + ";" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "&" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 4) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 4, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = LONGTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = LONGTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=4;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" - cmps$ = cmps$ + "&&" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 8) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 8, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = INTEGER64TYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = INTEGER64TYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=8;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$ + "!" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 4) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 4, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = SINGLETYPE - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = SINGLETYPE - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=4;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$ + "#" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 8) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 8, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = DOUBLETYPE - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = DOUBLETYPE - IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f = 1 THEN PRINT #13, "cmem_sp-=8;" - IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN - arraydesc = 0 - cmps$ = varname$ + "##" - IF f = 1 THEN - try = findid(cmps$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (id.arraytype) THEN - l$ = RTRIM$(id.cn) - arraydesc = currentid: scope2$ = scope$ - EXIT DO - END IF - IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - n$ = scope2$ + "ARRAY_" + n$ - - 'nume = allocarray(n$, elements$, 32) - 'IF arraydesc THEN goto dim2exitfunc - 'clearid - - IF f = 1 THEN - - IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" - E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array - END IF - nume = allocarray(n$, elements$, 32, 0) - IF Error_Happened THEN EXIT FUNCTION - l$ = l$ + sp + tlayout$ - IF arraydesc THEN GOTO dim2exitfunc - clearid - - ELSE - clearid - IF elements$ = "?" THEN - nume = -1 - id.linkid = glinkid - id.linkarg = glinkarg - ELSE - nume = VAL(elements$) - END IF - END IF - - id.arraytype = FLOATTYPE - IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY - IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 - - id.arrayelements = nume - id.callname = n$ - ELSE - n$ = scope2$ + n$ - clearid - id.t = FLOATTYPE - IF f THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" - IF f THEN PRINT #13, "if(" + n$ + "==NULL){" - IF cmemlist(idn + 1) THEN - id.t = id.t + ISINCONVENTIONALMEMORY - IF f THEN PRINT #13, "cmem_sp-=32;" - IF f THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" - IF f THEN PRINT #13, "if (cmem_sp 0 AND dimshared = 0 THEN - defdatahandle = 13 - CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR APPEND AS #13 - CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR APPEND AS #19 - END IF - - tlayout$ = l$ - -END FUNCTION - - -FUNCTION udtreference$ (o$, a$, typ AS LONG) - 'UDT REFERENCE FORMAT - 'idno|udtno|udtelementno|byteoffset - ' ^udt of the element, not of the id - - obak$ = o$ - - 'PRINT "called udtreference!" - - - r$ = str2$(currentid) + sp3 - - - o = 0 'the fixed/known part of the offset - - incmem = 0 - IF id.t THEN - u = id.t AND 511 - IF id.t AND ISINCONVENTIONALMEMORY THEN incmem = 1 - ELSE - u = id.arraytype AND 511 - IF id.arraytype AND ISINCONVENTIONALMEMORY THEN incmem = 1 - END IF - E = 0 - - n = numelements(a$) - IF n = 0 THEN GOTO fulludt - - i = 1 - udtfindelenext: - IF getelement$(a$, i) <> "." THEN Give_Error "Expected .": EXIT FUNCTION - i = i + 1 - n$ = getelement$(a$, i) - nsym$ = removesymbol(n$): IF LEN(nsym$) THEN ntyp = typname2typ(nsym$): ntypsize = typname2typsize - IF Error_Happened THEN EXIT FUNCTION - - IF n$ = "" THEN Give_Error "Expected .elementname": EXIT FUNCTION - udtfindele: - IF E = 0 THEN E = udtxnext(u) ELSE E = udtenext(E) - IF E = 0 THEN Give_Error "Element not defined": EXIT FUNCTION - n2$ = RTRIM$(udtename(E)) - IF udtebytealign(E) THEN - IF o MOD 8 THEN o = o + (8 - (o MOD 8)) - END IF - - IF n$ <> n2$ THEN - 'increment fixed offset - o = o + udtesize(E) - GOTO udtfindele - END IF - - 'check symbol after element's name (if given) is correct - IF LEN(nsym$) THEN - - IF udtetype(E) AND ISUDT THEN Give_Error "Invalid symbol after user defined type": EXIT FUNCTION - IF ntyp <> udtetype(E) OR ntypsize <> udtetypesize(E) THEN - IF nsym$ = "$" AND ((udtetype(E) AND ISFIXEDLENGTH) <> 0) THEN GOTO correctsymbol - Give_Error "Incorrect symbol after element name": EXIT FUNCTION - END IF - END IF - correctsymbol: - - 'Move into another UDT structure? - IF i <> n THEN - IF (udtetype(E) AND ISUDT) = 0 THEN Give_Error "Expected user defined type": EXIT FUNCTION - u = udtetype(E) AND 511 - E = 0 - i = i + 1 - GOTO udtfindelenext - END IF - - 'Change e reference to u | 0 reference? - IF udtetype(E) AND ISUDT THEN - u = udtetype(E) AND 511 - E = 0 - END IF - - fulludt: - - r$ = r$ + str2$(u) + sp3 + str2$(E) + sp3 - - IF o MOD 8 THEN Give_Error "QB64 cannot handle bit offsets within user defined types": EXIT FUNCTION - o = o \ 8 - - IF o$ <> "" THEN - IF o <> 0 THEN 'dont add an unnecessary 0 - o$ = o$ + "+" + str2$(o) - END IF - ELSE - o$ = str2$(o) - END IF - - r$ = r$ + o$ - - udtreference$ = r$ - typ = udtetype(E) + ISUDT + ISREFERENCE - - 'full udt override: - IF E = 0 THEN - typ = u + ISUDT + ISREFERENCE - END IF - - IF obak$ <> "" THEN typ = typ + ISARRAY - IF incmem THEN typ = typ + ISINCONVENTIONALMEMORY - - 'print "UDTREF:"+r$+","+str2$(typ) - -END FUNCTION - -FUNCTION evaluate$ (a2$, typ AS LONG) - DIM block(1000) AS STRING - DIM evaledblock(1000) AS INTEGER - DIM blocktype(1000) AS LONG - 'typ IS A RETURN VALUE - '''DIM cli(15) AS INTEGER - a$ = a2$ - typ = -1 - - IF Debug THEN PRINT #9, "evaluating:[" + a2$ + "]" - IF a2$ = "" THEN Give_Error "Syntax error": EXIT FUNCTION - - - - - - - '''cl$ = classify(a$) - - blockn = 0 - n = numelements(a$) - b = 0 'bracketting level - FOR i = 1 TO n - - reevaluate: - - - - - l$ = getelement(a$, i) - - - IF Debug THEN PRINT #9, "#*#*#* reevaluating:" + l$, i - - - IF i <> n THEN nextl$ = getelement(a$, i + 1) ELSE nextl$ = "" - - '''getclass cl$, i, cli() - - IF b = 0 THEN 'don't evaluate anything within brackets - - IF Debug THEN PRINT #9, l$ - - l2$ = l$ 'pure version of l$ - FOR try_method = 1 TO 4 - l$ = l2$ - IF try_method = 2 OR try_method = 4 THEN - IF Error_Happened THEN EXIT FUNCTION - dtyp$ = removesymbol(l$): IF Error_Happened THEN dtyp$ = "": Error_Happened = 0 - IF LEN(dtyp$) = 0 THEN - IF isoperator(l$) = 0 THEN - IF isvalidvariable(l$) THEN - IF LEFT$(l$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(l$)) - 64 - l$ = l$ + defineextaz(v) - END IF - END IF - ELSE - l$ = l2$ - END IF - END IF - try = findid(l$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - - IF Debug THEN PRINT #9, try - - 'is l$ an array? - IF nextl$ = "(" THEN - IF id.arraytype THEN - IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN - arrayid = currentid - constequation = 0 - i2 = i + 2 - b2 = 0 - evalnextele3: - l2$ = getelement(a$, i2) - IF l2$ = "(" THEN b2 = b2 + 1 - IF l2$ = ")" THEN - b2 = b2 - 1 - IF b2 = -1 THEN - c$ = arrayreference(getelements$(a$, i + 2, i2 - 1), typ2) - IF Error_Happened THEN EXIT FUNCTION - i = i2 - - 'UDT - IF typ2 AND ISUDT THEN - 'print "arrayref returned:"+c$ - getid arrayid - IF Error_Happened THEN EXIT FUNCTION - o$ = RIGHT$(c$, LEN(c$) - INSTR(c$, sp3)) - 'change o$ to a byte offset if necessary - u = typ2 AND 511 - s = udtxsize(u) - IF udtxbytealign(u) THEN - IF s MOD 8 THEN s = s + (8 - (s MOD 8)) 'round up to nearest byte - s = s \ 8 - END IF - o$ = "(" + o$ + ")*" + str2$(s) - 'print "calling evaludt with o$:"+o$ - GOTO evaludt - END IF - - GOTO evalednextele3 - END IF - END IF - i2 = i2 + 1 - GOTO evalnextele3 - evalednextele3: - blockn = blockn + 1 - block(blockn) = c$ - evaledblock(blockn) = 2 - blocktype(blockn) = typ2 - IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 - GOTO evaled - END IF - END IF - - ELSE - 'not followed by "(" - - 'is l$ a simple variable? - IF id.t <> 0 AND (id.t AND ISUDT) = 0 THEN - IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN - constequation = 0 - blockn = blockn + 1 - makeidrefer block(blockn), blocktype(blockn) - IF (blocktype(blockn) AND ISSTRING) THEN stringprocessinghappened = 1 - evaledblock(blockn) = 2 - GOTO evaled - END IF - END IF - - 'is l$ a UDT? - IF id.t AND ISUDT THEN - IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN - constequation = 0 - o$ = "" - evaludt: - b2 = 0 - i3 = i + 1 - FOR i2 = i3 TO n - e2$ = getelement(a$, i2) - IF e2$ = "(" THEN b2 = b2 + 1 - IF b2 = 0 THEN - IF e2$ = ")" OR isoperator(e2$) THEN - i4 = i2 - 1 - GOTO gotudt - END IF - END IF - IF e2$ = ")" THEN b2 = b2 - 1 - NEXT - i4 = n - gotudt: - IF i4 < i3 THEN e$ = "" ELSE e$ = getelements$(a$, i3, i4) - 'PRINT "UDTREFERENCE:";l$; e$ - e$ = udtreference(o$, e$, typ2) - IF Error_Happened THEN EXIT FUNCTION - i = i4 - blockn = blockn + 1 - block(blockn) = e$ - evaledblock(blockn) = 2 - blocktype(blockn) = typ2 - 'is the following next necessary? - 'IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 - GOTO evaled - END IF - END IF - - END IF '"(" or no "(" - - 'is l$ a function? - IF id.subfunc = 1 THEN - constequation = 0 - IF getelement(a$, i + 1) = "(" THEN - i2 = i + 2 - b2 = 0 - args = 1 - evalnextele: - l2$ = getelement(a$, i2) - IF l2$ = "(" THEN b2 = b2 + 1 - IF l2$ = ")" THEN - b2 = b2 - 1 - IF b2 = -1 THEN - IF i2 = i + 2 THEN Give_Error "Expected (...)": EXIT FUNCTION - c$ = evaluatefunc(getelements$(a$, i + 2, i2 - 1), args, typ2) - IF Error_Happened THEN EXIT FUNCTION - i = i2 - GOTO evalednextele - END IF - END IF - IF l2$ = "," AND b2 = 0 THEN args = args + 1 - i2 = i2 + 1 - GOTO evalnextele - ELSE - 'no brackets - c$ = evaluatefunc("", 0, typ2) - IF Error_Happened THEN EXIT FUNCTION - END IF - evalednextele: - blockn = blockn + 1 - block(blockn) = c$ - evaledblock(blockn) = 2 - blocktype(blockn) = typ2 - IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 - GOTO evaled - END IF - - IF try = 2 THEN findanotherid = 1: try = findid(l$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - NEXT 'try method (1-4) - - 'assume l$ an undefined array? - - IF i <> n THEN - IF getelement$(a$, i + 1) = "(" THEN - IF isoperator(l$) = 0 THEN - IF isvalidvariable(l$) THEN - IF Debug THEN - PRINT #9, "**************" - PRINT #9, "about to auto-create array:" + l$, i - PRINT #9, "**************" - END IF - dtyp$ = removesymbol(l$) - IF Error_Happened THEN EXIT FUNCTION - 'count the number of elements - nume = 1 - b2 = 0 - FOR i2 = i + 2 TO n - e$ = getelement(a$, i2) - IF e$ = "(" THEN b2 = b2 + 1 - IF b2 = 0 AND e$ = "," THEN nume = nume + 1 - IF e$ = ")" THEN b2 = b2 - 1 - IF b2 = -1 THEN EXIT FOR - NEXT - fakee$ = "10": FOR i2 = 2 TO nume: fakee$ = fakee$ + sp + "," + sp + "10": NEXT - IF Debug THEN PRINT #9, "evaluate:creating undefined array using dim2(" + l$ + "," + dtyp$ + ",1," + fakee$ + ")" - IF optionexplicit OR optionexplicitarray THEN Give_Error "Array '" + l$ + "' (" + symbol2fulltypename$(dtyp$) + ") not defined": EXIT FUNCTION - IF Error_Happened THEN EXIT FUNCTION - olddimstatic = dimstatic - method = 1 - IF subfuncn THEN - autoarray = 1 'move dimensioning of auto array to data???.txt from inline - 'static array declared by STATIC name()? - 'check if varname is on the static list - xi = 1 - FOR x = 1 TO staticarraylistn - varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 - typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 - dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 - 'check if they are similar - IF UCASE$(l$) = UCASE$(varname2$) THEN - l3$ = l2$: s$ = removesymbol(l3$) - IF symbol2fulltypename$(dtyp$) = typ2$ OR (dimmethod2 = 0 AND s$ = "") THEN - IF Error_Happened THEN EXIT FUNCTION - 'adopt properties - l$ = varname2$ - dtyp$ = typ2$ - method = dimmethod2 - dimstatic = 3 - END IF 'typ - IF Error_Happened THEN EXIT FUNCTION - END IF 'varname - NEXT - END IF 'subfuncn - bypassNextVariable = -1 - ignore = dim2(l$, dtyp$, method, fakee$) - IF Error_Happened THEN EXIT FUNCTION - dimstatic = olddimstatic - IF Debug THEN PRINT #9, "#*#*#* dim2 has returned!!!" - GOTO reevaluate - END IF - END IF - END IF - END IF - - l$ = l2$ 'restore l$ - - END IF 'b=0 - - IF l$ = "(" THEN - IF b = 0 THEN i1 = i + 1 - b = b + 1 - END IF - - IF b = 0 THEN - blockn = blockn + 1 - block(blockn) = l$ - evaledblock(blockn) = 0 - END IF - - IF l$ = ")" THEN - b = b - 1 - IF b = 0 THEN - c$ = evaluate(getelements$(a$, i1, i - 1), typ2) - IF Error_Happened THEN EXIT FUNCTION - IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 - blockn = blockn + 1 - IF (typ2 AND ISPOINTER) THEN - block(blockn) = c$ - ELSE - block(blockn) = "(" + c$ + ")" - END IF - evaledblock(blockn) = 1 - blocktype(blockn) = typ2 - END IF - END IF - evaled: - NEXT - - r$ = "" 'return value - - IF Debug THEN PRINT #9, "evaluated blocks:"; - FOR i = 1 TO blockn - IF i <> blockn THEN - IF Debug THEN PRINT #9, block(i) + CHR$(219); - ELSE - IF Debug THEN PRINT #9, block(i) - END IF - NEXT - - - - 'identify any referencable values - FOR i = 1 TO blockn - IF isoperator(block(i)) = 0 THEN - IF evaledblock(i) = 0 THEN - - 'a number? - c = ASC(LEFT$(block(i), 1)) - IF c = 45 OR (c >= 48 AND c <= 57) THEN - num$ = block(i) - 'a float? - f = 0 - x = INSTR(num$, "E") - IF x THEN - f = 1: blocktype(i) = SINGLETYPE - ISPOINTER - ELSE - x = INSTR(num$, "D") - IF x THEN - f = 2: blocktype(i) = DOUBLETYPE - ISPOINTER - ELSE - x = INSTR(num$, "F") - IF x THEN - f = 3: blocktype(i) = FLOATTYPE - ISPOINTER - END IF - END IF - END IF - IF f THEN - 'float - IF f = 2 OR f = 3 THEN MID$(num$, x, 1) = "E" 'D,F invalid in C++ - IF f = 3 THEN num$ = num$ + "L" 'otherwise number is rounded to a double - ELSE - 'integer - blocktype(i) = typname2typ(removesymbol$(num$)) - IF Error_Happened THEN EXIT FUNCTION - IF blocktype(i) AND ISPOINTER THEN blocktype(i) = blocktype(i) - ISPOINTER - IF (blocktype(i) AND 511) > 32 THEN - IF blocktype(i) AND ISUNSIGNED THEN num$ = num$ + "ull" ELSE num$ = num$ + "ll" - END IF - END IF - block(i) = " " + num$ + " " 'pad with spaces to avoid C++ computation errors - evaledblock(i) = 1 - GOTO evaledblock - END IF - - 'number? - 'fc = ASC(LEFT$(block(i), 1)) - 'IF fc = 45 OR (fc >= 48 AND fc <= 57) THEN '- or 0-9 - ''it's a number - ''check for an extension, if none, assume integer - 'blocktype(i) = INTEGER64TYPE - ISPOINTER - 'tblock$ = " " + block(i) - 'IF RIGHT$(tblock$, 2) = "##" THEN blocktype(i) = FLOATTYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 2): GOTO evfltnum - 'IF RIGHT$(tblock$, 1) = "#" THEN blocktype(i) = DOUBLETYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 1): GOTO evfltnum - 'IF RIGHT$(tblock$, 1) = "!" THEN blocktype(i) = SINGLETYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 1): GOTO evfltnum - ' - ''C++ 32bit unsigned to signed 64bit - 'IF INSTR(block(i),".")=0 THEN - ' - 'negated=0 - 'if left$(block(i),1)="-" then block(i)=right$(block(i),len(block(i))-1):negated=1 - ' - 'if left$(block(i),2)="0x" then 'hex - 'if len(block(i))=10 then - 'if block(i)>="0x80000000" and block(i)<="0xFFFFFFFF" then block(i)="(int64)"+block(i): goto evnum - 'end if - 'if len(block(i))>10 then block(i)=block(i)+"ll": goto evnum - 'goto evnum - 'end if - ' - 'if left$(block(i),1)="0" then 'octal - 'if len(block(i))=12 then - 'if block(i)>="020000000000" and block(i)<="037777777777" then block(i)="(int64)"+block(i): goto evnum - 'if block(i)>"037777777777" then block(i)=block(i)+"ll": goto evnum - 'end if - 'if len(block(i))>12 then block(i)=block(i)+"ll": goto evnum - 'goto evnum - 'end if - ' - ''decimal - 'if len(block(i))=10 then - 'if block(i)>="2147483648" and block(i)<="4294967295" then block(i)="(int64)"+block(i): goto evnum - 'if block(i)>"4294967295" then block(i)=block(i)+"ll": goto evnum - 'end if - 'if len(block(i))>10 then block(i)=block(i)+"ll" - ' - 'evnum: - ' - 'if negated=1 then block(i)="-"+block(i) - ' - 'END IF - ' - 'evfltnum: - ' - 'block(i) = " " + block(i)+" " - 'evaledblock(i) = 1 - 'GOTO evaledblock - 'END IF - - 'a typed string in "" - IF LEFT$(block(i), 1) = CHR$(34) THEN - IF RIGHT$(block(i), 1) <> CHR$(34) THEN - block(i) = "qbs_new_txt_len(" + block(i) + ")" - ELSE - block(i) = "qbs_new_txt(" + block(i) + ")" - END IF - blocktype(i) = ISSTRING - evaledblock(i) = 1 - stringprocessinghappened = 1 - GOTO evaledblock - END IF - - 'create variable - IF isvalidvariable(block(i)) THEN - x$ = block(i) - - typ$ = removesymbol$(x$) - IF Error_Happened THEN EXIT FUNCTION - - 'add symbol extension if none given - IF LEN(typ$) = 0 THEN - IF LEFT$(x$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(x$)) - 64 - typ$ = defineextaz(v) - END IF - - 'check that it hasn't just been created within this loop (a=b+b) - try = findid(x$ + typ$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF Debug THEN PRINT #9, try - IF id.t <> 0 AND (id.t AND ISUDT) = 0 THEN 'is x$ a simple variable? - GOTO simplevarfound - END IF - IF try = 2 THEN findanotherid = 1: try = findid(x$ + typ$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - IF Debug THEN PRINT #9, "CREATING VARIABLE:" + x$ - IF optionexplicit THEN Give_Error "Variable '" + x$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": EXIT FUNCTION - bypassNextVariable = -1 - retval = dim2(x$, typ$, 1, "") - manageVariableList "", vWatchNewVariable$, 0, 3 - IF Error_Happened THEN EXIT FUNCTION - - simplevarfound: - constequation = 0 - makeidrefer block(i), blocktype(i) - IF (blocktype(i) AND ISSTRING) THEN stringprocessinghappened = 1 - IF blockn = 1 THEN - IF (blocktype(i) AND ISREFERENCE) THEN GOTO returnpointer - END IF - 'reference value - block(i) = refer(block(i), blocktype(i), 0): IF Error_Happened THEN EXIT FUNCTION - evaledblock(i) = 1 - GOTO evaledblock - END IF - Give_Error "Invalid expression": EXIT FUNCTION - - ELSE - IF (blocktype(i) AND ISREFERENCE) THEN - IF blockn = 1 THEN GOTO returnpointer - - 'if blocktype(i) and ISUDT then PRINT "UDT passed to refer by evaluate" - - block(i) = refer(block(i), blocktype(i), 0) - IF Error_Happened THEN EXIT FUNCTION - - END IF - - END IF - END IF - evaledblock: - NEXT - - - 'return a POINTER if possible - IF blockn = 1 THEN - IF evaledblock(1) THEN - IF (blocktype(1) AND ISREFERENCE) THEN - returnpointer: - IF (blocktype(1) AND ISSTRING) THEN stringprocessinghappened = 1 - IF Debug THEN PRINT #9, "evaluated reference:" + block(1) - typ = blocktype(1) - evaluate$ = block(1) - EXIT FUNCTION - END IF - END IF - END IF - 'it cannot be returned as a pointer - - - - - - - - - IF Debug THEN PRINT #9, "applying operators:"; - - - IF typ = -1 THEN - typ = blocktype(1) 'init typ with first blocktype - - - IF isoperator(block(1)) THEN 'but what if it starts with a UNARY operator? - typ = blocktype(2) 'init typ with second blocktype - END IF - END IF - - nonop = 0 - FOR i = 1 TO blockn - - IF evaledblock(i) = 0 THEN - isop = isoperator(block(i)) - IF isop THEN - nonop = 0 - - constequation = 0 - - 'operator found - o$ = block(i) - u = operatorusage(o$, typ, i$, lhstyp, rhstyp, result) - - IF u <> 5 THEN 'not unary - nonop = 1 - IF i = 1 OR evaledblock(i - 1) = 0 THEN - IF i = 1 AND blockn = 1 AND o$ = "-" THEN Give_Error "Expected variable/value after '" + UCASE$(o$) + "'": EXIT FUNCTION 'guess - is neg in this case - Give_Error "Expected variable/value before '" + UCASE$(o$) + "'": EXIT FUNCTION - END IF - END IF - IF i = blockn OR evaledblock(i + 1) = 0 THEN Give_Error "Expected variable/value after '" + UCASE$(o$) + "'": EXIT FUNCTION - - 'lhstyp & rhstyp bit-field values - '1=integeral - '2=floating point - '4=string - '8=bool *only used for result - - oldtyp = typ - newtyp = blocktype(i + 1) - - 'IF block(i - 1) = "6" THEN - 'PRINT o$ - 'PRINT oldtyp AND ISFLOAT - 'PRINT blocktype(i - 1) AND ISFLOAT - 'END - 'END IF - - - - 'numeric->string is illegal! - IF (typ AND ISSTRING) = 0 AND (newtyp AND ISSTRING) <> 0 THEN - Give_Error "Cannot convert number to string": EXIT FUNCTION - END IF - - 'Offset protection: Override conversion rules for operator as necessary - offsetmode = 0 - offsetcvi = 0 - IF (oldtyp AND ISOFFSET) <> 0 OR (newtyp AND ISOFFSET) <> 0 THEN - offsetmode = 2 - IF newtyp AND ISOFFSET THEN - IF (newtyp AND ISUNSIGNED) = 0 THEN offsetmode = 1 - END IF - IF oldtyp AND ISOFFSET THEN - IF (oldtyp AND ISUNSIGNED) = 0 THEN offsetmode = 1 - END IF - - 'depending on the operater we may do things differently - 'the default method is convert both sides to integer first - 'but these operators are different: * / ^ - IF o$ = "*" OR o$ = "/" OR o$ = "^" THEN - IF o$ = "*" OR o$ = "^" THEN - 'for mult, if either side is a float cast integers to 'long double's first - IF (newtyp AND ISFLOAT) <> 0 OR (oldtyp AND ISFLOAT) <> 0 THEN - offsetcvi = 1 - IF (oldtyp AND ISFLOAT) = 0 THEN lhstyp = 2 - IF (newtyp AND ISFLOAT) = 0 THEN rhstyp = 2 - END IF - END IF - IF o$ = "/" OR o$ = "^" THEN - 'for division or exponentials, to prevent integer division cast integers to 'long double's - offsetcvi = 1 - IF (oldtyp AND ISFLOAT) = 0 THEN lhstyp = 2 - IF (newtyp AND ISFLOAT) = 0 THEN rhstyp = 2 - END IF - ELSE - IF lhstyp AND 2 THEN lhstyp = 1 'force lhs and rhs to be integer values - IF rhstyp AND 2 THEN rhstyp = 1 - END IF - - IF result = 2 THEN result = 1 'force integer result - 'note: result=1 just sets typ&=64 if typ is a float - - END IF - - 'STEP 1: convert oldtyp and/or newtyp if required for the operator - 'convert lhs - IF (oldtyp AND ISSTRING) THEN - IF (lhstyp AND 4) = 0 THEN Give_Error "Cannot convert string to number": EXIT FUNCTION - ELSE - 'oldtyp is numeric - IF lhstyp = 4 THEN Give_Error "Cannot convert number to string": EXIT FUNCTION - IF (oldtyp AND ISFLOAT) THEN - IF (lhstyp AND 2) = 0 THEN - 'convert float to int - block(i - 1) = "qbr(" + block(i - 1) + ")" - oldtyp = 64& - END IF - ELSE - 'oldtyp is an int - IF (lhstyp AND 1) = 0 THEN - 'convert int to float - block(i - 1) = "((long double)(" + block(i - 1) + "))" - oldtyp = 256& + ISFLOAT - END IF - END IF - END IF - 'convert rhs - IF (newtyp AND ISSTRING) THEN - IF (rhstyp AND 4) = 0 THEN Give_Error "Cannot convert string to number": EXIT FUNCTION - ELSE - 'newtyp is numeric - IF rhstyp = 4 THEN Give_Error "Cannot convert number to string": EXIT FUNCTION - IF (newtyp AND ISFLOAT) THEN - IF (rhstyp AND 2) = 0 THEN - 'convert float to int - block(i + 1) = "qbr(" + block(i + 1) + ")" - newtyp = 64& - END IF - ELSE - 'newtyp is an int - IF (rhstyp AND 1) = 0 THEN - 'convert int to float - block(i + 1) = "((long double)(" + block(i + 1) + "))" - newtyp = 256& + ISFLOAT - END IF - END IF - END IF - - 'Reduce floating point values to common base for comparison? - IF isop = 7 THEN 'comparitive operator - 'Corrects problems encountered such as: - ' S = 2.1 - ' IF S = 2.1 THEN PRINT "OK" ELSE PRINT "ERROR S PRINTS AS"; S; "BUT IS SEEN BY QB64 AS..." - ' IF S < 2.1 THEN PRINT "LESS THAN 2.1" - 'concerns: - '1. Return value from TIMER will be reduced to a SINGLE in direct comparisons - 'solution: assess, and only apply to SINGLE variables/arrays - '2. Comparison of a double higher/lower than single range may fail - 'solution: out of range values convert to +/-1.#INF, making comparison still possible - IF (oldtyp AND ISFLOAT) <> 0 AND (newtyp AND ISFLOAT) <> 0 THEN 'both floating point - s1 = oldtyp AND 511: s2 = newtyp AND 511 - IF s2 < s1 THEN s1 = s2 - IF s1 = 32 THEN - block(i - 1) = "((float)(" + block(i - 1) + "))": oldtyp = 32& + ISFLOAT - block(i + 1) = "((float)(" + block(i + 1) + "))": newtyp = 32& + ISFLOAT - END IF - IF s1 = 64 THEN - block(i - 1) = "((double)(" + block(i - 1) + "))": oldtyp = 64& + ISFLOAT - block(i + 1) = "((double)(" + block(i + 1) + "))": newtyp = 64& + ISFLOAT - END IF - END IF 'both floating point - END IF 'comparitive operator - - typ = newtyp - - 'STEP 2: markup typ - ' if either side is a float, markup typ to largest float - ' if either side is integer, markup typ - 'Note: A markup is a GUESS of what the return type will be, - ' 'result' can override this markup - IF (oldtyp AND ISSTRING) = 0 AND (newtyp AND ISSTRING) = 0 THEN - IF (oldtyp AND ISFLOAT) <> 0 OR (newtyp AND ISFLOAT) <> 0 THEN - 'float - b = 0: IF (oldtyp AND ISFLOAT) THEN b = oldtyp AND 511 - IF (newtyp AND ISFLOAT) THEN - b2 = newtyp AND 511: IF b2 > b THEN b = b2 - END IF - typ = ISFLOAT + b - ELSE - 'integer - '***THIS IS THE IDEAL MARKUP FOR A 64-BIT SYSTEM*** - 'In reality 32-bit C++ only marks-up to 32-bit integers - b = oldtyp AND 511: b2 = newtyp AND 511: IF b2 > b THEN b = b2 - typ = 64& - IF b = 64 THEN - IF (oldtyp AND ISUNSIGNED) <> 0 AND (newtyp AND ISUNSIGNED) <> 0 THEN typ = 64& + ISUNSIGNED - END IF - END IF - END IF - - IF result = 1 THEN - IF (typ AND ISFLOAT) <> 0 OR (typ AND ISSTRING) <> 0 THEN typ = 64 'otherwise keep markuped integer type - END IF - IF result = 2 THEN - IF (typ AND ISFLOAT) = 0 THEN typ = ISFLOAT + 256 - END IF - IF result = 4 THEN - typ = ISSTRING - END IF - IF result = 8 THEN 'bool - typ = 32 - END IF - - 'Offset protection: Force result to be an offset type with correct signage - IF offsetmode THEN - IF result <> 8 THEN 'boolean comparison results are allowed - typ = OFFSETTYPE - ISPOINTER: IF offsetmode = 2 THEN typ = typ + ISUNSIGNED - END IF - END IF - - 'override typ=ISFLOAT+256 to typ=ISFLOAT+64 for ^ operator's result - IF u = 2 THEN - IF i$ = "pow2" THEN - - IF offsetmode THEN Give_Error "Operator '^' cannot be used with an _OFFSET": EXIT FUNCTION - - 'QB-like conversion of math functions returning floating point values - 'reassess oldtype & newtype - b = oldtyp AND 511 - IF oldtyp AND ISFLOAT THEN - 'no change to b - ELSE - IF b > 16 THEN b = 64 'larger than INTEGER? return DOUBLE - IF b > 32 THEN b = 256 'larger than LONG? return FLOAT - IF b <= 16 THEN b = 32 - END IF - b2 = newtyp AND 511 - IF newtyp AND ISFLOAT THEN - IF b2 > b THEN b = b2 - ELSE - b3 = 32 - IF b2 > 16 THEN b3 = 64 'larger than INTEGER? return DOUBLE - IF b2 > 32 THEN b3 = 256 'larger than LONG? return FLOAT - IF b3 > b THEN b = b3 - END IF - typ = ISFLOAT + b - - END IF 'pow2 - END IF 'u=2 - - 'STEP 3: apply operator appropriately - - IF u = 5 THEN - block(i + 1) = i$ + "(" + block(i + 1) + ")" - block(i) = "": i = i + 1: GOTO operatorapplied - END IF - - 'binary operators - - IF u = 1 THEN - block(i + 1) = block(i - 1) + i$ + block(i + 1) - block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied - END IF - - IF u = 2 THEN - block(i + 1) = i$ + "(" + block(i - 1) + "," + block(i + 1) + ")" - block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied - END IF - - IF u = 3 THEN - block(i + 1) = "-(" + block(i - 1) + i$ + block(i + 1) + ")" - block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied - END IF - - IF u = 4 THEN - block(i + 1) = "~" + block(i - 1) + i$ + block(i + 1) - block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied - END IF - - '...more?... - - Give_Error "ERROR: Operator could not be applied correctly!": EXIT FUNCTION '<--should never happen! - operatorapplied: - - IF offsetcvi THEN block(i) = "qbr(" + block(i) + ")": offsetcvi = 0 - offsetmode = 0 - - ELSE - nonop = nonop + 1 - END IF - ELSE - nonop = nonop + 1 - END IF - IF nonop > 1 THEN Give_Error "Expected operator in equation": EXIT FUNCTION - NEXT - IF Debug THEN PRINT #9, "" - - 'join blocks - FOR i = 1 TO blockn - r$ = r$ + block(i) - NEXT - - IF Debug THEN - PRINT #9, "evaluated:" + r$ + " AS TYPE:"; - IF (typ AND ISSTRING) THEN PRINT #9, "[ISSTRING]"; - IF (typ AND ISFLOAT) THEN PRINT #9, "[ISFLOAT]"; - IF (typ AND ISUNSIGNED) THEN PRINT #9, "[ISUNSIGNED]"; - IF (typ AND ISPOINTER) THEN PRINT #9, "[ISPOINTER]"; - IF (typ AND ISFIXEDLENGTH) THEN PRINT #9, "[ISFIXEDLENGTH]"; - IF (typ AND ISINCONVENTIONALMEMORY) THEN PRINT #9, "[ISINCONVENTIONALMEMORY]"; - PRINT #9, "(size in bits=" + str2$(typ AND 511) + ")" - END IF - - - evaluate$ = r$ - - - -END FUNCTION - - - - -FUNCTION evaluatefunc$ (a2$, args AS LONG, typ AS LONG) - a$ = a2$ - - IF Debug THEN PRINT #9, "evaluatingfunction:" + RTRIM$(id.n) + ":" + a$ - - DIM id2 AS idstruct - - id2 = id - n$ = RTRIM$(id2.n) - typ = id2.ret - targetid = currentid - - IF RTRIM$(id2.callname) = "func_stub" THEN Give_Error "Command not implemented": EXIT FUNCTION - IF RTRIM$(id2.callname) = "func_input" AND args = 1 AND inputfunctioncalled = 0 THEN - inputfunctioncalled = -1 - IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - END IF - - SetDependency id2.Dependency - - passomit = 0 - omitarg_first = 0: omitarg_last = 0 - - f$ = RTRIM$(id2.specialformat) - IF LEN(f$) THEN 'special format given - - 'count omittable args - sqb = 0 - a = 0 - FOR fi = 1 TO LEN(f$) - fa = ASC(f$, fi) - IF fa = ASC_QUESTIONMARK THEN - a = a + 1 - IF sqb <> 0 AND omitarg_first = 0 THEN omitarg_first = a - END IF - IF fa = ASC_LEFTSQUAREBRACKET THEN sqb = 1 - IF fa = ASC_RIGHTSQUAREBRACKET THEN sqb = 0: omitarg_last = a - NEXT - omitargs = omitarg_last - omitarg_first + 1 - - IF args <> id2.args - omitargs AND args <> id2.args THEN - IF LEN(id2.hr_syntax) > 0 THEN - Give_Error "Incorrect number of arguments - Reference: " + id2.hr_syntax - ELSE - Give_Error "Incorrect number of arguments passed to function" - END IF - EXIT FUNCTION - END IF - - passomit = 1 'pass omit flags param to function - - IF id2.args = args THEN omitarg_first = 0: omitarg_last = 0 'all arguments were passed! - - ELSE 'no special format given - - IF n$ = "ASC" AND args = 2 THEN GOTO skipargnumchk - IF id2.overloaded = -1 AND (args >= id2.minargs AND args <= id2.args) THEN GOTO skipargnumchk - - IF id2.args <> args THEN - IF LEN(id2.hr_syntax) > 0 THEN - Give_Error "Incorrect number of arguments - Reference: " + id2.hr_syntax - ELSE - Give_Error "Incorrect number of arguments passed to function" - END IF - EXIT FUNCTION - END IF - - END IF - - skipargnumchk: - - r$ = RTRIM$(id2.callname) + "(" - - - IF id2.args <> 0 THEN - - curarg = 1 - firsti = 1 - - n = numelements(a$) - IF n = 0 THEN i = 0: GOTO noargs - - FOR i = 1 TO n - - - - IF curarg >= omitarg_first AND curarg <= omitarg_last THEN - noargs: - targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) - - 'IF (targettyp AND ISSTRING) THEN Give_Error "QB64 doesn't support optional string arguments for functions yet!": EXIT FUNCTION - - FOR fi = 1 TO omitargs - 1: r$ = r$ + "NULL,": NEXT: r$ = r$ + "NULL" - curarg = curarg + omitargs - IF i = n THEN EXIT FOR - r$ = r$ + "," - END IF - - l$ = getelement(a$, i) - IF l$ = "(" THEN b = b + 1 - IF l$ = ")" THEN b = b - 1 - IF (l$ = "," AND b = 0) OR (i = n) THEN - - targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) - nele = ASC(MID$(id2.nele, curarg, 1)) - nelereq = ASC(MID$(id2.nelereq, curarg, 1)) - - IF i = n THEN - e$ = getelements$(a$, firsti, i) - ELSE - e$ = getelements$(a$, firsti, i - 1) - END IF - - IF LEFT$(e$, 2) = "(" + sp THEN dereference = 1 ELSE dereference = 0 - - - - '*special case CVI,CVL,CVS,CVD,_CV (part #1) - IF n$ = "_CV" OR (n$ = "CV" AND qb64prefix_set = 1) THEN - IF curarg = 1 THEN - cvtype$ = type2symbol$(e$) - IF Error_Happened THEN EXIT FUNCTION - e$ = "" - GOTO dontevaluate - END IF - END IF - - '*special case MKI,MKL,MKS,MKD,_MK (part #1) - - IF n$ = "_MK" OR (n$ = "MK" AND qb64prefix_set = 1) THEN - IF RTRIM$(id2.musthave) = "$" THEN - IF curarg = 1 THEN - mktype$ = type2symbol$(e$) - IF Error_Happened THEN EXIT FUNCTION - IF Debug THEN PRINT #9, "_MK:[" + e$ + "]:[" + mktype$ + "]" - e$ = "" - GOTO dontevaluate - END IF - END IF - END IF - - IF n$ = "UBOUND" OR n$ = "LBOUND" THEN - IF curarg = 1 THEN - 'perform a "fake" evaluation of the array - e$ = e$ + sp + "(" + sp + ")" - e$ = evaluate(e$, sourcetyp) - IF Error_Happened THEN EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected array-name": EXIT FUNCTION - IF (sourcetyp AND ISARRAY) = 0 THEN Give_Error "Expected array-name": EXIT FUNCTION - 'make a note of the array's index for later - ulboundarray$ = e$ - ulboundarraytyp = sourcetyp - e$ = "" - r$ = "" - GOTO dontevaluate - END IF - END IF - - - '*special case: INPUT$ function - IF n$ = "INPUT" THEN - IF RTRIM$(id2.musthave) = "$" THEN - IF curarg = 2 THEN - IF LEFT$(e$, 2) = "#" + sp THEN e$ = RIGHT$(e$, LEN(e$) - 2) - END IF - END IF - END IF - - - '*special case* - IF n$ = "ASC" THEN - IF curarg = 2 THEN - e$ = evaluatetotyp$(e$, 32&) - IF Error_Happened THEN EXIT FUNCTION - typ& = LONGTYPE - ISPOINTER - r$ = r$ + e$ + ")" - GOTO evalfuncspecial - END IF - END IF - - - 'PRINT #12, "n$="; n$ - 'PRINT #12, "curarg="; curarg - 'PRINT #12, "e$="; e$ - 'PRINT #12, "r$="; r$ - - '*special case* - IF n$ = "_MEMGET" OR (n$ = "MEMGET" AND qb64prefix_set = 1) THEN - IF curarg = 1 THEN - memget_blk$ = e$ - END IF - IF curarg = 2 THEN - memget_offs$ = e$ - END IF - IF curarg = 3 THEN - e$ = UCASE$(e$) - IF INSTR(e$, sp + "*" + sp) THEN 'multiplier will have an appended %,& or && symbol - IF RIGHT$(e$, 2) = "&&" THEN - e$ = LEFT$(e$, LEN(e$) - 2) - ELSE - IF RIGHT$(e$, 1) = "&" OR RIGHT$(e$, 1) = "%" THEN e$ = LEFT$(e$, LEN(e$) - 1) - END IF - END IF - t = typname2typ(e$) - IF t = 0 THEN Give_Error "Invalid TYPE name": EXIT FUNCTION - IF t AND ISOFFSETINBITS THEN Give_Error qb64prefix$ + "BIT TYPE unsupported": EXIT FUNCTION - memget_size = typname2typsize - IF t AND ISSTRING THEN - IF (t AND ISFIXEDLENGTH) = 0 THEN Give_Error "Expected STRING * ...": EXIT FUNCTION - memget_ctyp$ = "qbs*" - ELSE - IF t AND ISUDT THEN - memget_size = udtxsize(t AND 511) \ 8 - memget_ctyp$ = "void*" - ELSE - memget_size = (t AND 511) \ 8 - memget_ctyp$ = typ2ctyp$(t, "") - END IF - END IF - - - - - - 'assume checking off - offs$ = evaluatetotyp(memget_offs$, OFFSETTYPE - ISPOINTER) - blkoffs$ = evaluatetotyp(memget_blk$, -6) - IF NoChecks = 0 THEN - 'change offs$ to be the return of the safe version - offs$ = "func__memget((mem_block*)" + blkoffs$ + "," + offs$ + "," + str2(memget_size) + ")" - END IF - IF t AND ISSTRING THEN - r$ = "qbs_new_txt_len((char*)" + offs$ + "," + str2(memget_size) + ")" - ELSE - IF t AND ISUDT THEN - r$ = "((void*)+" + offs$ + ")" - t = ISUDT + ISPOINTER + (t AND 511) - ELSE - r$ = "*(" + memget_ctyp$ + "*)(" + offs$ + ")" - IF t AND ISPOINTER THEN t = t - ISPOINTER - END IF - END IF - - - - - - - - typ& = t - - - GOTO evalfuncspecial - END IF - END IF - - '------------------------------------------------------------------------------------------------------------ - e2$ = e$ - e$ = evaluate(e$, sourcetyp) - IF Error_Happened THEN EXIT FUNCTION - '------------------------------------------------------------------------------------------------------------ - - '***special case*** - IF n$ = "_MEM" OR (n$ = "MEM" AND qb64prefix_set = 1) THEN - IF curarg = 1 THEN - IF args = 1 THEN - targettyp = -7 - END IF - IF args = 2 THEN - r$ = RTRIM$(id2.callname) + "_at_offset" + RIGHT$(r$, LEN(r$) - LEN(RTRIM$(id2.callname))) - IF (sourcetyp AND ISOFFSET) = 0 THEN Give_Error "Expected _MEM(_OFFSET-value,...)": EXIT FUNCTION - END IF - END IF - END IF - - '*special case* - IF n$ = "_OFFSET" OR (n$ = "OFFSET" AND qb64prefix_set = 1) THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN - Give_Error qb64prefix$ + "OFFSET expects the name of a variable/array": EXIT FUNCTION - END IF - IF (sourcetyp AND ISARRAY) THEN - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error qb64prefix$ + "OFFSET cannot reference _BIT type arrays": EXIT FUNCTION - END IF - r$ = "((uptrszint)(" + evaluatetotyp$(e2$, -6) + "))" - IF Error_Happened THEN EXIT FUNCTION - typ& = UOFFSETTYPE - ISPOINTER - GOTO evalfuncspecial - END IF '_OFFSET - - '*_OFFSET exceptions* - IF sourcetyp AND ISOFFSET THEN - IF n$ = "MKSMBF" AND RTRIM$(id2.musthave) = "$" THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - IF n$ = "MKDMBF" AND RTRIM$(id2.musthave) = "$" THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - END IF - - '*special case* - IF n$ = "ENVIRON" THEN - IF sourcetyp AND ISSTRING THEN - IF sourcetyp AND ISREFERENCE THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - GOTO dontevaluate - END IF - END IF - - '*special case* - IF n$ = "LEN" THEN - typ& = LONGTYPE - ISPOINTER - IF (sourcetyp AND ISREFERENCE) = 0 THEN - 'could be a string expression - IF sourcetyp AND ISSTRING THEN - r$ = "((int32)(" + e$ + ")->len)" - GOTO evalfuncspecial - END IF - Give_Error "String expression or variable name required in LEN statement": EXIT FUNCTION - END IF - r$ = evaluatetotyp$(e2$, -5) 'use evaluatetotyp to get 'element' size - IF Error_Happened THEN EXIT FUNCTION - GOTO evalfuncspecial - END IF - - - '*special case* - IF n$ = "_BIN" OR (n$ = "BIN" AND qb64prefix_set = 1) THEN - IF RTRIM$(id2.musthave) = "$" THEN - bits = sourcetyp AND 511 - - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - wasref = 0 - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 - IF Error_Happened THEN EXIT FUNCTION - bits = sourcetyp AND 511 - IF (sourcetyp AND ISOFFSETINBITS) THEN - e$ = "func__bin(" + e$ + "," + str2$(bits) + ")" - ELSE - IF (sourcetyp AND ISFLOAT) THEN - e$ = "func__bin_float(" + e$ + ")" - ELSE - IF bits = 64 THEN - IF wasref = 0 THEN bits = 0 - END IF - e$ = "func__bin(" + e$ + "," + str2$(bits) + ")" - END IF - END IF - typ& = STRINGTYPE - ISPOINTER - r$ = e$ - GOTO evalfuncspecial - END IF - END IF - - '*special case* - IF n$ = "OCT" THEN - IF RTRIM$(id2.musthave) = "$" THEN - bits = sourcetyp AND 511 - - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - wasref = 0 - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 - IF Error_Happened THEN EXIT FUNCTION - bits = sourcetyp AND 511 - IF (sourcetyp AND ISOFFSETINBITS) THEN - e$ = "func_oct(" + e$ + "," + str2$(bits) + ")" - ELSE - IF (sourcetyp AND ISFLOAT) THEN - e$ = "func_oct_float(" + e$ + ")" - ELSE - IF bits = 64 THEN - IF wasref = 0 THEN bits = 0 - END IF - e$ = "func_oct(" + e$ + "," + str2$(bits) + ")" - END IF - END IF - typ& = STRINGTYPE - ISPOINTER - r$ = e$ - GOTO evalfuncspecial - END IF - END IF - - '*special case* - IF n$ = "HEX" THEN - IF RTRIM$(id2.musthave) = "$" THEN - bits = sourcetyp AND 511 - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - wasref = 0 - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 - IF Error_Happened THEN EXIT FUNCTION - bits = sourcetyp AND 511 - IF (sourcetyp AND ISOFFSETINBITS) THEN - chars = (bits + 3) \ 4 - e$ = "func_hex(" + e$ + "," + str2$(chars) + ")" - ELSE - IF (sourcetyp AND ISFLOAT) THEN - e$ = "func_hex_float(" + e$ + ")" - ELSE - IF bits = 8 THEN chars = 2 - IF bits = 16 THEN chars = 4 - IF bits = 32 THEN chars = 8 - IF bits = 64 THEN - IF wasref = 1 THEN chars = 16 ELSE chars = 0 - END IF - e$ = "func_hex(" + e$ + "," + str2$(chars) + ")" - END IF - END IF - typ& = STRINGTYPE - ISPOINTER - r$ = e$ - GOTO evalfuncspecial - END IF - END IF - - - '*special case* - IF n$ = "EXP" THEN - bits = sourcetyp AND 511 - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - bits = sourcetyp AND 511 - typ& = SINGLETYPE - ISPOINTER - IF (sourcetyp AND ISFLOAT) THEN - IF bits = 32 THEN e$ = "func_exp_single(" + e$ + ")" ELSE e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER - ELSE - IF (sourcetyp AND ISOFFSETINBITS) THEN - e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER - ELSE - IF bits <= 16 THEN e$ = "func_exp_single(" + e$ + ")" ELSE e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER - END IF - END IF - r$ = e$ - GOTO evalfuncspecial - END IF - - '*special case* - IF n$ = "INT" THEN - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - IF (sourcetyp AND ISFLOAT) THEN e$ = "floor(" + e$ + ")" ELSE e$ = "(" + e$ + ")" - r$ = e$ - typ& = sourcetyp - GOTO evalfuncspecial - END IF - - '*special case* - IF n$ = "FIX" THEN - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits > 64 THEN e$ = "func_fix_float(" + e$ + ")" ELSE e$ = "func_fix_double(" + e$ + ")" - ELSE - e$ = "(" + e$ + ")" - END IF - r$ = e$ - typ& = sourcetyp - GOTO evalfuncspecial - END IF - - '*special case* - IF n$ = "_ROUND" OR (n$ = "ROUND" AND qb64prefix_set = 1) THEN - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - IF (sourcetyp AND ISFLOAT) THEN - bits = sourcetyp AND 511 - IF bits > 64 THEN e$ = "func_round_float(" + e$ + ")" ELSE e$ = "func_round_double(" + e$ + ")" - ELSE - e$ = "(" + e$ + ")" - END IF - r$ = e$ - typ& = 64& - IF (sourcetyp AND ISOFFSET) THEN - IF sourcetyp AND ISUNSIGNED THEN typ& = UOFFSETTYPE - ISPOINTER ELSE typ& = OFFSETTYPE - ISPOINTER - END IF - GOTO evalfuncspecial - END IF - - - '*special case* - IF n$ = "CDBL" THEN - IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits > 64 THEN e$ = "func_cdbl_float(" + e$ + ")" - ELSE - e$ = "((double)(" + e$ + "))" - END IF - r$ = e$ - typ& = DOUBLETYPE - ISPOINTER - GOTO evalfuncspecial - END IF - - '*special case* - IF n$ = "CSNG" THEN - IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits = 64 THEN e$ = "func_csng_double(" + e$ + ")" - IF bits > 64 THEN e$ = "func_csng_float(" + e$ + ")" - ELSE - e$ = "((double)(" + e$ + "))" - END IF - r$ = e$ - typ& = SINGLETYPE - ISPOINTER - GOTO evalfuncspecial - END IF - - - '*special case* - IF n$ = "CLNG" THEN - IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits > 64 THEN e$ = "func_clng_float(" + e$ + ")" ELSE e$ = "func_clng_double(" + e$ + ")" - ELSE 'integer - IF (sourcetyp AND ISUNSIGNED) THEN - IF bits = 32 THEN e$ = "func_clng_ulong(" + e$ + ")" - IF bits > 32 THEN e$ = "func_clng_uint64(" + e$ + ")" - ELSE 'signed - IF bits > 32 THEN e$ = "func_clng_int64(" + e$ + ")" - END IF - END IF - r$ = e$ - typ& = 32& - GOTO evalfuncspecial - END IF - - '*special case* - IF n$ = "CINT" THEN - IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'establish which function (if any!) should be used - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits > 64 THEN e$ = "func_cint_float(" + e$ + ")" ELSE e$ = "func_cint_double(" + e$ + ")" - ELSE 'integer - IF (sourcetyp AND ISUNSIGNED) THEN - IF bits > 15 AND bits <= 32 THEN e$ = "func_cint_ulong(" + e$ + ")" - IF bits > 32 THEN e$ = "func_cint_uint64(" + e$ + ")" - ELSE 'signed - IF bits > 16 AND bits <= 32 THEN e$ = "func_cint_long(" + e$ + ")" - IF bits > 32 THEN e$ = "func_cint_int64(" + e$ + ")" - END IF - END IF - r$ = e$ - typ& = 16& - GOTO evalfuncspecial - END IF - - '*special case MKI,MKL,MKS,MKD,_MK (part #2) - mktype = 0 - size = 0 - IF n$ = "MKI" THEN mktype = 1: mktype$ = "%" - IF n$ = "MKL" THEN mktype = 2: mktype$ = "&" - IF n$ = "MKS" THEN mktype = 3: mktype$ = "!" - IF n$ = "MKD" THEN mktype = 4: mktype$ = "#" - IF n$ = "_MK" OR (n$ = "MK" AND qb64prefix_set = 1) THEN mktype = -1 - IF mktype THEN - IF mktype <> -1 OR curarg = 2 THEN - 'IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert " + qb64prefix$ + "OFFSET type to other types": EXIT FUNCTION - 'both _MK and trad. process the following - qtyp& = 0 - IF mktype$ = "%%" THEN ctype$ = "b": qtyp& = BYTETYPE - ISPOINTER - IF mktype$ = "~%%" THEN ctype$ = "ub": qtyp& = UBYTETYPE - ISPOINTER - IF mktype$ = "%" THEN ctype$ = "i": qtyp& = INTEGERTYPE - ISPOINTER - IF mktype$ = "~%" THEN ctype$ = "ui": qtyp& = UINTEGERTYPE - ISPOINTER - IF mktype$ = "&" THEN ctype$ = "l": qtyp& = LONGTYPE - ISPOINTER - IF mktype$ = "~&" THEN ctype$ = "ul": qtyp& = ULONGTYPE - ISPOINTER - IF mktype$ = "&&" THEN ctype$ = "i64": qtyp& = INTEGER64TYPE - ISPOINTER - IF mktype$ = "~&&" THEN ctype$ = "ui64": qtyp& = UINTEGER64TYPE - ISPOINTER - IF mktype$ = "!" THEN ctype$ = "s": qtyp& = SINGLETYPE - ISPOINTER - IF mktype$ = "#" THEN ctype$ = "d": qtyp& = DOUBLETYPE - ISPOINTER - IF mktype$ = "##" THEN ctype$ = "f": qtyp& = FLOATTYPE - ISPOINTER - IF mktype$ = "%&" THEN ctype$ = "o": qtyp& = OFFSETTYPE - ISPOINTER - IF mktype$ = "~%&" THEN ctype$ = "uo": qtyp& = UOFFSETTYPE - ISPOINTER - IF LEFT$(mktype$, 2) = "~`" THEN ctype$ = "ubit": qtyp& = UINTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(mktype$, LEN(mktype$) - 2)) - IF LEFT$(mktype$, 1) = "`" THEN ctype$ = "bit": qtyp& = INTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(mktype$, LEN(mktype$) - 1)) - IF qtyp& = 0 THEN Give_Error qb64prefix$ + "MK only accepts numeric types": EXIT FUNCTION - IF size THEN - r$ = ctype$ + "2string(" + str2(size) + "," - ELSE - r$ = ctype$ + "2string(" - END IF - nocomma = 1 - targettyp = qtyp& - END IF - END IF - - '*special case CVI,CVL,CVS,CVD,_CV (part #2) - cvtype = 0 - IF n$ = "CVI" THEN cvtype = 1: cvtype$ = "%" - IF n$ = "CVL" THEN cvtype = 2: cvtype$ = "&" - IF n$ = "CVS" THEN cvtype = 3: cvtype$ = "!" - IF n$ = "CVD" THEN cvtype = 4: cvtype$ = "#" - IF n$ = "_CV" OR (n$ = "CV" AND qb64prefix_set = 1) THEN cvtype = -1 - IF cvtype THEN - IF cvtype <> -1 OR curarg = 2 THEN - IF (sourcetyp AND ISSTRING) = 0 THEN Give_Error n$ + " requires a STRING argument": EXIT FUNCTION - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - typ& = 0 - IF cvtype$ = "%%" THEN ctype$ = "b": typ& = BYTETYPE - ISPOINTER - IF cvtype$ = "~%%" THEN ctype$ = "ub": typ& = UBYTETYPE - ISPOINTER - IF cvtype$ = "%" THEN ctype$ = "i": typ& = INTEGERTYPE - ISPOINTER - IF cvtype$ = "~%" THEN ctype$ = "ui": typ& = UINTEGERTYPE - ISPOINTER - IF cvtype$ = "&" THEN ctype$ = "l": typ& = LONGTYPE - ISPOINTER - IF cvtype$ = "~&" THEN ctype$ = "ul": typ& = ULONGTYPE - ISPOINTER - IF cvtype$ = "&&" THEN ctype$ = "i64": typ& = INTEGER64TYPE - ISPOINTER - IF cvtype$ = "~&&" THEN ctype$ = "ui64": typ& = UINTEGER64TYPE - ISPOINTER - IF cvtype$ = "!" THEN ctype$ = "s": typ& = SINGLETYPE - ISPOINTER - IF cvtype$ = "#" THEN ctype$ = "d": typ& = DOUBLETYPE - ISPOINTER - IF cvtype$ = "##" THEN ctype$ = "f": typ& = FLOATTYPE - ISPOINTER - IF cvtype$ = "%&" THEN ctype$ = "o": typ& = OFFSETTYPE - ISPOINTER - IF cvtype$ = "~%&" THEN ctype$ = "uo": typ& = UOFFSETTYPE - ISPOINTER - IF LEFT$(cvtype$, 2) = "~`" THEN ctype$ = "ubit": typ& = UINTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(cvtype$, LEN(cvtype$) - 2)) - IF LEFT$(cvtype$, 1) = "`" THEN ctype$ = "bit": typ& = INTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(cvtype$, LEN(cvtype$) - 1)) - IF typ& = 0 THEN Give_Error qb64prefix$ + "CV cannot return STRING type!": EXIT FUNCTION - IF ctype$ = "bit" OR ctype$ = "ubit" THEN - r$ = "string2" + ctype$ + "(" + e$ + "," + str2(size) + ")" - ELSE - r$ = "string2" + ctype$ + "(" + e$ + ")" - END IF - GOTO evalfuncspecial - END IF - END IF - - '*special case - IF RTRIM$(id2.n) = "STRING" THEN - IF curarg = 2 THEN - IF (sourcetyp AND ISSTRING) THEN - IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - sourcetyp = 64& - e$ = "(" + e$ + "->chr[0])" - END IF - END IF - END IF - - '*special case - IF RTRIM$(id2.n) = "SADD" THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN - Give_Error "SADD only accepts variable-length string variables": EXIT FUNCTION - END IF - IF (sourcetyp AND ISFIXEDLENGTH) THEN - Give_Error "SADD only accepts variable-length string variables": EXIT FUNCTION - END IF - IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN - recompile = 1 - cmemlist(VAL(e$)) = 1 - r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" - typ& = 64& - GOTO evalfuncspecial - END IF - r$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - r$ = "((unsigned short)(" + r$ + "->chr-&cmem[1280]))" - typ& = 64& - GOTO evalfuncspecial - END IF - - '*special case - IF RTRIM$(id2.n) = "VARPTR" THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN - Give_Error "Expected reference to a variable/array": EXIT FUNCTION - END IF - - IF RTRIM$(id2.musthave) = "$" THEN - IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN - recompile = 1 - cmemlist(VAL(e$)) = 1 - r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" - typ& = ISSTRING - GOTO evalfuncspecial - END IF - - IF (sourcetyp AND ISARRAY) THEN - IF (sourcetyp AND ISSTRING) = 0 THEN Give_Error "VARPTR$ only accepts variable-length string arrays": EXIT FUNCTION - IF (sourcetyp AND ISFIXEDLENGTH) THEN Give_Error "VARPTR$ only accepts variable-length string arrays": EXIT FUNCTION - END IF - - 'must be a simple variable - '!assuming it is in cmem in DBLOCK - r$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN - IF (sourcetyp AND ISARRAY) THEN r$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - r$ = r$ + "->cmem_descriptor_offset" - t = 3 - ELSE - r$ = "((unsigned short)(((uint8*)" + r$ + ")-&cmem[1280]))" - '*top bit on=unsigned - '*second top bit on=bit-value (lower bits indicate the size) - 'BYTE=1 - 'INTEGER=2 - 'STRING=3 - 'SINGLE=4 - 'INT64=5 - 'FLOAT=6 - 'DOUBLE=8 - 'LONG=20 - 'BIT=64+n - t = 0 - IF (sourcetyp AND ISUNSIGNED) THEN t = t + 128 - IF (sourcetyp AND ISOFFSETINBITS) THEN - t = t + 64 - t = t + (sourcetyp AND 63) - ELSE - bits = sourcetyp AND 511 - IF (sourcetyp AND ISFLOAT) THEN - IF bits = 32 THEN t = t + 4 - IF bits = 64 THEN t = t + 8 - IF bits = 256 THEN t = t + 6 - ELSE - IF bits = 8 THEN t = t + 1 - IF bits = 16 THEN t = t + 2 - IF bits = 32 THEN t = t + 20 - IF bits = 64 THEN t = t + 5 - END IF - END IF - END IF - r$ = "func_varptr_helper(" + str2(t) + "," + r$ + ")" - typ& = ISSTRING - GOTO evalfuncspecial - END IF 'end of varptr$ - - - - - - - - - - - - 'VARPTR - IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN - recompile = 1 - cmemlist(VAL(e$)) = 1 - r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" - typ& = 64& - GOTO evalfuncspecial - END IF - - IF (sourcetyp AND ISARRAY) THEN - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "VARPTR cannot reference _BIT type arrays": EXIT FUNCTION - - 'string array? - IF (sourcetyp AND ISSTRING) THEN - IF (sourcetyp AND ISFIXEDLENGTH) THEN - getid VAL(e$) - IF Error_Happened THEN EXIT FUNCTION - m = id.tsize - index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) - typ = 64& - r$ = "((" + index$ + ")*" + str2(m) + ")" - GOTO evalfuncspecial - ELSE - 'return the offset of the string's descriptor - r$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - r$ = r$ + "->cmem_descriptor_offset" - typ = 64& - GOTO evalfuncspecial - END IF - END IF - - IF sourcetyp AND ISUDT THEN - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u - o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e - typ = 64& - r$ = "(" + o$ + ")" - GOTO evalfuncspecial - END IF - - 'non-UDT array - m = (sourcetyp AND 511) \ 8 'calculate size multiplier - index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) - typ = 64& - r$ = "((" + index$ + ")*" + str2(m) + ")" - GOTO evalfuncspecial - - END IF - - 'not an array - - IF sourcetyp AND ISUDT THEN - r$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u - o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e - typ = 64& - - 'if sub/func arg, may not be in DBLOCK - getid VAL(e$) - IF Error_Happened THEN EXIT FUNCTION - IF id.sfarg THEN 'could be in DBLOCK - 'note: segment could be the closest segment to UDT element or the base of DBLOCK - r$ = "varptr_dblock_check(((uint8*)" + r$ + ")+(" + o$ + "))" - ELSE 'definitely in DBLOCK - 'give offset relative to DBLOCK - r$ = "((unsigned short)(((uint8*)" + r$ + ") - &cmem[1280] + (" + o$ + ") ))" - END IF - - GOTO evalfuncspecial - END IF - - typ = 64& - r$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - IF (sourcetyp AND ISSTRING) THEN - IF (sourcetyp AND ISFIXEDLENGTH) THEN - - 'if sub/func arg, may not be in DBLOCK - getid VAL(e$) - IF Error_Happened THEN EXIT FUNCTION - IF id.sfarg THEN 'could be in DBLOCK - r$ = "varptr_dblock_check(" + r$ + "->chr)" - ELSE 'definitely in DBLOCK - r$ = "((unsigned short)(" + r$ + "->chr-&cmem[1280]))" - END IF - - ELSE - r$ = r$ + "->cmem_descriptor_offset" - END IF - GOTO evalfuncspecial - END IF - - 'single, simple variable - 'if sub/func arg, may not be in DBLOCK - getid VAL(e$) - IF Error_Happened THEN EXIT FUNCTION - IF id.sfarg THEN 'could be in DBLOCK - r$ = "varptr_dblock_check((uint8*)" + r$ + ")" - ELSE 'definitely in DBLOCK - r$ = "((unsigned short)(((uint8*)" + r$ + ")-&cmem[1280]))" - END IF - - GOTO evalfuncspecial - END IF - - '*special case* - IF RTRIM$(id2.n) = "VARSEG" THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN - Give_Error "Expected reference to a variable/array": EXIT FUNCTION - END IF - IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN - recompile = 1 - cmemlist(VAL(e$)) = 1 - r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" - typ& = 64& - GOTO evalfuncspecial - END IF - 'array? - IF (sourcetyp AND ISARRAY) THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - IF (sourcetyp AND ISSTRING) THEN - r$ = "80" - typ = 64& - GOTO evalfuncspecial - END IF - END IF - typ = 64& - r$ = "( ( ((ptrszint)(" + refer(e$, sourcetyp, 1) + "[0])) - ((ptrszint)(&cmem[0])) ) /16)" - IF Error_Happened THEN EXIT FUNCTION - GOTO evalfuncspecial - END IF - - 'single variable/(var-len)string/udt? (usually stored in DBLOCK) - typ = 64& - 'if sub/func arg, may not be in DBLOCK - getid VAL(e$) - IF Error_Happened THEN EXIT FUNCTION - IF id.sfarg <> 0 AND (sourcetyp AND ISSTRING) = 0 THEN - IF sourcetyp AND ISUDT THEN - r$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber - e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u - o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e - r$ = "varseg_dblock_check(((uint8*)" + r$ + ")+(" + o$ + "))" - ELSE - r$ = "varseg_dblock_check((uint8*)" + refer(e$, sourcetyp, 1) + ")" - IF Error_Happened THEN EXIT FUNCTION - END IF - ELSE - 'can be assumed to be in DBLOCK - r$ = "80" - END IF - GOTO evalfuncspecial - END IF 'varseg - - - - - - - - - - - - - - - - 'note: this code has already been called... - '------------------------------------------------------------------------------------------------------------ - 'e2$ = e$ - 'e$ = evaluate(e$, sourcetyp) - '------------------------------------------------------------------------------------------------------------ - - 'note: this comment makes no sense... - 'any numeric variable, but it must be type-speficied - - IF targettyp = -2 THEN - e$ = evaluatetotyp(e2$, -2) - IF Error_Happened THEN EXIT FUNCTION - GOTO dontevaluate - END IF '-2 - - IF targettyp = -7 THEN - e$ = evaluatetotyp(e2$, -7) - IF Error_Happened THEN EXIT FUNCTION - GOTO dontevaluate - END IF '-7 - - IF targettyp = -8 THEN - e$ = evaluatetotyp(e2$, -8) - IF Error_Happened THEN EXIT FUNCTION - GOTO dontevaluate - END IF '-8 - - IF sourcetyp AND ISOFFSET THEN - IF (targettyp AND ISOFFSET) = 0 THEN - IF id2.internal_subfunc = 0 THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - END IF - END IF - - 'note: this is used for functions like STR(...) which accept all types... - explicitreference = 0 - IF targettyp = -1 THEN - explicitreference = 1 - IF (sourcetyp AND ISSTRING) THEN Give_Error "Number required for function": EXIT FUNCTION - targettyp = sourcetyp - IF (targettyp AND ISPOINTER) THEN targettyp = targettyp - ISPOINTER - END IF - - 'pointer? - IF (targettyp AND ISPOINTER) THEN - IF dereference = 0 THEN 'check deferencing wasn't used - - - - 'note: array pointer - IF (targettyp AND ISARRAY) THEN - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected arrayname()": EXIT FUNCTION - IF (sourcetyp AND ISARRAY) = 0 THEN Give_Error "Expected arrayname()": EXIT FUNCTION - IF Debug THEN PRINT #9, "evaluatefunc:array reference:[" + e$ + "]" - - 'check arrays are of same type - targettyp2 = targettyp: sourcetyp2 = sourcetyp - targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) - sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) - IF sourcetyp2 <> targettyp2 THEN Give_Error "Incorrect array type passed to function": EXIT FUNCTION - - 'check arrayname was followed by '()' - IF targettyp AND ISUDT THEN - IF Debug THEN PRINT #9, "evaluatefunc:array reference:udt reference:[" + e$ + "]" - 'get UDT info - udtrefid = VAL(e$) - getid udtrefid - IF Error_Happened THEN EXIT FUNCTION - udtrefi = INSTR(e$, sp3) 'end of id - udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u - udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) - udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e - udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) - o$ = RIGHT$(e$, LEN(e$) - udtrefi3) - 'note: most of the UDT info above is not required - IF LEFT$(o$, 4) <> "(0)*" THEN Give_Error "Expected arrayname()": EXIT FUNCTION - ELSE - IF RIGHT$(e$, 2) <> sp3 + "0" THEN Give_Error "Expected arrayname()": EXIT FUNCTION - END IF - - - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) - getid idnum - IF Error_Happened THEN EXIT FUNCTION - - IF targettyp AND ISFIXEDLENGTH THEN - targettypsize = CVL(MID$(id2.argsize, curarg * 4 - 4 + 1, 4)) - IF id.tsize <> targettypsize THEN Give_Error "Incorrect array type passed to function": EXIT FUNCTION - END IF - - IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - - recompile = 1 - END IF - END IF - - - - IF id.linkid = 0 THEN - 'if id.linkid is 0, it means the number of array elements is definietly - 'known of the array being passed, this is not some "fake"/unknown array. - 'using the numer of array elements of a fake array would be dangerous! - - IF nelereq = 0 THEN - 'only continue if the number of array elements required is unknown - 'and it needs to be set - - IF id.arrayelements <> -1 THEN - nelereq = id.arrayelements - MID$(id2.nelereq, curarg, 1) = CHR$(nelereq) - END IF - - ids(targetid) = id2 - - ELSE - - 'the number of array elements required is known AND - 'the number of elements in the array to be passed is known - - - - 'REMOVE FOR TESTING PURPOSES ONLY!!! SHOULD BE UNREM'd! - 'print id.arrayelements,nelereq - ' 1 , 2 - - IF id.arrayelements <> nelereq THEN Give_Error "Passing arrays with a differing number of elements to a SUB/FUNCTION is not supported": EXIT FUNCTION - - - - END IF - END IF - - - e$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - GOTO dontevaluate - END IF - - - - - - - - - - - - - 'note: not an array... - - 'target is not an array - - IF (targettyp AND ISSTRING) = 0 THEN - IF (sourcetyp AND ISREFERENCE) THEN - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp - - targettyp2 = targettyp: sourcetyp2 = sourcetyp - - 'get info about source/target - arr = 0: IF (sourcetyp2 AND ISARRAY) THEN arr = 1 - passudtelement = 0: IF (targettyp2 AND ISUDT) = 0 AND (sourcetyp2 AND ISUDT) <> 0 THEN passudtelement = 1: sourcetyp2 = sourcetyp2 - ISUDT - - 'remove flags irrelevant for comparison... ISPOINTER,ISREFERENCE,ISINCONVENTIONALMEMORY,ISARRAY - targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) - sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) - - 'compare types - IF sourcetyp2 = targettyp2 THEN - - IF sourcetyp AND ISUDT THEN - 'udt/udt array - - 'get info - udtrefid = VAL(e$) - getid udtrefid - IF Error_Happened THEN EXIT FUNCTION - udtrefi = INSTR(e$, sp3) 'end of id - udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u - udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) - udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e - udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) - o$ = RIGHT$(e$, LEN(e$) - udtrefi3) - 'note: most of the UDT info above is not required - - IF arr THEN - n2$ = scope$ + "ARRAY_UDT_" + RTRIM$(id.n) + "[0]" - ELSE - n2$ = scope$ + "UDT_" + RTRIM$(id.n) - END IF - - e$ = "(void*)( ((char*)(" + n2$ + ")) + (" + o$ + ") )" - - 'convert void* to target type* - IF passudtelement THEN e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ - IF Error_Happened THEN EXIT FUNCTION - - ELSE - 'not a udt - IF arr THEN - IF (sourcetyp2 AND ISOFFSETINBITS) THEN Give_Error "Cannot pass BIT array offsets": EXIT FUNCTION - e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" - IF Error_Happened THEN EXIT FUNCTION - ELSE - e$ = refer(e$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - END IF - - 'note: signed/unsigned mismatch requires casting - IF (sourcetyp AND ISUNSIGNED) <> (targettyp AND ISUNSIGNED) THEN - e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ - IF Error_Happened THEN EXIT FUNCTION - END IF - - END IF 'udt? - - 'force recompile if target needs to be in cmem and the source is not - IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - recompile = 1 - END IF - END IF - - GOTO dontevaluate - END IF 'similar - - 'IF sourcetyp2 = targettyp2 THEN - 'IF arr THEN - 'IF (sourcetyp2 AND ISOFFSETINBITS) THEN Give_Error "Cannot pass BIT array offsets yet": EXIT FUNCTION - 'e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" - 'ELSE - 'e$ = refer(e$, sourcetyp, 1) - 'END IF - 'GOTO dontevaluate - 'END IF - - END IF 'source is a reference - - ELSE 'string - 'its a string - - IF (sourcetyp AND ISREFERENCE) THEN - idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp - IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? - IF cmemlist(idnum) = 0 THEN - cmemlist(idnum) = 1 - recompile = 1 - END IF - END IF - END IF 'reference - - END IF 'string - - END IF 'dereference was not used - END IF 'pointer - - - 'note: Target is not a pointer... - - 'IF (targettyp AND ISSTRING) = 0 THEN - 'IF (sourcetyp AND ISREFERENCE) THEN - 'targettyp2 = targettyp: sourcetyp2 = sourcetyp - ISREFERENCE - 'IF (sourcetyp2 AND ISINCONVENTIONALMEMORY) THEN sourcetyp2 = sourcetyp2 - ISINCONVENTIONALMEMORY - 'IF sourcetyp2 = targettyp2 THEN e$ = refer(e$, sourcetyp, 1): GOTO dontevaluate - 'END IF - 'END IF - 'END IF - - 'String-numeric mismatch? - IF targettyp AND ISSTRING THEN - IF (sourcetyp AND ISSTRING) = 0 THEN - nth = curarg - IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 - IF ids(targetid).args = 1 THEN Give_Error "String required for function": EXIT FUNCTION - Give_Error str_nth$(nth) + " function argument requires a string": EXIT FUNCTION - END IF - END IF - IF (targettyp AND ISSTRING) = 0 THEN - IF sourcetyp AND ISSTRING THEN - nth = curarg - IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 - IF ids(targetid).args = 1 THEN Give_Error "Number required for function": EXIT FUNCTION - Give_Error str_nth$(nth) + " function argument requires a number": EXIT FUNCTION - END IF - END IF - - 'change to "non-pointer" value - IF (sourcetyp AND ISREFERENCE) THEN - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - END IF - - IF explicitreference = 0 THEN - IF targettyp AND ISUDT THEN - nth = curarg - IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 - IF qb64prefix_set AND udtxcname(targettyp AND 511) = "_MEM" THEN - x$ = "'" + MID$(RTRIM$(udtxcname(targettyp AND 511)), 2) + "'" - ELSE - x$ = "'" + RTRIM$(udtxcname(targettyp AND 511)) + "'" - END IF - IF ids(targetid).args = 1 THEN Give_Error "TYPE " + x$ + " required for function": EXIT FUNCTION - Give_Error str_nth$(nth) + " function argument requires TYPE " + x$: EXIT FUNCTION - END IF - ELSE - IF sourcetyp AND ISUDT THEN Give_Error "Number required for function": EXIT FUNCTION - END IF - - 'round to integer if required - IF (sourcetyp AND ISFLOAT) THEN - IF (targettyp AND ISFLOAT) = 0 THEN - '**32 rounding fix - bits = targettyp AND 511 - IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" - IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" - IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" - END IF - END IF - - IF explicitreference THEN - IF (targettyp AND ISOFFSETINBITS) THEN - 'integer value can fit inside int64 - e$ = "(int64)(" + e$ + ")" - ELSE - IF (targettyp AND ISFLOAT) THEN - IF (targettyp AND 511) = 32 THEN e$ = "(float)(" + e$ + ")" - IF (targettyp AND 511) = 64 THEN e$ = "(double)(" + e$ + ")" - IF (targettyp AND 511) = 256 THEN e$ = "(long double)(" + e$ + ")" - ELSE - IF (targettyp AND ISUNSIGNED) THEN - IF (targettyp AND 511) = 8 THEN e$ = "(uint8)(" + e$ + ")" - IF (targettyp AND 511) = 16 THEN e$ = "(uint16)(" + e$ + ")" - IF (targettyp AND 511) = 32 THEN e$ = "(uint32)(" + e$ + ")" - IF (targettyp AND 511) = 64 THEN e$ = "(uint64)(" + e$ + ")" - ELSE - IF (targettyp AND 511) = 8 THEN e$ = "(int8)(" + e$ + ")" - IF (targettyp AND 511) = 16 THEN e$ = "(int16)(" + e$ + ")" - IF (targettyp AND 511) = 32 THEN e$ = "(int32)(" + e$ + ")" - IF (targettyp AND 511) = 64 THEN e$ = "(int64)(" + e$ + ")" - END IF - END IF 'float? - END IF 'offset in bits? - END IF 'explicit? - - - IF (targettyp AND ISPOINTER) THEN 'pointer required - IF (targettyp AND ISSTRING) THEN GOTO dontevaluate 'no changes required - '20090703 - t$ = typ2ctyp$(targettyp, "") - IF Error_Happened THEN EXIT FUNCTION - v$ = "pass" + str2$(uniquenumber) - 'assume numeric type - IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? - bytesreq = ((targettyp AND 511) + 7) \ 8 - PRINT #defdatahandle, t$ + " *" + v$ + "=NULL;" - PRINT #13, "if(" + v$ + "==NULL){" - PRINT #13, "cmem_sp-=" + str2(bytesreq) + ";" - PRINT #13, v$ + "=(" + t$ + "*)(dblock+cmem_sp);" - PRINT #13, "if (cmem_spchr" - END IF - - IF LTRIM$(RTRIM$(e$)) = "0" THEN e$ = "NULL" - - END IF - - r$ = r$ + e$ - - '***special case**** - IF n$ = "_MEM" OR (n$ = "MEM" AND qb64prefix_set = 1) THEN - IF args = 1 THEN - IF curarg = 1 THEN r$ = r$ + ")": GOTO evalfuncspecial - END IF - IF args = 2 THEN - IF curarg = 2 THEN r$ = r$ + ")": GOTO evalfuncspecial - END IF - END IF - - IF i <> n AND nocomma = 0 THEN r$ = r$ + "," - nocomma = 0 - firsti = i + 1 - curarg = curarg + 1 - END IF - - IF (curarg >= omitarg_first AND curarg <= omitarg_last) AND i = n THEN - targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) - 'IF (targettyp AND ISSTRING) THEN Give_Error "QB64 doesn't support optional string arguments for functions yet!": EXIT FUNCTION - FOR fi = 1 TO omitargs: r$ = r$ + ",NULL": NEXT - curarg = curarg + omitargs - END IF - - NEXT - END IF - - IF n$ = "UBOUND" OR n$ = "LBOUND" THEN - IF r$ = ",NULL" THEN r$ = ",1" - IF n$ = "UBOUND" THEN r2$ = "func_ubound(" ELSE r2$ = "func_lbound(" - e$ = refer$(ulboundarray$, sourcetyp, 1) - IF Error_Happened THEN EXIT FUNCTION - 'note: ID contins refer'ed array info - - arrayelements = id.arrayelements '2009 - IF arrayelements = -1 THEN arrayelements = 1 '2009 - - r$ = r2$ + e$ + r$ + "," + str2$(arrayelements) + ")" - typ& = INTEGER64TYPE - ISPOINTER - GOTO evalfuncspecial - END IF - - IF passomit THEN - IF omitarg_first THEN r$ = r$ + ",0" ELSE r$ = r$ + ",1" - END IF - r$ = r$ + ")" - - evalfuncspecial: - - IF n$ = "ABS" THEN typ& = sourcetyp 'ABS Note: ABS() returns argument #1's type - - 'QB-like conversion of math functions returning floating point values - IF n$ = "SIN" OR n$ = "COS" OR n$ = "TAN" OR n$ = "ATN" OR n$ = "SQR" OR n$ = "LOG" THEN - b = sourcetyp AND 511 - IF sourcetyp AND ISFLOAT THEN - 'Default is FLOATTYPE - IF b = 64 THEN typ& = DOUBLETYPE - ISPOINTER - IF b = 32 THEN typ& = SINGLETYPE - ISPOINTER - ELSE - 'Default is FLOATTYPE - IF b <= 32 THEN typ& = DOUBLETYPE - ISPOINTER - IF b <= 16 THEN typ& = SINGLETYPE - ISPOINTER - END IF - END IF - - IF id2.ret = ISUDT + (1) THEN - '***special case*** - v$ = "func" + str2$(uniquenumber) - PRINT #defdatahandle, "mem_block " + v$ + ";" - r$ = "(" + v$ + "=" + r$ + ")" - END IF - - IF id2.ccall THEN - IF LEFT$(r$, 11) = "( char* )" THEN - r$ = "qbs_new_txt(" + r$ + ")" - END IF - END IF - - IF Debug THEN PRINT #9, "evaluatefunc:out:"; r$ - evaluatefunc$ = r$ -END FUNCTION - -FUNCTION variablesize$ (i AS LONG) 'ID or -1 (if ID already 'loaded') - 'Note: assumes whole bytes, no bit offsets/sizes - IF i <> -1 THEN getid i - IF Error_Happened THEN EXIT FUNCTION - 'find base size from type - t = id.t: IF t = 0 THEN t = id.arraytype - bytes = (t AND 511) \ 8 - - IF t AND ISUDT THEN 'correct size for UDTs - u = t AND 511 - bytes = udtxsize(u) \ 8 - END IF - - IF t AND ISSTRING THEN 'correct size for strings - IF t AND ISFIXEDLENGTH THEN - bytes = id.tsize - ELSE - IF id.arraytype THEN Give_Error "Cannot determine size of variable-length string array": EXIT FUNCTION - variablesize$ = scope$ + "STRING_" + RTRIM$(id.n) + "->len" - EXIT FUNCTION - END IF - END IF - - IF id.arraytype THEN 'multiply size for arrays - n$ = RTRIM$(id.callname) - s$ = str2(bytes) + "*(" + n$ + "[2]&1)" 'note: multiplying by 0 if array not currently defined (affects dynamic arrays) - arrayelements = id.arrayelements: IF arrayelements = -1 THEN arrayelements = 1 '2009 - FOR i2 = 1 TO arrayelements - s$ = s$ + "*" + n$ + "[" + str2(i2 * 4 - 4 + 5) + "]" - NEXT - variablesize$ = "(" + s$ + ")" - EXIT FUNCTION - END IF - - variablesize$ = str2(bytes) -END FUNCTION - - - -FUNCTION evaluatetotyp$ (a2$, targettyp AS LONG) - 'note: 'evaluatetotyp' no longer performs 'fixoperationorder' on a2$ (in many cases, this has already been done) - a$ = a2$ - e$ = evaluate(a$, sourcetyp) - IF Error_Happened THEN EXIT FUNCTION - - 'Offset protection: - IF sourcetyp AND ISOFFSET THEN - IF (targettyp AND ISOFFSET) = 0 AND targettyp >= 0 THEN - Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION - END IF - END IF - - '-5 size - '-6 offset - IF targettyp = -4 OR targettyp = -5 OR targettyp = -6 THEN '? -> byte_element(offset,element size in bytes) - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION - - ' print "-4: evaluated as ["+e$+"]":sleep 1 - - IF (sourcetyp AND ISUDT) THEN 'User Defined Type -> byte_element(offset,bytes) - IF udtxvariable(sourcetyp AND 511) THEN Give_Error "UDT must have fixed size": EXIT FUNCTION - idnumber = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - u = VAL(e$) 'closest parent - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - E = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - o$ = e$ - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - n$ = "UDT_" + RTRIM$(id.n) - IF id.arraytype THEN - n$ = "ARRAY_" + n$ + "[0]" - 'whole array reference examplename()? - IF LEFT$(o$, 3) = "(0)" THEN - 'use -2 type method - GOTO method2usealludt - END IF - END IF - - dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - - 'determine size of element - IF E = 0 THEN 'no specific element, use size of entire type - bytes$ = str2(udtxsize(u) \ 8) - ELSE 'a specific element - IF (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -5) THEN - evaluatetotyp$ = "(*(qbs**)" + dst$ + ")->len" - EXIT FUNCTION - ELSEIF (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -4) THEN - dst$ = "(*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + "))))->chr" - bytes$ = "(*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + "))))->len" - evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" - EXIT FUNCTION - END IF - bytes$ = str2(udtesize(E) \ 8) - END IF - evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = dst$ - EXIT FUNCTION - END IF - - IF (sourcetyp AND ISARRAY) THEN 'Array reference -> byte_element(offset,bytes) - 'whole array reference examplename()? - IF RIGHT$(e$, 2) = sp3 + "0" THEN - 'use -2 type method - IF sourcetyp AND ISSTRING THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - Give_Error "Cannot pass array of variable-length strings": EXIT FUNCTION - END IF - END IF - GOTO method2useall - END IF - 'assume a specific element - IF sourcetyp AND ISSTRING THEN - IF sourcetyp AND ISFIXEDLENGTH THEN - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - ELSE - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - - evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + e$ + "->len," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = e$ + "->len" - IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - END IF - EXIT FUNCTION - END IF - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - e$ = "(&(" + e$ + "))" - bytes$ = str2((sourcetyp AND 511) \ 8) - evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = e$ - EXIT FUNCTION - END IF - - IF sourcetyp AND ISSTRING THEN 'String -> byte_element(offset,bytes) - IF sourcetyp AND ISFIXEDLENGTH THEN - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - ELSE - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - bytes$ = e$ + "->len" - END IF - evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - EXIT FUNCTION - END IF - - 'Standard variable -> byte_element(offset,bytes) - e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name - IF Error_Happened THEN EXIT FUNCTION - size = (sourcetyp AND 511) \ 8 'calculate its size in bytes - evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = str2(size) - IF targettyp = -6 THEN evaluatetotyp$ = e$ - EXIT FUNCTION - - END IF '-4, -5, -6 - - - - - IF targettyp = -8 THEN '? -> _MEM structure helper {offset, fullsize, typeval, elementsize, sf_mem_lock|???} - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION - - - IF (sourcetyp AND ISUDT) THEN 'User Defined Type -> byte_element(offset,bytes) - idnumber = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - u = VAL(e$) 'closest parent - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - E = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - o$ = e$ - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - n$ = "UDT_" + RTRIM$(id.n) - IF id.arraytype THEN - n$ = "ARRAY_" + n$ + "[0]" - 'whole array reference examplename()? - IF LEFT$(o$, 3) = "(0)" THEN - 'use -7 type method - GOTO method2usealludt__7 - END IF - END IF - 'determine size of element - IF E = 0 THEN 'no specific element, use size of entire type - bytes$ = str2(udtxsize(u) \ 8) - t1 = ISUDT + udtetype(u) - ELSE 'a specific element - bytes$ = str2(udtesize(E) \ 8) - t1 = udtetype(E) - END IF - dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - 'evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" - 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - 'IF targettyp = -6 THEN evaluatetotyp$ = dst$ - - t = Type2MemTypeValue(t1) - evaluatetotyp$ = "(ptrszint)" + dst$ + "," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" - - EXIT FUNCTION - END IF - - IF (sourcetyp AND ISARRAY) THEN 'Array reference -> byte_element(offset,bytes) - 'whole array reference examplename()? - IF RIGHT$(e$, 2) = sp3 + "0" THEN - 'use -7 type method - IF sourcetyp AND ISSTRING THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - Give_Error "Cannot pass array of variable-length strings": EXIT FUNCTION - END IF - END IF - GOTO method2useall__7 - END IF - - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - n$ = RTRIM$(id.callname) - lk$ = "(mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * id.arrayelements + 4 + 1 - 1) + "]" - - 'assume a specific element - - IF sourcetyp AND ISSTRING THEN - IF sourcetyp AND ISFIXEDLENGTH THEN - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" - 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + "," + lk$ - - ELSE - - Give_Error qb64prefix$ + "MEMELEMENT cannot reference variable-length strings": EXIT FUNCTION - - END IF - EXIT FUNCTION - END IF - - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - e$ = "(&(" + e$ + "))" - bytes$ = str2((sourcetyp AND 511) \ 8) - 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" - 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - 'IF targettyp = -6 THEN evaluatetotyp$ = e$ - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "," + bytes$ + "," + str2(t) + "," + bytes$ + "," + lk$ - - EXIT FUNCTION - END IF 'isarray - - IF sourcetyp AND ISSTRING THEN 'String -> byte_element(offset,bytes) - IF sourcetyp AND ISFIXEDLENGTH THEN - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - ELSE - Give_Error qb64prefix$ + "MEMELEMENT cannot reference variable-length strings": EXIT FUNCTION - END IF - - 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" - 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" - - EXIT FUNCTION - END IF - - 'Standard variable -> byte_element(offset,bytes) - e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name - IF Error_Happened THEN EXIT FUNCTION - size = (sourcetyp AND 511) \ 8 'calculate its size in bytes - 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" - 'IF targettyp = -5 THEN evaluatetotyp$ = str2(size) - 'IF targettyp = -6 THEN evaluatetotyp$ = e$ - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "," + str2(size) + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" - - EXIT FUNCTION - - END IF '-8 - - - - - - - - - - - IF targettyp = -7 THEN '? -> _MEM structure helper {offset, fullsize, typeval, elementsize, sf_mem_lock|???} - method2useall__7: - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION - - 'User Defined Type - IF (sourcetyp AND ISUDT) THEN - ' print "CI: -2 type from a UDT":sleep 1 - idnumber = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - u = VAL(e$) 'closest parent - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - E = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - - o$ = e$ - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - n$ = "UDT_" + RTRIM$(id.n): IF id.arraytype THEN n$ = "ARRAY_" + n$ + "[0]" - method2usealludt__7: - bytes$ = variablesize$(-1) + "-(" + o$ + ")" - IF Error_Happened THEN EXIT FUNCTION - dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - - - 'evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" - - 'note: myudt.myelement results in a size of 1 because it is a continuous run of no consistent granularity - IF E <> 0 THEN size = 1 ELSE size = udtxsize(u) \ 8 - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + dst$ + "," + bytes$ + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" - - EXIT FUNCTION - END IF - - 'Array reference - IF (sourcetyp AND ISARRAY) THEN - IF sourcetyp AND ISSTRING THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - Give_Error qb64prefix$ + "MEM cannot reference variable-length strings": EXIT FUNCTION - END IF - END IF - - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - - n$ = RTRIM$(id.callname) - lk$ = "(mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * id.arrayelements + 4 + 1 - 1) + "]" - - tsize = id.tsize 'used later to determine element size of fixed length strings - 'note: array references consist of idnumber|unmultiplied-element-index - index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'get element index - bytes$ = variablesize$(-1) - IF Error_Happened THEN EXIT FUNCTION - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - - IF sourcetyp AND ISSTRING THEN - e$ = "((" + e$ + ")->chr)" '[2013] handle fixed string arrays differently because they are already pointers - ELSE - e$ = "(&(" + e$ + "))" - END IF - - ' print "CI: array: e$["+e$+"], bytes$["+bytes$+"]":sleep 1 - 'calculate size of elements - IF sourcetyp AND ISSTRING THEN - bytes = tsize - ELSE - bytes = (sourcetyp AND 511) \ 8 - END IF - bytes$ = bytes$ + "-(" + str2(bytes) + "*(" + index$ + "))" - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "," + bytes$ + "," + str2(t) + "," + str2(bytes) + "," + lk$ - - EXIT FUNCTION - END IF - - 'String - IF sourcetyp AND ISSTRING THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN Give_Error qb64prefix$ + "MEM cannot reference variable-length strings": EXIT FUNCTION - - idnumber = VAL(e$) - getid idnumber: IF Error_Happened THEN EXIT FUNCTION - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0): IF Error_Happened THEN EXIT FUNCTION - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" - - EXIT FUNCTION - END IF - - 'Standard variable -> byte_element(offset,bytes) - e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name - IF Error_Happened THEN EXIT FUNCTION - size = (sourcetyp AND 511) \ 8 'calculate its size in bytes - - t = Type2MemTypeValue(sourcetyp) - evaluatetotyp$ = "(ptrszint)" + e$ + "," + str2(size) + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" - - EXIT FUNCTION - - END IF '-7 _MEM structure helper - - - IF targettyp = -2 THEN '? -> byte_element(offset,max possible bytes) - method2useall: - ' print "CI: eval2typ detected target type of -2 for ["+a2$+"] evaluated as ["+e$+"]":sleep 1 - - IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION - IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION - - 'User Defined Type -> byte_element(offset,bytes) - IF (sourcetyp AND ISUDT) THEN - ' print "CI: -2 type from a UDT":sleep 1 - idnumber = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - u = VAL(e$) 'closest parent - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - E = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) - o$ = e$ - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - n$ = "UDT_" + RTRIM$(id.n): IF id.arraytype THEN n$ = "ARRAY_" + n$ + "[0]" - method2usealludt: - bytes$ = variablesize$(-1) + "-(" + o$ + ")" - IF Error_Happened THEN EXIT FUNCTION - dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = dst$ - EXIT FUNCTION - END IF - - 'Array reference -> byte_element(offset,bytes) - IF (sourcetyp AND ISARRAY) THEN - 'array of variable length strings (special case, can only refer to single element) - IF sourcetyp AND ISSTRING THEN - IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + e$ + "->len," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = e$ + "->len" - IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - EXIT FUNCTION - END IF - END IF - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - tsize = id.tsize 'used later to determine element size of fixed length strings - 'note: array references consist of idnumber|unmultiplied-element-index - index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'get element index - bytes$ = variablesize$(-1) - IF Error_Happened THEN EXIT FUNCTION - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - e$ = "(&(" + e$ + "))" - ' print "CI: array: e$["+e$+"], bytes$["+bytes$+"]":sleep 1 - 'calculate size of elements - IF sourcetyp AND ISSTRING THEN - bytes = tsize - ELSE - bytes = (sourcetyp AND 511) \ 8 - END IF - bytes$ = bytes$ + "-(" + str2(bytes) + "*(" + index$ + "))" - evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = e$ - ' print "CI: array ->["+"byte_element((uint64)" + e$ + "," + bytes$+ ","+NewByteElement$+")"+"]":sleep 1 - EXIT FUNCTION - END IF - - 'String -> byte_element(offset,bytes) - IF sourcetyp AND ISSTRING THEN - IF sourcetyp AND ISFIXEDLENGTH THEN - idnumber = VAL(e$) - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - bytes$ = str2(id.tsize) - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - ELSE - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - bytes$ = e$ + "->len" - END IF - evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = bytes$ - IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" - EXIT FUNCTION - END IF - - 'Standard variable -> byte_element(offset,bytes) - e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name - IF Error_Happened THEN EXIT FUNCTION - size = (sourcetyp AND 511) \ 8 'calculate its size in bytes - evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" - IF targettyp = -5 THEN evaluatetotyp$ = str2(size) - IF targettyp = -6 THEN evaluatetotyp$ = e$ - EXIT FUNCTION - - END IF '-2 byte_element(offset,bytes) - - - - 'string? - IF (sourcetyp AND ISSTRING) <> (targettyp AND ISSTRING) THEN - Give_Error "Illegal string-number conversion": EXIT FUNCTION - END IF - - IF (sourcetyp AND ISSTRING) THEN - evaluatetotyp$ = e$ - IF (sourcetyp AND ISREFERENCE) THEN - evaluatetotyp$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - END IF - EXIT FUNCTION - END IF - - 'pointer required? - IF (targettyp AND ISPOINTER) THEN - Give_Error "evaluatetotyp received a request for a pointer (unsupported)": EXIT FUNCTION - '... - Give_Error "Invalid pointer": EXIT FUNCTION - END IF - - 'change to "non-pointer" value - IF (sourcetyp AND ISREFERENCE) THEN - e$ = refer(e$, sourcetyp, 0) - IF Error_Happened THEN EXIT FUNCTION - END IF - 'check if successful - IF (sourcetyp AND ISPOINTER) THEN - Give_Error "evaluatetotyp couldn't convert pointer type!": EXIT FUNCTION - END IF - - 'round to integer if required - IF (sourcetyp AND ISFLOAT) THEN - IF (targettyp AND ISFLOAT) = 0 THEN - bits = targettyp AND 511 - '**32 rounding fix - IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" - IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" - IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" - END IF - END IF - - evaluatetotyp$ = e$ -END FUNCTION - -FUNCTION findid& (n2$) - n$ = UCASE$(n2$) 'case insensitive - - 'return all strings as 'not found' - IF ASC(n$) = 34 THEN GOTO noid - - 'if findidsecondarg was set, it will be used for finding the name of a sub (not a func or variable) - secondarg$ = findidsecondarg: findidsecondarg = "" - - 'if findanotherid was set, findid will continue scan from last index, otherwise, it will begin a new search - findanother = findanotherid: findanotherid = 0 - IF findanother <> 0 AND findidinternal <> 2 THEN Give_Error "FINDID() ERROR: Invalid repeat search requested!": EXIT FUNCTION 'cannot continue search, no more indexes left! - IF Error_Happened THEN EXIT FUNCTION - '(the above should never happen) - findid& = 2 '2=not finished searching all indexes - - 'seperate symbol from name (if a symbol has been added), this is the only way symbols can be passed to findid - i = 0 - i = INSTR(n$, "~"): IF i THEN GOTO gotsc - i = INSTR(n$, "`"): IF i THEN GOTO gotsc - i = INSTR(n$, "%"): IF i THEN GOTO gotsc - i = INSTR(n$, "&"): IF i THEN GOTO gotsc - i = INSTR(n$, "!"): IF i THEN GOTO gotsc - i = INSTR(n$, "#"): IF i THEN GOTO gotsc - i = INSTR(n$, "$"): IF i THEN GOTO gotsc - gotsc: - IF i THEN - sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1) - IF sc$ = "`" OR sc$ = "~`" THEN sc$ = sc$ + "1" 'clarify abbreviated 1 bit reference - ELSE - ''' 'no symbol passed, so check what symbol could be assumed under the current DEF... - ''' v = ASC(n$): IF v = 95 THEN v = 27 ELSE v = v - 64 - ''' IF v >= 1 AND v <= 27 THEN 'safeguard against n$ not being a standard name - ''' couldhavesc$ = defineextaz(v) - ''' IF couldhavesc$ = "`" OR couldhavesc$ = "~`" THEN couldhavesc$ = couldhavesc$ + "1" 'clarify abbreviated 1 bit reference - ''' END IF 'safeguard - END IF - - 'optimizations for later comparisons - insf$ = subfunc + SPACE$(256 - LEN(subfunc)) - secondarg$ = secondarg$ + SPACE$(256 - LEN(secondarg$)) - IF LEN(sc$) THEN scpassed = 1: sc$ = sc$ + SPACE$(8 - LEN(sc$)) ELSE scpassed = 0 - '''IF LEN(couldhavesc$) THEN couldhavesc$ = couldhavesc$ + SPACE$(8 - LEN(couldhavesc$)): couldhavescpassed = 1 ELSE couldhavescpassed = 0 - IF LEN(n$) < 256 THEN n$ = n$ + SPACE$(256 - LEN(n$)) - - 'FUNCTION HashFind (a$, searchflags, resultflags, resultreference) - '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) - '0=doesn't exist - '1=found, no more items to scan - '2=found, more items still to scan - - 'NEW HASH SYSTEM - n$ = RTRIM$(n$) - IF findanother THEN - hashretry: - z = HashFindCont(unrequired, i) - ELSE - z = HashFind(n$, 1, unrequired, i) - END IF - findidinternal = z - IF z = 0 THEN GOTO noid - findid = z - - - 'continue from previous position? - ''IF findanother THEN start = findidinternal ELSE start = idn - - ''FOR i = start TO 1 STEP -1 - - '' findidinternal = i - 1 - '' IF findidinternal = 0 THEN findid& = 1 '1=found id, but no more to search - - '' IF ids(i).n = n$ THEN 'same name? - - 'in scope? - IF ids(i).subfunc = 0 AND ids(i).share = 0 THEN 'scope check required (not a shared variable or the name of a sub/function) - IF ids(i).insubfunc <> insf$ THEN GOTO findidnomatch - END IF - - 'some subs require a second argument (eg. PUT #, DEF SEG, etc.) - IF ids(i).subfunc = 2 THEN - IF ASC(ids(i).secondargmustbe) <> 32 THEN 'exists? - IF RTRIM$(secondarg$) = UCASE$(RTRIM$(ids(i).secondargmustbe)) THEN - ELSEIF qb64prefix_set = 1 AND LEFT$(ids(i).secondargmustbe, 1) = "_" AND LEFT$(secondarg$, 1) <> "_" AND RTRIM$(secondarg$) = UCASE$(MID$(RTRIM$(ids(i).secondargmustbe), 2)) THEN - ELSE - GOTO findidnomatch - END IF - END IF - IF ASC(ids(i).secondargcantbe) <> 32 THEN 'exists? - IF RTRIM$(secondarg$) <> UCASE$(RTRIM$(ids(i).secondargcantbe)) THEN - ELSEIF qb64prefix_set = 1 AND LEFT$(ids(i).secondargcantbe, 1) = "_" AND LEFT$(secondarg$, 1) <> "_" AND RTRIM$(secondarg$) <> UCASE$(MID$(RTRIM$(ids(i).secondargcantbe), 2)) THEN - ELSE - GOTO findidnomatch - END IF - END IF - END IF 'second sub argument possible - - 'must have symbol? - 'typically for variables defined automatically or by a symbol and not the full type name - imusthave = CVI(ids(i).musthave) 'speed up checks of first 2 characters - amusthave = imusthave AND 255 'speed up checks of first character - IF amusthave <> 32 THEN - IF scpassed THEN - IF sc$ = ids(i).musthave THEN GOTO findidok - END IF - ''' IF couldhavescpassed THEN - ''' IF couldhavesc$ = ids(i).musthave THEN GOTO findidok - ''' END IF - 'Q: why is the above triple-commented? - 'A: because if something must have a symbol to refer to it, then a could-have is - ' not sufficient, and it could mask shared variables in global scope - - 'note: symbol defined fixed length strings cannot be referred to by $ without an extension - 'note: sc$ and couldhavesc$ are already changed from ` to `1 to match stored musthave - GOTO findidnomatch - END IF - - 'may have symbol? - 'typically for variables formally dim'd - 'note: couldhavesc$ needn't be considered for mayhave checks - IF scpassed THEN 'symbol was passed, so it must match the mayhave symbol - imayhave = CVI(ids(i).mayhave) 'speed up checks of first 2 characters - amayhave = imayhave AND 255 'speed up checks of first character - IF amayhave = 32 THEN GOTO findidnomatch 'it cannot have the symbol passed (nb. musthave symbols have already been ok'd) - 'note: variable length strings are not a problem here, as they can only have one possible extension - - IF amayhave = 36 THEN '"$" - IF imayhave <> 8228 THEN '"$ " - 'it is a fixed length string - IF CVI(sc$) = 8228 THEN GOTO findidok 'allow myvariable$ to become myvariable$10 - 'allow later comparison to verify if extension is correct - END IF - END IF - IF sc$ <> ids(i).mayhave THEN GOTO findidnomatch - END IF 'scpassed - - 'return id - findidok: - - id = ids(i) - - t = id.t - temp$ = refer$(str2$(i), t, 1) - manageVariableList "", temp$, 0, 1 - currentid = i - EXIT FUNCTION - - 'END IF 'same name - findidnomatch: - 'NEXT - IF z = 2 THEN GOTO hashretry - - 'totally unclassifiable - noid: - findid& = 0 - currentid = -1 -END FUNCTION - -FUNCTION FindArray (secure$) - FindArray = -1 - n$ = secure$ - IF Debug THEN PRINT #9, "func findarray:in:" + n$ - IF alphanumeric(ASC(n$)) = 0 THEN FindArray = 0: EXIT FUNCTION - - 'establish whether n$ includes an extension - i = INSTR(n$, "~"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "`"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "%"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "&"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "!"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "#"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - i = INSTR(n$, "$"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 - gotsc2: - n2$ = n$ + sc$ - - IF sc$ <> "" THEN - 'has an extension - 'note! findid must unambiguify ` to `5 or $ to $10 where applicable - try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype THEN - EXIT FUNCTION - END IF - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - ELSE - 'no extension - - '1. pass as is, without any extension (local) - try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype THEN - IF subfuncn = 0 THEN EXIT FUNCTION - IF id.insubfuncn = subfuncn THEN EXIT FUNCTION - END IF - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - '2. that failed, so apply the _define'd extension and pass (local) - a = ASC(UCASE$(n$)): IF a = 95 THEN a = 91 - a = a - 64 'so A=1, Z=27 and _=28 - n2$ = n$ + defineextaz(a) - try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype THEN - IF subfuncn = 0 THEN EXIT FUNCTION - IF id.insubfuncn = subfuncn THEN EXIT FUNCTION - EXIT FUNCTION - END IF - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - '3. pass as is, without any extension (global) - n2$ = n$ - try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype THEN - EXIT FUNCTION - END IF - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - '4. that failed, so apply the _define'd extension and pass (global) - a = ASC(UCASE$(n$)): IF a = 95 THEN a = 91 - a = a - 64 'so A=1, Z=27 and _=28 - n2$ = n$ + defineextaz(a) - try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype THEN - EXIT FUNCTION - END IF - IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - - END IF - FindArray = 0 -END FUNCTION - - - - - -FUNCTION fixoperationorder$ (savea$) - STATIC uboundlbound AS _BYTE - - a$ = savea$ - IF Debug THEN PRINT #9, "fixoperationorder:in:" + a$ - - fooindwel = fooindwel + 1 - - n = numelements(a$) 'n is maintained throughout function - - IF fooindwel = 1 THEN 'actions to take on initial call only - uboundlbound = 0 - - 'Quick check for duplicate binary operations - uppercasea$ = UCASE$(a$) 'capitalize it once to reduce calls to ucase over and over - FOR i = 1 TO n - 1 - temp1$ = getelement(uppercasea$, i) - temp2$ = getelement(uppercasea$, i + 1) - IF temp1$ = "AND" AND temp2$ = "AND" THEN Give_Error "Error: AND AND": EXIT FUNCTION - IF temp1$ = "OR" AND temp2$ = "OR" THEN Give_Error "Error: OR OR": EXIT FUNCTION - IF temp1$ = "XOR" AND temp2$ = "XOR" THEN Give_Error "Error: XOR XOR": EXIT FUNCTION - IF temp1$ = "IMP" AND temp2$ = "IMP" THEN Give_Error "Error: IMP IMP": EXIT FUNCTION - IF temp1$ = "EQV" AND temp2$ = "EQV" THEN Give_Error "Error: EQV EQV": EXIT FUNCTION - NEXT - - '----------------A. 'Quick' mismatched brackets check---------------- - b = 0 - a2$ = sp + a$ + sp - b1$ = sp + "(" + sp - b2$ = sp + ")" + sp - i = 1 - findmmb: - i1 = INSTR(i, a2$, b1$) - i2 = INSTR(i, a2$, b2$) - i3 = i1 - IF i2 THEN - IF i1 = 0 THEN - i3 = i2 - ELSE - IF i2 < i1 THEN i3 = i2 - END IF - END IF - IF i3 THEN - IF i3 = i1 THEN b = b + 1 - IF i3 = i2 THEN b = b - 1 - i = i3 + 2 - IF b < 0 THEN Give_Error "Missing (": EXIT FUNCTION - GOTO findmmb - END IF - IF b > 0 THEN Give_Error "Missing )": EXIT FUNCTION - - '----------------B. 'Quick' correction of over-use of +,- ---------------- - 'note: the results of this change are beneficial to foolayout - a2$ = sp + a$ + sp - - 'rule 1: change ++ to + - rule1: - i = INSTR(a2$, sp + "+" + sp + "+" + sp) - IF i THEN - a2$ = LEFT$(a2$, i + 2) + RIGHT$(a2$, LEN(a2$) - i - 4) - a$ = MID$(a2$, 2, LEN(a2$) - 2) - n = n - 1 - IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ - GOTO rule1 - END IF - - 'rule 2: change -+ to - - rule2: - i = INSTR(a2$, sp + "-" + sp + "+" + sp) - IF i THEN - a2$ = LEFT$(a2$, i + 2) + RIGHT$(a2$, LEN(a2$) - i - 4) - a$ = MID$(a2$, 2, LEN(a2$) - 2) - n = n - 1 - IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ - GOTO rule2 - END IF - - 'rule 3: change anyoperator-- to anyoperator - rule3: - IF INSTR(a2$, sp + "-" + sp + "-" + sp) THEN - FOR i = 1 TO n - 2 - IF isoperator(getelement(a$, i)) THEN - IF getelement(a$, i + 1) = "-" THEN - IF getelement(a$, i + 2) = "-" THEN - removeelements a$, i + 1, i + 2, 0 - a2$ = sp + a$ + sp - n = n - 2 - IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ - GOTO rule3 - END IF - END IF - END IF - NEXT - END IF 'rule 3 - - - - '----------------C. 'Quick' location of negation---------------- - 'note: the results of this change are beneficial to foolayout - - 'for numbers... - 'before: anyoperator,-,number - 'after: anyoperator,-number - - 'for variables... - 'before: anyoperator,-,variable - 'after: anyoperator,CHR$(241),variable - - 'exception for numbers followed by ^... (they will be bracketed up along with the ^ later) - 'before: anyoperator,-,number,^ - 'after: anyoperator,CHR$(241),number,^ - - FOR i = 1 TO n - 1 - IF i > n - 1 THEN EXIT FOR 'n changes, so manually exit if required - - IF ASC(getelement(a$, i)) = 45 THEN '- - - neg = 0 - IF i = 1 THEN - neg = 1 - ELSE - a2$ = getelement(a$, i - 1) - c = ASC(a2$) - IF c = 40 OR c = 44 THEN '(, - neg = 1 - ELSE - IF isoperator(a2$) THEN neg = 1 - END IF '() - END IF 'i=1 - IF neg = 1 THEN - - a2$ = getelement(a$, i + 1) - c = ASC(a2$) - IF c >= 48 AND c <= 57 THEN - c2 = 0: IF i < n - 1 THEN c2 = ASC(getelement(a$, i + 2)) - IF c2 <> 94 THEN 'not ^ - 'number... - i2 = INSTR(a2$, ",") - IF i2 AND ASC(a2$, i2 + 1) <> 38 THEN '&H/&O/&B values don't need the assumed negation - a2$ = "-" + LEFT$(a2$, i2) + "-" + RIGHT$(a2$, LEN(a2$) - i2) - ELSE - a2$ = "-" + a2$ - END IF - removeelements a$, i, i + 1, 0 - insertelements a$, i - 1, a2$ - n = n - 1 - IF Debug THEN PRINT #9, "fixoperationorder:negation:" + a$ - - GOTO negdone - - END IF - END IF - - - 'not a number (or for exceptions)... - removeelements a$, i, i, 0 - insertelements a$, i - 1, CHR$(241) - IF Debug THEN PRINT #9, "fixoperationorder:negation:" + a$ - - END IF 'isoperator - END IF '- - negdone: - NEXT - - - - END IF 'fooindwel=1 - - - - '----------------D. 'Quick' Add 'power of' with negation {}bracketing to bottom bracket level---------------- - pownegused = 0 - powneg: - IF INSTR(a$, "^" + sp + CHR$(241)) THEN 'quick check - b = 0 - b1 = 0 - FOR i = 1 TO n - a2$ = getelement(a$, i) - c = ASC(a2$) - IF c = 40 THEN b = b + 1 - IF c = 41 THEN b = b - 1 - IF b = 0 THEN - IF b1 THEN - IF isoperator(a2$) THEN - IF a2$ <> "^" AND a2$ <> CHR$(241) THEN - insertelements a$, i - 1, "}" - insertelements a$, b1, "{" - n = n + 2 - IF Debug THEN PRINT #9, "fixoperationorder:^-:" + a$ - GOTO powneg - pownegused = 1 - END IF - END IF - END IF - IF c = 94 THEN '^ - IF getelement$(a$, i + 1) = CHR$(241) THEN b1 = i: i = i + 1 - END IF - END IF 'b=0 - NEXT i - IF b1 THEN - insertelements a$, b1, "{" - a$ = a$ + sp + "}" - n = n + 2 - IF Debug THEN PRINT #9, "fixoperationorder:^-:" + a$ - pownegused = 1 - GOTO powneg - END IF - - END IF 'quick check - - - '----------------E. Find lowest & highest operator level in bottom bracket level---------------- - NOT_recheck: - lco = 255 - hco = 0 - b = 0 - FOR i = 1 TO n - a2$ = getelement(a$, i) - c = ASC(a2$) - IF c = 40 OR c = 123 THEN b = b + 1 - IF c = 41 OR c = 125 THEN b = b - 1 - IF b = 0 THEN - op = isoperator(a2$) - IF op THEN - IF op < lco THEN lco = op - IF op > hco THEN hco = op - END IF - END IF - NEXT - - '----------------F. Add operator {}bracketting---------------- - 'apply bracketting only if required - IF hco <> 0 THEN 'operators were used - IF lco <> hco THEN - 'brackets needed - - IF lco = 6 THEN 'NOT exception - 'Step 1: Add brackets as follows ~~~ ( NOT ( ~~~ NOT ~~~ NOT ~~~ NOT ~~~ )) - 'Step 2: Recheck line from beginning - IF n = 1 THEN Give_Error "Expected NOT ...": EXIT FUNCTION - b = 0 - FOR i = 1 TO n - a2$ = getelement(a$, i) - c = ASC(a2$) - IF c = 40 OR c = 123 THEN b = b + 1 - IF c = 41 OR c = 125 THEN b = b - 1 - IF b = 0 THEN - IF UCASE$(a2$) = "NOT" THEN - IF i = n THEN Give_Error "Expected NOT ...": EXIT FUNCTION - IF i = 1 THEN a$ = "NOT" + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2: GOTO lco_bracketting_done - a$ = getelements$(a$, 1, i - 1) + sp + "{" + sp + "NOT" + sp + "{" + sp + getelements$(a$, i + 1, n) + sp + "}" + sp + "}" - n = n + 4 - GOTO NOT_recheck - END IF 'not - END IF 'b=0 - NEXT - END IF 'NOT exception - - n2 = n - b = 0 - a3$ = "{" - n = 1 - FOR i = 1 TO n2 - a2$ = getelement(a$, i) - c = ASC(a2$) - IF c = 40 OR c = 123 THEN b = b + 1 - IF c = 41 OR c = 125 THEN b = b - 1 - IF b = 0 THEN - op = isoperator(a2$) - IF op = lco THEN - IF i = 1 THEN - a3$ = a2$ + sp + "{" - n = 2 - ELSE - IF i = n2 THEN Give_Error "Expected variable/value after '" + UCASE$(a2$) + "'": EXIT FUNCTION - a3$ = a3$ + sp + "}" + sp + a2$ + sp + "{" - n = n + 3 - END IF - GOTO fixop0 - END IF - - END IF 'b=0 - a3$ = a3$ + sp + a2$ - n = n + 1 - fixop0: - NEXT - a3$ = a3$ + sp + "}" - n = n + 1 - a$ = a3$ - - lco_bracketting_done: - IF Debug THEN PRINT #9, "fixoperationorder:lco bracketing["; lco; ","; hco; "]:" + a$ - - '--------(F)G. Remove indwelling {}bracketting from power-negation-------- - IF pownegused THEN - b = 0 - i = 0 - DO - i = i + 1 - IF i > n THEN EXIT DO - c = ASC(getelement(a$, i)) - IF c = 41 OR c = 125 THEN b = b - 1 - IF (c = 123 OR c = 125) AND b <> 0 THEN - removeelements a$, i, i, 0 - n = n - 1 - i = i - 1 - IF Debug THEN PRINT #9, "fixoperationorder:^- {} removed:" + a$ - END IF - IF c = 40 OR c = 123 THEN b = b + 1 - LOOP - END IF 'pownegused - - END IF 'lco <> hco - END IF 'hco <> 0 - - '--------Bracketting of multiple NOT/negation unary operators-------- - IF LEFT$(a$, 4) = CHR$(241) + sp + CHR$(241) + sp THEN - a$ = CHR$(241) + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2 - END IF - IF UCASE$(LEFT$(a$, 8)) = "NOT" + sp + "NOT" + sp THEN - a$ = "NOT" + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2 - END IF - - '----------------H. Identification/conversion of elements within bottom bracket level---------------- - 'actions performed: - ' ->builds f$(tlayout) - ' ->adds symbols to all numbers - ' ->evaluates constants to numbers - - f$ = "" - b = 0 - c = 0 - lastt = 0: lastti = 0 - FOR i = 1 TO n - f2$ = getelement(a$, i) - lastc = c - c = ASC(f2$) - - IF c = 40 OR c = 123 THEN - IF c <> 40 OR b <> 0 THEN f2$ = "" 'skip temporary & indwelling brackets - b = b + 1 - GOTO classdone - END IF - IF c = 41 OR c = 125 THEN - - b = b - 1 - - 'check for "("+sp+")" after literal-string, operator, number or nothing - IF b = 0 THEN 'must be within the lowest level - IF c = 41 THEN - IF lastc = 40 THEN - IF lastti = i - 2 OR lastti = 0 THEN - IF lastt >= 0 AND lastt <= 3 THEN - Give_Error "Unexpected (": EXIT FUNCTION - END IF - END IF - END IF - END IF - END IF - - IF c <> 41 OR b <> 0 THEN f2$ = "" 'skip temporary & indwelling brackets - GOTO classdone - END IF - - IF b = 0 THEN - - 'classifications/conversions: - '1. quoted string ("....) - '2. number - '3. operator - '4. constant - '5. variable/array/udt/function (note: nothing can share the same name as a function except a label) - - - 'quoted string? - IF c = 34 THEN '" - lastt = 1: lastti = i - - 'convert \\ to \ - 'convert \??? to CHR$(&O???) - x2 = 1 - x = INSTR(x2, f2$, "\") - DO WHILE x - c2 = ASC(f2$, x + 1) - IF c2 = 92 THEN '\\ - f2$ = LEFT$(f2$, x) + RIGHT$(f2$, LEN(f2$) - x - 1) 'remove second \ - x2 = x + 1 - ELSE - 'octal triplet value - c3 = (ASC(f2$, x + 3) - 48) + (ASC(f2$, x + 2) - 48) * 8 + (ASC(f2$, x + 1) - 48) * 64 - f2$ = LEFT$(f2$, x - 1) + CHR$(c3) + RIGHT$(f2$, LEN(f2$) - x - 3) - x2 = x + 1 - END IF - x = INSTR(x2, f2$, "\") - LOOP - 'remove ',len' (if it exists) - x = INSTR(2, f2$, CHR$(34) + ","): IF x THEN f2$ = LEFT$(f2$, x) - GOTO classdone - END IF - - 'number? - IF (c >= 48 AND c <= 57) OR c = 45 THEN - lastt = 2: lastti = i - - x = INSTR(f2$, ",") - IF x THEN - removeelements a$, i, i, 0: insertelements a$, i - 1, LEFT$(f2$, x - 1) - f2$ = RIGHT$(f2$, LEN(f2$) - x) - END IF - - IF x = 0 THEN - c2 = ASC(f2$, LEN(f2$)) - IF c2 < 48 OR c2 > 57 THEN - x = 1 'extension given - ELSE - x = INSTR(f2$, "`") - END IF - END IF - - 'add appropriate integer symbol if none present - IF x = 0 THEN - f3$ = f2$ - s$ = "" - IF c = 45 THEN - s$ = "&&" - IF (f3$ < "-2147483648" AND LEN(f3$) = 11) OR LEN(f3$) < 11 THEN s$ = "&" - IF (f3$ <= "-32768" AND LEN(f3$) = 6) OR LEN(f3$) < 6 THEN s$ = "%" - ELSE - s$ = "~&&" - IF (f3$ <= "9223372036854775807" AND LEN(f3$) = 19) OR LEN(f3$) < 19 THEN s$ = "&&" - IF (f3$ <= "2147483647" AND LEN(f3$) = 10) OR LEN(f3$) < 10 THEN s$ = "&" - IF (f3$ <= "32767" AND LEN(f3$) = 5) OR LEN(f3$) < 5 THEN s$ = "%" - END IF - f3$ = f3$ + s$ - removeelements a$, i, i, 0: insertelements a$, i - 1, f3$ - END IF 'x=0 - - GOTO classdone - END IF - - 'operator? - IF isoperator(f2$) THEN - lastt = 3: lastti = i - IF LEN(f2$) > 1 THEN - IF f2$ <> SCase2$(f2$) THEN - f2$ = SCase2$(f2$) - removeelements a$, i, i, 0 - insertelements a$, i - 1, f2$ - END IF - END IF - 'append negation - IF f2$ = CHR$(241) THEN f$ = f$ + sp + "-": GOTO classdone_special - GOTO classdone - END IF - - IF alphanumeric(c) THEN - lastt = 4: lastti = i - - IF i < n THEN nextc = ASC(getelement(a$, i + 1)) ELSE nextc = 0 - - ' a constant? - IF nextc <> 40 THEN '<>"(" (not an array) - IF lastc <> 46 THEN '<>"." (not an element of a UDT) - - e$ = UCASE$(f2$) - es$ = removesymbol$(e$) - IF Error_Happened THEN EXIT FUNCTION - - hashfound = 0 - hashname$ = e$ - hashchkflags = HASHFLAG_CONSTANT - hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN - IF constdefined(hashresref) THEN - hashfound = 1 - EXIT DO - END IF - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - - IF hashfound THEN - i2 = hashresref - 'FOR i2 = constlast TO 0 STEP -1 - 'IF e$ = constname(i2) THEN - - - - - - 'is a STATIC variable overriding this constant? - staticvariable = 0 - try = findid(e$ + es$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype = 0 THEN staticvariable = 1: EXIT DO 'if it's not an array, it's probably a static variable - IF try = 2 THEN findanotherid = 1: try = findid(e$ + es$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - 'add symbol and try again - IF staticvariable = 0 THEN - IF LEN(es$) = 0 THEN - a = ASC(UCASE$(e$)): IF a = 95 THEN a = 91 - a = a - 64 'so A=1, Z=27 and _=28 - es2$ = defineextaz(a) - try = findid(e$ + es2$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF id.arraytype = 0 THEN staticvariable = 1: EXIT DO 'if it's not an array, it's probably a static variable - IF try = 2 THEN findanotherid = 1: try = findid(e$ + es2$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - END IF - END IF - - IF staticvariable = 0 THEN - - t = consttype(i2) - IF t AND ISSTRING THEN - IF LEN(es$) > 0 AND es$ <> "$" THEN Give_Error "Type mismatch": EXIT FUNCTION - e$ = conststring(i2) - ELSE 'not a string - IF LEN(es$) THEN et = typname2typ(es$) ELSE et = 0 - IF Error_Happened THEN EXIT FUNCTION - IF et AND ISSTRING THEN Give_Error "Type mismatch": EXIT FUNCTION - 'convert value to general formats - IF t AND ISFLOAT THEN - v## = constfloat(i2) - v&& = v## - v~&& = v&& - ELSE - IF t AND ISUNSIGNED THEN - v~&& = constuinteger(i2) - v&& = v~&& - v## = v&& - ELSE - v&& = constinteger(i2) - v## = v&& - v~&& = v&& - END IF - END IF - 'apply type conversion if necessary - IF et THEN t = et - '(todo: range checking) - 'convert value into string for returning - IF t AND ISFLOAT THEN - e$ = LTRIM$(RTRIM$(STR$(v##))) - ELSE - IF t AND ISUNSIGNED THEN - e$ = LTRIM$(RTRIM$(STR$(v~&&))) - ELSE - e$ = LTRIM$(RTRIM$(STR$(v&&))) - END IF - END IF - - 'floats returned by str$ must be converted to qb64 standard format - IF t AND ISFLOAT THEN - t2 = t AND 511 - 'find E,D or F - s$ = "" - IF INSTR(e$, "E") THEN s$ = "E" - IF INSTR(e$, "D") THEN s$ = "D" - IF INSTR(e$, "F") THEN s$ = "F" - IF LEN(s$) THEN - 'E,D,F found - x = INSTR(e$, s$) - 'as incorrect type letter may have been returned by STR$, override it - IF t2 = 32 THEN s$ = "E" - IF t2 = 64 THEN s$ = "D" - IF t2 = 256 THEN s$ = "F" - MID$(e$, x, 1) = s$ - IF INSTR(e$, ".") = 0 THEN e$ = LEFT$(e$, x - 1) + ".0" + RIGHT$(e$, LEN(e$) - x + 1): x = x + 2 - IF LEFT$(e$, 1) = "." THEN e$ = "0" + e$ - IF LEFT$(e$, 2) = "-." THEN e$ = "-0" + RIGHT$(e$, LEN(e$) - 1) - IF INSTR(e$, "+") = 0 AND INSTR(e$, "-") = 0 THEN - e$ = LEFT$(e$, x) + "+" + RIGHT$(e$, LEN(e$) - x) - END IF - ELSE - 'E,D,F not found - IF INSTR(e$, ".") = 0 THEN e$ = e$ + ".0" - IF LEFT$(e$, 1) = "." THEN e$ = "0" + e$ - IF LEFT$(e$, 2) = "-." THEN e$ = "-0" + RIGHT$(e$, LEN(e$) - 1) - IF t2 = 32 THEN e$ = e$ + "E+0" - IF t2 = 64 THEN e$ = e$ + "D+0" - IF t2 = 256 THEN e$ = e$ + "F+0" - END IF - ELSE - s$ = typevalue2symbol$(t) - IF Error_Happened THEN EXIT FUNCTION - e$ = e$ + s$ 'simply append symbol to integer - END IF - - END IF 'not a string - - removeelements a$, i, i, 0 - insertelements a$, i - 1, e$ - 'alter f2$ here to original casing - f2$ = constcname(i2) + es$ - GOTO classdone - - END IF 'not static - 'END IF 'same name - 'NEXT - END IF 'hashfound - END IF 'not udt element - END IF 'not array - - 'variable/array/udt? - u$ = f2$ - - try_string$ = f2$ - try_string2$ = try_string$ 'pure version of try_string$ - - FOR try_method = 1 TO 4 - try_string$ = try_string2$ - IF try_method = 2 OR try_method = 4 THEN - dtyp$ = removesymbol(try_string$) - IF LEN(dtyp$) = 0 THEN - IF isoperator(try_string$) = 0 THEN - IF isvalidvariable(try_string$) THEN - IF LEFT$(try_string$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(try_string$)) - 64 - try_string$ = try_string$ + defineextaz(v) - END IF - END IF - ELSE - try_string$ = try_string2$ - END IF - END IF - try = findid(try_string$) - IF Error_Happened THEN EXIT FUNCTION - DO WHILE try - IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN - - IF Debug THEN PRINT #9, "found id matching " + f2$ - - IF nextc = 40 OR uboundlbound <> 0 THEN '( - - uboundlbound = 0 - - 'function or array? - IF id.arraytype <> 0 OR id.subfunc = 1 THEN - 'note: even if it's an array of UDTs, the bracketted index will follow immediately - - 'correct name - f3$ = f2$ - s$ = removesymbol$(f3$) - IF Error_Happened THEN EXIT FUNCTION - IF id.internal_subfunc THEN - f2$ = SCase$(RTRIM$(id.cn)) + s$ - IF (UCASE$(f2$) = "UBOUND" OR UCASE$(f2$) = "LBOUND") THEN - uboundlbound = 2 - END IF - ELSE - f2$ = RTRIM$(id.cn) + s$ - END IF - removeelements a$, i, i, 0 - insertelements a$, i - 1, UCASE$(f2$) - f$ = f$ + f2$ + sp + "(" + sp - - 'skip (but record with nothing inside them) brackets - b2 = 1 'already in first bracket - FOR i2 = i + 2 TO n - c2 = ASC(getelement(a$, i2)) - IF c2 = 40 THEN b2 = b2 + 1 - IF c2 = 41 THEN b2 = b2 - 1 - IF b2 = 0 THEN EXIT FOR 'note: mismatched brackets check ensures this always succeeds - f$ = f$ + sp - NEXT - - 'adjust i accordingly - i = i2 - - f$ = f$ + ")" - - 'jump to UDT section if array is of UDT type (and elements are referenced) - IF id.arraytype AND ISUDT THEN - IF i < n THEN nextc = ASC(getelement(a$, i + 1)) ELSE nextc = 0 - IF nextc = 46 THEN t = id.arraytype: GOTO fooudt - END IF - - f$ = f$ + sp - GOTO classdone_special - END IF 'id.arraytype - END IF 'nextc "(" - - IF nextc <> 40 THEN 'not "(" (this avoids confusing simple variables with arrays) - IF id.t <> 0 OR id.subfunc = 1 THEN 'simple variable or function (without parameters) - - IF id.t AND ISUDT THEN - 'note: it may or may not be followed by a period (eg. if whole udt is being referred to) - 'check if next item is a period - - 'correct name - IF id.internal_subfunc THEN - f2$ = SCase$(RTRIM$(id.cn)) + removesymbol$(f2$) - ELSE - f2$ = RTRIM$(id.cn) + removesymbol$(f2$) - END IF - IF Error_Happened THEN EXIT FUNCTION - removeelements a$, i, i, 0 - insertelements a$, i - 1, UCASE$(f2$) - f$ = f$ + f2$ - - - - IF nextc <> 46 THEN f$ = f$ + sp: GOTO classdone_special 'no sub-elements referenced - t = id.t - - fooudt: - - f$ = f$ + sp + "." + sp - E = udtxnext(t AND 511) 'next element to check - i = i + 2 - - 'loop - - '"." encountered, i must be an element - IF i > n THEN Give_Error "Expected .element": EXIT FUNCTION - f2$ = getelement(a$, i) - s$ = removesymbol$(f2$) - IF Error_Happened THEN EXIT FUNCTION - u$ = UCASE$(f2$) + SPACE$(256 - LEN(f2$)) 'fast scanning - - 'is f$ the same as element e? - fooudtnexte: - IF udtename(E) = u$ THEN - 'match found - 'todo: check symbol(s$) matches element's type - - 'correct name - f2$ = RTRIM$(udtecname(E)) + s$ - removeelements a$, i, i, 0 - insertelements a$, i - 1, UCASE$(f2$) - f$ = f$ + f2$ - - IF i = n THEN f$ = f$ + sp: GOTO classdone_special - nextc = ASC(getelement(a$, i + 1)) - IF nextc <> 46 THEN f$ = f$ + sp: GOTO classdone_special 'no sub-elements referenced - 'sub-element exists - t = udtetype(E) - IF (t AND ISUDT) = 0 THEN Give_Error "Invalid . after element": EXIT FUNCTION - GOTO fooudt - - END IF 'match found - - 'no, so check next element - E = udtenext(E) - IF E = 0 THEN Give_Error "Element not defined": EXIT FUNCTION - GOTO fooudtnexte - - END IF 'udt - - 'non array/udt based variable - f3$ = f2$ - s$ = removesymbol$(f3$) - IF Error_Happened THEN EXIT FUNCTION - IF id.internal_subfunc THEN - f2$ = SCase$(RTRIM$(id.cn)) + s$ - ELSE - f2$ = RTRIM$(id.cn) + s$ - END IF - 'change was is returned to uppercase - removeelements a$, i, i, 0 - insertelements a$, i - 1, UCASE$(f2$) - GOTO CouldNotClassify - END IF 'id.t - - END IF 'nextc not "(" - - END IF - IF try = 2 THEN findanotherid = 1: try = findid(try_string$) ELSE try = 0 - IF Error_Happened THEN EXIT FUNCTION - LOOP - NEXT 'try method (1-4) - CouldNotClassify: - - 'alphanumeric, but item name is unknown... is it an internal type? if so, use capitals - f3$ = UCASE$(f2$) - internaltype = 0 - IF f3$ = "STRING" THEN internaltype = 1 - IF f3$ = "_UNSIGNED" OR (f3$ = "UNSIGNED" AND qb64prefix_set = 1) THEN internaltype = 1 - IF f3$ = "_BIT" OR (f3$ = "BIT" AND qb64prefix_set = 1) THEN internaltype = 1 - IF f3$ = "_BYTE" OR (f3$ = "BYTE" AND qb64prefix_set = 1) THEN internaltype = 1 - IF f3$ = "INTEGER" THEN internaltype = 1 - IF f3$ = "LONG" THEN internaltype = 1 - IF f3$ = "_INTEGER64" OR (f3$ = "INTEGER64" AND qb64prefix_set = 1) THEN internaltype = 1 - IF f3$ = "SINGLE" THEN internaltype = 1 - IF f3$ = "DOUBLE" THEN internaltype = 1 - IF f3$ = "_FLOAT" OR (f3$ = "FLOAT" AND qb64prefix_set = 1) THEN internaltype = 1 - IF f3$ = "_OFFSET" OR (f3$ = "OFFSET" AND qb64prefix_set = 1) THEN internaltype = 1 - IF internaltype = 1 THEN - f2$ = SCase2$(f3$) - removeelements a$, i, i, 0 - insertelements a$, i - 1, f3$ - GOTO classdone - END IF - - GOTO classdone - END IF 'alphanumeric - - classdone: - f$ = f$ + f2$ - END IF 'b=0 - f$ = f$ + sp - classdone_special: - NEXT - - IF LEN(f$) THEN f$ = LEFT$(f$, LEN(f$) - 1) 'remove trailing 'sp' - - IF Debug THEN PRINT #9, "fixoperationorder:identification:" + a$, n - IF Debug THEN PRINT #9, "fixoperationorder:identification(layout):" + f$, n - - - '----------------I. Pass (){}bracketed items (if any) to fixoperationorder & build return---------------- - 'note: items seperated by commas are done seperately - - ff$ = "" - b = 0 - b2 = 0 - p1 = 0 'where level 1 began - aa$ = "" - n = numelements(a$) - FOR i = 1 TO n - - openbracket = 0 - - a2$ = getelement(a$, i) - - c = ASC(a2$) - - - - IF c = 40 OR c = 123 THEN '({ - b = b + 1 - - IF b = 1 THEN - - - - - p1 = i + 1 - aa$ = aa$ + "(" + sp - - END IF - - openbracket = 1 - - GOTO foopass - - END IF '({ - - IF c = 44 THEN ', - IF b = 1 THEN - GOTO foopassit - END IF - END IF - - IF c = 41 OR c = 125 THEN ')} - IF uboundlbound THEN uboundlbound = uboundlbound - 1 - b = b - 1 - - IF b = 0 THEN - foopassit: - IF p1 <> i THEN - foo$ = fixoperationorder(getelements(a$, p1, i - 1)) - IF Error_Happened THEN EXIT FUNCTION - IF LEN(foo$) THEN - aa$ = aa$ + foo$ + sp - IF c = 125 THEN ff$ = ff$ + tlayout$ + sp ELSE ff$ = ff$ + tlayout$ + sp2 'spacing between ) } , varies - END IF - END IF - IF c = 44 THEN aa$ = aa$ + "," + sp: ff$ = ff$ + "," + sp ELSE aa$ = aa$ + ")" + sp - p1 = i + 1 - END IF - - GOTO foopass - END IF ')} - - - - - IF b = 0 THEN aa$ = aa$ + a2$ + sp - - - foopass: - - f2$ = getelementspecial(f$, i) - IF Error_Happened THEN EXIT FUNCTION - IF LEN(f2$) THEN - - 'use sp2 to join items connected by a period - IF c = 46 THEN '"." - IF i > 1 AND i < n THEN 'stupidity check - IF LEN(ff$) THEN MID$(ff$, LEN(ff$), 1) = sp2 'convert last spacer to a sp2 - ff$ = ff$ + "." + sp2 - GOTO fooloopnxt - END IF - END IF - - 'spacing just before ( - IF openbracket THEN - - 'convert last spacer? - IF i <> 1 THEN - IF isoperator(getelement$(a$, i - 1)) = 0 THEN - MID$(ff$, LEN(ff$), 1) = sp2 - END IF - END IF - ff$ = ff$ + f2$ + sp2 - ELSE 'not openbracket - ff$ = ff$ + f2$ + sp - END IF - - END IF 'len(f2$) - - fooloopnxt: - - NEXT - - IF LEN(aa$) THEN aa$ = LEFT$(aa$, LEN(aa$) - 1) - IF LEN(ff$) THEN ff$ = LEFT$(ff$, LEN(ff$) - 1) - - IF Debug THEN PRINT #9, "fixoperationorder:return:" + aa$ - IF Debug THEN PRINT #9, "fixoperationorder:layout:" + ff$ - tlayout$ = ff$ - fixoperationorder$ = aa$ - - fooindwel = fooindwel - 1 -END FUNCTION - - - - -FUNCTION getelementspecial$ (savea$, elenum) - a$ = savea$ - IF a$ = "" THEN EXIT FUNCTION 'no elements! - - n = 1 - p = 1 - getelementspecialnext: - i = INSTR(p, a$, sp) - - 'avoid sp inside "..." - i2 = INSTR(p, a$, CHR$(34)) - IF i2 < i AND i2 <> 0 THEN - i3 = INSTR(i2 + 1, a$, CHR$(34)): IF i3 = 0 THEN Give_Error "Expected " + CHR$(34): EXIT FUNCTION - i = INSTR(i3, a$, sp) - END IF - - IF elenum = n THEN - IF i THEN - getelementspecial$ = MID$(a$, p, i - p) - ELSE - getelementspecial$ = RIGHT$(a$, LEN(a$) - p + 1) - END IF - EXIT FUNCTION - END IF - - IF i = 0 THEN EXIT FUNCTION 'no more elements! - n = n + 1 - p = i + 1 - GOTO getelementspecialnext -END FUNCTION - - - -FUNCTION getelement$ (a$, elenum) - IF a$ = "" THEN EXIT FUNCTION 'no elements! - - n = 1 - p = 1 - getelementnext: - i = INSTR(p, a$, sp) - - IF elenum = n THEN - IF i THEN - getelement$ = MID$(a$, p, i - p) - ELSE - getelement$ = RIGHT$(a$, LEN(a$) - p + 1) - END IF - EXIT FUNCTION - END IF - - IF i = 0 THEN EXIT FUNCTION 'no more elements! - n = n + 1 - p = i + 1 - GOTO getelementnext -END FUNCTION - -FUNCTION getelements$ (a$, i1, i2) - IF i2 < i1 THEN getelements$ = "": EXIT FUNCTION - n = 1 - p = 1 - getelementsnext: - i = INSTR(p, a$, sp) - IF n = i1 THEN - i1pos = p - END IF - IF n = i2 THEN - IF i THEN - getelements$ = MID$(a$, i1pos, i - i1pos) - ELSE - getelements$ = RIGHT$(a$, LEN(a$) - i1pos + 1) - END IF - EXIT FUNCTION - END IF - n = n + 1 - p = i + 1 - GOTO getelementsnext -END FUNCTION - -SUB getid (i AS LONG) - IF i = -1 THEN Give_Error "-1 passed to getid!": EXIT SUB - - id = ids(i) - - currentid = i -END SUB - -SUB insertelements (a$, i, elements$) - IF i = 0 THEN - IF a$ = "" THEN - a$ = elements$ - EXIT SUB - END IF - a$ = elements$ + sp + a$ - EXIT SUB - END IF - - a2$ = "" - n = numelements(a$) - - - - - FOR i2 = 1 TO n - IF i2 > 1 THEN a2$ = a2$ + sp - a2$ = a2$ + getelement$(a$, i2) - IF i = i2 THEN a2$ = a2$ + sp + elements$ - NEXT - - a$ = a2$ - -END SUB - -FUNCTION isoperator (a2$) - a$ = UCASE$(a2$) - l = 0 - l = l + 1: IF a$ = "IMP" THEN GOTO opfound - l = l + 1: IF a$ = "EQV" THEN GOTO opfound - l = l + 1: IF a$ = "XOR" THEN GOTO opfound - l = l + 1: IF a$ = "OR" THEN GOTO opfound - l = l + 1: IF a$ = "AND" THEN GOTO opfound - l = l + 1: IF a$ = "NOT" THEN GOTO opfound - l = l + 1 - IF a$ = "=" THEN GOTO opfound - IF a$ = ">" THEN GOTO opfound - IF a$ = "<" THEN GOTO opfound - IF a$ = "<>" THEN GOTO opfound - IF a$ = "<=" THEN GOTO opfound - IF a$ = ">=" THEN GOTO opfound - l = l + 1 - IF a$ = "+" THEN GOTO opfound - IF a$ = "-" THEN GOTO opfound '!CAREFUL! could be negation - l = l + 1: IF a$ = "MOD" THEN GOTO opfound - l = l + 1: IF a$ = "\" THEN GOTO opfound - l = l + 1 - IF a$ = "*" THEN GOTO opfound - IF a$ = "/" THEN GOTO opfound - 'NEGATION LEVEL (MUST BE SET AFTER CALLING ISOPERATOR BY CONTEXT) - l = l + 1: IF a$ = CHR$(241) THEN GOTO opfound - l = l + 1: IF a$ = "^" THEN GOTO opfound - EXIT FUNCTION - opfound: - isoperator = l -END FUNCTION - -FUNCTION isuinteger (i$) - IF LEN(i$) = 0 THEN EXIT FUNCTION - IF ASC(i$, 1) = 48 AND LEN(i$) > 1 THEN EXIT FUNCTION - FOR c = 1 TO LEN(i$) - v = ASC(i$, c) - IF v < 48 OR v > 57 THEN EXIT FUNCTION - NEXT - isuinteger = -1 -END FUNCTION - -FUNCTION isvalidvariable (a$) - FOR i = 1 TO LEN(a$) - c = ASC(a$, i) - t = 0 - IF c >= 48 AND c <= 57 THEN t = 1 'numeric - IF c >= 65 AND c <= 90 THEN t = 2 'uppercase - IF c >= 97 AND c <= 122 THEN t = 2 'lowercase - IF c = 95 THEN t = 2 '_ underscore - IF t = 2 OR (t = 1 AND i > 1) THEN - 'valid (continue) - ELSE - IF i = 1 THEN isvalidvariable = 0: EXIT FUNCTION - EXIT FOR - END IF - NEXT - - isvalidvariable = 1 - IF i > n THEN EXIT FUNCTION 'i is always greater than n because n is undefined here. Why didn't I remove this line and the ones below it, which will never run? Cause I'm a coward. F.h. - e$ = RIGHT$(a$, LEN(a$) - i - 1) - IF e$ = "%%" OR e$ = "~%%" THEN EXIT FUNCTION - IF e$ = "%" OR e$ = "~%" THEN EXIT FUNCTION - IF e$ = "&" OR e$ = "~&" THEN EXIT FUNCTION - IF e$ = "&&" OR e$ = "~&&" THEN EXIT FUNCTION - IF e$ = "!" OR e$ = "#" OR e$ = "##" THEN EXIT FUNCTION - IF e$ = "$" THEN EXIT FUNCTION - IF e$ = "`" THEN EXIT FUNCTION - IF LEFT$(e$, 1) <> "$" AND LEFT$(e$, 1) <> "`" THEN isvalidvariable = 0: EXIT FUNCTION - e$ = RIGHT$(e$, LEN(e$) - 1) - IF isuinteger(e$) THEN isvalidvariable = 1: EXIT FUNCTION - isvalidvariable = 0 -END FUNCTION - - - - -FUNCTION lineformat$ (a$) - a2$ = "" - linecontinuation = 0 - - continueline: - - a$ = a$ + " " 'add 2 extra spaces to make reading next char easier - - ca$ = a$ - a$ = UCASE$(a$) - - n = LEN(a$) - i = 1 - lineformatnext: - IF i >= n THEN GOTO lineformatdone - - c = ASC(a$, i) - c$ = CHR$(c) '***remove later*** - - '----------------quoted string---------------- - IF c = 34 THEN '" - a2$ = a2$ + sp + CHR$(34) - p1 = i + 1 - FOR i2 = i + 1 TO n - 2 - c2 = ASC(a$, i2) - - IF c2 = 34 THEN - a2$ = a2$ + MID$(ca$, p1, i2 - p1 + 1) + "," + str2$(i2 - (i + 1)) - i = i2 + 1 - EXIT FOR - END IF - - IF c2 = 92 THEN '\ - a2$ = a2$ + MID$(ca$, p1, i2 - p1) + "\\" - p1 = i2 + 1 - END IF - - IF c2 < 32 OR c2 > 126 THEN - o$ = OCT$(c2) - IF LEN(o$) < 3 THEN - o$ = "0" + o$ - IF LEN(o$) < 3 THEN o$ = "0" + o$ - END IF - a2$ = a2$ + MID$(ca$, p1, i2 - p1) + "\" + o$ - p1 = i2 + 1 - END IF - - NEXT - - IF i2 = n - 1 THEN 'no closing " - a2$ = a2$ + MID$(ca$, p1, (n - 2) - p1 + 1) + CHR$(34) + "," + str2$((n - 2) - (i + 1) + 1) - i = n - 1 - END IF - - GOTO lineformatnext - - END IF - - '----------------number---------------- - firsti = i - IF c = 46 THEN - c2$ = MID$(a$, i + 1, 1): c2 = ASC(c2$) - IF (c2 >= 48 AND c2 <= 57) THEN GOTO lfnumber - END IF - IF (c >= 48 AND c <= 57) THEN '0-9 - lfnumber: - - 'handle 'IF a=1 THEN a=2 ELSE 100' by assuming numeric after ELSE to be a - IF RIGHT$(a2$, 5) = sp + "ELSE" THEN - a2$ = a2$ + sp + "GOTO" - END IF - - 'Number will be converted to the following format: - ' 999999 . 99999 E + 999 - '[whole$][dp(0/1)][frac$][ed(1/2)][pm(1/-1)][ex$] - ' 0 1 2 3 <-mode - - mode = 0 - whole$ = "" - dp = 0 - frac$ = "" - ed = 0 'E=1, D=2, F=3 - pm = 1 - ex$ = "" - - - - - lfreadnumber: - valid = 0 - - IF c = 46 THEN - IF mode = 0 THEN valid = 1: dp = 1: mode = 1 - END IF - - IF c >= 48 AND c <= 57 THEN '0-9 - valid = 1 - IF mode = 0 THEN whole$ = whole$ + c$ - IF mode = 1 THEN frac$ = frac$ + c$ - IF mode = 2 THEN mode = 3 - IF mode = 3 THEN ex$ = ex$ + c$ - END IF - - IF c = 69 OR c = 68 OR c = 70 THEN 'E,D,F - IF mode < 2 THEN - valid = 1 - IF c = 69 THEN ed = 1 - IF c = 68 THEN ed = 2 - IF c = 70 THEN ed = 3 - mode = 2 - END IF - END IF - - IF c = 43 OR c = 45 THEN '+,- - IF mode = 2 THEN - valid = 1 - IF c = 45 THEN pm = -1 - mode = 3 - END IF - END IF - - IF valid THEN - IF i <= n THEN i = i + 1: c$ = MID$(a$, i, 1): c = ASC(c$): GOTO lfreadnumber - END IF - - - - 'cull leading 0s off whole$ - DO WHILE LEFT$(whole$, 1) = "0": whole$ = RIGHT$(whole$, LEN(whole$) - 1): LOOP - 'cull trailing 0s off frac$ - DO WHILE RIGHT$(frac$, 1) = "0": frac$ = LEFT$(frac$, LEN(frac$) - 1): LOOP - 'cull leading 0s off ex$ - DO WHILE LEFT$(ex$, 1) = "0": ex$ = RIGHT$(ex$, LEN(ex$) - 1): LOOP - - IF dp <> 0 OR ed <> 0 THEN float = 1 ELSE float = 0 - - extused = 1 - - IF ed THEN e$ = "": GOTO lffoundext 'no extensions valid after E/D/F specified - - '3-character extensions - IF i <= n - 2 THEN - e$ = MID$(a$, i, 3) - IF e$ = "~%%" AND float = 0 THEN i = i + 3: GOTO lffoundext - IF e$ = "~&&" AND float = 0 THEN i = i + 3: GOTO lffoundext - IF e$ = "~%&" AND float = 0 THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - END IF - '2-character extensions - IF i <= n - 1 THEN - e$ = MID$(a$, i, 2) - IF e$ = "%%" AND float = 0 THEN i = i + 2: GOTO lffoundext - IF e$ = "~%" AND float = 0 THEN i = i + 2: GOTO lffoundext - IF e$ = "&&" AND float = 0 THEN i = i + 2: GOTO lffoundext - IF e$ = "~&" AND float = 0 THEN i = i + 2: GOTO lffoundext - IF e$ = "%&" AND float = 0 THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - IF e$ = "##" THEN - i = i + 2 - ed = 3 - e$ = "" - GOTO lffoundext - END IF - IF e$ = "~`" THEN - i = i + 2 - GOTO lffoundbitext - END IF - END IF - '1-character extensions - IF i <= n THEN - e$ = MID$(a$, i, 1) - IF e$ = "%" AND float = 0 THEN i = i + 1: GOTO lffoundext - IF e$ = "&" AND float = 0 THEN i = i + 1: GOTO lffoundext - IF e$ = "!" THEN - i = i + 1 - ed = 1 - e$ = "" - GOTO lffoundext - END IF - IF e$ = "#" THEN - i = i + 1 - ed = 2 - e$ = "" - GOTO lffoundext - END IF - IF e$ = "`" THEN - i = i + 1 - lffoundbitext: - bitn$ = "" - DO WHILE i <= n - c2 = ASC(MID$(a$, i, 1)) - IF c2 >= 48 AND c2 <= 57 THEN - bitn$ = bitn$ + CHR$(c2) - i = i + 1 - ELSE - EXIT DO - END IF - LOOP - IF bitn$ = "" THEN bitn$ = "1" - 'cull leading 0s off bitn$ - DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP - e$ = e$ + bitn$ - GOTO lffoundext - END IF - END IF - - IF float THEN 'floating point types CAN be assumed - 'calculate first significant digit offset & number of significant digits - IF whole$ <> "" THEN - offset = LEN(whole$) - 1 - sigdigits = LEN(whole$) + LEN(frac$) - ELSE - IF frac$ <> "" THEN - offset = -1 - sigdigits = LEN(frac$) - FOR i2 = 1 TO LEN(frac$) - IF MID$(frac$, i2, 1) <> "0" THEN EXIT FOR - offset = offset - 1 - sigdigits = sigdigits - 1 - NEXT - ELSE - 'number is 0 - offset = 0 - sigdigits = 0 - END IF - END IF - sigdig$ = RIGHT$(whole$ + frac$, sigdigits) - 'SINGLE? - IF sigdigits <= 7 THEN 'QBASIC interprets anything with more than 7 sig. digits as a DOUBLE - IF offset <= 38 AND offset >= -38 THEN 'anything outside this range cannot be represented as a SINGLE - IF offset = 38 THEN - IF sigdig$ > "3402823" THEN GOTO lfxsingle - END IF - IF offset = -38 THEN - IF sigdig$ < "1175494" THEN GOTO lfxsingle - END IF - ed = 1 - e$ = "" - GOTO lffoundext - END IF - END IF - lfxsingle: - 'DOUBLE? - IF sigdigits <= 16 THEN 'QB64 handles DOUBLES with 16-digit precision - IF offset <= 308 AND offset >= -308 THEN 'anything outside this range cannot be represented as a DOUBLE - IF offset = 308 THEN - IF sigdig$ > "1797693134862315" THEN GOTO lfxdouble - END IF - IF offset = -308 THEN - IF sigdig$ < "2225073858507201" THEN GOTO lfxdouble - END IF - ed = 2 - e$ = "" - GOTO lffoundext - END IF - END IF - lfxdouble: - 'assume _FLOAT - ed = 3 - e$ = "": GOTO lffoundext - END IF - - extused = 0 - e$ = "" - lffoundext: - - 'make sure a leading numberic character exists - IF whole$ = "" THEN whole$ = "0" - 'if a float, ensure frac$<>"" and dp=1 - IF float THEN - dp = 1 - IF frac$ = "" THEN frac$ = "0" - END IF - 'if ed is specified, make sure ex$ exists - IF ed <> 0 AND ex$ = "" THEN ex$ = "0" - - a2$ = a2$ + sp - a2$ = a2$ + whole$ - IF dp THEN a2$ = a2$ + "." + frac$ - IF ed THEN - IF ed = 1 THEN a2$ = a2$ + "E" - IF ed = 2 THEN a2$ = a2$ + "D" - IF ed = 3 THEN a2$ = a2$ + "F" - IF pm = -1 AND ex$ <> "0" THEN a2$ = a2$ + "-" ELSE a2$ = a2$ + "+" - a2$ = a2$ + ex$ - END IF - a2$ = a2$ + e$ - - IF extused THEN a2$ = a2$ + "," + MID$(a$, firsti, i - firsti) - - GOTO lineformatnext - END IF - - '----------------(number)&H...---------------- - 'note: the final value, not the number of hex characters, sets the default type - IF c = 38 THEN '& - IF MID$(a$, i + 1, 1) = "H" THEN - i = i + 2 - hx$ = "" - lfreadhex: - IF i <= n THEN - c$ = MID$(a$, i, 1): c = ASC(c$) - IF (c >= 48 AND c <= 57) OR (c >= 65 AND c <= 70) THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadhex - END IF - fullhx$ = "&H" + hx$ - - 'cull leading 0s off hx$ - DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP - IF hx$ = "" THEN hx$ = "0" - - bitn$ = "" - '3-character extensions - IF i <= n - 2 THEN - e$ = MID$(a$, i, 3) - IF e$ = "~%%" THEN i = i + 3: GOTO lfhxext - IF e$ = "~&&" THEN i = i + 3: GOTO lfhxext - IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - END IF - '2-character extensions - IF i <= n - 1 THEN - e$ = MID$(a$, i, 2) - IF e$ = "%%" THEN i = i + 2: GOTO lfhxext - IF e$ = "~%" THEN i = i + 2: GOTO lfhxext - IF e$ = "&&" THEN i = i + 2: GOTO lfhxext - IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - IF e$ = "~&" THEN i = i + 2: GOTO lfhxext - IF e$ = "~`" THEN - i = i + 2 - GOTO lfhxbitext - END IF - END IF - '1-character extensions - IF i <= n THEN - e$ = MID$(a$, i, 1) - IF e$ = "%" THEN i = i + 1: GOTO lfhxext - IF e$ = "&" THEN i = i + 1: GOTO lfhxext - IF e$ = "`" THEN - i = i + 1 - lfhxbitext: - DO WHILE i <= n - c2 = ASC(MID$(a$, i, 1)) - IF c2 >= 48 AND c2 <= 57 THEN - bitn$ = bitn$ + CHR$(c2) - i = i + 1 - ELSE - EXIT DO - END IF - LOOP - IF bitn$ = "" THEN bitn$ = "1" - 'cull leading 0s off bitn$ - DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP - GOTO lfhxext - END IF - END IF - 'if no valid extension context was given, assume one - 'note: leading 0s have been culled, so LEN(hx$) reflects its values size - e$ = "&&" - IF LEN(hx$) <= 8 THEN e$ = "&" 'as in QBASIC, signed values must be used - IF LEN(hx$) <= 4 THEN e$ = "%" 'as in QBASIC, signed values must be used - GOTO lfhxext2 - lfhxext: - fullhx$ = fullhx$ + e$ + bitn$ - lfhxext2: - - 'build 8-byte unsigned integer rep. of hx$ - IF LEN(hx$) > 16 THEN Give_Error "Overflow": EXIT FUNCTION - v~&& = 0 - FOR i2 = 1 TO LEN(hx$) - v2 = ASC(MID$(hx$, i2, 1)) - IF v2 <= 57 THEN v2 = v2 - 48 ELSE v2 = v2 - 65 + 10 - v~&& = v~&& * 16 + v2 - NEXT - - finishhexoctbin: - num$ = str2u64$(v~&&) 'correct for unsigned values (overflow of unsigned can be checked later) - IF LEFT$(e$, 1) <> "~" THEN 'note: range checking will be performed later in fixop.order - 'signed - - IF e$ = "%%" THEN - IF v~&& > 127 THEN - IF v~&& > 255 THEN Give_Error "Overflow": EXIT FUNCTION - v~&& = ((NOT v~&&) AND 255) + 1 - num$ = "-" + sp + str2u64$(v~&&) - END IF - END IF - - IF e$ = "%" THEN - IF v~&& > 32767 THEN - IF v~&& > 65535 THEN Give_Error "Overflow": EXIT FUNCTION - v~&& = ((NOT v~&&) AND 65535) + 1 - num$ = "-" + sp + str2u64$(v~&&) - END IF - END IF - - IF e$ = "&" THEN - IF v~&& > 2147483647 THEN - IF v~&& > 4294967295 THEN Give_Error "Overflow": EXIT FUNCTION - v~&& = ((NOT v~&&) AND 4294967295) + 1 - num$ = "-" + sp + str2u64$(v~&&) - END IF - END IF - - IF e$ = "&&" THEN - IF v~&& > 9223372036854775807 THEN - 'note: no error checking necessary - v~&& = (NOT v~&&) + 1 - num$ = "-" + sp + str2u64$(v~&&) - END IF - END IF - - IF e$ = "`" THEN - vbitn = VAL(bitn$) - h~&& = 1: FOR i2 = 1 TO vbitn - 1: h~&& = h~&& * 2: NEXT: h~&& = h~&& - 1 'build h~&& - IF v~&& > h~&& THEN - h~&& = 1: FOR i2 = 1 TO vbitn: h~&& = h~&& * 2: NEXT: h~&& = h~&& - 1 'build h~&& - IF v~&& > h~&& THEN Give_Error "Overflow": EXIT FUNCTION - v~&& = ((NOT v~&&) AND h~&&) + 1 - num$ = "-" + sp + str2u64$(v~&&) - END IF - END IF - - END IF '<>"~" - - a2$ = a2$ + sp + num$ + e$ + bitn$ + "," + fullhx$ - - GOTO lineformatnext - END IF - END IF - - '----------------(number)&O...---------------- - 'note: the final value, not the number of oct characters, sets the default type - IF c = 38 THEN '& - IF MID$(a$, i + 1, 1) = "O" THEN - i = i + 2 - 'note: to avoid mistakes, hx$ is used instead of 'ot$' - hx$ = "" - lfreadoct: - IF i <= n THEN - c$ = MID$(a$, i, 1): c = ASC(c$) - IF c >= 48 AND c <= 55 THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadoct - END IF - fullhx$ = "&O" + hx$ - - 'cull leading 0s off hx$ - DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP - IF hx$ = "" THEN hx$ = "0" - - bitn$ = "" - '3-character extensions - IF i <= n - 2 THEN - e$ = MID$(a$, i, 3) - IF e$ = "~%%" THEN i = i + 3: GOTO lfotext - IF e$ = "~&&" THEN i = i + 3: GOTO lfotext - IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - END IF - '2-character extensions - IF i <= n - 1 THEN - e$ = MID$(a$, i, 2) - IF e$ = "%%" THEN i = i + 2: GOTO lfotext - IF e$ = "~%" THEN i = i + 2: GOTO lfotext - IF e$ = "&&" THEN i = i + 2: GOTO lfotext - IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - IF e$ = "~&" THEN i = i + 2: GOTO lfotext - IF e$ = "~`" THEN - i = i + 2 - GOTO lfotbitext - END IF - END IF - '1-character extensions - IF i <= n THEN - e$ = MID$(a$, i, 1) - IF e$ = "%" THEN i = i + 1: GOTO lfotext - IF e$ = "&" THEN i = i + 1: GOTO lfotext - IF e$ = "`" THEN - i = i + 1 - lfotbitext: - bitn$ = "" - DO WHILE i <= n - c2 = ASC(MID$(a$, i, 1)) - IF c2 >= 48 AND c2 <= 57 THEN - bitn$ = bitn$ + CHR$(c2) - i = i + 1 - ELSE - EXIT DO - END IF - LOOP - IF bitn$ = "" THEN bitn$ = "1" - 'cull leading 0s off bitn$ - DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP - GOTO lfotext - END IF - END IF - 'if no valid extension context was given, assume one - 'note: leading 0s have been culled, so LEN(hx$) reflects its values size - e$ = "&&" - '37777777777 - IF LEN(hx$) <= 11 THEN - IF LEN(hx$) < 11 OR ASC(LEFT$(hx$, 1)) <= 51 THEN e$ = "&" - END IF - '177777 - IF LEN(hx$) <= 6 THEN - IF LEN(hx$) < 6 OR LEFT$(hx$, 1) = "1" THEN e$ = "%" - END IF - - GOTO lfotext2 - lfotext: - fullhx$ = fullhx$ + e$ + bitn$ - lfotext2: - - 'build 8-byte unsigned integer rep. of hx$ - '1777777777777777777777 (22 digits) - IF LEN(hx$) > 22 THEN Give_Error "Overflow": EXIT FUNCTION - IF LEN(hx$) = 22 THEN - IF LEFT$(hx$, 1) <> "1" THEN Give_Error "Overflow": EXIT FUNCTION - END IF - '********change v& to v~&&******** - v~&& = 0 - FOR i2 = 1 TO LEN(hx$) - v2 = ASC(MID$(hx$, i2, 1)) - v2 = v2 - 48 - v~&& = v~&& * 8 + v2 - NEXT - - GOTO finishhexoctbin - END IF - END IF - - '----------------(number)&B...---------------- - 'note: the final value, not the number of bin characters, sets the default type - IF c = 38 THEN '& - IF MID$(a$, i + 1, 1) = "B" THEN - i = i + 2 - 'note: to avoid mistakes, hx$ is used instead of 'bi$' - hx$ = "" - lfreadbin: - IF i <= n THEN - c$ = MID$(a$, i, 1): c = ASC(c$) - IF c >= 48 AND c <= 49 THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadbin - END IF - fullhx$ = "&B" + hx$ - - 'cull leading 0s off hx$ - DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP - IF hx$ = "" THEN hx$ = "0" - - bitn$ = "" - '3-character extensions - IF i <= n - 2 THEN - e$ = MID$(a$, i, 3) - IF e$ = "~%%" THEN i = i + 3: GOTO lfbiext - IF e$ = "~&&" THEN i = i + 3: GOTO lfbiext - IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - END IF - '2-character extensions - IF i <= n - 1 THEN - e$ = MID$(a$, i, 2) - IF e$ = "%%" THEN i = i + 2: GOTO lfbiext - IF e$ = "~%" THEN i = i + 2: GOTO lfbiext - IF e$ = "&&" THEN i = i + 2: GOTO lfbiext - IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION - IF e$ = "~&" THEN i = i + 2: GOTO lfbiext - IF e$ = "~`" THEN - i = i + 2 - GOTO lfbibitext - END IF - END IF - - - '1-character extensions - IF i <= n THEN - e$ = MID$(a$, i, 1) - IF e$ = "%" THEN i = i + 1: GOTO lfbiext - IF e$ = "&" THEN i = i + 1: GOTO lfbiext - IF e$ = "`" THEN - i = i + 1 - lfbibitext: - bitn$ = "" - DO WHILE i <= n - c2 = ASC(MID$(a$, i, 1)) - IF c2 >= 48 AND c2 <= 57 THEN - bitn$ = bitn$ + CHR$(c2) - i = i + 1 - ELSE - EXIT DO - END IF - LOOP - IF bitn$ = "" THEN bitn$ = "1" - 'cull leading 0s off bitn$ - DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP - GOTO lfbiext - END IF - END IF - 'if no valid extension context was given, assume one - 'note: leading 0s have been culled, so LEN(hx$) reflects its values size - e$ = "&&" - IF LEN(hx$) <= 32 THEN e$ = "&" - IF LEN(hx$) <= 16 THEN e$ = "%" - - GOTO lfbiext2 - lfbiext: - fullhx$ = fullhx$ + e$ + bitn$ - lfbiext2: - - 'build 8-byte unsigned integer rep. of hx$ - IF LEN(hx$) > 64 THEN Give_Error "Overflow": EXIT FUNCTION - - v~&& = 0 - FOR i2 = 1 TO LEN(hx$) - v2 = ASC(MID$(hx$, i2, 1)) - v2 = v2 - 48 - v~&& = v~&& * 2 + v2 - NEXT - - GOTO finishhexoctbin - END IF - END IF - - - '----------------(number)&H??? error---------------- - IF c = 38 THEN Give_Error "Expected &H... or &O...": EXIT FUNCTION - - '----------------variable/name---------------- - '*trailing _ is treated as a seperate line extension* - IF (c >= 65 AND c <= 90) OR c = 95 THEN 'A-Z(a-z) or _ - IF c = 95 THEN p2 = 0 ELSE p2 = i - FOR i2 = i + 1 TO n - c2 = ASC(a$, i2) - IF NOT alphanumeric(c2) THEN EXIT FOR - IF c2 <> 95 THEN p2 = i2 - NEXT - IF p2 THEN 'not just underscores! - 'char is from i to p2 - n2 = p2 - i + 1 - a3$ = MID$(a$, i, n2) - - '----(variable/name)rem---- - IF n2 = 3 THEN - IF a3$ = "REM" THEN - i = i + n2 - IF i < n THEN - c = ASC(a$, i) - IF c = 46 THEN a2$ = a2$ + sp + MID$(ca$, i - n2, n2): GOTO extcheck 'rem.Variable is a valid variable name in QB45 - END IF - - 'note: In QBASIC 'IF cond THEN REM comment' counts as a single line IF statement, however use of ' instead of REM does not - IF UCASE$(RIGHT$(a2$, 5)) = sp + "THEN" THEN a2$ = a2$ + sp + "'" 'add nop - layoutcomment = SCase$("Rem") - GOTO comment - END IF - END IF - - '----(variable/name)data---- - IF n2 = 4 THEN - IF a3$ = "DATA" THEN - x$ = "" - i = i + n2 - IF i < n THEN - c = ASC(a$, i) - IF c = 46 THEN a2$ = a2$ + sp + MID$(ca$, i - n2, n2): GOTO extcheck 'data.Variable is a valid variable name in QB45 - END IF - - scan = 0 - speechmarks = 0 - commanext = 0 - finaldata = 0 - e$ = "" - p1 = 0 - p2 = 0 - nextdatachr: - IF i < n THEN - c = ASC(a$, i) - IF c = 9 OR c = 32 THEN - IF scan = 0 THEN GOTO skipwhitespace - END IF - - IF c = 58 THEN '":" - IF speechmarks = 0 THEN finaldata = 1: GOTO adddata - END IF - - IF c = 44 THEN '"," - IF speechmarks = 0 THEN - adddata: - IF prepass = 0 THEN - IF p1 THEN - 'FOR i2 = p1 TO p2 - ' DATA_add ASC(ca$, i2) - 'NEXT - x$ = x$ + MID$(ca$, p1, p2 - p1 + 1) - END IF - 'assume closing " - IF speechmarks THEN - 'DATA_add 34 - x$ = x$ + CHR$(34) - END IF - 'append comma - 'DATA_add 44 - x$ = x$ + CHR$(44) - END IF - IF finaldata = 1 THEN GOTO finisheddata - e$ = "" - p1 = 0 - p2 = 0 - speechmarks = 0 - scan = 0 - commanext = 0 - i = i + 1 - GOTO nextdatachr - END IF - END IF '"," - - IF commanext = 1 THEN - IF c <> 32 AND c <> 9 THEN Give_Error "Expected , after quoted string in DATA statement": EXIT FUNCTION - END IF - - IF c = 34 THEN - IF speechmarks = 1 THEN - commanext = 1 - speechmarks = 0 - END IF - IF scan = 0 THEN speechmarks = 1 - END IF - - scan = 1 - - IF p1 = 0 THEN p1 = i: p2 = i - IF c <> 9 AND c <> 32 THEN p2 = i - - skipwhitespace: - i = i + 1: GOTO nextdatachr - END IF 'i 40 THEN Give_Error "Identifier longer than 40 character limit": EXIT FUNCTION - c3 = ASC(a$, i) - m = 0 - IF c3 = 126 THEN '"~" - e2$ = MID$(a$, i + 1, 2) - IF e2$ = "&&" THEN e2$ = "~&&": GOTO lfgetve - IF e2$ = "%%" THEN e2$ = "~%%": GOTO lfgetve - IF e2$ = "%&" THEN e2$ = "~%&": GOTO lfgetve - e2$ = CHR$(ASC(e2$)) - IF e2$ = "&" THEN e2$ = "~&": GOTO lfgetve - IF e2$ = "%" THEN e2$ = "~%": GOTO lfgetve - IF e2$ = "`" THEN m = 1: e2$ = "~`": GOTO lfgetve - END IF - IF c3 = 37 THEN - c4 = ASC(a$, i + 1) - IF c4 = 37 THEN e2$ = "%%": GOTO lfgetve - IF c4 = 38 THEN e2$ = "%&": GOTO lfgetve - e2$ = "%": GOTO lfgetve - END IF - IF c3 = 38 THEN - c4 = ASC(a$, i + 1) - IF c4 = 38 THEN e2$ = "&&": GOTO lfgetve - e2$ = "&": GOTO lfgetve - END IF - IF c3 = 33 THEN e2$ = "!": GOTO lfgetve - IF c3 = 35 THEN - c4 = ASC(a$, i + 1) - IF c4 = 35 THEN e2$ = "##": GOTO lfgetve - e2$ = "#": GOTO lfgetve - END IF - IF c3 = 36 THEN m = 1: e2$ = "$": GOTO lfgetve - IF c3 = 96 THEN m = 1: e2$ = "`": GOTO lfgetve - '(no symbol) - - 'cater for unusual names/labels (eg a.0b%) - IF ASC(a$, i) = 46 THEN '"." - c2 = ASC(a$, i + 1) - IF c2 >= 48 AND c2 <= 57 THEN - 'scan until no further alphanumerics - p2 = i + 1 - FOR i2 = i + 2 TO n - c = ASC(a$, i2) - - IF NOT alphanumeric(c) THEN EXIT FOR - IF c <> 95 THEN p2 = i2 'don't including trailing _ - NEXT - a2$ = a2$ + sp + "." + sp + MID$(ca$, i + 1, p2 - (i + 1) + 1) 'case sensitive - n2 = n2 + 1 + (p2 - (i + 1) + 1) - i = p2 + 1 - GOTO extcheck 'it may have an extension or be continued with another "." - END IF - END IF - - GOTO lineformatnext - - lfgetve: - i = i + LEN(e2$) - a2$ = a2$ + e2$ - IF m THEN 'allow digits after symbol - lfgetvd: - IF i < n THEN - c = ASC(a$, i) - IF c >= 48 AND c <= 57 THEN a2$ = a2$ + CHR$(c): i = i + 1: GOTO lfgetvd - END IF - END IF 'm - - GOTO lineformatnext - - END IF 'p2 - END IF 'variable/name - '----------------variable/name end---------------- - - '----------------spacing---------------- - IF c = 32 OR c = 9 THEN i = i + 1: GOTO lineformatnext - - '----------------symbols---------------- - '--------single characters-------- - IF lfsinglechar(c) THEN - IF (c = 60) OR (c = 61) OR (c = 62) THEN - count = 0 - DO - count = count + 1 - IF i + count >= LEN(a$) - 2 THEN EXIT DO - LOOP UNTIL ASC(a$, i + count) <> 32 - c2 = ASC(a$, i + count) - IF c = 60 THEN '< - IF c2 = 61 THEN a2$ = a2$ + sp + "<=": i = i + count + 1: GOTO lineformatnext - IF c2 = 62 THEN a2$ = a2$ + sp + "<>": i = i + count + 1: GOTO lineformatnext - ELSEIF c = 62 THEN '> - IF c2 = 61 THEN a2$ = a2$ + sp + ">=": i = i + count + 1: GOTO lineformatnext - IF c2 = 60 THEN a2$ = a2$ + sp + "<>": i = i + count + 1: GOTO lineformatnext '>< to <> - ELSEIF c = 61 THEN '= - IF c2 = 62 THEN a2$ = a2$ + sp + ">=": i = i + count + 1: GOTO lineformatnext '=> to >= - IF c2 = 60 THEN a2$ = a2$ + sp + "<=": i = i + count + 1: GOTO lineformatnext '=< to <= - END IF - END IF - - IF c = 36 AND LEN(a2$) THEN GOTO badusage '$ - - - a2$ = a2$ + sp + CHR$(c) - i = i + 1 - GOTO lineformatnext - END IF - badusage: - - IF c <> 39 THEN Give_Error "Unexpected character on line": EXIT FUNCTION 'invalid symbol encountered - - '----------------comment(')---------------- - layoutcomment = "'" - i = i + 1 - comment: - IF i >= n THEN GOTO lineformatdone2 - c$ = RIGHT$(a$, LEN(a$) - i + 1) - cc$ = RIGHT$(ca$, LEN(ca$) - i + 1) - IF LEN(c$) = 0 THEN GOTO lineformatdone2 - layoutcomment$ = RTRIM$(layoutcomment$ + cc$) - - c$ = LTRIM$(c$) - IF LEN(c$) = 0 THEN GOTO lineformatdone2 - ac = ASC(c$) - 'note: any non-whitespace character between the comment leader and the - ' first '$' renders this a plain comment - ' : the leading '$' does NOT have to be part of a valid metacommand. - ' E.g., REM $FOO $DYNAMIC is a valid metacommand line - IF ac <> 36 THEN GOTO lineformatdone2 - nocasec$ = LTRIM$(RIGHT$(ca$, LEN(ca$) - i + 1)) - memmode = 0 - x = 1 - DO - 'note: metacommands may appear on a line any number of times but only - ' the last appearance of $INCLUDE, and either $STATIC or $DYNAMIC, - ' is processed - ' : metacommands do not need to be terminated by word boundaries. - ' E.g., $STATICanychars$DYNAMIC is valid - - IF MID$(c$, x, 7) = "$STATIC" THEN - memmode = 1 - ELSEIF MID$(c$, x, 8) = "$DYNAMIC" THEN - memmode = 2 - ELSEIF MID$(c$, x, 8) = "$INCLUDE" THEN - 'note: INCLUDE adds the file AFTER the line it is on has been processed - 'skip spaces until : - FOR xx = x + 8 TO LEN(c$) - ac = ASC(MID$(c$, xx, 1)) - IF ac = 58 THEN EXIT FOR ': - IF ac <> 32 AND ac <> 9 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION - NEXT - x = xx - 'skip spaces until ' - FOR xx = x + 1 TO LEN(c$) - ac = ASC(MID$(c$, xx, 1)) - IF ac = 39 THEN EXIT FOR 'character:' - IF ac <> 32 AND ac <> 9 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION - NEXT - x = xx - xx = INSTR(x + 1, c$, "'") - IF xx = 0 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION - addmetainclude$ = MID$(nocasec$, x + 1, xx - x - 1) - IF addmetainclude$ = "" THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION - END IF - - x = INSTR(x + 1, c$, "$") - LOOP WHILE x <> 0 - - IF memmode = 1 THEN addmetastatic = 1 - IF memmode = 2 THEN addmetadynamic = 1 - - GOTO lineformatdone2 - - - - lineformatdone: - - 'line continuation? - 'note: line continuation in idemode is illegal - IF LEN(a2$) THEN - IF RIGHT$(a2$, 1) = "_" THEN - - linecontinuation = 1 'avoids auto-format glitches - layout$ = "" - - 'remove _ from the end of the building string - IF LEN(a2$) >= 2 THEN - IF RIGHT$(a2$, 2) = sp + "_" THEN a2$ = LEFT$(a2$, LEN(a2$) - 1) - END IF - a2$ = LEFT$(a2$, LEN(a2$) - 1) - - IF inclevel THEN - fh = 99 + inclevel - IF EOF(fh) THEN GOTO lineformatdone2 - LINE INPUT #fh, a$ - inclinenumber(inclevel) = inclinenumber(inclevel) + 1 - GOTO includecont 'note: should not increase linenumber - END IF - - IF idemode THEN - idecommand$ = CHR$(100) - ignore = ide(0) - ideerror = 0 - a$ = idereturn$ - IF a$ = "" THEN GOTO lineformatdone2 - ELSE - a$ = lineinput3$ - IF a$ = CHR$(13) THEN GOTO lineformatdone2 - END IF - - linenumber = linenumber + 1 - - includecont: - - contline = 1 - GOTO continueline - END IF - END IF - - lineformatdone2: - IF LEFT$(a2$, 1) = sp THEN a2$ = RIGHT$(a2$, LEN(a2$) - 1) - - 'fix for trailing : error - IF RIGHT$(a2$, 1) = ":" THEN a2$ = a2$ + sp + "'" 'add nop - - IF Debug THEN PRINT #9, "lineformat():return:" + a2$ - IF Error_Happened THEN EXIT FUNCTION - lineformat$ = a2$ - -END FUNCTION - - -SUB makeidrefer (ref$, typ AS LONG) - ref$ = str2$(currentid) - typ = id.t + ISREFERENCE -END SUB - -FUNCTION numelements (a$) - IF a$ = "" THEN EXIT FUNCTION - n = 1 - p = 1 - numelementsnext: - i = INSTR(p, a$, sp) - IF i = 0 THEN numelements = n: EXIT FUNCTION - n = n + 1 - p = i + 1 - GOTO numelementsnext -END FUNCTION - -FUNCTION operatorusage (operator$, typ AS LONG, info$, lhs AS LONG, rhs AS LONG, result AS LONG) - lhs = 7: rhs = 7: result = 0 - 'return values - '1 = use info$ as the operator without any other changes - '2 = use the function returned in info$ to apply this operator - ' upon left and right side of equation - '3= bracket left and right side with negation and change operator to info$ - '4= BINARY NOT l.h.s, then apply operator in info$ - '5= UNARY, bracket up rhs, apply operator info$ to left, rebracket again - - 'lhs & rhs bit-field values - '1=integeral - '2=floating point - '4=string - '8=bool - - 'string operator - IF (typ AND ISSTRING) THEN - lhs = 4: rhs = 4 - result = 4 - IF operator$ = "+" THEN info$ = "qbs_add": operatorusage = 2: EXIT FUNCTION - result = 8 - IF operator$ = "=" THEN info$ = "qbs_equal": operatorusage = 2: EXIT FUNCTION - IF operator$ = "<>" THEN info$ = "qbs_notequal": operatorusage = 2: EXIT FUNCTION - IF operator$ = ">" THEN info$ = "qbs_greaterthan": operatorusage = 2: EXIT FUNCTION - IF operator$ = "<" THEN info$ = "qbs_lessthan": operatorusage = 2: EXIT FUNCTION - IF operator$ = ">=" THEN info$ = "qbs_greaterorequal": operatorusage = 2: EXIT FUNCTION - IF operator$ = "<=" THEN info$ = "qbs_lessorequal": operatorusage = 2: EXIT FUNCTION - IF Debug THEN PRINT #9, "INVALID STRING OPERATOR!": END - END IF - - 'assume numeric operator - lhs = 1 + 2: rhs = 1 + 2 - IF operator$ = "^" THEN result = 2: info$ = "pow2": operatorusage = 2: EXIT FUNCTION - IF operator$ = CHR$(241) THEN info$ = "-": operatorusage = 5: EXIT FUNCTION - IF operator$ = "/" THEN - info$ = "/ ": operatorusage = 1 - 'for / division, either the lhs or the rhs must be a float to make - 'c++ return a result in floating point form - IF (typ AND ISFLOAT) THEN - 'lhs is a float - lhs = 2 - rhs = 1 + 2 - ELSE - 'lhs isn't a float! - lhs = 1 + 2 - rhs = 2 - END IF - result = 2 - EXIT FUNCTION - END IF - IF operator$ = "*" THEN info$ = "*": operatorusage = 1: EXIT FUNCTION - IF operator$ = "+" THEN info$ = "+": operatorusage = 1: EXIT FUNCTION - IF operator$ = "-" THEN info$ = "-": operatorusage = 1: EXIT FUNCTION - - result = 8 - IF operator$ = "=" THEN info$ = "==": operatorusage = 3: EXIT FUNCTION - IF operator$ = ">" THEN info$ = ">": operatorusage = 3: EXIT FUNCTION - IF operator$ = "<" THEN info$ = "<": operatorusage = 3: EXIT FUNCTION - IF operator$ = "<>" THEN info$ = "!=": operatorusage = 3: EXIT FUNCTION - IF operator$ = "<=" THEN info$ = "<=": operatorusage = 3: EXIT FUNCTION - IF operator$ = ">=" THEN info$ = ">=": operatorusage = 3: EXIT FUNCTION - - lhs = 1: rhs = 1: result = 1 - operator$ = UCASE$(operator$) - IF operator$ = "MOD" THEN info$ = "%": operatorusage = 1: EXIT FUNCTION - IF operator$ = "\" THEN info$ = "/ ": operatorusage = 1: EXIT FUNCTION - IF operator$ = "IMP" THEN info$ = "|": operatorusage = 4: EXIT FUNCTION - IF operator$ = "EQV" THEN info$ = "^": operatorusage = 4: EXIT FUNCTION - IF operator$ = "XOR" THEN info$ = "^": operatorusage = 1: EXIT FUNCTION - IF operator$ = "OR" THEN info$ = "|": operatorusage = 1: EXIT FUNCTION - IF operator$ = "AND" THEN info$ = "&": operatorusage = 1: EXIT FUNCTION - - lhs = 7 - IF operator$ = "NOT" THEN info$ = "~": operatorusage = 5: EXIT FUNCTION - - IF Debug THEN PRINT #9, "INVALID NUMBERIC OPERATOR!": END - -END FUNCTION - -FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) - typbak = typ - 'method: 0 return an equation which calculates the value of the "variable" - ' 1 return the C name of the variable, typ will be left unchanged - - a$ = a2$ - - 'retrieve ID - i = INSTR(a$, sp3) - IF i THEN - idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) - ELSE - idnumber = VAL(a$) - END IF - getid idnumber - IF Error_Happened THEN EXIT FUNCTION - - 'UDT? - IF typ AND ISUDT THEN - IF method = 1 THEN - n$ = "UDT_" + RTRIM$(id.n) - IF id.t = 0 THEN n$ = "ARRAY_" + n$ - n$ = scope$ + n$ - refer$ = n$ - EXIT FUNCTION - END IF - - 'print "UDTSUBSTRING[idX|u|e|o]:"+a$ - - u = VAL(a$) - i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) - i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) - n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" - IF E = 0 THEN Give_Error "User defined types in expressions are invalid": EXIT FUNCTION - IF typ AND ISOFFSETINBITS THEN Give_Error "Cannot resolve bit-length variables inside user defined types": EXIT FUNCTION - - IF typ AND ISSTRING THEN - IF typ AND ISFIXEDLENGTH THEN - o2$ = "(((uint8*)" + scope$ + n$ + ")+(" + o$ + "))" - r$ = "qbs_new_fixed(" + o2$ + "," + str2(udtetypesize(E)) + ",1)" - typ = STRINGTYPE + ISFIXEDLENGTH 'ISPOINTER retained, it is still a pointer! - ELSE - r$ = "*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + ")))" - typ = STRINGTYPE - END IF - ELSE - typ = typ - ISUDT - ISREFERENCE - ISPOINTER - IF typ AND ISARRAY THEN typ = typ - ISARRAY - t$ = typ2ctyp$(typ, "") - IF Error_Happened THEN EXIT FUNCTION - o2$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - r$ = "*" + "(" + t$ + "*)" + o2$ - END IF - - 'print "REFER:"+r$+","+str2$(typ) - refer$ = r$ - EXIT FUNCTION - END IF - - - 'array? - IF id.arraytype THEN - - n$ = RTRIM$(id.callname) - IF method = 1 THEN - refer$ = n$ - typ = typbak - EXIT FUNCTION - END IF - typ = typ - ISPOINTER - ISREFERENCE 'typ now looks like a regular value - - IF (typ AND ISSTRING) THEN - IF (typ AND ISFIXEDLENGTH) THEN - offset$ = "&((uint8*)(" + n$ + "[0]))[(" + a$ + ")*" + str2(id.tsize) + "]" - r$ = "qbs_new_fixed(" + offset$ + "," + str2(id.tsize) + ",1)" - ELSE - r$ = "((qbs*)(((uint64*)(" + n$ + "[0]))[" + a$ + "]))" - END IF - stringprocessinghappened = 1 - refer$ = r$ - EXIT FUNCTION - END IF - - IF (typ AND ISOFFSETINBITS) THEN - 'IF (typ AND ISUNSIGNED) THEN r$ = "getubits_" ELSE r$ = "getbits_" - 'r$ = r$ + str2(typ AND 511) + "(" - IF (typ AND ISUNSIGNED) THEN r$ = "getubits" ELSE r$ = "getbits" - r$ = r$ + "(" + str2(typ AND 511) + "," - r$ = r$ + "(uint8*)(" + n$ + "[0])" + "," - r$ = r$ + a$ + ")" - refer$ = r$ - EXIT FUNCTION - ELSE - t$ = "" - IF (typ AND ISFLOAT) THEN - IF (typ AND 511) = 32 THEN t$ = "float" - IF (typ AND 511) = 64 THEN t$ = "double" - IF (typ AND 511) = 256 THEN t$ = "long double" - ELSE - IF (typ AND ISUNSIGNED) THEN - IF (typ AND 511) = 8 THEN t$ = "uint8" - IF (typ AND 511) = 16 THEN t$ = "uint16" - IF (typ AND 511) = 32 THEN t$ = "uint32" - IF (typ AND 511) = 64 THEN t$ = "uint64" - IF typ AND ISOFFSET THEN t$ = "uptrszint" - ELSE - IF (typ AND 511) = 8 THEN t$ = "int8" - IF (typ AND 511) = 16 THEN t$ = "int16" - IF (typ AND 511) = 32 THEN t$ = "int32" - IF (typ AND 511) = 64 THEN t$ = "int64" - IF typ AND ISOFFSET THEN t$ = "ptrszint" - END IF - END IF - END IF - IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT FUNCTION - r$ = "((" + t$ + "*)(" + n$ + "[0]))[" + a$ + "]" - refer$ = r$ - EXIT FUNCTION - END IF 'array - - 'variable? - IF id.t THEN - r$ = RTRIM$(id.n) - t = id.t - 'remove irrelavant flags - IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY - 'string? - IF (t AND ISSTRING) THEN - IF (t AND ISFIXEDLENGTH) THEN - r$ = scope$ + "STRING" + str2(id.tsize) + "_" + r$: GOTO ref - END IF - r$ = scope$ + "STRING_" + r$: GOTO ref - END IF - 'bit-length single variable? - IF (t AND ISOFFSETINBITS) THEN - IF (t AND ISUNSIGNED) THEN - r$ = "*" + scope$ + "UBIT" + str2(t AND 511) + "_" + r$ - ELSE - r$ = "*" + scope$ + "BIT" + str2(t AND 511) + "_" + r$ - END IF - GOTO ref - END IF - IF t = BYTETYPE THEN r$ = "*" + scope$ + "BYTE_" + r$: GOTO ref - IF t = UBYTETYPE THEN r$ = "*" + scope$ + "UBYTE_" + r$: GOTO ref - IF t = INTEGERTYPE THEN r$ = "*" + scope$ + "INTEGER_" + r$: GOTO ref - IF t = UINTEGERTYPE THEN r$ = "*" + scope$ + "UINTEGER_" + r$: GOTO ref - IF t = LONGTYPE THEN r$ = "*" + scope$ + "LONG_" + r$: GOTO ref - IF t = ULONGTYPE THEN r$ = "*" + scope$ + "ULONG_" + r$: GOTO ref - IF t = INTEGER64TYPE THEN r$ = "*" + scope$ + "INTEGER64_" + r$: GOTO ref - IF t = UINTEGER64TYPE THEN r$ = "*" + scope$ + "UINTEGER64_" + r$: GOTO ref - IF t = SINGLETYPE THEN r$ = "*" + scope$ + "SINGLE_" + r$: GOTO ref - IF t = DOUBLETYPE THEN r$ = "*" + scope$ + "DOUBLE_" + r$: GOTO ref - IF t = FLOATTYPE THEN r$ = "*" + scope$ + "FLOAT_" + r$: GOTO ref - IF t = OFFSETTYPE THEN r$ = "*" + scope$ + "OFFSET_" + r$: GOTO ref - IF t = UOFFSETTYPE THEN r$ = "*" + scope$ + "UOFFSET_" + r$: GOTO ref - ref: - IF (t AND ISSTRING) THEN stringprocessinghappened = 1 - IF (t AND ISPOINTER) THEN t = t - ISPOINTER - typ = t - IF method = 1 THEN - IF LEFT$(r$, 1) = "*" THEN r$ = RIGHT$(r$, LEN(r$) - 1) - typ = typbak - END IF - refer$ = r$ - EXIT FUNCTION - END IF 'variable - - - -END FUNCTION - -SUB regid - idn = idn + 1 - - IF idn > ids_max THEN - ids_max = ids_max * 2 - REDIM _PRESERVE ids(1 TO ids_max) AS idstruct - REDIM _PRESERVE cmemlist(1 TO ids_max + 1) AS INTEGER - REDIM _PRESERVE sfcmemargs(1 TO ids_max + 1) AS STRING * 100 - REDIM _PRESERVE arrayelementslist(1 TO ids_max + 1) AS INTEGER - END IF - - n$ = RTRIM$(id.n) - - IF reginternalsubfunc = 0 THEN - IF validname(n$) = 0 THEN Give_Error "Invalid name": EXIT SUB - END IF - - 'register case sensitive name if none given - IF ASC(id.cn) = 32 THEN - n$ = RTRIM$(id.n) - id.n = UCASE$(n$) - id.cn = n$ - END IF - - id.insubfunc = subfunc - id.insubfuncn = subfuncn - - 'note: cannot be STATIC and SHARED at the same time - IF dimshared THEN - id.share = dimshared - ELSE - IF dimstatic THEN id.staticscope = 1 - END IF - - ids(idn) = id - - currentid = idn - - 'prepare hash flags and check for conflicts - hashflags = 1 - - 'sub/function? - 'Note: QBASIC does not allow: Internal type names (INTEGER,LONG,...) - IF id.subfunc THEN - ids(currentid).internal_subfunc = reginternalsubfunc - IF id.subfunc = 1 THEN hashflags = hashflags + HASHFLAG_FUNCTION ELSE hashflags = hashflags + HASHFLAG_SUB - IF reginternalsubfunc = 0 THEN 'allow internal definition of subs/functions without checks - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_CONSTANT - IF id.subfunc = 1 THEN hashchkflags = hashchkflags + HASHFLAG_FUNCTION ELSE hashchkflags = hashchkflags + HASHFLAG_SUB - hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF hashres THEN - 'Note: Numeric sub/function names like 'mid' do not clash with Internal string sub/function names - ' like 'MID$' because MID$ always requires a '$'. For user defined string sub/function names - ' the '$' would be optional so the rule should not be applied there. - allow = 0 - IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN - IF RTRIM$(ids(hashresref).musthave) = "$" THEN - IF INSTR(ids(currentid).mayhave, "$") = 0 THEN allow = 1 - END IF - END IF - IF allow = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF 'hashres - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - IF idemode THEN - IF INSTR(listOfCustomKeywords$, "@" + UCASE$(n$) + "@") = 0 THEN - listOfCustomKeywords$ = listOfCustomKeywords$ + "@" + UCASE$(n$) + "@" - END IF - END IF - END IF 'reginternalsubfunc = 0 - END IF - - 'variable? - IF id.t THEN - hashflags = hashflags + HASHFLAG_VARIABLE - IF reginternalvariable = 0 THEN - allow = 0 - var_recheck: - IF ASC(id.musthave) = 32 THEN astype2 = 1 '"AS type" declaration? - scope2 = subfuncn - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_CONSTANT + HASHFLAG_VARIABLE - hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - - 'conflict with reserved word? - IF hashresflags AND HASHFLAG_RESERVED THEN - musthave$ = RTRIM$(id.musthave) - IF INSTR(musthave$, "$") THEN - 'All reserved words can be used as variables in QBASIC if "$" is appended to the variable name! - '(allow) - ELSE - Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Conflicts with reserved word - END IF - END IF 'HASHFLAG_RESERVED - - 'conflict with sub/function? - IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN - IF ids(hashresref).internal_subfunc = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'QBASIC doesn't allow a variable of the same name as a user-defined sub/func - IF RTRIM$(id.n) = "WIDTH" AND ids(hashresref).subfunc = 2 THEN GOTO varname_exception - musthave$ = RTRIM$(id.musthave) - IF LEN(musthave$) = 0 THEN - IF RTRIM$(ids(hashresref).musthave) = "$" THEN - 'a sub/func requiring "$" can co-exist with implicit numeric variables - IF INSTR(id.mayhave, "$") THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - ELSE - Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Implicitly defined variables cannot conflict with sub/func names - END IF - END IF 'len(musthave$)=0 - IF INSTR(musthave$, "$") THEN - IF RTRIM$(ids(hashresref).musthave) = "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A sub/function name already exists as a string - '(allow) - ELSE - IF RTRIM$(ids(hashresref).musthave) <> "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A non-"$" sub/func name already exists with this name - END IF - END IF 'HASHFLAG_FUNCTION + HASHFLAG_SUB - - 'conflict with constant? - IF hashresflags AND HASHFLAG_CONSTANT THEN - scope1 = constsubfunc(hashresref) - IF (scope1 = 0 AND AllowLocalName = 0) OR scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - - 'conflict with variable? - IF hashresflags AND HASHFLAG_VARIABLE THEN - astype1 = 0: IF ASC(ids(hashresref).musthave) = 32 THEN astype1 = 1 - scope1 = ids(hashresref).insubfuncn - IF astype1 = 1 AND astype2 = 1 THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - 'same type? - IF id.t = ids(hashresref).t THEN - IF id.tsize = ids(hashresref).tsize THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - END IF - 'will astype'd fixed STRING-variable mask a non-fixed string? - IF id.t AND ISFIXEDLENGTH THEN - IF astype2 = 1 THEN - IF ids(hashresref).t AND ISSTRING THEN - IF (ids(hashresref).t AND ISFIXEDLENGTH) = 0 THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - END IF - END IF - END IF - END IF - - varname_exception: - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - END IF 'reginternalvariable - END IF 'variable - - 'array? - IF id.arraytype THEN - hashflags = hashflags + HASHFLAG_ARRAY - allow = 0 - ary_recheck: - scope2 = subfuncn - IF ASC(id.musthave) = 32 THEN astype2 = 1 '"AS type" declaration? - hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_ARRAY - hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - - 'conflict with reserved word? - IF hashresflags AND HASHFLAG_RESERVED THEN - musthave$ = RTRIM$(id.musthave) - IF INSTR(musthave$, "$") THEN - 'All reserved words can be used as variables in QBASIC if "$" is appended to the variable name! - '(allow) - ELSE - Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Conflicts with reserved word - END IF - END IF 'HASHFLAG_RESERVED - - 'conflict with sub/function? - IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN - IF ids(hashresref).internal_subfunc = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'QBASIC doesn't allow a variable of the same name as a user-defined sub/func - IF RTRIM$(id.n) = "WIDTH" AND ids(hashresref).subfunc = 2 THEN GOTO arrayname_exception - musthave$ = RTRIM$(id.musthave) - - IF LEN(musthave$) = 0 THEN - IF RTRIM$(ids(hashresref).musthave) = "$" THEN - 'a sub/func requiring "$" can co-exist with implicit numeric variables - IF INSTR(id.mayhave, "$") THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - ELSE - Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Implicitly defined variables cannot conflict with sub/func names - END IF - END IF 'len(musthave$)=0 - IF INSTR(musthave$, "$") THEN - IF RTRIM$(ids(hashresref).musthave) = "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A sub/function name already exists as a string - '(allow) - ELSE - IF RTRIM$(ids(hashresref).musthave) <> "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A non-"$" sub/func name already exists with this name - END IF - END IF 'HASHFLAG_FUNCTION + HASHFLAG_SUB - - 'conflict with array? - IF hashresflags AND HASHFLAG_ARRAY THEN - astype1 = 0: IF ASC(ids(hashresref).musthave) = 32 THEN astype1 = 1 - scope1 = ids(hashresref).insubfuncn - IF astype1 = 1 AND astype2 = 1 THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - 'same type? - IF id.arraytype = ids(hashresref).arraytype THEN - IF id.tsize = ids(hashresref).tsize THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - END IF - 'will astype'd fixed STRING-variable mask a non-fixed string? - IF id.arraytype AND ISFIXEDLENGTH THEN - IF astype2 = 1 THEN - IF ids(hashresref).arraytype AND ISSTRING THEN - IF (ids(hashresref).arraytype AND ISFIXEDLENGTH) = 0 THEN - IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB - END IF - END IF - END IF - END IF - END IF - - arrayname_exception: - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - END IF 'array - - 'add it to the hash table - HashAdd n$, hashflags, currentid - -END SUB - -SUB reginternal - reginternalsubfunc = 1 - '$INCLUDE:'subs_functions\subs_functions.bas' - reginternalsubfunc = 0 -END SUB - -'this sub is faulty atm! -'sub replacelement (a$, i, newe$) -''note: performs no action for out of range values of i -'e=1 -'s=1 -'do -'x=instr(s,a$,sp) -'if x then -'if e=i then -'a1$=left$(a$,s-1): a2$=right$(a$,len(a$)-x+1) -'a$=a1$+sp+newe$+a2$ 'note: a2 includes spacer -'exit sub -'end if -'s=x+1 -'e=e+1 -'end if -'loop until x=0 -'if e=i then -'a$=left$(a$,s-1)+sp+newe$ -'end if -'end sub - - -SUB removeelements (a$, first, last, keepindexing) - a2$ = "" - 'note: first and last MUST be valid - ' keepindexing means the number of elements will stay the same - ' but some elements will be equal to "" - - n = numelements(a$) - FOR i = 1 TO n - IF i < first OR i > last THEN - a2$ = a2$ + sp + getelement(a$, i) - ELSE - IF keepindexing THEN a2$ = a2$ + sp - END IF - NEXT - IF LEFT$(a2$, 1) = sp THEN a2$ = RIGHT$(a2$, LEN(a2$) - 1) - - a$ = a2$ - -END SUB - - - -FUNCTION symboltype (s$) 'returns type or 0(not a valid symbol) - 'note: sets symboltype_size for fixed length strings - 'created: 2011 (fast & comprehensive) - IF LEN(s$) = 0 THEN EXIT FUNCTION - 'treat common cases first - a = ASC(s$) - l = LEN(s$) - IF a = 37 THEN '% - IF l = 1 THEN symboltype = 16: EXIT FUNCTION - IF l > 2 THEN EXIT FUNCTION - IF ASC(s$, 2) = 37 THEN symboltype = 8: EXIT FUNCTION - IF ASC(s$, 2) = 38 THEN symboltype = OFFSETTYPE - ISPOINTER: EXIT FUNCTION '%& - EXIT FUNCTION - END IF - IF a = 38 THEN '& - IF l = 1 THEN symboltype = 32: EXIT FUNCTION - IF l > 2 THEN EXIT FUNCTION - IF ASC(s$, 2) = 38 THEN symboltype = 64: EXIT FUNCTION - EXIT FUNCTION - END IF - IF a = 33 THEN '! - IF l = 1 THEN symboltype = 32 + ISFLOAT: EXIT FUNCTION - EXIT FUNCTION - END IF - IF a = 35 THEN '# - IF l = 1 THEN symboltype = 64 + ISFLOAT: EXIT FUNCTION - IF l > 2 THEN EXIT FUNCTION - IF ASC(s$, 2) = 35 THEN symboltype = 64 + ISFLOAT: EXIT FUNCTION - EXIT FUNCTION - END IF - IF a = 36 THEN '$ - IF l = 1 THEN symboltype = ISSTRING: EXIT FUNCTION - IF isuinteger(RIGHT$(s$, l - 1)) THEN - IF l >= (1 + 10) THEN - IF l > (1 + 10) THEN EXIT FUNCTION - IF s$ > "$2147483647" THEN EXIT FUNCTION - END IF - symboltype_size = VAL(RIGHT$(s$, l - 1)) - symboltype = ISSTRING + ISFIXEDLENGTH - EXIT FUNCTION - END IF - EXIT FUNCTION - END IF - IF a = 96 THEN '` - IF l = 1 THEN symboltype = 1 + ISOFFSETINBITS: EXIT FUNCTION - IF isuinteger(RIGHT$(s$, l - 1)) THEN - IF l > 3 THEN EXIT FUNCTION - n = VAL(RIGHT$(s$, l - 1)) - IF n > 64 THEN EXIT FUNCTION - symboltype = n + ISOFFSETINBITS: EXIT FUNCTION - END IF - EXIT FUNCTION - END IF - IF a = 126 THEN '~ - IF l = 1 THEN EXIT FUNCTION - a = ASC(s$, 2) - IF a = 37 THEN '% - IF l = 2 THEN symboltype = 16 + ISUNSIGNED: EXIT FUNCTION - IF l > 3 THEN EXIT FUNCTION - IF ASC(s$, 3) = 37 THEN symboltype = 8 + ISUNSIGNED: EXIT FUNCTION - IF ASC(s$, 3) = 38 THEN symboltype = UOFFSETTYPE - ISPOINTER: EXIT FUNCTION '~%& - EXIT FUNCTION - END IF - IF a = 38 THEN '& - IF l = 2 THEN symboltype = 32 + ISUNSIGNED: EXIT FUNCTION - IF l > 3 THEN EXIT FUNCTION - IF ASC(s$, 3) = 38 THEN symboltype = 64 + ISUNSIGNED: EXIT FUNCTION - EXIT FUNCTION - END IF - IF a = 96 THEN '` - IF l = 2 THEN symboltype = 1 + ISOFFSETINBITS + ISUNSIGNED: EXIT FUNCTION - IF isuinteger(RIGHT$(s$, l - 2)) THEN - IF l > 4 THEN EXIT FUNCTION - n = VAL(RIGHT$(s$, l - 2)) - IF n > 64 THEN EXIT FUNCTION - symboltype = n + ISOFFSETINBITS + ISUNSIGNED: EXIT FUNCTION - END IF - EXIT FUNCTION - END IF - END IF '~ -END FUNCTION - -FUNCTION removesymbol$ (varname$) - i = INSTR(varname$, "~"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "`"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "%"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "&"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "!"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "#"): IF i THEN GOTO foundsymbol - i = INSTR(varname$, "$"): IF i THEN GOTO foundsymbol - EXIT FUNCTION - foundsymbol: - IF i = 1 THEN Give_Error "Expected variable name before symbol": EXIT FUNCTION - symbol$ = RIGHT$(varname$, LEN(varname$) - i + 1) - IF symboltype(symbol$) = 0 THEN Give_Error "Invalid symbol": EXIT FUNCTION - removesymbol$ = symbol$ - varname$ = LEFT$(varname$, i - 1) -END FUNCTION - -FUNCTION scope$ - IF id.share THEN scope$ = module$ + "__": EXIT FUNCTION - scope$ = module$ + "_" + subfunc$ + "_" -END FUNCTION - -FUNCTION seperateargs (a$, ca$, pass&) - pass& = 0 - - FOR i = 1 TO OptMax: separgs(i) = "": NEXT - FOR i = 1 TO OptMax + 1: separgslayout(i) = "": NEXT - FOR i = 1 TO OptMax - Lev(i) = 0 - EntryLev(i) = 0 - DitchLev(i) = 0 - DontPass(i) = 0 - TempList(i) = 0 - PassRule(i) = 0 - LevelEntered(i) = 0 - NEXT - - DIM id2 AS idstruct - - id2 = id - - IF id2.args = 0 THEN EXIT FUNCTION 'no arguments! - - - s$ = id2.specialformat - s$ = RTRIM$(s$) - - 'build a special format if none exists - IF s$ = "" THEN - FOR i = 1 TO id2.args - IF i <> 1 THEN s$ = s$ + ",?" ELSE s$ = "?" - NEXT - END IF - - 'note: dim'd arrays moved to global to prevent high recreation cost - - PassFlag = 1 - nextentrylevel = 0 - nextentrylevelset = 1 - level = 0 - lastt = 0 - ditchlevel = 0 - FOR i = 1 TO LEN(s$) - s2$ = MID$(s$, i, 1) - - IF s2$ = "[" THEN - level = level + 1 - LevelEntered(level) = 0 - GOTO nextsymbol - END IF - - IF s2$ = "]" THEN - level = level - 1 - IF level < ditchlevel THEN ditchlevel = level - GOTO nextsymbol - END IF - - IF s2$ = "{" THEN - lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 - DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level - i = i + 1 - i2 = INSTR(i, s$, "}") - numopts = 0 - nextopt: - numopts = numopts + 1 - i3 = INSTR(i + 1, s$, "|") - IF i3 <> 0 AND i3 < i2 THEN - Opt(lastt, numopts) = MID$(s$, i, i3 - i) - i = i3 + 1: GOTO nextopt - END IF - Opt(lastt, numopts) = MID$(s$, i, i2 - i) - T(lastt) = numopts - 'calculate words in each option - FOR x = 1 TO T(lastt) - w = 1 - x2 = 1 - newword: - IF INSTR(x2, RTRIM$(Opt(lastt, x)), " ") THEN w = w + 1: x2 = INSTR(x2, RTRIM$(Opt(lastt, x)), " ") + 1: GOTO newword - OptWords(lastt, x) = w - NEXT - i = i2 - - 'set entry level routine - EntryLev(lastt) = level 'default level when continuing a previously entered level - IF LevelEntered(level) = 0 THEN - EntryLev(lastt) = 0 - FOR i2 = 1 TO level - 1 - IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 - NEXT - END IF - LevelEntered(level) = 1 - - GOTO nextsymbol - END IF - - IF s2$ = "?" THEN - lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 - DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level - T(lastt) = 0 - 'set entry level routine - EntryLev(lastt) = level 'default level when continuing a previously entered level - IF LevelEntered(level) = 0 THEN - EntryLev(lastt) = 0 - FOR i2 = 1 TO level - 1 - IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 - NEXT - END IF - LevelEntered(level) = 1 - - GOTO nextsymbol - END IF - - 'assume "special" character (like ( ) , . - etc.) - lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 - DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level - T(lastt) = 1: Opt(lastt, 1) = s2$: OptWords(lastt, 1) = 1: DontPass(lastt) = 1 - - 'set entry level routine - EntryLev(lastt) = level 'default level when continuing a previously entered level - IF LevelEntered(level) = 0 THEN - EntryLev(lastt) = 0 - FOR i2 = 1 TO level - 1 - IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 - NEXT - END IF - LevelEntered(level) = 1 - - GOTO nextsymbol - - nextsymbol: - NEXT - - - IF Debug THEN - PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:1--------" - FOR i = 1 TO lastt - PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) - PRINT #9, i, "OPTWORDS="; OptWords(i, 1) - PRINT #9, i, "T="; T(i) - PRINT #9, i, "DONTPASS="; DontPass(i) - PRINT #9, i, "PASSRULE="; PassRule(i) - PRINT #9, i, "LEV="; Lev(i) - PRINT #9, i, "ENTRYLEV="; EntryLev(i) - NEXT - END IF - - - 'Any symbols already have dontpass() set to 1 - 'This sets any {}blocks with only one option/word (eg. {PRINT}) at the lowest level to dontpass()=1 - 'because their content is manadatory and there is no choice as to which word to use - FOR x = 1 TO lastt - IF Lev(x) = 0 THEN - IF T(x) = 1 THEN DontPass(x) = 1 - END IF - NEXT - - IF Debug THEN - PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:2--------" - FOR i = 1 TO lastt - PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) - PRINT #9, i, "OPTWORDS="; OptWords(i, 1) - PRINT #9, i, "T="; T(i) - PRINT #9, i, "DONTPASS="; DontPass(i) - PRINT #9, i, "PASSRULE="; PassRule(i) - PRINT #9, i, "LEV="; Lev(i) - PRINT #9, i, "ENTRYLEV="; EntryLev(i) - NEXT - END IF - - - - - x1 = 0 'the 'x' position of the beginning element of the current levelled block - MustPassOpt = 0 'the 'x' position of the FIRST opt () in the block which must be passed - MustPassOptNeedsFlag = 0 '{}blocks don't need a flag, ? blocks do - - 'Note: For something like [{HELLO}x] a choice between passing 'hello' or passing a flag to signify x was specified - ' has to be made, in such cases, a flag is preferable to wasting a full new int32 on 'hello' - - templistn = 0 - FOR l = 1 TO 32767 - scannextlevel = 0 - FOR x = 1 TO lastt - IF Lev(x) > l THEN scannextlevel = 1 - - IF x1 THEN - IF EntryLev(x) < l THEN 'end of block reached - IF MustPassOpt THEN - 'If there's an opt () which must be passed that will be identified, - 'all the 1 option {}blocks can be assumed... - IF MustPassOptNeedsFlag THEN - 'The MustPassOpt requires a flag, so use the same flag for everything - FOR x2 = 1 TO templistn - PassRule(TempList(x2)) = PassFlag - NEXT - PassFlag = PassFlag * 2 - ELSE - 'The MustPassOpt is a {}block which doesn't need a flag, so everything else needs to - 'reference it - FOR x2 = 1 TO templistn - IF TempList(x2) <> MustPassOpt THEN PassRule(TempList(x2)) = -MustPassOpt - NEXT - END IF - ELSE - 'if not, use a unique flag for everything in this block - FOR x2 = 1 TO templistn: PassRule(TempList(x2)) = PassFlag: NEXT - IF templistn <> 0 THEN PassFlag = PassFlag * 2 - END IF - x1 = 0 - END IF - END IF - - - IF Lev(x) = l THEN 'on same level - IF EntryLev(x) < l THEN 'just (re)entered this level (not continuing along it) - x1 = x 'set x1 to the starting element of this level - MustPassOpt = 0 - templistn = 0 - END IF - END IF - - IF x1 THEN - IF Lev(x) = l THEN 'same level - - IF T(x) <> 1 THEN - 'It isn't a symbol or a {}block with only one option therefore this opt () must be passed - IF MustPassOpt = 0 THEN - MustPassOpt = x 'Only record the first instance (it MAY require a flag) - IF T(x) = 0 THEN MustPassOptNeedsFlag = 1 ELSE MustPassOptNeedsFlag = 0 - ELSE - 'Update current MustPassOpt to non-flag-based {}block if possible (to save flag usage) - '(Consider [{A|B}?], where a flag is not required) - IF MustPassOptNeedsFlag = 1 THEN - IF T(x) > 1 THEN - MustPassOpt = x: MustPassOptNeedsFlag = 0 - END IF - END IF - END IF - 'add to list - templistn = templistn + 1: TempList(templistn) = x - END IF - - IF T(x) = 1 THEN - 'It is a symbol or a {}block with only one option - 'a {}block with only one option MAY not need to be passed - 'depending on if anything else is in this block could make the existance of this opt () assumed - 'Note: Symbols which are not encapsulated inside a {}block never need to be passed - ' Symbols already have dontpass() set to 1 - IF DontPass(x) = 0 THEN templistn = templistn + 1: TempList(templistn) = x: DontPass(x) = 1 - END IF - - END IF - END IF - - NEXT - - 'scan last run (mostly just a copy of code from above) - IF x1 THEN - IF MustPassOpt THEN - 'If there's an opt () which must be passed that will be identified, - 'all the 1 option {}blocks can be assumed... - IF MustPassOptNeedsFlag THEN - 'The MustPassOpt requires a flag, so use the same flag for everything - FOR x2 = 1 TO templistn - PassRule(TempList(x2)) = PassFlag - NEXT - PassFlag = PassFlag * 2 - ELSE - 'The MustPassOpt is a {}block which doesn't need a flag, so everything else needs to - 'reference it - FOR x2 = 1 TO templistn - IF TempList(x2) <> MustPassOpt THEN PassRule(TempList(x2)) = -MustPassOpt - NEXT - END IF - ELSE - 'if not, use a unique flag for everything in this block - FOR x2 = 1 TO templistn: PassRule(TempList(x2)) = PassFlag: NEXT - IF templistn <> 0 THEN PassFlag = PassFlag * 2 - END IF - x1 = 0 - END IF - - IF scannextlevel = 0 THEN EXIT FOR - NEXT - - IF Debug THEN - PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:3--------" - FOR i = 1 TO lastt - PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) - PRINT #9, i, "OPTWORDS="; OptWords(i, 1) - PRINT #9, i, "T="; T(i) - PRINT #9, i, "DONTPASS="; DontPass(i) - PRINT #9, i, "PASSRULE="; PassRule(i) - PRINT #9, i, "LEV="; Lev(i) - PRINT #9, i, "ENTRYLEV="; EntryLev(i) - NEXT - END IF - - - - FOR i = 1 TO lastt: separgs(i) = "n-ll": NEXT - - - - - 'Consider: "?,[?]" - 'Notes: The comma is mandatory but the second ? is entirely optional - 'Consider: "[?[{B}?]{A}]?" - 'Notes: As unlikely as the above is, it is still valid, but pivots on the outcome of {A} being present - 'Consider: "[?]{A}" - 'Consider: "[?{A}][?{B}][?{C}]?" - 'Notes: The trick here is to realize {A} has greater priority than {B}, so all lines of enquiry must - ' be exhausted before considering {B} - - 'Use inquiry approach to solve format - 'Each line of inquiry must be exhausted - 'An expression ("?") simply means a branch where you can scan ahead - - Branches = 0 - DIM BranchFormatPos(1 TO 100) AS LONG - DIM BranchTaken(1 TO 100) AS LONG - '1=taken (this usually involves moving up a level) - '0=not taken - DIM BranchInputPos(1 TO 100) AS LONG - DIM BranchWithExpression(1 TO 100) AS LONG - 'non-zero=expression expected before next item for format item value represents - '0=no expression allowed before next item - DIM BranchLevel(1 TO 100) AS LONG 'Level before this branch was/wasn't taken - - n = numelements(ca$) - i = 1 'Position within ca$ - - level = 0 - Expression = 0 - FOR x = 1 TO lastt - - ContinueScan: - - IF DitchLev(x) < level THEN 'dropping down to a lower level - 'we can only go as low as the 'ditch' will allow us, which will limit our options - level = DitchLev(x) - END IF - - IF EntryLev(x) <= level THEN 'possible to enter level - - 'But was this optional or were we forced to be on this level? - IF EntryLev(x) < Lev(x) THEN - optional = 1 - IF level > EntryLev(x) THEN optional = 0 - ELSE - 'entrylev=lev - optional = 0 - END IF - - t = T(x) - - IF t = 0 THEN 'A "?" expression - IF Expression THEN - '*********backtrack************ - 'We are tracking an expression which we assumed would be present but was not - GOTO Backtrack - '****************************** - END IF - IF optional THEN - Branches = Branches + 1 - BranchFormatPos(Branches) = x - BranchTaken(Branches) = 1 - BranchInputPos(Branches) = i - BranchWithExpression(Branches) = 0 - BranchLevel(Branches) = level - level = Lev(x) - END IF - Expression = x - END IF 'A "?" expression - - IF t THEN - - currentlev = level - - 'Add new branch if new level will be entered - IF optional THEN - Branches = Branches + 1 - BranchFormatPos(Branches) = x - BranchTaken(Branches) = 1 - BranchInputPos(Branches) = i - BranchWithExpression(Branches) = Expression - BranchLevel(Branches) = level - END IF - - 'Scan for Opt () options - i1 = i: i2 = i - IF Expression THEN i2 = n - 'Scan a$ for opt () x - 'Note: Finding the closest opt option is necessary - 'Note: This needs to be bracket sensitive - OutOfRange = 2147483647 - position = OutOfRange - which = 0 - removePrefix = 0 - IF i <= n THEN 'Past end of contect check - FOR o = 1 TO t - words = OptWords(x, o) - b = 0 - FOR i3 = i1 TO i2 - IF i3 + words - 1 <= n THEN 'enough elements exist - c$ = getelement$(a$, i3) - IF b = 0 THEN - 'Build comparison string (spacing elements) - FOR w = 2 TO words - c$ = c$ + " " + getelement$(a$, i3 + w - 1) - NEXT w - 'Compare - noPrefixMatch = LEFT$(Opt(x, o), 1) = "_" AND qb64prefix_set = 1 AND c$ = UCASE$(MID$(RTRIM$(Opt(x, o)), 2)) - IF c$ = UCASE$(RTRIM$(Opt(x, o))) OR noPrefixMatch THEN - 'Record Match - IF i3 < position THEN - position = i3 - which = o - IF noPrefixMatch THEN removePrefix = 1 - bvalue = b - EXIT FOR 'Exit the i3 loop - END IF 'position check - END IF 'match - END IF - - IF ASC(c$) = 44 AND b = 0 THEN - EXIT FOR 'Expressions cannot contain a "," in their base level - 'Because this wasn't interceppted by the above code it isn't the Opt either - END IF - IF ASC(c$) = 40 THEN - b = b + 1 - END IF - IF ASC(c$) = 41 THEN - b = b - 1 - IF b = -1 THEN EXIT FOR 'Exited current bracketting level, making any following match invalid - END IF - - END IF 'enough elements exist - NEXT i3 - NEXT o - END IF 'Past end of contect check - - IF position <> OutOfRange THEN 'Found? - 'Found... - level = Lev(x) 'Adjust level - IF Expression THEN - 'Found...Expression... - 'Has an expression been provided? - IF position > i AND bvalue = 0 THEN - 'Found...Expression...Provided... - separgs(Expression) = getelements$(ca$, i, position - 1) - Expression = 0 - i = position - ELSE - 'Found...Expression...Omitted... - '*********backtrack************ - GOTO OptCheckBacktrack - '****************************** - END IF - END IF 'Expression - i = i + OptWords(x, which) - separgslayout(x) = CHR$(LEN(RTRIM$(Opt(x, which))) - removePrefix) + SCase$(MID$(RTRIM$(Opt(x, which)), removePrefix + 1)) - separgs(x) = CHR$(0) + str2(which) - ELSE - 'Not Found... - '*********backtrack************ - OptCheckBacktrack: - 'Was this optional? - IF Lev(x) > EntryLev(x) THEN 'Optional Opt ()? - 'Not Found...Optional... - 'Simply don't enter the optional higher level and continue as normal - BranchTaken(Branches) = 0 - level = currentlev 'We aren't entering the level after all, so our level should remain at the opt's entrylevel - ELSE - Backtrack: - 'Not Found...Mandatory... - '1)Erase previous branches where both options have been tried - FOR branch = Branches TO 1 STEP -1 'Remove branches until last taken branch is found - IF BranchTaken(branch) THEN EXIT FOR - Branches = Branches - 1 'Remove branch (it has already been tried with both possible combinations) - NEXT - IF Branches = 0 THEN 'All options have been exhausted - seperateargs_error = 1 - seperateargs_error_message = "Syntax error" - IF LEN(id2.hr_syntax) > 0 THEN seperateargs_error_message = seperateargs_error_message + " - Reference: " + id2.hr_syntax - EXIT FUNCTION - END IF - '2)Toggle taken branch to untaken and revert - BranchTaken(Branches) = 0 'toggle branch to untaken - Expression = BranchWithExpression(Branches) - i = BranchInputPos(Branches) - x = BranchFormatPos(Branches) - level = BranchLevel(Branches) - '3)Erase any content created after revert position - IF Expression THEN separgs(Expression) = "n-ll" - FOR x2 = x TO lastt - separgs(x2) = "n-ll" - separgslayout(x2) = "" - NEXT - END IF 'Optional Opt ()? - '****************************** - - END IF 'Found? - - END IF 't - - END IF 'possible to enter level - - NEXT x - - 'Final expression? - IF Expression THEN - IF i <= n THEN - separgs(Expression) = getelements$(ca$, i, n) - - 'can this be an expression? - 'check it passes bracketting and comma rules - b = 0 - FOR i2 = i TO n - c$ = getelement$(a$, i2) - IF ASC(c$) = 44 AND b = 0 THEN - GOTO Backtrack - END IF - IF ASC(c$) = 40 THEN - b = b + 1 - END IF - IF ASC(c$) = 41 THEN - b = b - 1 - IF b = -1 THEN GOTO Backtrack - END IF - NEXT - IF b <> 0 THEN GOTO Backtrack - - i = n + 1 'So it passes the test below - ELSE - GOTO Backtrack - END IF - END IF 'Expression - - IF i <> n + 1 THEN GOTO Backtrack 'Trailing content? - - IF Debug THEN - PRINT #9, "--------SEPERATE ARGUMENTS REPORT #2--------" - FOR i = 1 TO lastt - PRINT #9, i, separgs(i) - NEXT - END IF - - ' DIM PassRule(1 TO 100) AS LONG - ' '0 means no pass rule - ' 'negative values refer to an opt () element - ' 'positive values refer to a flag value - ' PassFlag = 1 - - - IF PassFlag <> 1 THEN seperateargs = 1 'Return whether a 'passed' flags variable is required - pass& = 0 'The 'passed' value (shared by argument reference) - - 'Note: The separgs() elements will be compacted to the C++ function arguments - x = 1 'The new index to move compacted content to within separgs() - - FOR i = 1 TO lastt - - IF DontPass(i) = 0 THEN - - IF PassRule(i) > 0 THEN - IF separgs(i) <> "n-ll" THEN pass& = pass& OR PassRule(i) 'build 'passed' flags - END IF - - separgs(x) = separgs(i) - separgslayout(x) = separgslayout(i) - - IF LEN(separgs(x)) THEN - IF ASC(separgs(x)) = 0 THEN - 'switch omit layout tag from item to layout info - separgs(x) = RIGHT$(separgs(x), LEN(separgs(x)) - 1) - separgslayout(x) = separgslayout(x) + CHR$(0) - END IF - END IF - - IF separgs(x) = "n-ll" THEN separgs(x) = "N-LL" - x = x + 1 - - ELSE - 'its gonna be skipped! - 'add layout to the next one to be safe - - 'for syntax such as [{HELLO}] which uses a flag instead of being passed - IF PassRule(i) > 0 THEN - IF separgs(i) <> "n-ll" THEN pass& = pass& OR PassRule(i) 'build 'passed' flags - END IF - - separgslayout(i + 1) = separgslayout(i) + separgslayout(i + 1) - - END IF - NEXT - separgslayout(x) = separgslayout(i) 'set final layout - - 'x = x - 1 - 'PRINT "total arguments:"; x - 'PRINT "pass omit (0/1):"; omit - 'PRINT "pass&="; pass& - -END FUNCTION - -SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) - a$ = a2$: typ = typ2: e$ = e2$ - IF method <> 1 THEN e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - tl$ = tlayout$ - - 'method: 0 evaulatetotyp e$ - ' 1 skip evaluation of e$ and use as is - '*due to the complexity of setting a reference with a value/string - ' this function handles the problem - - 'retrieve ID - i = INSTR(a$, sp3) - IF i THEN - idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) - ELSE - idnumber = VAL(a$) - END IF - getid idnumber - IF Error_Happened THEN EXIT SUB - - 'UDT? - IF typ AND ISUDT THEN - - 'print "setrefer-ing a UDT!" - u = VAL(a$) - i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) - i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) - n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" - - IF E <> 0 AND u = 1 THEN 'Setting _MEM type elements is not allowed! - Give_Error "Cannot set read-only element of _MEM TYPE": EXIT SUB - END IF - - IF E = 0 THEN - 'use u and u's size - - IF method <> 0 THEN Give_Error "Unexpected internal code reference to UDT": EXIT SUB - lhsscope$ = scope$ - e$ = evaluate(e$, t2) - IF Error_Happened THEN EXIT SUB - IF (t2 AND ISUDT) = 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB - - IF (t2 AND ISREFERENCE) = 0 THEN - IF t2 AND ISPOINTER THEN - src$ = "((char*)" + e$ + ")" - e2 = 0: u2 = t2 AND 511 - ELSE - src$ = "((char*)&" + e$ + ")" - e2 = 0: u2 = t2 AND 511 - END IF - GOTO directudt - END IF - - '****problem**** - idnumber2 = VAL(e$) - getid idnumber2 - - - IF Error_Happened THEN EXIT SUB - n2$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n2$ = "ARRAY_" + n2$ + "[0]" - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): u2 = VAL(e$) - i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): e2 = VAL(e$) - i = INSTR(e$, sp3): o2$ = RIGHT$(e$, LEN(e$) - i) - 'WARNING: u2 may need minor modifications based on e to see if they are the same - - 'we have now established we have 2 pointers to similar data types! - 'ASSUME BYTE TYPE!!! - src$ = "((char*)" + scope$ + n2$ + ")+(" + o2$ + ")" - directudt: - IF u <> u2 OR e2 <> 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB - dst$ = "((char*)" + lhsscope$ + n$ + ")+(" + o$ + ")" - copy_full_udt dst$, src$, 12, 0, u - - 'print "setFULLUDTrefer!" - - tlayout$ = tl$ - EXIT SUB - - END IF 'e=0 - - IF typ AND ISOFFSETINBITS THEN Give_Error "Cannot resolve bit-length variables inside user defined types": EXIT SUB - IF typ AND ISSTRING THEN - IF typ AND ISFIXEDLENGTH THEN - o2$ = "(((uint8*)" + scope$ + n$ + ")+(" + o$ + "))" - r$ = "qbs_new_fixed(" + o2$ + "," + str2(udtetypesize(E)) + ",1)" - ELSE - r$ = "*((qbs**)((char*)(" + scope$ + n$ + ")+(" + o$ + ")))" - END IF - IF method = 0 THEN e$ = evaluatetotyp(e$, STRINGTYPE - ISPOINTER) - IF Error_Happened THEN EXIT SUB - PRINT #12, "qbs_set(" + r$ + "," + e$ + ");" - PRINT #12, cleanupstringprocessingcall$ + "0);" - ELSE - typ = typ - ISUDT - ISREFERENCE - ISPOINTER - IF typ AND ISARRAY THEN typ = typ - ISARRAY - t$ = typ2ctyp$(typ, "") - IF Error_Happened THEN EXIT SUB - o2$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" - r$ = "*" + "(" + t$ + "*)" + o2$ - IF method = 0 THEN e$ = evaluatetotyp(e$, typ) - IF Error_Happened THEN EXIT SUB - PRINT #12, r$ + "=" + e$ + ";" - END IF - - 'print "setUDTrefer:"+r$,e$ - tlayout$ = tl$ - IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - EXIT SUB - END IF - - - 'array? - IF id.arraytype THEN - n$ = RTRIM$(id.callname) - typ = typ - ISPOINTER - ISREFERENCE 'typ now looks like a regular value - - IF (typ AND ISSTRING) THEN - IF (typ AND ISFIXEDLENGTH) THEN - offset$ = "&((uint8*)(" + n$ + "[0]))[tmp_long*" + str2(id.tsize) + "]" - r$ = "qbs_new_fixed(" + offset$ + "," + str2(id.tsize) + ",1)" - PRINT #12, "tmp_long=" + a$ + ";" - IF method = 0 THEN - l$ = "if (!new_error) qbs_set(" + r$ + "," + evaluatetotyp(e$, typ) + ");" - IF Error_Happened THEN EXIT SUB - ELSE - l$ = "if (!new_error) qbs_set(" + r$ + "," + e$ + ");" - END IF - PRINT #12, l$ - ELSE - PRINT #12, "tmp_long=" + a$ + ";" - IF method = 0 THEN - l$ = "if (!new_error) qbs_set( ((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))," + evaluatetotyp(e$, typ) + ");" - IF Error_Happened THEN EXIT SUB - ELSE - l$ = "if (!new_error) qbs_set( ((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))," + e$ + ");" - END IF - PRINT #12, l$ - END IF - PRINT #12, cleanupstringprocessingcall$ + "0);" - tlayout$ = tl$ - IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - EXIT SUB - END IF - - IF (typ AND ISOFFSETINBITS) THEN - 'r$ = "setbits_" + str2(typ AND 511) + "(" - r$ = "setbits(" + str2(typ AND 511) + "," - r$ = r$ + "(uint8*)(" + n$ + "[0])" + ",tmp_long," - PRINT #12, "tmp_long=" + a$ + ";" - IF method = 0 THEN - l$ = "if (!new_error) " + r$ + evaluatetotyp(e$, typ) + ");" - IF Error_Happened THEN EXIT SUB - ELSE - l$ = "if (!new_error) " + r$ + e$ + ");" - END IF - PRINT #12, l$ - tlayout$ = tl$ - EXIT SUB - ELSE - t$ = "" - IF (typ AND ISFLOAT) THEN - IF (typ AND 511) = 32 THEN t$ = "float" - IF (typ AND 511) = 64 THEN t$ = "double" - IF (typ AND 511) = 256 THEN t$ = "long double" - ELSE - IF (typ AND ISUNSIGNED) THEN - IF (typ AND 511) = 8 THEN t$ = "uint8" - IF (typ AND 511) = 16 THEN t$ = "uint16" - IF (typ AND 511) = 32 THEN t$ = "uint32" - IF (typ AND 511) = 64 THEN t$ = "uint64" - IF typ AND ISOFFSET THEN t$ = "uptrszint" - ELSE - IF (typ AND 511) = 8 THEN t$ = "int8" - IF (typ AND 511) = 16 THEN t$ = "int16" - IF (typ AND 511) = 32 THEN t$ = "int32" - IF (typ AND 511) = 64 THEN t$ = "int64" - IF typ AND ISOFFSET THEN t$ = "ptrszint" - END IF - END IF - END IF - IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT SUB - PRINT #12, "tmp_long=" + a$ + ";" - IF method = 0 THEN - l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + evaluatetotyp(e$, typ) + ";" - IF Error_Happened THEN EXIT SUB - ELSE - l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + e$ + ";" - END IF - - PRINT #12, l$ - tlayout$ = tl$ - EXIT SUB - END IF 'array - - 'variable? - IF id.t THEN - r$ = RTRIM$(id.n) - t = id.t - 'remove irrelavant flags - IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY - typ = t - - 'string variable? - IF (t AND ISSTRING) THEN - IF (t AND ISFIXEDLENGTH) THEN - r$ = scope$ + "STRING" + str2(id.tsize) + "_" + r$ - ELSE - r$ = scope$ + "STRING_" + r$ - END IF - IF method = 0 THEN e$ = evaluatetotyp(e$, ISSTRING) - IF Error_Happened THEN EXIT SUB - PRINT #12, "qbs_set(" + r$ + "," + e$ + ");" - PRINT #12, cleanupstringprocessingcall$ + "0);" - IF arrayprocessinghappened THEN arrayprocessinghappened = 0 - tlayout$ = tl$ - IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - EXIT SUB - END IF - - 'bit-length variable? - IF (t AND ISOFFSETINBITS) THEN - b = t AND 511 - IF (t AND ISUNSIGNED) THEN - r$ = "*" + scope$ + "UBIT" + str2(t AND 511) + "_" + r$ - IF method = 0 THEN e$ = evaluatetotyp(e$, 64& + ISUNSIGNED) - IF Error_Happened THEN EXIT SUB - l$ = r$ + "=(" + e$ + ")&" + str2(bitmask(b)) + ";" - PRINT #12, l$ - ELSE - r$ = "*" + scope$ + "BIT" + str2(t AND 511) + "_" + r$ - IF method = 0 THEN e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN EXIT SUB - l$ = "if ((" + r$ + "=" + e$ + ")&" + str2(2 ^ (b - 1)) + "){" - PRINT #12, l$ - 'signed bit is set - l$ = r$ + "|=" + str2(bitmaskinv(b)) + ";" - PRINT #12, l$ - PRINT #12, "}else{" - 'signed bit is not set - l$ = r$ + "&=" + str2(bitmask(b)) + ";" - PRINT #12, l$ - PRINT #12, "}" - END IF - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 - IF arrayprocessinghappened THEN arrayprocessinghappened = 0 - tlayout$ = tl$ - IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - EXIT SUB - END IF - - 'standard variable? - IF t = BYTETYPE THEN r$ = "*" + scope$ + "BYTE_" + r$: GOTO sref - IF t = UBYTETYPE THEN r$ = "*" + scope$ + "UBYTE_" + r$: GOTO sref - IF t = INTEGERTYPE THEN r$ = "*" + scope$ + "INTEGER_" + r$: GOTO sref - IF t = UINTEGERTYPE THEN r$ = "*" + scope$ + "UINTEGER_" + r$: GOTO sref - IF t = LONGTYPE THEN r$ = "*" + scope$ + "LONG_" + r$: GOTO sref - IF t = ULONGTYPE THEN r$ = "*" + scope$ + "ULONG_" + r$: GOTO sref - IF t = INTEGER64TYPE THEN r$ = "*" + scope$ + "INTEGER64_" + r$: GOTO sref - IF t = UINTEGER64TYPE THEN r$ = "*" + scope$ + "UINTEGER64_" + r$: GOTO sref - IF t = SINGLETYPE THEN r$ = "*" + scope$ + "SINGLE_" + r$: GOTO sref - IF t = DOUBLETYPE THEN r$ = "*" + scope$ + "DOUBLE_" + r$: GOTO sref - IF t = FLOATTYPE THEN r$ = "*" + scope$ + "FLOAT_" + r$: GOTO sref - IF t = OFFSETTYPE THEN r$ = "*" + scope$ + "OFFSET_" + r$: GOTO sref - IF t = UOFFSETTYPE THEN r$ = "*" + scope$ + "UOFFSET_" + r$: GOTO sref - sref: - t2 = t - ISPOINTER - IF method = 0 THEN e$ = evaluatetotyp(e$, t2) - IF Error_Happened THEN EXIT SUB - l$ = r$ + "=" + e$ + ";" - PRINT #12, l$ - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 - IF arrayprocessinghappened THEN arrayprocessinghappened = 0 - tlayout$ = tl$ - - IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - EXIT SUB - END IF 'variable - - tlayout$ = tl$ -END SUB - -FUNCTION str2$ (v AS LONG) - str2$ = _TRIM$(STR$(v)) -END FUNCTION - -FUNCTION str2u64$ (v~&&) - str2u64$ = LTRIM$(RTRIM$(STR$(v~&&))) -END FUNCTION - -FUNCTION str2i64$ (v&&) - str2i64$ = LTRIM$(RTRIM$(STR$(v&&))) -END FUNCTION - -FUNCTION typ2ctyp$ (t AS LONG, tstr AS STRING) - ctyp$ = "" - 'typ can be passed as either: (the unused value is ignored) - 'i. as a typ value in t - 'ii. as a typ symbol (eg. "~%") in tstr - 'iii. as a typ name (eg. _UNSIGNED INTEGER) in tstr - IF tstr$ = "" THEN - IF (t AND ISARRAY) THEN EXIT FUNCTION 'cannot return array types - IF (t AND ISSTRING) THEN typ2ctyp$ = "qbs": EXIT FUNCTION - b = t AND 511 - IF (t AND ISUDT) THEN typ2ctyp$ = "void": EXIT FUNCTION - IF (t AND ISOFFSETINBITS) THEN - IF b <= 32 THEN ctyp$ = "int32" ELSE ctyp$ = "int64" - IF (t AND ISUNSIGNED) THEN ctyp$ = "u" + ctyp$ - typ2ctyp$ = ctyp$: EXIT FUNCTION - END IF - IF (t AND ISFLOAT) THEN - IF b = 32 THEN ctyp$ = "float" - IF b = 64 THEN ctyp$ = "double" - IF b = 256 THEN ctyp$ = "long double" - ELSE - IF b = 8 THEN ctyp$ = "int8" - IF b = 16 THEN ctyp$ = "int16" - IF b = 32 THEN ctyp$ = "int32" - IF b = 64 THEN ctyp$ = "int64" - IF t AND ISOFFSET THEN ctyp$ = "ptrszint" - IF (t AND ISUNSIGNED) THEN ctyp$ = "u" + ctyp$ - END IF - IF t AND ISOFFSET THEN - ctyp$ = "ptrszint": IF (t AND ISUNSIGNED) THEN ctyp$ = "uptrszint" - END IF - typ2ctyp$ = ctyp$: EXIT FUNCTION - END IF - - ts$ = tstr$ - 'is ts$ a symbol? - IF ts$ = "$" THEN ctyp$ = "qbs" - IF ts$ = "!" THEN ctyp$ = "float" - IF ts$ = "#" THEN ctyp$ = "double" - IF ts$ = "##" THEN ctyp$ = "long double" - IF LEFT$(ts$, 1) = "~" THEN unsgn = 1: ts$ = RIGHT$(ts$, LEN(ts$) - 1) - IF LEFT$(ts$, 1) = "`" THEN - n$ = RIGHT$(ts$, LEN(ts$) - 1) - b = 1 - IF n$ <> "" THEN - IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION - b = VAL(n$) - IF b > 64 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION - END IF - IF b <= 32 THEN ctyp$ = "int32" ELSE ctyp$ = "int64" - IF unsgn THEN ctyp$ = "u" + ctyp$ - typ2ctyp$ = ctyp$: EXIT FUNCTION - END IF - IF ts$ = "%&" THEN - typ2ctyp$ = "ptrszint": IF (t AND ISUNSIGNED) THEN typ2ctyp$ = "uptrszint" - EXIT FUNCTION - END IF - IF ts$ = "%%" THEN ctyp$ = "int8" - IF ts$ = "%" THEN ctyp$ = "int16" - IF ts$ = "&" THEN ctyp$ = "int32" - IF ts$ = "&&" THEN ctyp$ = "int64" - IF ctyp$ <> "" THEN - IF unsgn THEN ctyp$ = "u" + ctyp$ - typ2ctyp$ = ctyp$: EXIT FUNCTION - END IF - 'is tstr$ a named type? (eg. 'LONG') - s$ = type2symbol$(tstr$) - IF Error_Happened THEN EXIT FUNCTION - IF LEN(s$) THEN - typ2ctyp$ = typ2ctyp$(0, s$) - IF Error_Happened THEN EXIT FUNCTION - EXIT FUNCTION - END IF - - Give_Error "Invalid type": EXIT FUNCTION - -END FUNCTION - -FUNCTION type2symbol$ (typ$) - t$ = typ$ - FOR i = 1 TO LEN(t$) - IF MID$(t$, i, 1) = sp THEN MID$(t$, i, 1) = " " - NEXT - e$ = "Cannot convert type (" + typ$ + ") to symbol" - t2$ = "_UNSIGNED _BIT": s$ = "~`1": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED _BYTE": s$ = "~%%": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED LONG": s$ = "~&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED _INTEGER64": s$ = "~&&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED INTEGER": s$ = "~%": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED _OFFSET": s$ = "~%&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_BIT": s$ = "`1": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_BYTE": s$ = "%%": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "LONG": s$ = "&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_INTEGER64": s$ = "&&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_OFFSET": s$ = "%&": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "SINGLE": s$ = "!": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "DOUBLE": s$ = "#": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "_FLOAT": s$ = "##": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "STRING": s$ = "$": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED LONG": s$ = "~&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED INTEGER": s$ = "~%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED _BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED _BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED _INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "UNSIGNED _OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "_UNSIGNED OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "BIT": s$ = "`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "BYTE": s$ = "%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "INTEGER64": s$ = "&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "INTEGER": s$ = "%": IF t$ = t2$ THEN GOTO t2sfound - t2$ = "OFFSET": s$ = "%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - t2$ = "FLOAT": s$ = "##": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound - Give_Error e$: EXIT FUNCTION - t2sfound: - type2symbol$ = s$ - IF LEN(t2$) <> LEN(t$) THEN - IF s$ <> "$" AND s$ <> "~`1" AND s$ <> "`1" THEN Give_Error e$: EXIT FUNCTION - t$ = RIGHT$(t$, LEN(t$) - LEN(t2$)) - IF LEFT$(t$, 3) <> " * " THEN Give_Error e$: EXIT FUNCTION - t$ = RIGHT$(t$, LEN(t$) - 3) - IF isuinteger(t$) = 0 THEN Give_Error e$: EXIT FUNCTION - v = VAL(t$) - IF v = 0 THEN Give_Error e$: EXIT FUNCTION - IF s$ <> "$" AND v > 64 THEN Give_Error e$: EXIT FUNCTION - IF s$ = "$" THEN - s$ = s$ + str2$(v) - ELSE - s$ = LEFT$(s$, LEN(s$) - 1) + str2$(v) - END IF - type2symbol$ = s$ - END IF -END FUNCTION - -'Strips away bits/indentifiers which make locating a variables source difficult -FUNCTION typecomp (typ) - typ2 = typ - IF (typ2 AND ISINCONVENTIONALMEMORY) THEN typ2 = typ2 - ISINCONVENTIONALMEMORY - typecomp = typ2 -END FUNCTION - -FUNCTION typname2typ& (t2$) - typname2typsize = 0 'the default - - t$ = t2$ - - 'symbol? - ts$ = t$ - IF ts$ = "$" THEN typname2typ& = STRINGTYPE: EXIT FUNCTION - IF ts$ = "!" THEN typname2typ& = SINGLETYPE: EXIT FUNCTION - IF ts$ = "#" THEN typname2typ& = DOUBLETYPE: EXIT FUNCTION - IF ts$ = "##" THEN typname2typ& = FLOATTYPE: EXIT FUNCTION - - 'fixed length string? - IF LEFT$(ts$, 1) = "$" THEN - n$ = RIGHT$(ts$, LEN(ts$) - 1) - IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after STRING * type": EXIT FUNCTION - b = VAL(n$) - IF b = 0 THEN Give_Error "Invalid index after STRING * type": EXIT FUNCTION - typname2typsize = b - typname2typ& = STRINGTYPE + ISFIXEDLENGTH - EXIT FUNCTION - END IF - - 'unsigned? - IF LEFT$(ts$, 1) = "~" THEN unsgn = 1: ts$ = RIGHT$(ts$, LEN(ts$) - 1) - - 'bit-type? - IF LEFT$(ts$, 1) = "`" THEN - n$ = RIGHT$(ts$, LEN(ts$) - 1) - b = 1 - IF n$ <> "" THEN - IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION - b = VAL(n$) - IF b > 64 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION - END IF - IF unsgn THEN typname2typ& = UBITTYPE + (b - 1) ELSE typname2typ& = BITTYPE + (b - 1) - EXIT FUNCTION - END IF - - t = 0 - IF ts$ = "%%" THEN t = BYTETYPE - IF ts$ = "%" THEN t = INTEGERTYPE - IF ts$ = "&" THEN t = LONGTYPE - IF ts$ = "&&" THEN t = INTEGER64TYPE - IF ts$ = "%&" THEN t = OFFSETTYPE - - IF t THEN - IF unsgn THEN t = t + ISUNSIGNED - typname2typ& = t: EXIT FUNCTION - END IF - 'not a valid symbol - - 'type name? - FOR i = 1 TO LEN(t$) - IF MID$(t$, i, 1) = sp THEN MID$(t$, i, 1) = " " - NEXT - IF t$ = "STRING" THEN typname2typ& = STRINGTYPE: EXIT FUNCTION - - IF LEFT$(t$, 9) = "STRING * " THEN - - n$ = RIGHT$(t$, LEN(t$) - 9) - - 'constant check 2011 - hashfound = 0 - hashname$ = n$ - hashchkflags = HASHFLAG_CONSTANT - hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) - DO WHILE hashres - IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN - IF constdefined(hashresref) THEN - hashfound = 1 - EXIT DO - END IF - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - IF hashfound THEN - i2 = hashresref - t = consttype(i2) - IF t AND ISSTRING THEN Give_Error "Expected STRING * numeric-constant": EXIT FUNCTION - 'convert value to general formats - IF t AND ISFLOAT THEN - v## = constfloat(i2) - v&& = v## - v~&& = v&& - ELSE - IF t AND ISUNSIGNED THEN - v~&& = constuinteger(i2) - v&& = v~&& - v## = v&& - ELSE - v&& = constinteger(i2) - v## = v&& - v~&& = v&& - END IF - END IF - IF v&& < 1 OR v&& > 9999999999 THEN Give_Error "STRING * out-of-range constant": EXIT FUNCTION - b = v&& - GOTO constantlenstr - END IF - - IF isuinteger(n$) = 0 OR LEN(n$) > 10 THEN Give_Error "Invalid number/constant after STRING * type": EXIT FUNCTION - b = VAL(n$) - IF b = 0 OR LEN(n$) > 10 THEN Give_Error "Invalid number after STRING * type": EXIT FUNCTION - constantlenstr: - typname2typsize = b - typname2typ& = STRINGTYPE + ISFIXEDLENGTH - EXIT FUNCTION - END IF - - IF t$ = "SINGLE" THEN typname2typ& = SINGLETYPE: EXIT FUNCTION - IF t$ = "DOUBLE" THEN typname2typ& = DOUBLETYPE: EXIT FUNCTION - IF t$ = "_FLOAT" OR (t$ = "FLOAT" AND qb64prefix_set = 1) THEN typname2typ& = FLOATTYPE: EXIT FUNCTION - IF LEFT$(t$, 10) = "_UNSIGNED " OR (LEFT$(t$, 9) = "UNSIGNED " AND qb64prefix_set = 1) THEN - u = 1 - t$ = MID$(t$, INSTR(t$, CHR$(32)) + 1) - END IF - IF LEFT$(t$, 4) = "_BIT" OR (LEFT$(t$, 3) = "BIT" AND qb64prefix_set = 1) THEN - IF t$ = "_BIT" OR (t$ = "BIT" AND qb64prefix_set = 1) THEN - IF u THEN typname2typ& = UBITTYPE ELSE typname2typ& = BITTYPE - EXIT FUNCTION - END IF - IF LEFT$(t$, 7) <> "_BIT * " OR (LEFT$(t$, 6) = "BIT * " AND qb64prefix_set = 1) THEN Give_Error "Expected _BIT * number": EXIT FUNCTION - - n$ = RIGHT$(t$, LEN(t$) - 7) - IF isuinteger(n$) = 0 THEN Give_Error "Invalid size after " + qb64prefix$ + "BIT *": EXIT FUNCTION - b = VAL(n$) - IF b = 0 OR b > 64 THEN Give_Error "Invalid size after " + qb64prefix$ + "BIT *": EXIT FUNCTION - t = BITTYPE - 1 + b: IF u THEN t = t + ISUNSIGNED - typname2typ& = t - EXIT FUNCTION - END IF - - t = 0 - IF t$ = "_BYTE" OR (t$ = "BYTE" AND qb64prefix_set = 1) THEN t = BYTETYPE - IF t$ = "INTEGER" THEN t = INTEGERTYPE - IF t$ = "LONG" THEN t = LONGTYPE - IF t$ = "_INTEGER64" OR (t$ = "INTEGER64" AND qb64prefix_set = 1) THEN t = INTEGER64TYPE - IF t$ = "_OFFSET" OR (t$ = "OFFSET" AND qb64prefix_set = 1) THEN t = OFFSETTYPE - IF t THEN - IF u THEN t = t + ISUNSIGNED - typname2typ& = t - EXIT FUNCTION - END IF - IF u THEN EXIT FUNCTION '_UNSIGNED (nothing) - - 'UDT? - FOR i = 1 TO lasttype - IF t$ = RTRIM$(udtxname(i)) THEN - typname2typ& = ISUDT + ISPOINTER + i - EXIT FUNCTION - ELSEIF RTRIM$(udtxname(i)) = "_MEM" AND t$ = "MEM" AND qb64prefix_set = 1 THEN - typname2typ& = ISUDT + ISPOINTER + i - EXIT FUNCTION - END IF - NEXT - - 'return 0 (failed) -END FUNCTION - -FUNCTION uniquenumber& - uniquenumbern = uniquenumbern + 1 - uniquenumber& = uniquenumbern -END FUNCTION - -FUNCTION validlabel (LABEL2$) - create = CreatingLabel: CreatingLabel = 0 - validlabel = 0 - IF LEN(LABEL2$) = 0 THEN EXIT FUNCTION - clabel$ = LABEL2$ - label$ = UCASE$(LABEL2$) - - n = numelements(label$) - - IF n = 1 THEN - - 'Note: Reserved words and internal sub/function names are invalid - hashres = HashFind(label$, HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION, hashresflags, hashresref) - DO WHILE hashres - IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN - IF ids(hashresref).internal_subfunc THEN EXIT FUNCTION - - IF hashresflags AND HASHFLAG_SUB THEN 'could be a label or a sub call! - - 'analyze format - IF ASC(ids(hashresref).specialformat) = 32 THEN - IF ids(hashresref).args = 0 THEN onecommandsub = 1 ELSE onecommandsub = 0 - ELSE - IF ASC(ids(hashresref).specialformat) <> 91 THEN '"[" - onecommandsub = 0 - ELSE - onecommandsub = 1 - a$ = RTRIM$(ids(hashresref).specialformat) - b = 1 - FOR x = 2 TO LEN(a$) - a = ASC(a$, x) - IF a = 91 THEN b = b + 1 - IF a = 93 THEN b = b - 1 - IF b = 0 AND x <> LEN(a$) THEN onecommandsub = 0: EXIT FOR - NEXT - END IF - END IF - IF create <> 0 AND onecommandsub = 1 THEN - IF INSTR(SubNameLabels$, sp + UCASE$(label$) + sp) = 0 THEN PossibleSubNameLabels$ = PossibleSubNameLabels$ + UCASE$(label$) + sp: EXIT FUNCTION 'treat as sub call - END IF - - END IF 'sub name - - ELSE - 'reserved - EXIT FUNCTION - END IF - IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 - LOOP - - 'Numeric label? - 'quasi numbers are possible, but: - 'a) They may only have one decimal place - 'b) They must be typed with the exact same characters to match - t$ = label$ - 'numeric? - a = ASC(t$) - IF (a >= 48 AND a <= 57) OR a = 46 THEN - - 'refer to original formatting if possible (eg. 1.10 not 1.1) - x = INSTR(t$, CHR$(44)) - IF x THEN - t$ = RIGHT$(t$, LEN(t$) - x) - END IF - - 'note: The symbols ! and # are valid trailing symbols in QBASIC, regardless of the number's size, - ' so they are allowed in QB64 for compatibility reasons - addsymbol$ = removesymbol$(t$) - IF Error_Happened THEN EXIT FUNCTION - IF LEN(addsymbol$) THEN - IF INSTR(addsymbol$, "$") THEN EXIT FUNCTION - IF addsymbol$ <> "#" AND addsymbol$ <> "!" THEN addsymbol$ = "" - END IF - - IF a = 46 THEN dp = 1 - FOR x = 2 TO LEN(t$) - a = ASC(MID$(t$, x, 1)) - IF a = 46 THEN dp = dp + 1 - IF (a < 48 OR a > 57) AND a <> 46 THEN EXIT FUNCTION 'not numeric - NEXT x - IF dp > 1 THEN EXIT FUNCTION 'too many decimal points - IF dp = 1 AND LEN(t$) = 1 THEN EXIT FUNCTION 'cant have '.' as a label - - tlayout$ = t$ + addsymbol$ - - i = INSTR(t$, "."): IF i THEN MID$(t$, i, 1) = "p" - IF addsymbol$ = "#" THEN t$ = t$ + "d" - IF addsymbol$ = "!" THEN t$ = t$ + "s" - - IF LEN(t$) > 40 THEN EXIT FUNCTION - - LABEL2$ = t$ - validlabel = 1 - EXIT FUNCTION - END IF 'numeric - - END IF 'n=1 - - 'Alpha-numeric label? - 'Build label - - 'structure check (???.???.???.???) - IF (n AND 1) = 0 THEN EXIT FUNCTION 'must be an odd number of elements - FOR nx = 2 TO n - 1 STEP 2 - a$ = getelement$(LABEL2$, nx) - IF a$ <> "." THEN EXIT FUNCTION 'every 2nd element must be a period - NEXT - - 'cannot begin with numeric - c = ASC(clabel$): IF c >= 48 AND c <= 57 THEN EXIT FUNCTION - - 'elements check - label3$ = "" - FOR nx = 1 TO n STEP 2 - label$ = getelement$(clabel$, nx) - - 'alpha-numeric? - FOR x = 1 TO LEN(label$) - IF alphanumeric(ASC(label$, x)) = 0 THEN EXIT FUNCTION - NEXT - - 'build label - IF label3$ = "" THEN label3$ = UCASE$(label$): tlayout$ = label$ ELSE label3$ = label3$ + fix046$ + UCASE$(label$): tlayout$ = tlayout$ + "." + label$ - NEXT nx - - validlabel = 1 - LABEL2$ = label3$ - -END FUNCTION - -SUB xend - IF vWatchOn = 1 THEN - 'check if closedmain = 0 in case a main module ends in an include. - IF (inclinenumber(inclevel) = 0 OR closedmain = 0) THEN vWatchAddLabel 0, -1 - PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" - END IF - PRINT #12, "sub_end();" -END SUB - -SUB xfileprint (a$, ca$, n) - u$ = str2$(uniquenumber) - PRINT #12, "tab_spc_cr_size=2;" - IF n = 2 THEN Give_Error "Expected # ... , ...": EXIT SUB - a3$ = "" - b = 0 - FOR i = 3 TO n - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF a2$ = "," AND b = 0 THEN - IF a3$ = "" THEN Give_Error "Expected # ... , ...": EXIT SUB - GOTO printgotfn - END IF - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - NEXT - Give_Error "Expected # ... ,": EXIT SUB - printgotfn: - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN EXIT SUB - l$ = SCase$("Print") + sp + "#" + sp2 + tlayout$ + sp2 + "," - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN EXIT SUB - PRINT #12, "tab_fileno=tmp_fileno=" + e$ + ";" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - i = i + 1 - - 'PRINT USING? (file) - IF n >= i THEN - IF getelement(a$, i) = "USING" THEN - 'get format string - fpujump: - l$ = l$ + sp + SCase$("Using") - e$ = "": b = 0: puformat$ = "" - FOR i = i + 1 TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = "," THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB - IF a2$ = ";" THEN - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - l$ = l$ + sp + tlayout$ + sp2 + ";" - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISSTRING) = 0 THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB - puformat$ = e$ - EXIT FOR - END IF '; - END IF 'b - IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - NEXT - IF puformat$ = "" THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB - IF i = n THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB - 'create build string - PRINT #12, "tqbs=qbs_new(0,0);" - 'set format start/index variable - PRINT #12, "tmp_long=0;" 'scan format from beginning - 'create string to hold format in for multiple references - puf$ = "print_using_format" + u$ - IF subfunc = "" THEN - PRINT #13, "static qbs *" + puf$ + ";" - ELSE - PRINT #13, "qbs *" + puf$ + ";" - END IF - PRINT #12, puf$ + "=qbs_new(0,0); qbs_set(" + puf$ + "," + puformat$ + ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - 'print expressions - b = 0 - e$ = "" - last = 0 - FOR i = i + 1 TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = ";" OR a2$ = "," THEN - fprintulast: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - IF typ AND ISSTRING THEN - - IF LEFT$(e$, 9) = "func_tab(" OR LEFT$(e$, 9) = "func_spc(" THEN - - 'TAB/SPC exception - 'note: position in format-string must be maintained - '-print any string up until now - PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0,0);" - '-print e$ - PRINT #12, "qbs_set(tqbs," + e$ + ");" - PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" - PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0,0);" - '-set length of tqbs to 0 - PRINT #12, "tqbs->len=0;" - - ELSE - - 'regular string - PRINT #12, "tmp_long=print_using(" + puf$ + ",tmp_long,tqbs," + e$ + ");" - - END IF - - ELSE 'not a string - IF typ AND ISFLOAT THEN - IF (typ AND 511) = 32 THEN PRINT #12, "tmp_long=print_using_single(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - IF (typ AND 511) = 64 THEN PRINT #12, "tmp_long=print_using_double(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - IF (typ AND 511) > 64 THEN PRINT #12, "tmp_long=print_using_float(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - ELSE - IF ((typ AND 511) = 64) AND (typ AND ISUNSIGNED) <> 0 THEN - PRINT #12, "tmp_long=print_using_uinteger64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - ELSE - PRINT #12, "tmp_long=print_using_integer64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - END IF - END IF - END IF 'string/not string - PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" - e$ = "" - IF last THEN EXIT FOR - GOTO fprintunext - END IF - END IF - IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - fprintunext: - NEXT - IF e$ <> "" THEN a2$ = "": last = 1: GOTO fprintulast - PRINT #12, "skip_pu" + u$ + ":" - 'check for errors - PRINT #12, "if (new_error){" - PRINT #12, "g_tmp_long=new_error; new_error=0; sub_file_print(tmp_fileno,tqbs,0,0,0); new_error=g_tmp_long;" - PRINT #12, "}else{" - IF a2$ = "," OR a2$ = ";" THEN nl = 0 ELSE nl = 1 'note: a2$ is set to the last element of a$ - PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0," + str2$(nl) + ");" - PRINT #12, "}" - PRINT #12, "qbs_free(tqbs);" - PRINT #12, "qbs_free(" + puf$ + ");" - PRINT #12, "skip" + u$ + ":" - PRINT #12, cleanupstringprocessingcall$ + "0);" - PRINT #12, "tab_spc_cr_size=1;" - tlayout$ = l$ - EXIT SUB - END IF - END IF - 'end of print using code - - IF i > n THEN - PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,0,1);" - GOTO printblankline - END IF - b = 0 - e$ = "" - last = 0 - FOR i = i TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = ";" OR a2$ = "," OR UCASE$(a2$) = "USING" THEN - printfilelast: - - IF UCASE$(a2$) = "USING" THEN - IF e$ <> "" THEN gotofpu = 1 ELSE GOTO fpujump - END IF - - IF a2$ = "," THEN usetab = 1 ELSE usetab = 0 - IF last = 1 THEN newline = 1 ELSE newline = 0 - extraspace = 0 - - IF LEN(e$) THEN - ebak$ = e$ - pnrtnum = 0 - printfilenumber: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF pnrtnum = 0 THEN - IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ - END IF - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISSTRING) = 0 THEN - e$ = "STR$" + sp + "(" + sp + ebak$ + sp + ")" - extraspace = 1 - pnrtnum = 1 - GOTO printfilenumber 'force re-evaluation - END IF - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line - PRINT #12, "sub_file_print(tmp_fileno," + e$ + ","; extraspace; ","; usetab; ","; newline; ");" - ELSE 'len(e$)=0 - IF a2$ = "," THEN l$ = l$ + sp + a2$ - IF a2$ = ";" THEN - IF RIGHT$(l$, 1) <> ";" THEN l$ = l$ + sp + a2$ 'concat ;; to ; - END IF - IF usetab THEN PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,1,0);" - END IF 'len(e$) - PRINT #12, "if (new_error) goto skip" + u$ + ";" - - e$ = "" - IF gotofpu THEN GOTO fpujump - IF last THEN EXIT FOR - GOTO printfilenext - END IF ', or ; - END IF 'b=0 - IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - printfilenext: - NEXT - IF e$ <> "" THEN a2$ = "": last = 1: GOTO printfilelast - printblankline: - PRINT #12, "skip" + u$ + ":" - PRINT #12, cleanupstringprocessingcall$ + "0);" - PRINT #12, "tab_spc_cr_size=1;" - tlayout$ = l$ -END SUB - -SUB xfilewrite (ca$, n) - l$ = SCase$("Write") + sp + "#" - u$ = str2$(uniquenumber) - PRINT #12, "tab_spc_cr_size=2;" - IF n = 2 THEN Give_Error "Expected # ...": EXIT SUB - a3$ = "" - b = 0 - FOR i = 3 TO n - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF a2$ = "," AND b = 0 THEN - IF a3$ = "" THEN Give_Error "Expected # ... , ...": EXIT SUB - GOTO writegotfn - END IF - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - NEXT - Give_Error "Expected # ... ,": EXIT SUB - writegotfn: - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN EXIT SUB - l$ = l$ + sp2 + tlayout$ + sp2 + "," - e$ = evaluatetotyp(e$, 64&) - IF Error_Happened THEN EXIT SUB - PRINT #12, "tab_fileno=tmp_fileno=" + e$ + ";" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - i = i + 1 - IF i > n THEN - PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,0,1);" - GOTO writeblankline - END IF - b = 0 - e$ = "" - last = 0 - FOR i = i TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = "," THEN - writefilelast: - IF last = 1 THEN newline = 1 ELSE newline = 0 - ebak$ = e$ - reevaled = 0 - writefilenumber: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF reevaled = 0 THEN - l$ = l$ + sp + tlayout$ - IF last = 0 THEN l$ = l$ + sp2 + "," - END IF - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF reevaled = 0 THEN - IF (typ AND ISSTRING) = 0 THEN - e$ = "LTRIM$" + sp + "(" + sp + "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + ")" - IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" - reevaled = 1 - GOTO writefilenumber 'force re-evaluation - ELSE - e$ = CHR$(34) + "\042" + CHR$(34) + ",1" + sp + "+" + sp + ebak$ + sp + "+" + sp + CHR$(34) + "\042" + CHR$(34) + ",1" - IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" - reevaled = 1 - GOTO writefilenumber 'force re-evaluation - END IF - END IF - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line - PRINT #12, "sub_file_print(tmp_fileno," + e$ + ",0,0,"; newline; ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - e$ = "" - IF last THEN EXIT FOR - GOTO writefilenext - END IF ', - END IF 'b=0 - IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - writefilenext: - NEXT - IF e$ <> "" THEN a2$ = ",": last = 1: GOTO writefilelast - writeblankline: - 'print #12, "}"'new_error - PRINT #12, "skip" + u$ + ":" - PRINT #12, cleanupstringprocessingcall$ + "0);" - PRINT #12, "tab_spc_cr_size=1;" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ -END SUB - -SUB xgosub (ca$) - a2$ = getelement(ca$, 2) - IF validlabel(a2$) = 0 THEN Give_Error "Invalid label": EXIT SUB - - v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk200: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk200 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd a2$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - Labels(r).Error_Line = linenumber - END IF 'x - - l$ = SCase$("GoSub") + sp + tlayout$ - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ - 'note: This code fragment also used by ON ... GOTO/GOSUB - 'assume label is reachable (revise) - PRINT #12, "return_point[next_return_point++]=" + str2(gosubid) + ";" - PRINT #12, "if (next_return_point>=return_points) more_return_points();" - PRINT #12, "goto LABEL_" + a2$ + ";" - 'add return point jump - PRINT #15, "case " + str2(gosubid) + ":" - PRINT #15, "goto RETURN_" + str2(gosubid) + ";" - PRINT #15, "break;" - PRINT #12, "RETURN_" + str2(gosubid) + ":;" - gosubid = gosubid + 1 -END SUB - -SUB xongotogosub (a$, ca$, n) - IF n < 4 THEN Give_Error "Expected ON expression GOTO/GOSUB label,label,...": EXIT SUB - l$ = SCase$("On") - b = 0 - FOR i = 2 TO n - e2$ = getelement$(a$, i) - IF e2$ = "(" THEN b = b + 1 - IF e2$ = ")" THEN b = b - 1 - IF e2$ = "GOTO" OR e2$ = "GOSUB" THEN EXIT FOR - NEXT - IF i >= n OR i = 2 THEN Give_Error "Expected ON expression GOTO/GOSUB label,label,...": EXIT SUB - e$ = getelements$(ca$, 2, i - 1) - - g = 0: IF e2$ = "GOSUB" THEN g = 1 - e$ = fixoperationorder(e$) - IF Error_Happened THEN EXIT SUB - l$ = l$ + sp + tlayout$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISSTRING) THEN Give_Error "Expected numeric expression": EXIT SUB - IF (typ AND ISFLOAT) THEN - e$ = "qbr_float_to_long(" + e$ + ")" - END IF - l$ = l$ + sp + e2$ - u$ = str2$(uniquenumber) - PRINT #13, "static int32 ongo_" + u$ + "=0;" - PRINT #12, "ongo_" + u$ + "=" + e$ + ";" - ln = 1 - labelwaslast = 0 - FOR i = i + 1 TO n - e$ = getelement$(ca$, i) - IF e$ = "," THEN - l$ = l$ + sp2 + "," - IF i = n THEN Give_Error "Trailing , invalid": EXIT SUB - ln = ln + 1 - labelwaslast = 0 - ELSE - IF labelwaslast THEN Give_Error "Expected ,": EXIT SUB - IF validlabel(e$) = 0 THEN Give_Error "Invalid label!": EXIT SUB - - v = HashFind(e$, HASHFLAG_LABEL, ignore, r) - x = 1 - labchk507: - IF v THEN - s = Labels(r).Scope - IF s = subfuncn OR s = -1 THEN 'same scope? - IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope - x = 0 'already defined - tlayout$ = RTRIM$(Labels(r).cn) - ELSE - IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk507 - END IF - END IF - IF x THEN - 'does not exist - nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type - Labels(nLabels) = Empty_Label - HashAdd e$, HASHFLAG_LABEL, nLabels - r = nLabels - Labels(r).State = 0 - Labels(r).cn = tlayout$ - Labels(r).Scope = subfuncn - Labels(r).Error_Line = linenumber - END IF 'x - - l$ = l$ + sp + tlayout$ - IF g THEN 'gosub - lb$ = e$ - PRINT #12, "if (ongo_" + u$ + "==" + str2$(ln) + "){" - 'note: This code fragment also used by ON ... GOTO/GOSUB - 'assume label is reachable (revise) - PRINT #12, "return_point[next_return_point++]=" + str2(gosubid) + ";" - PRINT #12, "if (next_return_point>=return_points) more_return_points();" - PRINT #12, "goto LABEL_" + lb$ + ";" - 'add return point jump - PRINT #15, "case " + str2(gosubid) + ":" - PRINT #15, "goto RETURN_" + str2(gosubid) + ";" - PRINT #15, "break;" - PRINT #12, "RETURN_" + str2(gosubid) + ":;" - gosubid = gosubid + 1 - PRINT #12, "goto ongo_" + u$ + "_skip;" - PRINT #12, "}" - ELSE 'goto - PRINT #12, "if (ongo_" + u$ + "==" + str2$(ln) + ") goto LABEL_" + e$ + ";" - END IF - labelwaslast = 1 - END IF - NEXT - PRINT #12, "if (ongo_" + u$ + "<0) error(5);" - IF g = 1 THEN PRINT #12, "ongo_" + u$ + "_skip:;" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ -END SUB - -SUB xprint (a$, ca$, n) - u$ = str2$(uniquenumber) - - l$ = SCase$("Print") - IF ASC(a$) = 76 THEN lp = 1: lp$ = "l": l$ = SCase$("LPrint"): PRINT #12, "tab_LPRINT=1;": DEPENDENCY(DEPENDENCY_PRINTER) = 1 '"L" - - 'PRINT USING? - IF n >= 2 THEN - IF getelement(a$, 2) = "USING" THEN - 'get format string - i = 3 - pujump: - l$ = l$ + sp + SCase$("Using") - e$ = "": b = 0: puformat$ = "" - FOR i = i TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = "," THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB - IF a2$ = ";" THEN - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - l$ = l$ + sp + tlayout$ + sp2 + ";" - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISSTRING) = 0 THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB - puformat$ = e$ - EXIT FOR - END IF '; - END IF 'b - IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - NEXT - IF puformat$ = "" THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB - IF i = n THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB - 'create build string - IF TQBSset = 0 THEN - PRINT #12, "tqbs=qbs_new(0,0);" - ELSE - PRINT #12, "qbs_set(tqbs,qbs_new_txt_len(" + CHR$(34) + CHR$(34) + ",0));" - END IF - 'set format start/index variable - PRINT #12, "tmp_long=0;" 'scan format from beginning - - - 'create string to hold format in for multiple references - puf$ = "print_using_format" + u$ - IF subfunc = "" THEN - PRINT #13, "static qbs *" + puf$ + ";" - ELSE - PRINT #13, "qbs *" + puf$ + ";" - END IF - PRINT #12, puf$ + "=qbs_new(0,0); qbs_set(" + puf$ + "," + puformat$ + ");" - PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" - - 'print expressions - b = 0 - e$ = "" - last = 0 - FOR i = i + 1 TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = ";" OR a2$ = "," THEN - printulast: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - IF typ AND ISSTRING THEN - - IF LEFT$(e$, 9) = "func_tab(" OR LEFT$(e$, 9) = "func_spc(" THEN - - 'TAB/SPC exception - 'note: position in format-string must be maintained - '-print any string up until now - PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" - '-print e$ - PRINT #12, "qbs_set(tqbs," + e$ + ");" - PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" - IF lp THEN PRINT #12, "lprint_makefit(tqbs);" ELSE PRINT #12, "makefit(tqbs);" - PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" - '-set length of tqbs to 0 - PRINT #12, "tqbs->len=0;" - - ELSE - - 'regular string - PRINT #12, "tmp_long=print_using(" + puf$ + ",tmp_long,tqbs," + e$ + ");" - - END IF - - - - ELSE 'not a string - IF typ AND ISFLOAT THEN - IF (typ AND 511) = 32 THEN PRINT #12, "tmp_long=print_using_single(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - IF (typ AND 511) = 64 THEN PRINT #12, "tmp_long=print_using_double(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - IF (typ AND 511) > 64 THEN PRINT #12, "tmp_long=print_using_float(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - ELSE - IF ((typ AND 511) = 64) AND (typ AND ISUNSIGNED) <> 0 THEN - PRINT #12, "tmp_long=print_using_uinteger64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - ELSE - PRINT #12, "tmp_long=print_using_integer64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" - END IF - END IF - END IF 'string/not string - PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" - e$ = "" - IF last THEN EXIT FOR - GOTO printunext - END IF - END IF - IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - printunext: - NEXT - IF e$ <> "" THEN a2$ = "": last = 1: GOTO printulast - PRINT #12, "skip_pu" + u$ + ":" - 'check for errors - PRINT #12, "if (new_error){" - PRINT #12, "g_tmp_long=new_error; new_error=0; qbs_" + lp$ + "print(tqbs,0); new_error=g_tmp_long;" - PRINT #12, "}else{" - IF a2$ = "," OR a2$ = ";" THEN nl = 0 ELSE nl = 1 'note: a2$ is set to the last element of a$ - PRINT #12, "qbs_" + lp$ + "print(tqbs," + str2$(nl) + ");" - PRINT #12, "}" - PRINT #12, "qbs_free(tqbs);" - PRINT #12, "qbs_free(" + puf$ + ");" - PRINT #12, "skip" + u$ + ":" - PRINT #12, cleanupstringprocessingcall$ + "0);" - IF lp THEN PRINT #12, "tab_LPRINT=0;" - tlayout$ = l$ - EXIT SUB - END IF - END IF - 'end of print using code - - b = 0 - e$ = "" - last = 0 - PRINT #12, "tqbs=qbs_new(0,0);" 'initialize the temp string - TQBSset = -1 'set the temporary flag so we don't create a temp string twice, in case USING comes after something - FOR i = 2 TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = ";" OR a2$ = "," OR UCASE$(a2$) = "USING" THEN - printlast: - - IF UCASE$(a2$) = "USING" THEN - IF e$ <> "" THEN gotopu = 1 ELSE i = i + 1: GOTO pujump - END IF - - IF LEN(e$) THEN - ebak$ = e$ - pnrtnum = 0 - printnumber: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF pnrtnum = 0 THEN - IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ - END IF - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF (typ AND ISSTRING) = 0 THEN - 'not a string expresion! - e$ = "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + "+" + sp + CHR$(34) + " " + CHR$(34) - pnrtnum = 1 - GOTO printnumber - END IF - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - PRINT #12, "qbs_set(tqbs," + e$ + ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - IF lp THEN PRINT #12, "lprint_makefit(tqbs);" ELSE PRINT #12, "makefit(tqbs);" - PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" - ELSE - IF a2$ = "," THEN l$ = l$ + sp + a2$ - IF a2$ = ";" THEN - IF RIGHT$(l$, 1) <> ";" THEN l$ = l$ + sp + a2$ 'concat ;; to ; - END IF - END IF 'len(e$) - IF a2$ = "," THEN PRINT #12, "tab();" - e$ = "" - - IF gotopu THEN i = i + 1: GOTO pujump - - IF last THEN - PRINT #12, "qbs_" + lp$ + "print(nothingstring,1);" 'go to new line - EXIT FOR - END IF - - GOTO printnext - END IF 'a2$ - END IF 'b=0 - - IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - printnext: - NEXT - IF LEN(e$) THEN a2$ = "": last = 1: GOTO printlast - IF n = 1 THEN PRINT #12, "qbs_" + lp$ + "print(nothingstring,1);" - PRINT #12, "skip" + u$ + ":" - PRINT #12, "qbs_free(tqbs);" - PRINT #12, cleanupstringprocessingcall$ + "0);" - IF lp THEN PRINT #12, "tab_LPRINT=0;" - tlayout$ = l$ -END SUB - - - - -SUB xread (ca$, n) - l$ = SCase$("Read") - IF n = 1 THEN Give_Error "Expected variable": EXIT SUB - i = 2 - IF i > n THEN Give_Error "Expected , ...": EXIT SUB - a3$ = "" - b = 0 - FOR i = i TO n - a2$ = getelement$(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF (a2$ = "," AND b = 0) OR i = n THEN - IF i = n THEN - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - END IF - IF a3$ = "" THEN Give_Error "Expected , ...": EXIT SUB - e$ = fixoperationorder$(a3$) - IF Error_Happened THEN EXIT SUB - l$ = l$ + sp + tlayout$: IF i <> n THEN l$ = l$ + sp2 + "," - e$ = evaluate(e$, t) - IF Error_Happened THEN EXIT SUB - IF (t AND ISREFERENCE) = 0 THEN Give_Error "Expected variable": EXIT SUB - - IF (t AND ISSTRING) THEN - e$ = refer(e$, t, 0) - IF Error_Happened THEN EXIT SUB - PRINT #12, "sub_read_string(data,&data_offset,data_size," + e$ + ");" - stringprocessinghappened = 1 - ELSE - 'numeric variable - IF (t AND ISFLOAT) <> 0 OR (t AND 511) <> 64 THEN - IF (t AND ISOFFSETINBITS) THEN - setrefer e$, t, "((int64)func_read_float(data,&data_offset,data_size," + str2(t) + "))", 1 - IF Error_Happened THEN EXIT SUB - ELSE - setrefer e$, t, "func_read_float(data,&data_offset,data_size," + str2(t) + ")", 1 - IF Error_Happened THEN EXIT SUB - END IF - ELSE - IF t AND ISUNSIGNED THEN - setrefer e$, t, "func_read_uint64(data,&data_offset,data_size)", 1 - IF Error_Happened THEN EXIT SUB - ELSE - setrefer e$, t, "func_read_int64(data,&data_offset,data_size)", 1 - IF Error_Happened THEN EXIT SUB - END IF - END IF - END IF 'string/numeric - IF i = n THEN EXIT FOR - a3$ = "": a2$ = "" - END IF - IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ - NEXT - IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ -END SUB - -SUB xwrite (ca$, n) - l$ = SCase$("Write") - u$ = str2$(uniquenumber) - IF n = 1 THEN - PRINT #12, "qbs_print(nothingstring,1);" - GOTO writeblankline2 - END IF - b = 0 - e$ = "" - last = 0 - FOR i = 2 TO n - a2$ = getelement(ca$, i) - IF a2$ = "(" THEN b = b + 1 - IF a2$ = ")" THEN b = b - 1 - IF b = 0 THEN - IF a2$ = "," THEN - writelast: - IF last = 1 THEN newline = 1 ELSE newline = 0 - ebak$ = e$ - reevaled = 0 - writechecked: - e$ = fixoperationorder$(e$) - IF Error_Happened THEN EXIT SUB - IF reevaled = 0 THEN - l$ = l$ + sp + tlayout$ - IF last = 0 THEN l$ = l$ + sp2 + "," - END IF - e$ = evaluate(e$, typ) - IF Error_Happened THEN EXIT SUB - IF reevaled = 0 THEN - IF (typ AND ISSTRING) = 0 THEN - e$ = "LTRIM$" + sp + "(" + sp + "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + ")" - IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" - reevaled = 1 - GOTO writechecked 'force re-evaluation - ELSE - e$ = CHR$(34) + "\042" + CHR$(34) + ",1" + sp + "+" + sp + ebak$ + sp + "+" + sp + CHR$(34) + "\042" + CHR$(34) + ",1" - IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" - reevaled = 1 - GOTO writechecked 'force re-evaluation - END IF - END IF - IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) - IF Error_Happened THEN EXIT SUB - 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line - PRINT #12, "qbs_print(" + e$ + ","; newline; ");" - PRINT #12, "if (new_error) goto skip" + u$ + ";" - e$ = "" - IF last THEN EXIT FOR - GOTO writenext - END IF ', - END IF 'b=0 - IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ - writenext: - NEXT - IF e$ <> "" THEN a2$ = ",": last = 1: GOTO writelast - writeblankline2: - PRINT #12, "skip" + u$ + ":" - PRINT #12, cleanupstringprocessingcall$ + "0);" - layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ -END SUB - -FUNCTION evaluateconst$ (a2$, t AS LONG) - a$ = a2$ - IF Debug THEN PRINT #9, "evaluateconst:in:" + a$ - - - DIM block(1000) AS STRING - DIM status(1000) AS INTEGER - '0=unprocessed (can be "") - '1=processed - DIM btype(1000) AS LONG 'for status=1 blocks - - 'put a$ into blocks - n = numelements(a$) - FOR i = 1 TO n - block(i) = getelement$(a$, i) - NEXT - - evalconstevalbrack: - - 'find highest bracket level - l = 0 - b = 0 - FOR i = 1 TO n - IF block(i) = "(" THEN b = b + 1 - IF block(i) = ")" THEN b = b - 1 - IF b > l THEN l = b - NEXT - - 'if brackets exist, evaluate that item first - IF l THEN - - b = 0 - e$ = "" - FOR i = 1 TO n - - IF block(i) = ")" THEN - IF b = l THEN block(i) = "": EXIT FOR - b = b - 1 - END IF - - IF b >= l THEN - IF LEN(e$) = 0 THEN e$ = block(i) ELSE e$ = e$ + sp + block(i) - block(i) = "" - END IF - - IF block(i) = "(" THEN - b = b + 1 - IF b = l THEN i2 = i: block(i) = "" - END IF - - NEXT i - - status(i) = 1 - block(i) = evaluateconst$(e$, btype(i)) - IF Error_Happened THEN EXIT FUNCTION - GOTO evalconstevalbrack - - END IF 'l - - 'linear equation remains with some pre-calculated & non-pre-calc blocks - - 'problem: type QBASIC assumes and type required to store calc. value may - ' differ dramatically. in qbasic, this would have caused an overflow, - ' but in qb64 it MUST work. eg. 32767% * 32767% - 'solution: all interger calc. will be performed using a signed _INTEGER64 - ' all float calc. will be performed using a _FLOAT - - 'convert non-calc block numbers into binary form with QBASIC-like type - FOR i = 1 TO n - IF status(i) = 0 THEN - IF LEN(block(i)) THEN - - a = ASC(block(i)) - IF (a = 45 AND LEN(block(i)) > 1) OR (a >= 48 AND a <= 57) THEN 'number? - - 'integers - e$ = RIGHT$(block(i), 3) - IF e$ = "~&&" THEN btype(i) = UINTEGER64TYPE - ISPOINTER: GOTO gotconstblkityp - IF e$ = "~%%" THEN btype(i) = UBYTETYPE - ISPOINTER: GOTO gotconstblkityp - e$ = RIGHT$(block(i), 2) - IF e$ = "&&" THEN btype(i) = INTEGER64TYPE - ISPOINTER: GOTO gotconstblkityp - IF e$ = "%%" THEN btype(i) = BYTETYPE - ISPOINTER: GOTO gotconstblkityp - IF e$ = "~%" THEN btype(i) = UINTEGERTYPE - ISPOINTER: GOTO gotconstblkityp - IF e$ = "~&" THEN btype(i) = ULONGTYPE - ISPOINTER: GOTO gotconstblkityp - e$ = RIGHT$(block(i), 1) - IF e$ = "%" THEN btype(i) = INTEGERTYPE - ISPOINTER: GOTO gotconstblkityp - IF e$ = "&" THEN btype(i) = LONGTYPE - ISPOINTER: GOTO gotconstblkityp - - 'ubit-type? - IF INSTR(block(i), "~`") THEN - x = INSTR(block(i), "~`") - IF x = LEN(block(i)) - 1 THEN block(i) = block(i) + "1" - btype(i) = UBITTYPE - ISPOINTER - 1 + VAL(RIGHT$(block(i), LEN(block(i)) - x - 1)) - block(i) = _MK$(_INTEGER64, VAL(LEFT$(block(i), x - 1))) - status(i) = 1 - GOTO gotconstblktyp - END IF - - 'bit-type? - IF INSTR(block(i), "`") THEN - x = INSTR(block(i), "`") - IF x = LEN(block(i)) THEN block(i) = block(i) + "1" - btype(i) = BITTYPE - ISPOINTER - 1 + VAL(RIGHT$(block(i), LEN(block(i)) - x)) - block(i) = _MK$(_INTEGER64, VAL(LEFT$(block(i), x - 1))) - status(i) = 1 - GOTO gotconstblktyp - END IF - - 'floats - IF INSTR(block(i), "E") THEN - block(i) = _MK$(_FLOAT, VAL(block(i))) - btype(i) = SINGLETYPE - ISPOINTER - status(i) = 1 - GOTO gotconstblktyp - END IF - IF INSTR(block(i), "D") THEN - block(i) = _MK$(_FLOAT, VAL(block(i))) - btype(i) = DOUBLETYPE - ISPOINTER - status(i) = 1 - GOTO gotconstblktyp - END IF - IF INSTR(block(i), "F") THEN - block(i) = _MK$(_FLOAT, VAL(block(i))) - btype(i) = FLOATTYPE - ISPOINTER - status(i) = 1 - GOTO gotconstblktyp - END IF - - Give_Error "Invalid CONST expression.1": EXIT FUNCTION - - gotconstblkityp: - block(i) = LEFT$(block(i), LEN(block(i)) - LEN(e$)) - block(i) = _MK$(_INTEGER64, VAL(block(i))) - status(i) = 1 - gotconstblktyp: - - END IF 'a - - IF a = 34 THEN 'string? - 'no changes need to be made to block(i) which is of format "CHARACTERS",size - btype(i) = STRINGTYPE - ISPOINTER - status(i) = 1 - END IF - - END IF 'len<>0 - END IF 'status - NEXT - - 'remove NULL blocks - n2 = 0 - FOR i = 1 TO n - IF block(i) <> "" THEN - n2 = n2 + 1 - block(n2) = block(i) - status(n2) = status(i) - btype(n2) = btype(i) - END IF - NEXT - n = n2 - - 'only one block? - IF n = 1 THEN - IF status(1) = 0 THEN Give_Error "Invalid CONST expression.2": EXIT FUNCTION - t = btype(1) - evaluateconst$ = block(1) - EXIT FUNCTION - END IF 'n=1 - - 'evaluate equation (equation cannot contain any STRINGs) - - '[negation/not][variable] - e$ = block(1) - IF status(1) = 0 THEN - IF n <> 2 THEN Give_Error "Invalid CONST expression.4": EXIT FUNCTION - IF status(2) = 0 THEN Give_Error "Invalid CONST expression.5": EXIT FUNCTION - IF btype(2) AND ISSTRING THEN Give_Error "Invalid CONST expression.6": EXIT FUNCTION - o$ = block(1) - - IF o$ = CHR$(241) THEN - IF btype(2) AND ISFLOAT THEN - r## = -_CV(_FLOAT, block(2)) - evaluateconst$ = _MK$(_FLOAT, r##) - ELSE - r&& = -_CV(_INTEGER64, block(2)) - evaluateconst$ = _MK$(_INTEGER64, r&&) - END IF - t = btype(2) - EXIT FUNCTION - END IF - - IF UCASE$(o$) = "NOT" THEN - IF btype(2) AND ISFLOAT THEN - r&& = _CV(_FLOAT, block(2)) - ELSE - r&& = _CV(_INTEGER64, block(2)) - END IF - r&& = NOT r&& - t = btype(2) - IF t AND ISFLOAT THEN t = LONGTYPE - ISPOINTER 'markdown to LONG - evaluateconst$ = _MK$(_INTEGER64, r&&) - EXIT FUNCTION - END IF - - Give_Error "Invalid CONST expression.7": EXIT FUNCTION - END IF - - '[variable][bool-operator][variable]... - - 'get first variable - et = btype(1) - ev$ = block(1) - - i = 2 - - evalconstequ: - - 'get operator - IF i >= n THEN Give_Error "Invalid CONST expression.8": EXIT FUNCTION - o$ = UCASE$(block(i)) - i = i + 1 - IF isoperator(o$) = 0 THEN Give_Error "Invalid CONST expression.9": EXIT FUNCTION - IF i > n THEN Give_Error "Invalid CONST expression.10": EXIT FUNCTION - - 'string/numeric mismatch? - IF (btype(i) AND ISSTRING) <> (et AND ISSTRING) THEN Give_Error "Invalid CONST expression.11": EXIT FUNCTION - - IF et AND ISSTRING THEN - IF o$ <> "+" THEN Give_Error "Invalid CONST expression.12": EXIT FUNCTION - 'concat strings - s1$ = RIGHT$(ev$, LEN(ev$) - 1) - s1$ = LEFT$(s1$, INSTR(s1$, CHR$(34)) - 1) - s1size = VAL(RIGHT$(ev$, LEN(ev$) - LEN(s1$) - 3)) - s2$ = RIGHT$(block(i), LEN(block(i)) - 1) - s2$ = LEFT$(s2$, INSTR(s2$, CHR$(34)) - 1) - s2size = VAL(RIGHT$(block(i), LEN(block(i)) - LEN(s2$) - 3)) - ev$ = CHR$(34) + s1$ + s2$ + CHR$(34) + "," + str2$(s1size + s2size) - GOTO econstmarkedup - END IF - - 'prepare left and right values - IF et AND ISFLOAT THEN - linteger = 0 - l## = _CV(_FLOAT, ev$) - l&& = l## - ELSE - linteger = 1 - l&& = _CV(_INTEGER64, ev$) - l## = l&& - END IF - IF btype(i) AND ISFLOAT THEN - rinteger = 0 - r## = _CV(_FLOAT, block(i)) - r&& = r## - ELSE - rinteger = 1 - r&& = _CV(_INTEGER64, block(i)) - r## = r&& - END IF - - IF linteger = 1 AND rinteger = 1 THEN - IF o$ = "+" THEN r&& = l&& + r&&: GOTO econstmarkupi - IF o$ = "-" THEN r&& = l&& - r&&: GOTO econstmarkupi - IF o$ = "*" THEN r&& = l&& * r&&: GOTO econstmarkupi - IF o$ = "^" THEN r## = l&& ^ r&&: GOTO econstmarkupf - IF o$ = "/" THEN r## = l&& / r&&: GOTO econstmarkupf - IF o$ = "\" THEN r&& = l&& \ r&&: GOTO econstmarkupi - IF o$ = "MOD" THEN r&& = l&& MOD r&&: GOTO econstmarkupi - IF o$ = "=" THEN r&& = l&& = r&&: GOTO econstmarkupi16 - IF o$ = ">" THEN r&& = l&& > r&&: GOTO econstmarkupi16 - IF o$ = "<" THEN r&& = l&& < r&&: GOTO econstmarkupi16 - IF o$ = ">=" THEN r&& = l&& >= r&&: GOTO econstmarkupi16 - IF o$ = "<=" THEN r&& = l&& <= r&&: GOTO econstmarkupi16 - IF o$ = "<>" THEN r&& = l&& <> r&&: GOTO econstmarkupi16 - IF o$ = "IMP" THEN r&& = l&& IMP r&&: GOTO econstmarkupi - IF o$ = "EQV" THEN r&& = l&& EQV r&&: GOTO econstmarkupi - IF o$ = "XOR" THEN r&& = l&& XOR r&&: GOTO econstmarkupi - IF o$ = "OR" THEN r&& = l&& OR r&&: GOTO econstmarkupi - IF o$ = "AND" THEN r&& = l&& AND r&&: GOTO econstmarkupi - END IF - - IF o$ = "+" THEN r## = l## + r##: GOTO econstmarkupf - IF o$ = "-" THEN r## = l## - r##: GOTO econstmarkupf - IF o$ = "*" THEN r## = l## * r##: GOTO econstmarkupf - IF o$ = "^" THEN r## = l## ^ r##: GOTO econstmarkupf - IF o$ = "/" THEN r## = l## / r##: GOTO econstmarkupf - IF o$ = "\" THEN r&& = l## \ r##: GOTO econstmarkupi32 - IF o$ = "MOD" THEN r&& = l## MOD r##: GOTO econstmarkupi32 - IF o$ = "=" THEN r&& = l## = r##: GOTO econstmarkupi16 - IF o$ = ">" THEN r&& = l## > r##: GOTO econstmarkupi16 - IF o$ = "<" THEN r&& = l## < r##: GOTO econstmarkupi16 - IF o$ = ">=" THEN r&& = l## >= r##: GOTO econstmarkupi16 - IF o$ = "<=" THEN r&& = l## <= r##: GOTO econstmarkupi16 - IF o$ = "<>" THEN r&& = l## <> r##: GOTO econstmarkupi16 - IF o$ = "IMP" THEN r&& = l## IMP r##: GOTO econstmarkupi32 - IF o$ = "EQV" THEN r&& = l## EQV r##: GOTO econstmarkupi32 - IF o$ = "XOR" THEN r&& = l## XOR r##: GOTO econstmarkupi32 - IF o$ = "OR" THEN r&& = l## OR r##: GOTO econstmarkupi32 - IF o$ = "AND" THEN r&& = l## AND r##: GOTO econstmarkupi32 - - Give_Error "Invalid CONST expression.13": EXIT FUNCTION - - econstmarkupi16: - et = INTEGERTYPE - ISPOINTER - ev$ = _MK$(_INTEGER64, r&&) - GOTO econstmarkedup - - econstmarkupi32: - et = LONGTYPE - ISPOINTER - ev$ = _MK$(_INTEGER64, r&&) - GOTO econstmarkedup - - econstmarkupi: - IF et <> btype(i) THEN - 'keep unsigned? - u = 0: IF (et AND ISUNSIGNED) <> 0 AND (btype(i) AND ISUNSIGNED) <> 0 THEN u = 1 - lb = et AND 511: rb = btype(i) AND 511 - ob = 0 - IF lb = rb THEN - IF (et AND ISOFFSETINBITS) <> 0 AND (btype(i) AND ISOFFSETINBITS) <> 0 THEN ob = 1 - b = lb - END IF - IF lb > rb THEN - IF (et AND ISOFFSETINBITS) <> 0 THEN ob = 1 - b = lb - END IF - IF lb < rb THEN - IF (btype(i) AND ISOFFSETINBITS) <> 0 THEN ob = 1 - b = rb - END IF - et = b - IF ob THEN et = et + ISOFFSETINBITS - IF u THEN et = et + ISUNSIGNED - END IF - ev$ = _MK$(_INTEGER64, r&&) - GOTO econstmarkedup - - econstmarkupf: - lfb = 0: rfb = 0 - lib = 0: rib = 0 - IF et AND ISFLOAT THEN lfb = et AND 511 ELSE lib = et AND 511 - IF btype(i) AND ISFLOAT THEN rfb = btype(i) AND 511 ELSE rib = btype(i) AND 511 - f = 32 - IF lib > 16 OR rib > 16 THEN f = 64 - IF lfb > 32 OR rfb > 32 THEN f = 64 - IF lib > 32 OR rib > 32 THEN f = 256 - IF lfb > 64 OR rfb > 64 THEN f = 256 - et = ISFLOAT + f - ev$ = _MK$(_FLOAT, r##) - - econstmarkedup: - - i = i + 1 - - IF i <= n THEN GOTO evalconstequ - - t = et - evaluateconst$ = ev$ - -END FUNCTION - -FUNCTION typevalue2symbol$ (t) - - IF t AND ISSTRING THEN - IF t AND ISFIXEDLENGTH THEN Give_Error "Cannot convert expression type to symbol": EXIT FUNCTION - typevalue2symbol$ = "$" - EXIT FUNCTION - END IF - - s$ = "" - - IF t AND ISUNSIGNED THEN s$ = "~" - - b = t AND 511 - - IF t AND ISOFFSETINBITS THEN - IF b > 1 THEN s$ = s$ + "`" + str2$(b) ELSE s$ = s$ + "`" - typevalue2symbol$ = s$ - EXIT FUNCTION - END IF - - IF t AND ISFLOAT THEN - IF b = 32 THEN s$ = "!" - IF b = 64 THEN s$ = "#" - IF b = 256 THEN s$ = "##" - typevalue2symbol$ = s$ - EXIT FUNCTION - END IF - - IF b = 8 THEN s$ = s$ + "%%" - IF b = 16 THEN s$ = s$ + "%" - IF b = 32 THEN s$ = s$ + "&" - IF b = 64 THEN s$ = s$ + "&&" - typevalue2symbol$ = s$ - -END FUNCTION - - -FUNCTION id2fulltypename$ - t = id.t - IF t = 0 THEN t = id.arraytype - size = id.tsize - bits = t AND 511 - IF t AND ISUDT THEN - a$ = RTRIM$(udtxcname(t AND 511)) - id2fulltypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISSTRING THEN - IF t AND ISFIXEDLENGTH THEN a$ = "STRING * " + str2(size) ELSE a$ = "STRING" - id2fulltypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISOFFSETINBITS THEN - IF bits > 1 THEN a$ = qb64prefix$ + "BIT * " + str2(bits) ELSE a$ = qb64prefix$ + "BIT" - IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ - id2fulltypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISFLOAT THEN - IF bits = 32 THEN a$ = "SINGLE" - IF bits = 64 THEN a$ = "DOUBLE" - IF bits = 256 THEN a$ = qb64prefix$ + "FLOAT" - ELSE 'integer-based - IF bits = 8 THEN a$ = qb64prefix$ + "BYTE" - IF bits = 16 THEN a$ = "INTEGER" - IF bits = 32 THEN a$ = "LONG" - IF bits = 64 THEN a$ = qb64prefix$ + "INTEGER64" - IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ - END IF - IF t AND ISOFFSET THEN - a$ = qb64prefix$ + "OFFSET" - IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ - END IF - id2fulltypename$ = a$ -END FUNCTION - -FUNCTION id2shorttypename$ - t = id.t - IF t = 0 THEN t = id.arraytype - size = id.tsize - bits = t AND 511 - IF t AND ISUDT THEN - a$ = RTRIM$(udtxcname(t AND 511)) - id2shorttypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISSTRING THEN - IF t AND ISFIXEDLENGTH THEN a$ = "STRING" + str2(size) ELSE a$ = "STRING" - id2shorttypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISOFFSETINBITS THEN - IF t AND ISUNSIGNED THEN a$ = "_U" ELSE a$ = "_" - IF bits > 1 THEN a$ = a$ + "BIT" + str2(bits) ELSE a$ = a$ + "BIT1" - id2shorttypename$ = a$: EXIT FUNCTION - END IF - IF t AND ISFLOAT THEN - IF bits = 32 THEN a$ = "SINGLE" - IF bits = 64 THEN a$ = "DOUBLE" - IF bits = 256 THEN a$ = "_FLOAT" - ELSE 'integer-based - IF bits = 8 THEN - IF (t AND ISUNSIGNED) THEN a$ = "_UBYTE" ELSE a$ = "_BYTE" - END IF - IF bits = 16 THEN - IF (t AND ISUNSIGNED) THEN a$ = "UINTEGER" ELSE a$ = "INTEGER" - END IF - IF bits = 32 THEN - IF (t AND ISUNSIGNED) THEN a$ = "ULONG" ELSE a$ = "LONG" - END IF - IF bits = 64 THEN - IF (t AND ISUNSIGNED) THEN a$ = "_UINTEGER64" ELSE a$ = "_INTEGER64" - END IF - END IF - id2shorttypename$ = a$ -END FUNCTION - -FUNCTION symbol2fulltypename$ (s2$) - 'note: accepts both symbols and type names - s$ = s2$ - - IF LEFT$(s$, 1) = "~" THEN - u = 1 - IF LEN(typ$) = 1 THEN Give_Error "Expected ~...": EXIT FUNCTION - s$ = RIGHT$(s$, LEN(s$) - 1) - u$ = qb64prefix$ + "UNSIGNED " - END IF - - IF s$ = "%%" THEN t$ = u$ + qb64prefix$ + "BYTE": GOTO gotsym2typ - IF s$ = "%" THEN t$ = u$ + "INTEGER": GOTO gotsym2typ - IF s$ = "&" THEN t$ = u$ + "LONG": GOTO gotsym2typ - IF s$ = "&&" THEN t$ = u$ + qb64prefix$ + "INTEGER64": GOTO gotsym2typ - IF s$ = "%&" THEN t$ = u$ + qb64prefix$ + "OFFSET": GOTO gotsym2typ - - IF LEFT$(s$, 1) = "`" THEN - IF LEN(s$) = 1 THEN - t$ = u$ + qb64prefix$ + "BIT * 1" - GOTO gotsym2typ - END IF - n$ = RIGHT$(s$, LEN(s$) - 1) - IF isuinteger(n$) = 0 THEN Give_Error "Expected number after symbol `": EXIT FUNCTION - t$ = u$ + qb64prefix$ + "BIT * " + n$ - GOTO gotsym2typ - END IF - - IF u = 1 THEN Give_Error "Expected type symbol after ~": EXIT FUNCTION - - IF s$ = "!" THEN t$ = "SINGLE": GOTO gotsym2typ - IF s$ = "#" THEN t$ = "DOUBLE": GOTO gotsym2typ - IF s$ = "##" THEN t$ = qb64prefix$ + "FLOAT": GOTO gotsym2typ - IF s$ = "$" THEN t$ = "STRING": GOTO gotsym2typ - - IF LEFT$(s$, 1) = "$" THEN - n$ = RIGHT$(s$, LEN(s$) - 1) - IF isuinteger(n$) = 0 THEN Give_Error "Expected number after symbol $": EXIT FUNCTION - t$ = "STRING * " + n$ - GOTO gotsym2typ - END IF - - t$ = s$ - - gotsym2typ: - - IF RIGHT$(" " + t$, 5) = " _BIT" THEN t$ = t$ + " * 1" 'clarify (_UNSIGNED) _BIT as (_UNSIGNED) _BIT * 1 - - FOR i = 1 TO LEN(t$) - IF ASC(t$, i) = ASC(sp) THEN ASC(t$, i) = 32 - NEXT - - symbol2fulltypename$ = t$ - -END FUNCTION - -SUB lineinput3load (f$) - OPEN f$ FOR BINARY AS #1 - l = LOF(1) - lineinput3buffer$ = SPACE$(l) - GET #1, , lineinput3buffer$ - IF LEN(lineinput3buffer$) THEN IF RIGHT$(lineinput3buffer$, 1) = CHR$(26) THEN lineinput3buffer$ = LEFT$(lineinput3buffer$, LEN(lineinput3buffer$) - 1) - CLOSE #1 - lineinput3index = 1 -END SUB - -FUNCTION lineinput3$ - 'returns CHR$(13) if no more lines are available - l = LEN(lineinput3buffer$) - IF lineinput3index > l THEN lineinput3$ = CHR$(13): EXIT FUNCTION - c13 = INSTR(lineinput3index, lineinput3buffer$, CHR$(13)) - c10 = INSTR(lineinput3index, lineinput3buffer$, CHR$(10)) - IF c10 = 0 AND c13 = 0 THEN - lineinput3$ = MID$(lineinput3buffer$, lineinput3index, l - lineinput3index + 1) - lineinput3index = l + 1 - EXIT FUNCTION - END IF - IF c10 = 0 THEN c10 = 2147483647 - IF c13 = 0 THEN c13 = 2147483647 - IF c10 < c13 THEN - '10 before 13 - lineinput3$ = MID$(lineinput3buffer$, lineinput3index, c10 - lineinput3index) - lineinput3index = c10 + 1 - IF lineinput3index <= l THEN - IF ASC(MID$(lineinput3buffer$, lineinput3index, 1)) = 13 THEN lineinput3index = lineinput3index + 1 - END IF - ELSE - '13 before 10 - lineinput3$ = MID$(lineinput3buffer$, lineinput3index, c13 - lineinput3index) - lineinput3index = c13 + 1 - IF lineinput3index <= l THEN - IF ASC(MID$(lineinput3buffer$, lineinput3index, 1)) = 10 THEN lineinput3index = lineinput3index + 1 - END IF - END IF -END FUNCTION - -FUNCTION eleucase$ (a$) - 'this function upper-cases all elements except for quoted strings - 'check first element - IF LEN(a$) = 0 THEN EXIT FUNCTION - i = 1 - IF ASC(a$) = 34 THEN - i2 = INSTR(a$, sp) - IF i2 = 0 THEN eleucase$ = a$: EXIT FUNCTION - a2$ = LEFT$(a$, i2 - 1) - i = i2 - END IF - 'check other elements - sp34$ = sp + CHR$(34) - IF i < LEN(a$) THEN - DO WHILE INSTR(i, a$, sp34$) - i2 = INSTR(i, a$, sp34$) - a2$ = a2$ + UCASE$(MID$(a$, i, i2 - i + 1)) 'everything prior including spacer - i3 = INSTR(i2 + 1, a$, sp): IF i3 = 0 THEN i3 = LEN(a$) ELSE i3 = i3 - 1 - a2$ = a2$ + MID$(a$, i2 + 1, i3 - (i2 + 1) + 1) 'everything from " to before next spacer or end - i = i3 + 1 - IF i > LEN(a$) THEN EXIT DO - LOOP - END IF - a2$ = a2$ + UCASE$(MID$(a$, i, LEN(a$) - i + 1)) - eleucase$ = a2$ -END FUNCTION - - -SUB SetDependency (requirement) - IF requirement THEN - DEPENDENCY(requirement) = 1 - END IF -END SUB - -'Steve Subs/Functins for _MATH support with CONST -FUNCTION Evaluate_Expression$ (e$) - t$ = e$ 'So we preserve our original data, we parse a temp copy of it - PreParse t$ - - - IF LEFT$(t$, 5) = "ERROR" THEN Evaluate_Expression$ = t$: EXIT FUNCTION - - 'Deal with brackets first - exp$ = "(" + t$ + ")" 'Starting and finishing brackets for our parse routine. - - DO - Eval_E = INSTR(exp$, ")") - IF Eval_E > 0 THEN - c = 0 - DO UNTIL Eval_E - c <= 0 - c = c + 1 - IF Eval_E THEN - IF MID$(exp$, Eval_E - c, 1) = "(" THEN EXIT DO - END IF - LOOP - s = Eval_E - c + 1 - IF s < 1 THEN Evaluate_Expression$ = "ERROR -- BAD () Count": EXIT FUNCTION - eval$ = " " + MID$(exp$, s, Eval_E - s) + " " 'pad with a space before and after so the parser can pick up the values properly. - - ParseExpression eval$ - eval$ = LTRIM$(RTRIM$(eval$)) - IF LEFT$(eval$, 5) = "ERROR" THEN Evaluate_Expression$ = eval$: EXIT FUNCTION - exp$ = DWD(LEFT$(exp$, s - 2) + eval$ + MID$(exp$, Eval_E + 1)) - IF MID$(exp$, 1, 1) = "N" THEN MID$(exp$, 1) = "-" - END IF - LOOP UNTIL Eval_E = 0 - c = 0 - DO - c = c + 1 - SELECT CASE MID$(exp$, c, 1) - CASE "0" TO "9", ".", "-" 'At this point, we should only have number values left. - CASE ELSE: Evaluate_Expression$ = "ERROR - Unknown Diagnosis: (" + exp$ + ") ": EXIT FUNCTION - END SELECT - LOOP UNTIL c >= LEN(exp$) - - Evaluate_Expression$ = exp$ -END FUNCTION - - - -SUB ParseExpression (exp$) - DIM num(10) AS STRING - 'PRINT exp$ - exp$ = DWD(exp$) - 'We should now have an expression with no () to deal with - - FOR J = 1 TO 250 - lowest = 0 - DO UNTIL lowest = LEN(exp$) - lowest = LEN(exp$): OpOn = 0 - FOR P = 1 TO UBOUND(OName) - 'Look for first valid operator - IF J = PL(P) THEN 'Priority levels match - IF LEFT$(exp$, 1) = "-" THEN startAt = 2 ELSE startAt = 1 - op = INSTR(startAt, exp$, OName(P)) - IF op = 0 AND LEFT$(OName(P), 1) = "_" AND qb64prefix_set = 1 THEN - 'try again without prefix - op = INSTR(startAt, exp$, MID$(OName(P), 2)) - IF op > 0 THEN - exp$ = LEFT$(exp$, op - 1) + "_" + MID$(exp$, op) - lowest = lowest + 1 - END IF - END IF - IF op > 0 AND op < lowest THEN lowest = op: OpOn = P - END IF - NEXT - IF OpOn = 0 THEN EXIT DO 'We haven't gotten to the proper PL for this OP to be processed yet. - IF LEFT$(exp$, 1) = "-" THEN startAt = 2 ELSE startAt = 1 - op = INSTR(startAt, exp$, OName(OpOn)) - - numset = 0 - - '*** SPECIAL OPERATION RULESETS - IF OName(OpOn) = "-" THEN 'check for BOOLEAN operators before the - - SELECT CASE MID$(exp$, op - 3, 3) - CASE "NOT", "XOR", "AND", "EQV", "IMP" - EXIT DO 'Not an operator, it's a negative - END SELECT - IF MID$(exp$, op - 3, 2) = "OR" THEN EXIT DO 'Not an operator, it's a negative - END IF - - IF op THEN - c = LEN(OName(OpOn)) - 1 - DO - SELECT CASE MID$(exp$, op + c + 1, 1) - CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "N": numset = -1 'Valid digit - CASE "-" 'We need to check if it's a minus or a negative - IF OName(OpOn) = "_PI" OR numset THEN EXIT DO - CASE ",": numset = 0 - CASE ELSE 'Not a valid digit, we found our separator - EXIT DO - END SELECT - c = c + 1 - LOOP UNTIL op + c >= LEN(exp$) - E = op + c - - c = 0 - DO - c = c + 1 - SELECT CASE MID$(exp$, op - c, 1) - CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "N" 'Valid digit - CASE "-" 'We need to check if it's a minus or a negative - c1 = c - bad = 0 - DO - c1 = c1 + 1 - SELECT CASE MID$(exp$, op - c1, 1) - CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." - bad = -1 - EXIT DO 'It's a minus sign - CASE ELSE - 'It's a negative sign and needs to count as part of our numbers - END SELECT - LOOP UNTIL op - c1 <= 0 - IF bad THEN EXIT DO 'We found our seperator - CASE ELSE 'Not a valid digit, we found our separator - EXIT DO - END SELECT - LOOP UNTIL op - c <= 0 - s = op - c - num(1) = MID$(exp$, s + 1, op - s - 1) 'Get our first number - num(2) = MID$(exp$, op + LEN(OName(OpOn)), E - op - LEN(OName(OpOn)) + 1) 'Get our second number - IF MID$(num(1), 1, 1) = "N" THEN MID$(num(1), 1) = "-" - IF MID$(num(2), 1, 1) = "N" THEN MID$(num(2), 1) = "-" - IF num(1) = "-" THEN - num(3) = "N" + EvaluateNumbers(OpOn, num()) - ELSE - num(3) = EvaluateNumbers(OpOn, num()) - END IF - IF MID$(num(3), 1, 1) = "-" THEN MID$(num(3), 1) = "N" - IF LEFT$(num(3), 5) = "ERROR" THEN exp$ = num(3): EXIT SUB - exp$ = LTRIM$(N2S(DWD(LEFT$(exp$, s) + RTRIM$(LTRIM$(num(3))) + MID$(exp$, E + 1)))) - END IF - op = 0 - LOOP - NEXT - -END SUB - - - -SUB Set_OrderOfOperations - 'PL sets our priortity level. 1 is highest to 65535 for the lowest. - 'I used a range here so I could add in new priority levels as needed. - 'OName ended up becoming the name of our commands, as I modified things.... Go figure! LOL! - REDIM OName(10000) AS STRING, PL(10000) AS INTEGER - 'Constants get evaluated first, with a Priority Level of 1 - - i = i + 1: OName(i) = "C_UOF": PL(i) = 5 'convert to unsigned offset - i = i + 1: OName(i) = "C_OF": PL(i) = 5 'convert to offset - i = i + 1: OName(i) = "C_UBY": PL(i) = 5 'convert to unsigned byte - i = i + 1: OName(i) = "C_BY": PL(i) = 5 'convert to byte - i = i + 1: OName(i) = "C_UIN": PL(i) = 5 'convert to unsigned integer - i = i + 1: OName(i) = "C_IN": PL(i) = 5 'convert to integer - i = i + 1: OName(i) = "C_UIF": PL(i) = 5 'convert to unsigned int64 - i = i + 1: OName(i) = "C_IF": PL(i) = 5 'convert to int64 - i = i + 1: OName(i) = "C_ULO": PL(i) = 5 'convert to unsigned long - i = i + 1: OName(i) = "C_LO": PL(i) = 5 'convert to long - i = i + 1: OName(i) = "C_SI": PL(i) = 5 'convert to single - i = i + 1: OName(i) = "C_FL": PL(i) = 5 'convert to float - i = i + 1: OName(i) = "C_DO": PL(i) = 5 'convert to double - i = i + 1: OName(i) = "C_UBI": PL(i) = 5 'convert to unsigned bit - i = i + 1: OName(i) = "C_BI": PL(i) = 5 'convert to bit - - 'Then Functions with PL 10 - i = i + 1:: OName(i) = "_PI": PL(i) = 10 - i = i + 1: OName(i) = "_ACOS": PL(i) = 10 - i = i + 1: OName(i) = "_ASIN": PL(i) = 10 - i = i + 1: OName(i) = "_ARCSEC": PL(i) = 10 - i = i + 1: OName(i) = "_ARCCSC": PL(i) = 10 - i = i + 1: OName(i) = "_ARCCOT": PL(i) = 10 - i = i + 1: OName(i) = "_SECH": PL(i) = 10 - i = i + 1: OName(i) = "_CSCH": PL(i) = 10 - i = i + 1: OName(i) = "_COTH": PL(i) = 10 - i = i + 1: OName(i) = "COS": PL(i) = 10 - i = i + 1: OName(i) = "SIN": PL(i) = 10 - i = i + 1: OName(i) = "TAN": PL(i) = 10 - i = i + 1: OName(i) = "LOG": PL(i) = 10 - i = i + 1: OName(i) = "EXP": PL(i) = 10 - i = i + 1: OName(i) = "ATN": PL(i) = 10 - i = i + 1: OName(i) = "_D2R": PL(i) = 10 - i = i + 1: OName(i) = "_D2G": PL(i) = 10 - i = i + 1: OName(i) = "_R2D": PL(i) = 10 - i = i + 1: OName(i) = "_R2G": PL(i) = 10 - i = i + 1: OName(i) = "_G2D": PL(i) = 10 - i = i + 1: OName(i) = "_G2R": PL(i) = 10 - i = i + 1: OName(i) = "ABS": PL(i) = 10 - i = i + 1: OName(i) = "SGN": PL(i) = 10 - i = i + 1: OName(i) = "INT": PL(i) = 10 - i = i + 1: OName(i) = "_ROUND": PL(i) = 10 - i = i + 1: OName(i) = "_CEIL": PL(i) = 10 - i = i + 1: OName(i) = "FIX": PL(i) = 10 - i = i + 1: OName(i) = "_SEC": PL(i) = 10 - i = i + 1: OName(i) = "_CSC": PL(i) = 10 - i = i + 1: OName(i) = "_COT": PL(i) = 10 - i = i + 1: OName(i) = "ASC": PL(i) = 10 - i = i + 1: OName(i) = "C_RG": PL(i) = 10 '_RGB32 converted - i = i + 1: OName(i) = "C_RA": PL(i) = 10 '_RGBA32 converted - i = i + 1: OName(i) = "_RGB": PL(i) = 10 - i = i + 1: OName(i) = "_RGBA": PL(i) = 10 - i = i + 1: OName(i) = "C_RX": PL(i) = 10 '_RED32 converted - i = i + 1: OName(i) = "C_GR": PL(i) = 10 ' _GREEN32 converted - i = i + 1: OName(i) = "C_BL": PL(i) = 10 '_BLUE32 converted - i = i + 1: OName(i) = "C_AL": PL(i) = 10 '_ALPHA32 converted - i = i + 1: OName(i) = "_RED": PL(i) = 10 - i = i + 1: OName(i) = "_GREEN": PL(i) = 10 - i = i + 1: OName(i) = "_BLUE": PL(i) = 10 - i = i + 1: OName(i) = "_ALPHA": PL(i) = 10 - - 'Exponents with PL 20 - i = i + 1: OName(i) = "^": PL(i) = 20 - i = i + 1: OName(i) = "SQR": PL(i) = 20 - i = i + 1: OName(i) = "ROOT": PL(i) = 20 - 'Multiplication and Division PL 30 - i = i + 1: OName(i) = "*": PL(i) = 30 - i = i + 1: OName(i) = "/": PL(i) = 30 - 'Integer Division PL 40 - i = i + 1: OName(i) = "\": PL(i) = 40 - 'MOD PL 50 - i = i + 1: OName(i) = "MOD": PL(i) = 50 - 'Addition and Subtraction PL 60 - i = i + 1: OName(i) = "+": PL(i) = 60 - i = i + 1: OName(i) = "-": PL(i) = 60 - - 'Relational Operators =, >, <, <>, <=, >= PL 70 - i = i + 1: OName(i) = "<>": PL(i) = 70 'These next three are just reversed symbols as an attempt to help process a common typo - i = i + 1: OName(i) = "><": PL(i) = 70 - i = i + 1: OName(i) = "<=": PL(i) = 70 - i = i + 1: OName(i) = ">=": PL(i) = 70 - i = i + 1: OName(i) = "=<": PL(i) = 70 'I personally can never keep these things straight. Is it < = or = <... - i = i + 1: OName(i) = "=>": PL(i) = 70 'Who knows, check both! - i = i + 1: OName(i) = ">": PL(i) = 70 - i = i + 1: OName(i) = "<": PL(i) = 70 - i = i + 1: OName(i) = "=": PL(i) = 70 - 'Logical Operations PL 80+ - i = i + 1: OName(i) = "NOT": PL(i) = 80 - i = i + 1: OName(i) = "AND": PL(i) = 90 - i = i + 1: OName(i) = "OR": PL(i) = 100 - i = i + 1: OName(i) = "XOR": PL(i) = 110 - i = i + 1: OName(i) = "EQV": PL(i) = 120 - i = i + 1: OName(i) = "IMP": PL(i) = 130 - i = i + 1: OName(i) = ",": PL(i) = 1000 - - REDIM _PRESERVE OName(i) AS STRING, PL(i) AS INTEGER -END SUB - -FUNCTION EvaluateNumbers$ (p, num() AS STRING) - DIM n1 AS _FLOAT, n2 AS _FLOAT, n3 AS _FLOAT - 'PRINT "EVALNUM:"; OName(p), num(1), num(2) - - IF _TRIM$(num(1)) = "" THEN num(1) = "0" - - IF PL(p) >= 20 AND (LEN(_TRIM$(num(1))) = 0 OR LEN(_TRIM$(num(2))) = 0) THEN - EvaluateNumbers$ = "ERROR - Missing operand": EXIT FUNCTION - END IF - - IF INSTR(num(1), ",") THEN - EvaluateNumbers$ = "ERROR - Invalid comma (" + num(1) + ")": EXIT FUNCTION - END IF - l2 = INSTR(num(2), ",") - IF l2 THEN - SELECT CASE OName(p) 'only certain commands should pass a comma value - CASE "C_RG", "C_RA", "_RGB", "_RGBA", "_RED", "_GREEN", "C_BL", "_ALPHA" - CASE ELSE - C$ = MID$(num(2), l2) - num(2) = LEFT$(num(2), l2 - 1) - END SELECT - END IF - - SELECT CASE PL(p) 'divide up the work so we want do as much case checking - CASE 5 'Type conversions - 'Note, these are special cases and work with the number BEFORE the command and not after - SELECT CASE OName(p) 'Depending on our operator.. - CASE "C_UOF": n1~%& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%&))) - CASE "C_ULO": n1%& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%&))) - CASE "C_UBY": n1~%% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%%))) - CASE "C_UIN": n1~% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%))) - CASE "C_BY": n1%% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%%))) - CASE "C_IN": n1% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%))) - CASE "C_UIF": n1~&& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~&&))) - CASE "C_OF": n1~& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~&))) - CASE "C_IF": n1&& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1&&))) - CASE "C_LO": n1& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1&))) - CASE "C_UBI": n1~` = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~`))) - CASE "C_BI": n1` = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1`))) - CASE "C_FL": n1## = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1##))) - CASE "C_DO": n1# = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1#))) - CASE "C_SI": n1! = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1!))) - END SELECT - EXIT FUNCTION - CASE 10 'functions - SELECT CASE OName(p) 'Depending on our operator.. - CASE "_PI" - n1 = 3.14159265358979323846264338327950288## 'Future compatable in case something ever stores extra digits for PI - IF num(2) <> "" THEN n1 = n1 * VAL(num(2)) - CASE "_ACOS": n1 = _ACOS(VAL(num(2))) - CASE "_ASIN": n1 = _ASIN(VAL(num(2))) - CASE "_ARCSEC": n1 = _ARCSEC(VAL(num(2))) - CASE "_ARCCSC": n1 = _ARCCSC(VAL(num(2))) - CASE "_ARCCOT": n1 = _ARCCOT(VAL(num(2))) - CASE "_SECH": n1 = _SECH(VAL(num(2))) - CASE "_CSCH": n1 = _CSCH(VAL(num(2))) - CASE "_COTH": n1 = _COTH(VAL(num(2))) - CASE "C_RG" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGB32": EXIT FUNCTION - c1 = INSTR(n$, ",") - IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") - IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") - IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") - IF c1 = 0 THEN 'there's no comma in the command to parse. It's a grayscale value - n = VAL(num(2)) - n1 = _RGB32(n, n, n) - ELSEIF c2 = 0 THEN 'there's one comma and not 2. It's grayscale with alpha. - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n1 = _RGBA32(n, n, n, n2) - ELSEIF c3 = 0 THEN 'there's two commas. It's _RGB values - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n3 = VAL(MID$(num(2), c2 + 1)) - n1 = _RGB32(n, n2, n3) - ELSEIF c4 = 0 THEN 'there's three commas. It's _RGBA values - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n3 = VAL(MID$(num(2), c2 + 1)) - n4 = VAL(MID$(num(2), c3 + 1)) - n1 = _RGBA32(n, n2, n3, n4) - ELSE 'we have more than three commas. I have no idea WTH type of values got passed here! - EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + ")": EXIT FUNCTION - END IF - CASE "C_RA" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGBA32": EXIT FUNCTION - c1 = INSTR(n$, ",") - IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") - IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") - IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") - IF c3 = 0 OR c4 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + ")": EXIT FUNCTION - 'we have to have 3 commas; not more, not less. - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n3 = VAL(MID$(num(2), c2 + 1)) - n4 = VAL(MID$(num(2), c3 + 1)) - n1 = _RGBA32(n, n2, n3, n4) - CASE "_RGB" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGB": EXIT FUNCTION - c1 = INSTR(n$, ",") - IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") - IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") - IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") - IF c3 = 0 OR c4 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + "). _RGB requires 4 parameters for Red, Green, Blue, ScreenMode.": EXIT FUNCTION - 'we have to have 3 commas; not more, not less. - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n3 = VAL(MID$(num(2), c2 + 1)) - n4 = VAL(MID$(num(2), c3 + 1)) - SELECT CASE n4 - CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values - CASE ELSE - EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n4) + ")": EXIT FUNCTION - END SELECT - t = _NEWIMAGE(1, 1, n4) - n1 = _RGB(n, n2, n3, t) - _FREEIMAGE t - CASE "_RGBA" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGBA": EXIT FUNCTION - c1 = INSTR(n$, ",") - IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") - IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") - IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") - IF c4 THEN c5 = INSTR(c4 + 1, n$, ",") - IF c4 = 0 OR c5 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + "). _RGBA requires 5 parameters for Red, Green, Blue, Alpha, ScreenMode.": EXIT FUNCTION - 'we have to have 4 commas; not more, not less. - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - n3 = VAL(MID$(num(2), c2 + 1)) - n4 = VAL(MID$(num(2), c3 + 1)) - n5 = VAL(MID$(num(2), c4 + 1)) - SELECT CASE n5 - CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values - CASE ELSE - EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n5) + ")": EXIT FUNCTION - END SELECT - t = _NEWIMAGE(1, 1, n5) - n1 = _RGBA(n, n2, n3, n4, t) - _FREEIMAGE t - CASE "_RED", "_GREEN", "_BLUE", "_ALPHA" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null " + OName(p): EXIT FUNCTION - c1 = INSTR(n$, ",") - IF c1 = 0 THEN EvaluateNumbers$ = "ERROR - " + OName(p) + " requires 2 parameters for Color, ScreenMode.": EXIT FUNCTION - IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") - IF c2 THEN EvaluateNumbers$ = "ERROR - " + OName(p) + " requires 2 parameters for Color, ScreenMode.": EXIT FUNCTION - n = VAL(LEFT$(num(2), c1)) - n2 = VAL(MID$(num(2), c1 + 1)) - SELECT CASE n2 - CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values - CASE ELSE - EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n2) + ")": EXIT FUNCTION - END SELECT - t = _NEWIMAGE(1, 1, n4) - SELECT CASE OName(p) - CASE "_RED": n1 = _RED(n, t) - CASE "_BLUE": n1 = _BLUE(n, t) - CASE "_GREEN": n1 = _GREEN(n, t) - CASE "_ALPHA": n1 = _ALPHA(n, t) - END SELECT - _FREEIMAGE t - CASE "C_RX", "C_GR", "C_BL", "C_AL" - n$ = num(2) - IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null " + OName(p): EXIT FUNCTION - n = VAL(num(2)) - SELECT CASE OName(p) - CASE "C_RX": n1 = _RED32(n) - CASE "C_BL": n1 = _BLUE32(n) - CASE "C_GR": n1 = _GREEN32(n) - CASE "C_AL": n1 = _ALPHA32(n) - END SELECT - CASE "COS": n1 = COS(VAL(num(2))) - CASE "SIN": n1 = SIN(VAL(num(2))) - CASE "TAN": n1 = TAN(VAL(num(2))) - CASE "LOG": n1 = LOG(VAL(num(2))) - CASE "EXP": n1 = EXP(VAL(num(2))) - CASE "ATN": n1 = ATN(VAL(num(2))) - CASE "_D2R": n1 = 0.0174532925 * (VAL(num(2))) - CASE "_D2G": n1 = 1.1111111111 * (VAL(num(2))) - CASE "_R2D": n1 = 57.2957795 * (VAL(num(2))) - CASE "_R2G": n1 = 0.015707963 * (VAL(num(2))) - CASE "_G2D": n1 = 0.9 * (VAL(num(2))) - CASE "_G2R": n1 = 63.661977237 * (VAL(num(2))) - CASE "ABS": n1 = ABS(VAL(num(2))) - CASE "SGN": n1 = SGN(VAL(num(2))) - CASE "INT": n1 = INT(VAL(num(2))) - CASE "_ROUND": n1 = _ROUND(VAL(num(2))) - CASE "_CEIL": n1 = _CEIL(VAL(num(2))) - CASE "FIX": n1 = FIX(VAL(num(2))) - CASE "_SEC": n1 = _SEC(VAL(num(2))) - CASE "_CSC": n1 = _CSC(VAL(num(2))) - CASE "_COT": n1 = _COT(VAL(num(2))) - END SELECT - CASE 20 TO 60 'Math Operators - SELECT CASE OName(p) 'Depending on our operator.. - CASE "^": n1 = VAL(num(1)) ^ VAL(num(2)) - CASE "SQR": n1 = SQR(VAL(num(2))) - CASE "ROOT" - n1 = VAL(num(1)): n2 = VAL(num(2)) - IF n2 = 1 THEN EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1))): EXIT FUNCTION - IF n1 < 0 AND n2 >= 1 THEN sign = -1: n1 = -n1 ELSE sign = 1 - n3 = 1## / n2 - IF n3 <> INT(n3) AND n2 < 1 THEN sign = SGN(n1): n1 = ABS(n1) - n1 = sign * (n1 ^ n3) - CASE "*": n1 = VAL(num(1)) * VAL(num(2)) - CASE "/" - IF VAL(num(2)) <> 0 THEN - n1 = VAL(num(1)) / VAL(num(2)) - ELSE - EvaluateNumbers$ = "ERROR - Division By Zero" - EXIT FUNCTION - END IF - CASE "\" - IF FIX(VAL(num(2))) = 0 THEN - EvaluateNumbers$ = "ERROR - Division By Zero" - EXIT FUNCTION - END IF - - n1 = VAL(num(1)) \ FIX(VAL(num(2))) - CASE "MOD" - IF FIX(VAL(num(2))) = 0 THEN - EvaluateNumbers$ = "ERROR - Division By Zero" - EXIT FUNCTION - END IF - - n1 = VAL(num(1)) MOD FIX(VAL(num(2))) - - CASE "+": n1 = VAL(num(1)) + VAL(num(2)) - CASE "-": - n1 = VAL(num(1)) - VAL(num(2)) - END SELECT - CASE 70 'Relational Operators =, >, <, <>, <=, >= - SELECT CASE OName(p) 'Depending on our operator.. - CASE "=": n1 = VAL(num(1)) = VAL(num(2)) - CASE ">": n1 = VAL(num(1)) > VAL(num(2)) - CASE "<": n1 = VAL(num(1)) < VAL(num(2)) - CASE "<>", "><": n1 = VAL(num(1)) <> VAL(num(2)) - CASE "<=", "=<": n1 = VAL(num(1)) <= VAL(num(2)) - CASE ">=", "=>": n1 = VAL(num(1)) >= VAL(num(2)) - END SELECT - CASE ELSE 'a value we haven't processed elsewhere - SELECT CASE OName(p) 'Depending on our operator.. - CASE "NOT": n1 = NOT VAL(num(2)) - CASE "AND": n1 = VAL(num(1)) AND VAL(num(2)) - CASE "OR": n1 = VAL(num(1)) OR VAL(num(2)) - CASE "XOR": n1 = VAL(num(1)) XOR VAL(num(2)) - CASE "EQV": n1 = VAL(num(1)) EQV VAL(num(2)) - CASE "IMP": n1 = VAL(num(1)) IMP VAL(num(2)) - END SELECT - END SELECT - - EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1))) + C$ -END FUNCTION - -FUNCTION DWD$ (exp$) 'Deal With Duplicates - 'To deal with duplicate operators in our code. - 'Such as -- becomes a + - '++ becomes a + - '+- becomes a - - '-+ becomes a - - t$ = exp$ - DO - bad = 0 - DO - l = INSTR(t$, "++") - IF l THEN t$ = LEFT$(t$, l - 1) + "+" + MID$(t$, l + 2): bad = -1 - LOOP UNTIL l = 0 - DO - l = INSTR(t$, "+-") - IF l THEN t$ = LEFT$(t$, l - 1) + "-" + MID$(t$, l + 2): bad = -1 - LOOP UNTIL l = 0 - DO - l = INSTR(t$, "-+") - IF l THEN t$ = LEFT$(t$, l - 1) + "-" + MID$(t$, l + 2): bad = -1 - LOOP UNTIL l = 0 - DO - l = INSTR(t$, "--") - IF l THEN t$ = LEFT$(t$, l - 1) + "+" + MID$(t$, l + 2): bad = -1 - LOOP UNTIL l = 0 - LOOP UNTIL NOT bad - DWD$ = t$ -END FUNCTION - -SUB PreParse (e$) - DIM f AS _FLOAT - STATIC TotalPrefixedPP_TypeMod AS LONG, TotalPP_TypeMod AS LONG - - IF PP_TypeMod(0) = "" THEN - REDIM PP_TypeMod(100) AS STRING, PP_ConvertedMod(100) AS STRING 'Large enough to hold all values to begin with - PP_TypeMod(0) = "Initialized" 'Set so we don't do this section over and over, as we keep the values in shared memory. - 'and the below is a conversion list so symbols don't get cross confused. - i = i + 1: PP_TypeMod(i) = "~`": PP_ConvertedMod(i) = "C_UBI" 'unsigned bit - i = i + 1: PP_TypeMod(i) = "~%%": PP_ConvertedMod(i) = "C_UBY" 'unsigned byte - i = i + 1: PP_TypeMod(i) = "~%&": PP_ConvertedMod(i) = "C_UOF" 'unsigned offset - i = i + 1: PP_TypeMod(i) = "~%": PP_ConvertedMod(i) = "C_UIN" 'unsigned integer - i = i + 1: PP_TypeMod(i) = "~&&": PP_ConvertedMod(i) = "C_UIF" 'unsigned integer64 - i = i + 1: PP_TypeMod(i) = "~&": PP_ConvertedMod(i) = "C_ULO" 'unsigned long - i = i + 1: PP_TypeMod(i) = "`": PP_ConvertedMod(i) = "C_BI" 'bit - i = i + 1: PP_TypeMod(i) = "%%": PP_ConvertedMod(i) = "C_BY" 'byte - i = i + 1: PP_TypeMod(i) = "%&": PP_ConvertedMod(i) = "C_OF" 'offset - i = i + 1: PP_TypeMod(i) = "%": PP_ConvertedMod(i) = "C_IN" 'integer - i = i + 1: PP_TypeMod(i) = "&&": PP_ConvertedMod(i) = "C_IF" 'integer64 - i = i + 1: PP_TypeMod(i) = "&": PP_ConvertedMod(i) = "C_LO" 'long - i = i + 1: PP_TypeMod(i) = "!": PP_ConvertedMod(i) = "C_SI" 'single - i = i + 1: PP_TypeMod(i) = "##": PP_ConvertedMod(i) = "C_FL" 'float - i = i + 1: PP_TypeMod(i) = "#": PP_ConvertedMod(i) = "C_DO" 'double - i = i + 1: PP_TypeMod(i) = "_RGB32": PP_ConvertedMod(i) = "C_RG" 'rgb32 - i = i + 1: PP_TypeMod(i) = "_RGBA32": PP_ConvertedMod(i) = "C_RA" 'rgba32 - i = i + 1: PP_TypeMod(i) = "_RED32": PP_ConvertedMod(i) = "C_RX" 'red32 - i = i + 1: PP_TypeMod(i) = "_GREEN32": PP_ConvertedMod(i) = "C_GR" 'green32 - i = i + 1: PP_TypeMod(i) = "_BLUE32": PP_ConvertedMod(i) = "C_BL" 'blue32 - i = i + 1: PP_TypeMod(i) = "_ALPHA32": PP_ConvertedMod(i) = "C_AL" 'alpha32 - TotalPrefixedPP_TypeMod = i - i = i + 1: PP_TypeMod(i) = "RGB32": PP_ConvertedMod(i) = "C_RG" 'rgb32 - i = i + 1: PP_TypeMod(i) = "RGBA32": PP_ConvertedMod(i) = "C_RA" 'rgba32 - i = i + 1: PP_TypeMod(i) = "RED32": PP_ConvertedMod(i) = "C_RX" 'red32 - i = i + 1: PP_TypeMod(i) = "GREEN32": PP_ConvertedMod(i) = "C_GR" 'green32 - i = i + 1: PP_TypeMod(i) = "BLUE32": PP_ConvertedMod(i) = "C_BL" 'blue32 - i = i + 1: PP_TypeMod(i) = "ALPHA32": PP_ConvertedMod(i) = "C_AL" 'alpha32 - TotalPP_TypeMod = i - REDIM _PRESERVE PP_TypeMod(i) AS STRING, PP_ConvertedMod(i) AS STRING 'And then resized to just contain the necessary space in memory - END IF - t$ = e$ - - 'First strip all spaces - t$ = "" - FOR i = 1 TO LEN(e$) - IF MID$(e$, i, 1) <> " " THEN t$ = t$ + MID$(e$, i, 1) - NEXT - - t$ = UCASE$(t$) - IF t$ = "" THEN e$ = "ERROR -- NULL string; nothing to evaluate": EXIT SUB - - 'ERROR CHECK by counting our brackets - l = 0 - DO - l = INSTR(l + 1, t$, "("): IF l THEN c = c + 1 - LOOP UNTIL l = 0 - l = 0 - DO - l = INSTR(l + 1, t$, ")"): IF l THEN c1 = c1 + 1 - LOOP UNTIL l = 0 - IF c <> c1 THEN e$ = "ERROR -- Bad Parenthesis:" + STR$(c) + "( vs" + STR$(c1) + ")": EXIT SUB - - 'replace existing CONST values - sep$ = "()+-*/\><=^" - FOR i2 = 0 TO constlast - thisConstName$ = constname(i2) - FOR replaceConstPass = 1 TO 2 - found = 0 - DO - found = INSTR(found + 1, UCASE$(t$), thisConstName$) - IF found THEN - IF found > 1 THEN - IF INSTR(sep$, MID$(t$, found - 1, 1)) = 0 THEN _CONTINUE - END IF - IF found + LEN(thisConstName$) <= LEN(t$) THEN - IF INSTR(sep$, MID$(t$, found + LEN(thisConstName$), 1)) = 0 THEN _CONTINUE - END IF - t = consttype(i2) - IF t AND ISSTRING THEN - r$ = conststring(i2) - i4 = _INSTRREV(r$, ",") - r$ = LEFT$(r$, i4 - 1) - ELSE - IF t AND ISFLOAT THEN - r$ = STR$(constfloat(i2)) - r$ = N2S(r$) - ELSE - IF t AND ISUNSIGNED THEN r$ = STR$(constuinteger(i2)) ELSE r$ = STR$(constinteger(i2)) - END IF - END IF - t$ = LEFT$(t$, found - 1) + _TRIM$(r$) + MID$(t$, found + LEN(thisConstName$)) - END IF - LOOP UNTIL found = 0 - thisConstName$ = constname(i2) + constnamesymbol(i2) - NEXT - NEXT - - 'Modify so that NOT will process properly - l = 0 - DO - l = INSTR(l + 1, t$, "NOT ") - IF l THEN - 'We need to work magic on the statement so it looks pretty. - ' 1 + NOT 2 + 1 is actually processed as 1 + (NOT 2 + 1) - 'Look for something not proper - l1 = INSTR(l + 1, t$, "AND") - IF l1 = 0 OR (INSTR(l + 1, t$, "OR") > 0 AND INSTR(l + 1, t$, "OR") < l1) THEN l1 = INSTR(l + 1, t$, "OR") - IF l1 = 0 OR (INSTR(l + 1, t$, "XOR") > 0 AND INSTR(l + 1, t$, "XOR") < l1) THEN l1 = INSTR(l + 1, t$, "XOR") - IF l1 = 0 OR (INSTR(l + 1, t$, "EQV") > 0 AND INSTR(l + 1, t$, "EQV") < l1) THEN l1 = INSTR(l + 1, t$, "EQV") - IF l1 = 0 OR (INSTR(l + 1, t$, "IMP") > 0 AND INSTR(l + 1, t$, "IMP") < l1) THEN l1 = INSTR(l + 1, t$, "IMP") - IF l1 = 0 THEN l1 = LEN(t$) + 1 - t$ = LEFT$(t$, l - 1) + "(" + MID$(t$, l, l1 - l) + ")" + MID$(t$, l + l1 - l) - l = l + 3 - 'PRINT t$ - END IF - LOOP UNTIL l = 0 - - uboundPP_TypeMod = TotalPrefixedPP_TypeMod - IF qb64prefix_set = 1 THEN uboundPP_TypeMod = TotalPP_TypeMod - FOR j = 1 TO uboundPP_TypeMod - l = 0 - DO - l = INSTR(l + 1, t$, PP_TypeMod(j)) - IF l = 0 THEN EXIT DO - i = 0: l1 = 0: l2 = 0: lo = LEN(PP_TypeMod(j)) - DO - IF PL(i) > 10 THEN - l2 = _INSTRREV(l, t$, OName$(i)) - IF l2 > 0 AND l2 > l1 THEN l1 = l2 - END IF - i = i + lo - LOOP UNTIL i > UBOUND(PL) - l$ = LEFT$(t$, l1) - m$ = MID$(t$, l1 + 1, l - l1 - 1) - r$ = PP_ConvertedMod(j) + MID$(t$, l + lo) - IF j > 15 THEN - t$ = l$ + m$ + r$ 'replacement routine for commands which might get confused with others, like _RGB and _RGB32 - ELSE - 'the first 15 commands need to properly place the parenthesis around the value we want to convert. - t$ = l$ + "(" + m$ + ")" + r$ - END IF - l = l + 2 + LEN(PP_TypeMod(j)) 'move forward from the length of the symbol we checked + the new "(" and ")" - LOOP - NEXT - - 'Check for bad operators before a ( bracket - l = 0 - DO - l = INSTR(l + 1, t$, "(") - IF l > 0 AND l > 2 THEN 'Don't check the starting bracket; there's nothing before it. - good = 0 - FOR i = 1 TO UBOUND(OName) - m$ = MID$(t$, l - LEN(OName(i)), LEN(OName(i))) - IF m$ = OName(i) THEN - good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) - ELSE - IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN - 'try without prefix - m$ = MID$(t$, l - (LEN(OName(i)) - 1), LEN(OName(i)) - 1) - IF m$ = MID$(OName(i), 2) THEN good = -1: EXIT FOR - END IF - END IF - NEXT - IF NOT good THEN e$ = "ERROR - Improper operations before (.": EXIT SUB - l = l + 1 - END IF - LOOP UNTIL l = 0 - - 'Check for bad operators after a ) bracket - l = 0 - DO - l = INSTR(l + 1, t$, ")") - IF l > 0 AND l < LEN(t$) THEN - good = 0 - FOR i = 1 TO UBOUND(OName) - m$ = MID$(t$, l + 1, LEN(OName(i))) - IF m$ = OName(i) THEN - good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI - ELSE - IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN - 'try without prefix - m$ = MID$(t$, l + 1, LEN(OName(i)) - 1) - IF m$ = MID$(OName(i), 2) THEN good = -1: EXIT FOR - END IF - END IF - NEXT - IF MID$(t$, l + 1, 1) = ")" THEN good = -1 - IF NOT good THEN e$ = "ERROR - Improper operations after ).": EXIT SUB - l = l + 1 - END IF - LOOP UNTIL l = 0 OR l = LEN(t$) 'last symbol is a bracket - - 'Turn all &H (hex) numbers into decimal values for the program to process properly - l = 0 - DO - l = INSTR(t$, "&H") - IF l THEN - E = l + 1: finished = 0 - DO - E = E + 1 - comp$ = MID$(t$, E, 1) - SELECT CASE comp$ - CASE "0" TO "9", "A" TO "F" 'All is good, our next digit is a number, continue to add to the hex$ - CASE ELSE - good = 0 - FOR i = 1 TO UBOUND(OName) - IF MID$(t$, E, LEN(OName(i))) = OName(i) AND PL(i) > 1 AND PL(i) <= 250 THEN good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) - NEXT - IF NOT good THEN e$ = "ERROR - Improper &H value. (" + comp$ + ")": EXIT SUB - E = E - 1 - finished = -1 - END SELECT - LOOP UNTIL finished OR E = LEN(t$) - t$ = LEFT$(t$, l - 1) + LTRIM$(RTRIM$(STR$(VAL(MID$(t$, l, E - l + 1))))) + MID$(t$, E + 1) - END IF - LOOP UNTIL l = 0 - - 'Turn all &B (binary) numbers into decimal values for the program to process properly - l = 0 - DO - l = INSTR(t$, "&B") - IF l THEN - E = l + 1: finished = 0 - DO - E = E + 1 - comp$ = MID$(t$, E, 1) - SELECT CASE comp$ - CASE "0", "1" 'All is good, our next digit is a number, continue to add to the hex$ - CASE ELSE - good = 0 - FOR i = 1 TO UBOUND(OName) - IF MID$(t$, E, LEN(OName(i))) = OName(i) AND PL(i) > 1 AND PL(i) <= 250 THEN good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) - NEXT - IF NOT good THEN e$ = "ERROR - Improper &B value. (" + comp$ + ")": EXIT SUB - E = E - 1 - finished = -1 - END SELECT - LOOP UNTIL finished OR E = LEN(t$) - bin$ = MID$(t$, l + 2, E - l - 1) - FOR i = 1 TO LEN(bin$) - IF MID$(bin$, i, 1) = "1" THEN f = f + 2 ^ (LEN(bin$) - i) - NEXT - t$ = LEFT$(t$, l - 1) + LTRIM$(RTRIM$(STR$(f))) + MID$(t$, E + 1) - END IF - LOOP UNTIL l = 0 - - - 't$ = N2S(t$) - VerifyString t$ - e$ = t$ -END SUB - - - -SUB VerifyString (t$) - 'ERROR CHECK for unrecognized operations - j = 1 - DO - comp$ = MID$(t$, j, 1) - SELECT CASE comp$ - CASE "0" TO "9", ".", "(", ")", ",": j = j + 1 - CASE ELSE - good = 0 - extrachar = 0 - FOR i = 1 TO UBOUND(OName) - IF MID$(t$, j, LEN(OName(i))) = OName(i) THEN - good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) - ELSE - IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN - 'try without prefix - IF MID$(t$, j, LEN(OName(i)) - 1) = MID$(OName(i), 2) THEN - good = -1: extrachar = 1: EXIT FOR - END IF - END IF - END IF - NEXT - IF NOT good THEN t$ = "ERROR - Bad Operational value. (" + comp$ + ")": EXIT SUB - j = j + (LEN(OName(i)) - extrachar) - END SELECT - LOOP UNTIL j > LEN(t$) -END SUB - -FUNCTION N2S$ (exp$) 'scientific Notation to String - - t$ = LTRIM$(RTRIM$(exp$)) - IF LEFT$(t$, 1) = "-" OR LEFT$(t$, 1) = "N" THEN sign$ = "-": t$ = MID$(t$, 2) - - dp = INSTR(t$, "D+"): dm = INSTR(t$, "D-") - ep = INSTR(t$, "E+"): em = INSTR(t$, "E-") - check1 = SGN(dp) + SGN(dm) + SGN(ep) + SGN(em) - IF check1 < 1 OR check1 > 1 THEN N2S = exp$: EXIT FUNCTION 'If no scientic notation is found, or if we find more than 1 type, it's not SN! - - SELECT CASE l 'l now tells us where the SN starts at. - CASE IS < dp: l = dp - CASE IS < dm: l = dm - CASE IS < ep: l = ep - CASE IS < em: l = em - END SELECT - - l$ = LEFT$(t$, l - 1) 'The left of the SN - r$ = MID$(t$, l + 1): r&& = VAL(r$) 'The right of the SN, turned into a workable long - - - IF INSTR(l$, ".") THEN 'Location of the decimal, if any - IF r&& > 0 THEN - r&& = r&& - LEN(l$) + 2 - ELSE - r&& = r&& + 1 - END IF - l$ = LEFT$(l$, 1) + MID$(l$, 3) - END IF - - SELECT CASE r&& - CASE 0 'what the heck? We solved it already? - 'l$ = l$ - CASE IS < 0 - FOR i = 1 TO -r&& - l$ = "0" + l$ - NEXT - l$ = "0." + l$ - CASE ELSE - FOR i = 1 TO r&& - l$ = l$ + "0" - NEXT - END SELECT - - N2S$ = sign$ + l$ -END FUNCTION - - -FUNCTION QuotedFilename$ (f$) - - IF os$ = "WIN" THEN - QuotedFilename$ = CHR$(34) + f$ + CHR$(34) - EXIT FUNCTION - END IF - - IF os$ = "LNX" THEN - QuotedFilename$ = "'" + f$ + "'" - EXIT FUNCTION - END IF - -END FUNCTION - - -FUNCTION HashValue& (a$) 'returns the hash table value of a string - '[5(first)][5(second)][5(last)][5(2nd-last)][3(length AND 7)][1(first char is underscore)] - l = LEN(a$) - IF l = 0 THEN EXIT FUNCTION 'an (invalid) NULL string equates to 0 - a = ASC(a$) - IF a <> 95 THEN 'does not begin with underscore - SELECT CASE l - CASE 1 - HashValue& = hash1char(a) + 1048576 - EXIT FUNCTION - CASE 2 - HashValue& = hash2char(CVI(a$)) + 2097152 - EXIT FUNCTION - CASE 3 - HashValue& = hash2char(CVI(a$)) + hash1char(ASC(a$, 3)) * 1024 + 3145728 - EXIT FUNCTION - CASE ELSE - HashValue& = hash2char(CVI(a$)) + hash2char(ASC(a$, l) + ASC(a$, l - 1) * 256) * 1024 + (l AND 7) * 1048576 - EXIT FUNCTION - END SELECT - ELSE 'does begin with underscore - SELECT CASE l - CASE 1 - HashValue& = (1048576 + 8388608): EXIT FUNCTION 'note: underscore only is illegal in QB64 but supported by hash - CASE 2 - HashValue& = hash1char(ASC(a$, 2)) + (2097152 + 8388608) - EXIT FUNCTION - CASE 3 - HashValue& = hash2char(ASC(a$, 2) + ASC(a$, 3) * 256) + (3145728 + 8388608) - EXIT FUNCTION - CASE 4 - HashValue& = hash2char((CVL(a$) AND &HFFFF00) \ 256) + hash1char(ASC(a$, 4)) * 1024 + (4194304 + 8388608) - EXIT FUNCTION - CASE ELSE - HashValue& = hash2char((CVL(a$) AND &HFFFF00) \ 256) + hash2char(ASC(a$, l) + ASC(a$, l - 1) * 256) * 1024 + (l AND 7) * 1048576 + 8388608 - EXIT FUNCTION - END SELECT - END IF -END FUNCTION - -SUB HashAdd (a$, flags, reference) - - 'find the index to use - IF HashListFreeLast > 0 THEN - 'take from free list - i = HashListFree(HashListFreeLast) - HashListFreeLast = HashListFreeLast - 1 - ELSE - IF HashListNext > HashListSize THEN - 'double hash list size - HashListSize = HashListSize * 2 - REDIM _PRESERVE HashList(1 TO HashListSize) AS HashListItem - REDIM _PRESERVE HashListName(1 TO HashListSize) AS STRING * 256 - END IF - i = HashListNext - HashListNext = HashListNext + 1 - END IF - - 'setup links to index - x = HashValue(a$) - i2 = HashTable(x) - IF i2 THEN - i3 = HashList(i2).LastItem - HashList(i2).LastItem = i - HashList(i3).NextItem = i - HashList(i).PrevItem = i3 - ELSE - HashTable(x) = i - HashList(i).PrevItem = 0 - HashList(i).LastItem = i - END IF - HashList(i).NextItem = 0 - - 'set common hashlist values - HashList(i).Flags = flags - HashList(i).Reference = reference - HashListName(i) = UCASE$(a$) - -END SUB - -FUNCTION HashFind (a$, searchflags, resultflags, resultreference) - '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) - '0=doesn't exist - '1=found, no more items to scan - '2=found, more items still to scan - i = HashTable(HashValue(a$)) - IF i THEN - ua$ = UCASE$(a$) + SPACE$(256 - LEN(a$)) - hashfind_next: - f = HashList(i).Flags - IF searchflags AND f THEN 'flags in common - IF HashListName(i) = ua$ THEN - resultflags = f - resultreference = HashList(i).Reference - i2 = HashList(i).NextItem - IF i2 THEN - HashFind = 2 - HashFind_NextListItem = i2 - HashFind_Reverse = 0 - HashFind_SearchFlags = searchflags - HashFind_Name = ua$ - HashRemove_LastFound = i - EXIT FUNCTION - ELSE - HashFind = 1 - HashRemove_LastFound = i - EXIT FUNCTION - END IF - END IF - END IF - i = HashList(i).NextItem - IF i THEN GOTO hashfind_next - END IF -END FUNCTION - -FUNCTION HashFindRev (a$, searchflags, resultflags, resultreference) - '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) - '0=doesn't exist - '1=found, no more items to scan - '2=found, more items still to scan - i = HashTable(HashValue(a$)) - IF i THEN - i = HashList(i).LastItem - ua$ = UCASE$(a$) + SPACE$(256 - LEN(a$)) - hashfindrev_next: - f = HashList(i).Flags - IF searchflags AND f THEN 'flags in common - IF HashListName(i) = ua$ THEN - resultflags = f - resultreference = HashList(i).Reference - i2 = HashList(i).PrevItem - IF i2 THEN - HashFindRev = 2 - HashFind_NextListItem = i2 - HashFind_Reverse = 1 - HashFind_SearchFlags = searchflags - HashFind_Name = ua$ - HashRemove_LastFound = i - EXIT FUNCTION - ELSE - HashFindRev = 1 - HashRemove_LastFound = i - EXIT FUNCTION - END IF - END IF - END IF - i = HashList(i).PrevItem - IF i THEN GOTO hashfindrev_next - END IF -END FUNCTION - -FUNCTION HashFindCont (resultflags, resultreference) - '(0,1,2)z=hashfind[rev](resflag,resref) - '0=no more items exist - '1=found, no more items to scan - '2=found, more items still to scan - IF HashFind_Reverse THEN - - i = HashFind_NextListItem - hashfindrevc_next: - f = HashList(i).Flags - IF HashFind_SearchFlags AND f THEN 'flags in common - IF HashListName(i) = HashFind_Name THEN - resultflags = f - resultreference = HashList(i).Reference - i2 = HashList(i).PrevItem - IF i2 THEN - HashFindCont = 2 - HashFind_NextListItem = i2 - HashRemove_LastFound = i - EXIT FUNCTION - ELSE - HashFindCont = 1 - HashRemove_LastFound = i - EXIT FUNCTION - END IF - END IF - END IF - i = HashList(i).PrevItem - IF i THEN GOTO hashfindrevc_next - EXIT FUNCTION - - ELSE - - i = HashFind_NextListItem - hashfindc_next: - f = HashList(i).Flags - IF HashFind_SearchFlags AND f THEN 'flags in common - IF HashListName(i) = HashFind_Name THEN - resultflags = f - resultreference = HashList(i).Reference - i2 = HashList(i).NextItem - IF i2 THEN - HashFindCont = 2 - HashFind_NextListItem = i2 - HashRemove_LastFound = i - EXIT FUNCTION - ELSE - HashFindCont = 1 - HashRemove_LastFound = i - EXIT FUNCTION - END IF - END IF - END IF - i = HashList(i).NextItem - IF i THEN GOTO hashfindc_next - EXIT FUNCTION - - END IF -END FUNCTION - -SUB HashRemove - - i = HashRemove_LastFound - - 'add to free list - HashListFreeLast = HashListFreeLast + 1 - IF HashListFreeLast > HashListFreeSize THEN - HashListFreeSize = HashListFreeSize * 2 - REDIM _PRESERVE HashListFree(1 TO HashListFreeSize) AS LONG - END IF - HashListFree(HashListFreeLast) = i - - 'unlink - i1 = HashList(i).PrevItem - IF i1 THEN - 'not first item in list - i2 = HashList(i).NextItem - IF i2 THEN - '(not first and) not last item - HashList(i1).NextItem = i2 - HashList(i2).LastItem = i1 - ELSE - 'last item - x = HashTable(HashValue(HashListName$(i))) - HashList(x).LastItem = i1 - HashList(i1).NextItem = 0 - END IF - ELSE - 'first item in list - x = HashTable(HashValue(HashListName$(i))) - i2 = HashList(i).NextItem - IF i2 THEN - '(first item but) not last item - HashTable(x) = i2 - HashList(i2).PrevItem = 0 - HashList(i2).LastItem = HashList(i).LastItem - ELSE - '(first and) last item - HashTable(x) = 0 - END IF - END IF - -END SUB - -SUB HashDump 'used for debugging purposes - fh = FREEFILE - OPEN "hashdump.txt" FOR OUTPUT AS #fh - b$ = "12345678901234567890123456789012}" - FOR x = 0 TO 16777215 - IF HashTable(x) THEN - - PRINT #fh, "START HashTable("; x; "):" - i = HashTable(x) - - 'validate - lasti = HashList(i).LastItem - IF HashList(i).LastItem = 0 OR HashList(i).PrevItem <> 0 OR HashValue(HashListName(i)) <> x THEN GOTO corrupt - - PRINT #fh, " HashList("; i; ").LastItem="; HashList(i).LastItem - hashdumpnextitem: - x$ = " [" + STR$(i) + "]" + HashListName(i) - - f = HashList(i).Flags - x$ = x$ + ",.Flags=" + STR$(f) + "{" - FOR z = 1 TO 32 - ASC(b$, z) = (f AND 1) + 48 - f = f \ 2 - NEXT - x$ = x$ + b$ - - x$ = x$ + ",.Reference=" + STR$(HashList(i).Reference) - - PRINT #fh, x$ - - 'validate - i1 = HashList(i).PrevItem - i2 = HashList(i).NextItem - IF i1 THEN - IF HashList(i1).NextItem <> i THEN GOTO corrupt - END IF - IF i2 THEN - IF HashList(i2).PrevItem <> i THEN GOTO corrupt - END IF - IF i2 = 0 THEN - IF lasti <> i THEN GOTO corrupt - END IF - - i = HashList(i).NextItem - IF i THEN GOTO hashdumpnextitem - - PRINT #fh, "END HashTable("; x; ")" - END IF - NEXT - CLOSE #fh - - EXIT SUB - corrupt: - PRINT #fh, "HASH TABLE CORRUPT!" 'should never happen - CLOSE #fh - -END SUB - -SUB HashClear 'clear entire hash table - - HashListSize = 65536 - HashListNext = 1 - HashListFreeSize = 1024 - HashListFreeLast = 0 - REDIM HashList(1 TO HashListSize) AS HashListItem - REDIM HashListName(1 TO HashListSize) AS STRING * 256 - REDIM HashListFree(1 TO HashListFreeSize) AS LONG - REDIM HashTable(16777215) AS LONG '64MB lookup table with indexes to the hashlist - - HashFind_NextListItem = 0 - HashFind_Reverse = 0 - HashFind_SearchFlags = 0 - HashFind_Name = "" - HashRemove_LastFound = 0 - -END SUB - -FUNCTION removecast$ (a$) - removecast$ = a$ - IF INSTR(a$, " )") THEN - removecast$ = RIGHT$(a$, LEN(a$) - INSTR(a$, " )") - 2) - END IF -END FUNCTION - -FUNCTION converttabs$ (a2$) - IF ideautoindent THEN s = ideautoindentsize ELSE s = 4 - a$ = a2$ - DO WHILE INSTR(a$, CHR_TAB) - x = INSTR(a$, CHR_TAB) - a$ = LEFT$(a$, x - 1) + SPACE$(s - ((x - 1) MOD s)) + RIGHT$(a$, LEN(a$) - x) - LOOP - converttabs$ = a$ -END FUNCTION - - -FUNCTION NewByteElement$ - a$ = "byte_element_" + str2$(uniquenumber) - NewByteElement$ = a$ - IF use_global_byte_elements THEN - PRINT #18, "byte_element_struct *" + a$ + "=(byte_element_struct*)malloc(12);" - ELSE - PRINT #13, "byte_element_struct *" + a$ + "=NULL;" - PRINT #13, "if (!" + a$ + "){" - PRINT #13, "if ((mem_static_pointer+=12) 40 THEN - IF l = 0 THEN EXIT FUNCTION - 'Note: variable names with periods need to be obfuscated, and this affects their length - i = INSTR(a$, fix046$) - DO WHILE i - l = l - LEN(fix046$) + 1 - i = INSTR(i + 1, a$, fix046$) - LOOP - IF l > 40 THEN EXIT FUNCTION - l = LEN(a$) - END IF - - 'check for single, leading underscore - IF l >= 2 THEN - IF ASC(a$, 1) = 95 AND ASC(a$, 2) <> 95 THEN EXIT FUNCTION - END IF - - FOR i = 1 TO l - a = ASC(a$, i) - IF alphanumeric(a) = 0 THEN EXIT FUNCTION - IF isnumeric(a) THEN - trailingunderscore = 0 - IF alphabetletter = 0 THEN EXIT FUNCTION - ELSE - IF a = 95 THEN - trailingunderscore = 1 - ELSE - alphabetletter = 1 - trailingunderscore = 0 - END IF - END IF - NEXT - IF trailingunderscore THEN EXIT FUNCTION - validname = 1 -END FUNCTION - -FUNCTION str_nth$ (x) - IF x = 1 THEN str_nth$ = "1st": EXIT FUNCTION - IF x = 2 THEN str_nth$ = "2nd": EXIT FUNCTION - IF x = 3 THEN str_nth$ = "3rd": EXIT FUNCTION - str_nth$ = str2(x) + "th" -END FUNCTION - -SUB Give_Error (a$) - Error_Happened = 1 - Error_Message = a$ -END SUB - -SUB WriteConfigSetting (section$, item$, value$) - WriteSetting ConfigFile$, section$, item$, value$ -END SUB - -FUNCTION ReadConfigSetting (section$, item$, value$) - value$ = ReadSetting$(ConfigFile$, section$, item$) - ReadConfigSetting = (LEN(value$) > 0) -END FUNCTION - -FUNCTION VRGBS~& (text$, DefaultColor AS _UNSIGNED LONG) - 'Value of RGB String = VRGBS without a ton of typing - 'A function to get the RGB value back from a string such as _RGB32(255,255,255) - 'text$ is the string that we send to check for a value - 'DefaultColor is the value we send back if the string isn't in the proper format - - VRGBS~& = DefaultColor 'A return the default value if we can't parse the string properly - IF UCASE$(LEFT$(text$, 4)) = "_RGB" THEN - rpos = INSTR(text$, "(") - gpos = INSTR(rpos, text$, ",") - bpos = INSTR(gpos + 1, text$, ",") - IF rpos <> 0 AND bpos <> 0 AND gpos <> 0 THEN - red = VAL(_TRIM$(MID$(text$, rpos + 1))) - green = VAL(_TRIM$(MID$(text$, gpos + 1))) - blue = VAL(_TRIM$(MID$(text$, bpos + 1))) - VRGBS~& = _RGB32(red, green, blue) - END IF - END IF -END FUNCTION - -FUNCTION rgbs$ (c AS _UNSIGNED LONG) - rgbs$ = "_RGB32(" + _TRIM$(STR$(_RED32(c))) + ", " + _TRIM$(STR$(_GREEN32(c))) + ", " + _TRIM$(STR$(_BLUE32(c))) + ")" -END FUNCTION - -FUNCTION EvalPreIF (text$, err$) - temp$ = text$ 'so we don't corrupt the string sent to us for evaluation - err$ = "" 'null the err message to begin with - 'first order of business is to solve for <>= - DIM PC_Op(3) AS STRING - PC_Op(1) = "=" - PC_Op(2) = "<" - PC_Op(3) = ">" - DO - 'look for the existence of the first symbol if there is any - firstsymbol$ = "": first = 0 - FOR i = 1 TO UBOUND(PC_Op) - temp = INSTR(temp$, PC_Op(i)) - IF first = 0 THEN first = temp: firstsymbol$ = PC_Op(i) - IF temp <> 0 AND temp < first THEN first = temp: firstsymbol$ = PC_Op(i) - NEXT - IF firstsymbol$ <> "" THEN 'we've got = < >; let's see if we have a combination of them - secondsymbol = 0: second = 0 - FOR i = first + 1 TO LEN(temp$) - a$ = MID$(temp$, i, 1) - SELECT CASE a$ - CASE " " 'ignore spaces - CASE "=", "<", ">" - IF a$ = firstsymbol$ THEN err$ = "Duplicate operator (" + a$ + ")": EXIT FUNCTION - second = i: secondsymbol$ = a$ - CASE ELSE 'we found a symbol we don't recognize - EXIT FOR - END SELECT - NEXT - END IF - IF first THEN 'we found a symbol - l$ = RTRIM$(LEFT$(temp$, first - 1)) - IF second THEN rightstart = second + 1 ELSE rightstart = first + 1 - - r$ = LTRIM$(MID$(temp$, rightstart)) - symbol$ = MID$(temp$, first, 1) + MID$(temp$, second, 1) - 'now we check for spaces to separate this segment from any other AND/OR conditions and such - FOR i = LEN(l$) TO 1 STEP -1 - IF ASC(l$, i) = 32 THEN EXIT FOR - NEXT - leftside$ = RTRIM$(LEFT$(temp$, i)) - l$ = LTRIM$(RTRIM$(MID$(temp$, i + 1, LEN(l$) - i))) - IF validname(l$) = 0 THEN err$ = "Invalid flag name": EXIT FUNCTION - rightstop = LEN(r$) - FOR i = 1 TO LEN(r$) - IF ASC(r$, i) = 32 THEN EXIT FOR - NEXT - rightside$ = LTRIM$(MID$(r$, i + 1)) - r$ = LTRIM$(RTRIM$(LEFT$(r$, i - 1))) - IF symbol$ = "=<" THEN symbol$ = "<=" - IF symbol$ = "=>" THEN symbol$ = ">=" - IF symbol$ = "><" THEN symbol$ = "<>" - result$ = " 0 " - IF symbol$ = "<>" THEN 'check to see if we're NOT equal in any case with <> - FOR i = 0 TO UserDefineCount - IF UserDefine(0, i) = l$ AND UserDefine(1, i) <> r$ THEN result$ = " -1 ": GOTO finishedcheck - NEXT - END IF - IF INSTR(symbol$, "=") THEN 'check to see if we're equal in any case with = - UserFound = 0 - FOR i = 0 TO UserDefineCount - IF UserDefine(0, i) = l$ THEN - UserFound = -1 - IF UserDefine(1, i) = r$ THEN result$ = " -1 ": GOTO finishedcheck - END IF - NEXT - IF UserFound = 0 AND LTRIM$(RTRIM$(r$)) = "UNDEFINED" THEN result$ = " -1 ": GOTO finishedcheck - IF UserFound = -1 AND LTRIM$(RTRIM$(r$)) = "DEFINED" THEN result$ = " -1 ": GOTO finishedcheck - END IF - - IF INSTR(symbol$, ">") THEN 'check to see if we're greater than in any case with > - FOR i = 0 TO UserDefineCount - IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values - IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) > VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck - ELSE - IF UserDefine(0, i) = l$ AND UserDefine(1, i) > r$ THEN result$ = " -1 ": GOTO finishedcheck - END IF - NEXT - END IF - IF INSTR(symbol$, "<") THEN 'check to see if we're less than in any case with < - FOR i = 0 TO UserDefineCount - IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values - IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) < VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck - ELSE - IF UserDefine(0, i) = l$ AND UserDefine(1, i) < r$ THEN result$ = " -1 ": GOTO finishedcheck - END IF - NEXT - END IF - - - - finishedcheck: - temp$ = leftside$ + result$ + rightside$ - END IF - LOOP UNTIL first = 0 - - 'And at this point we should now be down to a statement with nothing but AND/OR/XORS in it - - PC_Op(1) = " AND " - PC_Op(2) = " OR " - PC_Op(3) = " XOR " - - DO - first = 0 - FOR i = 1 TO UBOUND(PC_Op) - IF PC_Op(i) <> "" THEN - t = INSTR(temp$, PC_Op(i)) - IF first <> 0 THEN - IF t < first AND t <> 0 THEN first = t: firstsymbol = i - ELSE - first = t: firstsymbol = i - END IF - END IF - NEXT - IF first = 0 THEN EXIT DO - leftside$ = RTRIM$(LEFT$(temp$, first - 1)) - symbol$ = MID$(temp$, first, LEN(PC_Op(firstsymbol))) - t$ = MID$(temp$, first + LEN(PC_Op(firstsymbol))) - t = INSTR(t$, " ") 'the first space we come to - IF t THEN - m$ = LTRIM$(RTRIM$(LEFT$(t$, t - 1))) - rightside$ = LTRIM$(MID$(t$, t)) - ELSE - m$ = LTRIM$(MID$(t$, t)) - rightside$ = "" - END IF - leftresult = 0 - IF VerifyNumber(leftside$) THEN - IF VAL(leftside$) <> 0 THEN leftresult = -1 - ELSE - FOR i = 0 TO UserDefineCount - IF UserDefine(0, i) = leftside$ THEN - t$ = LTRIM$(RTRIM$(UserDefine(1, i))) - IF t$ <> "0" AND t$ <> "" THEN leftresult = -1: EXIT FOR - END IF - NEXT - END IF - rightresult = 0 - IF VerifyNumber(m$) THEN - IF VAL(m$) <> 0 THEN rightresult = -1 - ELSE - FOR i = 0 TO UserDefineCount - IF UserDefine(0, i) = m$ THEN - t$ = LTRIM$(RTRIM$(UserDefine(1, i))) - IF t$ <> "0" AND t$ <> "" THEN rightresult = -1: EXIT FOR - END IF - NEXT - END IF - SELECT CASE LTRIM$(RTRIM$(symbol$)) - CASE "AND" - IF leftresult <> 0 AND rightresult <> 0 THEN result$ = " -1 " ELSE result$ = " 0 " - CASE "OR" - IF leftresult <> 0 OR rightresult <> 0 THEN result$ = " -1 " ELSE result$ = " 0 " - CASE "XOR" - IF leftresult <> rightresult THEN result$ = " -1 " ELSE result$ = " 0 " - END SELECT - temp$ = result$ + rightside$ - LOOP - - IF VerifyNumber(temp$) THEN - EvalPreIF = VAL(temp$) - ELSE - IF INSTR(temp$, " ") THEN err$ = "Invalid Resolution of $IF; check statements" 'If we've got more than 1 statement, it's invalid - FOR i = 0 TO UserDefineCount - IF UserDefine(0, i) = temp$ THEN - t$ = LTRIM$(RTRIM$(UserDefine(1, i))) - IF t$ <> "0" AND t$ <> "" THEN EvalPreIF = -1: EXIT FOR - END IF - NEXT - END IF - -END FUNCTION - -FUNCTION VerifyNumber (text$) - t$ = LTRIM$(RTRIM$(text$)) - v = VAL(t$) - t1$ = LTRIM$(STR$(v)) - IF t$ = t1$ THEN VerifyNumber = -1 -END FUNCTION - -SUB initialise_udt_varstrings (n$, udt, file, base_offset) - IF NOT udtxvariable(udt) THEN EXIT SUB - element = udtxnext(udt) - offset = 0 - DO WHILE element - IF udtetype(element) AND ISSTRING THEN - IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - PRINT #file, "*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ") = qbs_new(0,0);" - END IF - ELSEIF udtetype(element) AND ISUDT THEN - initialise_udt_varstrings n$, udtetype(element) AND 511, file, offset - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - -SUB free_udt_varstrings (n$, udt, file, base_offset) - IF NOT udtxvariable(udt) THEN EXIT SUB - element = udtxnext(udt) - offset = 0 - DO WHILE element - IF udtetype(element) AND ISSTRING THEN - IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - PRINT #file, "qbs_free(*((qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ")));" - END IF - ELSEIF udtetype(element) AND ISUDT THEN - initialise_udt_varstrings n$, udtetype(element) AND 511, file, offset - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - -SUB clear_udt_with_varstrings (n$, udt, file, base_offset) - IF NOT udtxvariable(udt) THEN EXIT SUB - element = udtxnext(udt) - offset = 0 - DO WHILE element - IF udtetype(element) AND ISSTRING THEN - IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - PRINT #file, "(*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + "))->len=0;" - ELSE - PRINT #file, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");" - END IF - ELSE - IF udtetype(element) AND ISUDT THEN - clear_udt_with_varstrings n$, udtetype(element) AND 511, file, base_offset + offset - ELSE - PRINT #file, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");" - END IF - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - - -SUB initialise_array_udt_varstrings (n$, udt, base_offset, bytesperelement$, acc$) - IF NOT udtxvariable(udt) THEN EXIT SUB - offset = base_offset - element = udtxnext(udt) - DO WHILE element - IF udtetype(element) AND ISSTRING THEN - IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - acc$ = acc$ + CHR$(13) + CHR$(10) + "*(qbs**)(" + n$ + "[0]+(" + bytesperelement$ + "-1)*tmp_long+" + STR$(offset) + ")=qbs_new(0,0);" - END IF - ELSEIF udtetype(element) AND ISUDT THEN - initialise_array_udt_varstrings n$, udtetype(element) AND 511, offset, bytesperelement$, acc$ - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - -SUB free_array_udt_varstrings (n$, udt, base_offset, bytesperelement$, acc$) - IF NOT udtxvariable(udt) THEN EXIT SUB - offset = base_offset - element = udtxnext(udt) - DO WHILE element - IF udtetype(element) AND ISSTRING THEN - IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - acc$ = acc$ + CHR$(13) + CHR$(10) + "qbs_free(*(qbs**)(" + n$ + "[0]+(" + bytesperelement$ + "-1)*tmp_long+" + STR$(offset) + "));" - END IF - ELSEIF udtetype(element) AND ISUDT THEN - free_array_udt_varstrings n$, udtetype(element) AND 511, offset, bytesperelement$, acc$ - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - -SUB copy_full_udt (dst$, src$, file, base_offset, udt) - IF NOT udtxvariable(udt) THEN - PRINT #file, "memcpy(" + dst$ + "+" + STR$(base_offset) + "," + src$ + "+" + STR$(base_offset) + "," + STR$(udtxsize(udt) \ 8) + ");" - EXIT SUB - END IF - offset = base_offset - element = udtxnext(udt) - DO WHILE element - IF ((udtetype(element) AND ISSTRING) > 0) AND (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN - PRINT #file, "qbs_set(*(qbs**)(" + dst$ + "+" + STR$(offset) + "), *(qbs**)(" + src$ + "+" + STR$(offset) + "));" - ELSEIF ((udtetype(element) AND ISUDT) > 0) THEN - copy_full_udt dst$, src$, 12, offset, udtetype(element) AND 511 - ELSE - PRINT #file, "memcpy((" + dst$ + "+" + STR$(offset) + "),(" + src$ + "+" + STR$(offset) + ")," + STR$(udtesize(element) \ 8) + ");" - END IF - offset = offset + udtesize(element) \ 8 - element = udtenext(element) - LOOP -END SUB - -SUB dump_udts - f = FREEFILE - OPEN "types.txt" FOR OUTPUT AS #f - PRINT #f, "Name Size Align? Next Var?" - FOR i = 1 TO lasttype - PRINT #f, RTRIM$(udtxname(i)), udtxsize(i), udtxbytealign(i), udtxnext(i), udtxvariable(i) - NEXT i - PRINT #f, "Name Size Align? Next Type Tsize Arr" - FOR i = 1 TO lasttypeelement - PRINT #f, RTRIM$(udtename(i)), udtesize(i), udtebytealign(i), udtenext(i), udtetype(i), udtetypesize(i), udtearrayelements(i) - NEXT i - CLOSE #f -END SUB - -SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) - DIM findItem AS LONG, cname$, i AS LONG, j AS LONG, name$, temp$ - name$ = RTRIM$(__name$) - cname$ = RTRIM$(__cname$) - - IF LEN(cname$) = 0 THEN EXIT SUB - - findItem = INSTR(cname$, "[") - IF findItem THEN - cname$ = LEFT$(cname$, findItem - 1) - END IF - - found = 0 - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).cname = cname$ THEN found = -1: EXIT FOR - NEXT - - SELECT CASE action - CASE 0 'add - IF found = 0 THEN - IF i > UBOUND(usedVariableList) THEN - REDIM _PRESERVE usedVariableList(UBOUND(usedVariableList) + 999) AS usedVarList - END IF - - usedVariableList(i).id = currentid - usedVariableList(i).used = 0 - usedVariableList(i).watch = 0 - usedVariableList(i).displayFormat = 0 - usedVariableList(i).storage = "" - usedVariableList(i).linenumber = linenumber - usedVariableList(i).includeLevel = inclevel - IF inclevel > 0 THEN - usedVariableList(i).includedLine = inclinenumber(inclevel) - thisincname$ = getfilepath$(incname$(inclevel)) - thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) - usedVariableList(i).includedFile = thisincname$ - ELSE - totalMainVariablesCreated = totalMainVariablesCreated + 1 - usedVariableList(i).includedLine = 0 - usedVariableList(i).includedFile = "" - END IF - usedVariableList(i).scope = subfuncn - usedVariableList(i).subfunc = subfunc - usedVariableList(i).varType = id2fulltypename$ - usedVariableList(i).cname = cname$ - usedVariableList(i).localIndex = localIndex - - 'remove eventual instances of fix046$ in name$ - DO WHILE INSTR(name$, fix046$) - x = INSTR(name$, fix046$): name$ = LEFT$(name$, x - 1) + "." + RIGHT$(name$, LEN(name$) - x + 1 - LEN(fix046$)) - LOOP - - IF LEN(RTRIM$(id.musthave)) > 0 THEN - usedVariableList(i).name = name$ + RTRIM$(id.musthave) - ELSEIF LEN(RTRIM$(id.mayhave)) > 0 THEN - usedVariableList(i).name = name$ + RTRIM$(id.mayhave) - ELSE - usedVariableList(i).name = name$ - END IF - - IF (id.arrayelements > 0) THEN - usedVariableList(i).isarray = -1 - usedVariableList(i).name = usedVariableList(i).name + "()" - ELSE - usedVariableList(i).isarray = 0 - END IF - usedVariableList(i).watchRange = "" - usedVariableList(i).arrayElementSize = 0 - usedVariableList(i).indexes = "" - usedVariableList(i).elements = "" - usedVariableList(i).elementTypes = "" - usedVariableList(i).elementOffset = "" - totalVariablesCreated = totalVariablesCreated + 1 - - temp$ = MKL$(-1) + MKL$(LEN(cname$)) + cname$ - found = INSTR(backupVariableWatchList$, temp$) - IF found THEN - 'this variable existed in a previous edit of this program - 'in this same session; let's preselect it. - j = CVL(MID$(backupVariableWatchList$, found + LEN(temp$), 4)) - - 'if there have been changes in TYPEs, this variable won't be preselected - IF (LEN(backupUsedVariableList(j).elements) > 0 AND backupTypeDefinitions$ = typeDefinitions$) OR _ - (LEN(backupUsedVariableList(j).elements) = 0) THEN - usedVariableList(i).watch = backupUsedVariableList(j).watch - usedVariableList(i).watchRange = backupUsedVariableList(j).watchRange - usedVariableList(i).indexes = backupUsedVariableList(j).indexes - usedVariableList(i).displayFormat = backupUsedVariableList(j).displayFormat - usedVariableList(i).elements = backupUsedVariableList(j).elements - usedVariableList(i).elementTypes = backupUsedVariableList(j).elementTypes - usedVariableList(i).elementOffset = backupUsedVariableList(j).elementOffset - END IF - END IF - END IF - CASE ELSE 'find and mark as used - IF found THEN - usedVariableList(i).used = -1 - END IF - END SELECT -END SUB - -SUB addWarning (whichLineNumber AS LONG, includeLevel AS LONG, incLineNumber AS LONG, incFileName$, header$, text$) - warningsissued = -1 - totalWarnings = totalWarnings + 1 - - IF idemode = 0 AND ShowWarnings THEN - thissource$ = getfilepath$(CMDLineFile) - thissource$ = MID$(CMDLineFile, LEN(thissource$) + 1) - thisincname$ = getfilepath$(incFileName$) - thisincname$ = MID$(incFileName$, LEN(thisincname$) + 1) - - IF NOT MonochromeLoggingMode THEN COLOR 15 - IF includeLevel > 0 AND incLineNumber > 0 THEN - PRINT thisincname$; ":"; - PRINT str2$(incLineNumber); ": "; - ELSE - PRINT thissource$; ":"; - PRINT str2$(whichLineNumber); ": "; - END IF - - IF NOT MonochromeLoggingMode THEN COLOR 13 - PRINT "warning: "; - IF NOT MonochromeLoggingMode THEN COLOR 7 - PRINT header$ - - IF LEN(text$) > 0 THEN - IF NOT MonochromeLoggingMode THEN COLOR 2 - PRINT SPACE$(4); text$ - IF NOT MonochromeLoggingMode THEN COLOR 7 - END IF - ELSEIF idemode THEN - IF NOT IgnoreWarnings THEN - IF whichLineNumber > maxLineNumber THEN maxLineNumber = whichLineNumber - IF lastWarningHeader <> header$ THEN - lastWarningHeader = header$ - GOSUB increaseWarningCount - warning$(warningListItems) = header$ - warningLines(warningListItems) = 0 - END IF - - GOSUB increaseWarningCount - warning$(warningListItems) = text$ - warningLines(warningListItems) = whichLineNumber - IF includeLevel > 0 THEN - thisincname$ = getfilepath$(incFileName$) - thisincname$ = MID$(incFileName$, LEN(thisincname$) + 1) - warningIncLines(warningListItems) = incLineNumber - warningIncFiles(warningListItems) = thisincname$ - ELSE - warningIncLines(warningListItems) = 0 - warningIncFiles(warningListItems) = "" - END IF - END IF - END IF - EXIT SUB - increaseWarningCount: - warningListItems = warningListItems + 1 - IF warningListItems > UBOUND(warning$) THEN - REDIM _PRESERVE warning$(warningListItems + 999) - REDIM _PRESERVE warningLines(warningListItems + 999) AS LONG - REDIM _PRESERVE warningIncLines(warningListItems + 999) AS LONG - REDIM _PRESERVE warningIncFiles(warningListItems + 999) AS STRING - END IF - RETURN -END SUB - -FUNCTION SCase$ (t$) - IF ideautolayoutkwcapitals THEN SCase$ = UCASE$(t$) ELSE SCase$ = t$ -END FUNCTION - -FUNCTION SCase2$ (t$) - separator$ = sp - IF ideautolayoutkwcapitals THEN - SCase2$ = UCASE$(t$) - ELSE - newWord = -1 - temp$ = "" - FOR i = 1 TO LEN(t$) - s$ = MID$(t$, i, 1) - IF newWord THEN - IF s$ = "_" OR s$ = separator$ THEN - temp$ = temp$ + s$ - ELSE - temp$ = temp$ + UCASE$(s$) - newWord = 0 - END IF - ELSE - IF s$ = separator$ THEN - temp$ = temp$ + separator$ - newWord = -1 - ELSE - temp$ = temp$ + LCASE$(s$) - END IF - END IF - NEXT - SCase2$ = temp$ - END IF -END FUNCTION - -SUB increaseUDTArrays - x = UBOUND(udtxname) - REDIM _PRESERVE udtxname(x + 1000) AS STRING * 256 - REDIM _PRESERVE udtxcname(x + 1000) AS STRING * 256 - REDIM _PRESERVE udtxsize(x + 1000) AS LONG - REDIM _PRESERVE udtxbytealign(x + 1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 - REDIM _PRESERVE udtxnext(x + 1000) AS LONG - REDIM _PRESERVE udtxvariable(x + 1000) AS INTEGER 'true if the udt contains variable length elements - 'elements - REDIM _PRESERVE udtename(x + 1000) AS STRING * 256 - REDIM _PRESERVE udtecname(x + 1000) AS STRING * 256 - REDIM _PRESERVE udtebytealign(x + 1000) AS INTEGER - REDIM _PRESERVE udtesize(x + 1000) AS LONG - REDIM _PRESERVE udtetype(x + 1000) AS LONG - REDIM _PRESERVE udtetypesize(x + 1000) AS LONG - REDIM _PRESERVE udtearrayelements(x + 1000) AS LONG - REDIM _PRESERVE udtenext(x + 1000) AS LONG -END SUB - -'$INCLUDE:'utilities\strings.bas' -'$INCLUDE:'utilities\file.bas' -'$INCLUDE:'utilities\build.bas' -'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas' -'$INCLUDE:'utilities\ini-manager\ini.bm' - -DEFLNG A-Z - -'-------- Optional IDE Component (2/2) -------- -'$INCLUDE:'ide\ide_methods.bas' - - +'All variables will be of type LONG unless explicitly defined +DEFLNG A-Z + +'All arrays will be dynamically allocated so they can be REDIM-ed +'$DYNAMIC + +'We need console access to support command-line compilation via the -x command line compile option +$CONSOLE + +'Initially the "SCREEN" will be hidden, if the -x option is used it will never be created +$SCREENHIDE + +$EXEICON:'./qb64pe.ico' + +$VERSIONINFO:CompanyName=QB64 Phoenix Edition +$VERSIONINFO:FileDescription=QB64 IDE and Compiler +$VERSIONINFO:InternalName=qb64pe.bas +$VERSIONINFO:LegalCopyright=MIT +$VERSIONINFO:LegalTrademarks= +$VERSIONINFO:OriginalFilename=qb64pe.exe +$VERSIONINFO:ProductName=QB64-PE +$VERSIONINFO:Comments=QB64 is a modern extended BASIC programming language that retains QB4.5/QBasic compatibility and compiles native binaries for Windows, Linux and macOS. + +'$INCLUDE:'global\version.bas' +'$INCLUDE:'global\settings.bas' +'$INCLUDE:'global\constants.bas' +'$INCLUDE:'subs_functions\extensions\opengl\opengl_global.bas' +'$INCLUDE:'utilities\ini-manager\ini.bi' + +DEFLNG A-Z + +'-------- Optional IDE Component (1/2) -------- +'$INCLUDE:'ide\ide_global.bas' + +REDIM SHARED OName(1000) AS STRING 'Operation Name +REDIM SHARED PL(1000) AS INTEGER 'Priority Level +REDIM SHARED PP_TypeMod(0) AS STRING, PP_ConvertedMod(0) AS STRING 'Prepass Name Conversion variables. +Set_OrderOfOperations + +DIM SHARED NoExeSaved AS INTEGER + +DIM SHARED vWatchOn, vWatchRecompileAttempts, vWatchDesiredState, vWatchErrorCall$ +DIM SHARED vWatchNewVariable$, vWatchVariableExclusions$ +vWatchErrorCall$ = "if (stop_program) {*__LONG_VWATCH_LINENUMBER=0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);};if(new_error){bkp_new_error=new_error;new_error=0;*__LONG_VWATCH_LINENUMBER=-1; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);new_error=bkp_new_error;};" +vWatchVariableExclusions$ = "@__LONG_VWATCH_LINENUMBER@__LONG_VWATCH_SUBLEVEL@__LONG_VWATCH_GOTO@" + _ + "@__STRING_VWATCH_SUBNAME@__STRING_VWATCH_CALLSTACK@__ARRAY_BYTE_VWATCH_BREAKPOINTS" + _ + "@__ARRAY_BYTE_VWATCH_SKIPLINES@__STRING_VWATCH_INTERNALSUBNAME@__ARRAY_STRING_VWATCH_STACK@" + +DIM SHARED nativeDataTypes$ +nativeDataTypes$ = "@_OFFSET@OFFSET@_UNSIGNED _OFFSET@UNSIGNED OFFSET@_BIT@BIT@_UNSIGNED _BIT@UNSIGNED BIT@_BYTE@_UNSIGNED _BYTE@BYTE@UNSIGNED BYTE@INTEGER@_UNSIGNED INTEGER@UNSIGNED INTEGER@LONG@_UNSIGNED LONG@UNSIGNED LONG@_INTEGER64@INTEGER64@_UNSIGNED _INTEGER64@UNSIGNED INTEGER64@SINGLE@DOUBLE@_FLOAT@FLOAT@STRING@" + +DIM SHARED qb64prefix_set_recompileAttempts, qb64prefix_set_desiredState +DIM SHARED opex_recompileAttempts, opex_desiredState +DIM SHARED opexarray_recompileAttempts, opexarray_desiredState + +REDIM EveryCaseSet(100), SelectCaseCounter AS _UNSIGNED LONG +REDIM SelectCaseHasCaseBlock(100) +DIM ExecLevel(255), ExecCounter AS INTEGER +REDIM SHARED UserDefine(1, 100) AS STRING '0 element is the name, 1 element is the string value +REDIM SHARED InValidLine(10000) AS _BYTE +DIM DefineElse(255) AS _BYTE +DIM SHARED UserDefineCount AS INTEGER, UserDefineList$ +UserDefineList$ = "@DEFINED@UNDEFINED@WINDOWS@WIN@LINUX@MAC@MACOSX@32BIT@64BIT@VERSION@" +UserDefine(0, 0) = "WINDOWS": UserDefine(0, 1) = "WIN" +UserDefine(0, 2) = "LINUX" +UserDefine(0, 3) = "MAC": UserDefine(0, 4) = "MACOSX" +UserDefine(0, 5) = "32BIT": UserDefine(0, 6) = "64BIT" +UserDefine(0, 7) = "VERSION" +IF INSTR(_OS$, "WIN") THEN UserDefine(1, 0) = "-1": UserDefine(1, 1) = "-1" ELSE UserDefine(1, 0) = "0": UserDefine(1, 1) = "0" +IF INSTR(_OS$, "LINUX") THEN UserDefine(1, 2) = "-1" ELSE UserDefine(1, 2) = "0" +IF INSTR(_OS$, "MAC") THEN UserDefine(1, 3) = "-1": UserDefine(1, 4) = "-1" ELSE UserDefine(1, 3) = "0": UserDefine(1, 4) = "0" +IF INSTR(_OS$, "32BIT") THEN UserDefine(1, 5) = "-1": UserDefine(1, 6) = "0" ELSE UserDefine(1, 5) = "0": UserDefine(1, 6) = "-1" +UserDefine(1, 7) = Version$ + +DIM SHARED QB64_uptime! + +QB64_uptime! = TIMER + +NoInternalFolder: +IF _DIREXISTS("internal") = 0 THEN + _SCREENSHOW + PRINT "QB64-PE cannot locate the 'internal' folder" + PRINT + PRINT "Check that QB64-PE has been extracted properly." + PRINT "For MacOSX, launch 'qb64pe_start.command' or enter './qb64pe' in Terminal." + PRINT "For Linux, in the console enter './qb64pe'." + DO + _LIMIT 1 + LOOP UNTIL INKEY$ <> "" + SYSTEM 1 +END IF + +DIM SHARED Include_GDB_Debugging_Info 'set using "options.bin" + +DIM SHARED DEPENDENCY_LAST +CONST DEPENDENCY_LOADFONT = 1: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_AUDIO_CONVERSION = 2: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_AUDIO_DECODE = 3: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_AUDIO_OUT = 4: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_GL = 5: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_IMAGE_CODEC = 6: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_CONSOLE_ONLY = 7: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 '=2 if via -g switch, =1 if via metacommand $CONSOLE:ONLY +CONST DEPENDENCY_SOCKETS = 8: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_PRINTER = 9: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_ICON = 10: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_SCREENIMAGE = 11: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_DEVICEINPUT = 12: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'removes support for gamepad input if not present +CONST DEPENDENCY_ZLIB = 13: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'ZLIB library linkage, if desired, for compression/decompression. + + + +DIM SHARED DEPENDENCY(1 TO DEPENDENCY_LAST) + +DIM SHARED UseGL 'declared SUB _GL (no params) + + +DIM SHARED OS_BITS AS LONG, WindowTitle AS STRING +OS_BITS = 64: IF INSTR(_OS$, "[32BIT]") THEN OS_BITS = 32 + +IF OS_BITS = 32 THEN WindowTitle = "QB64 Phoenix Edition (x32)" ELSE WindowTitle = "QB64 Phoenix Edition (x64)" +_TITLE WindowTitle + +DIM SHARED ConsoleMode, No_C_Compile_Mode, NoIDEMode +DIM SHARED ShowWarnings AS _BYTE, QuietMode AS _BYTE, CMDLineFile AS STRING +DIM SHARED MonochromeLoggingMode AS _BYTE + +TYPE usedVarList + AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex + AS LONG arrayElementSize + AS _BYTE used, watch, isarray, displayFormat 'displayFormat: 0=DEC;1=HEX;2=BIN;3=OCT + AS STRING name, cname, varType, includedFile, subfunc + AS STRING watchRange, indexes, elements, elementTypes 'for Arrays and UDTs + AS STRING elementOffset, storage +END TYPE + +REDIM SHARED backupUsedVariableList(1000) AS usedVarList +DIM SHARED typeDefinitions$, backupTypeDefinitions$ +DIM SHARED totalVariablesCreated AS LONG, totalMainVariablesCreated AS LONG +DIM SHARED bypassNextVariable AS _BYTE +DIM SHARED totalWarnings AS LONG, warningListItems AS LONG, lastWarningHeader AS STRING +DIM SHARED duplicateConstWarning AS _BYTE, warningsissued AS _BYTE +DIM SHARED emptySCWarning AS _BYTE, maxLineNumber AS LONG +DIM SHARED ExeIconSet AS LONG, qb64prefix$, qb64prefix_set +DIM SHARED VersionInfoSet AS _BYTE + +'Variables to handle $VERSIONINFO metacommand: +DIM SHARED viFileVersionNum$, viProductVersionNum$, viCompanyName$ +DIM SHARED viFileDescription$, viFileVersion$, viInternalName$ +DIM SHARED viLegalCopyright$, viLegalTrademarks$, viOriginalFilename$ +DIM SHARED viProductName$, viProductVersion$, viComments$, viWeb$ + +DIM SHARED NoChecks + +DIM SHARED Console +DIM SHARED ScreenHide +DIM SHARED Asserts +DIM SHARED OptMax AS LONG +OptMax = 256 +REDIM SHARED Opt(1 TO OptMax, 1 TO 10) AS STRING * 256 +' (1,1)="READ" +' (1,2)="WRITE" +' (1,3)="READ WRITE" +REDIM SHARED OptWords(1 TO OptMax, 1 TO 10) AS INTEGER 'The number of words of each opt () element +' (1,1)=1 '"READ" +' (1,2)=1 '"WRITE" +' (1,3)=2 '"READ WRITE" +REDIM SHARED T(1 TO OptMax) AS INTEGER 'The type of the entry +' t is 0 for ? opts +' ---------- 0 means ? , 1+ means a symbol or {}block ---------- +' t is 1 for symbol opts +' t is the number of rhs opt () index enteries for {READ|WRITE|READ WRITE} like opts +REDIM SHARED Lev(1 TO OptMax) AS INTEGER 'The indwelling level of each opt () element (the lowest is 0) +REDIM SHARED EntryLev(1 TO OptMax) AS INTEGER 'The level required from which this opt () can be validly be entered/checked-for +REDIM SHARED DitchLev(1 TO OptMax) AS INTEGER 'The lowest level recorded between the previous Opt and this Opt +REDIM SHARED DontPass(1 TO OptMax) AS INTEGER 'Set to 1 or 0, with 1 meaning don't pass +'Determines whether the opt () entry needs to actually be passed to the C++ sub/function +REDIM SHARED TempList(1 TO OptMax) AS INTEGER +REDIM SHARED PassRule(1 TO OptMax) AS LONG +'0 means no pass rule +'negative values refer to an opt () element +'positive values refer to a flag value +REDIM SHARED LevelEntered(OptMax) 'up to 64 levels supported +REDIM SHARED separgs(OptMax + 1) AS STRING +REDIM SHARED separgslayout(OptMax + 1) AS STRING +REDIM SHARED separgs2(OptMax + 1) AS STRING +REDIM SHARED separgslayout2(OptMax + 1) AS STRING + + + + + +DIM SHARED E + + + + + + + + + + +DIM SHARED ResolveStaticFunctions +REDIM SHARED ResolveStaticFunction_File(1 TO 100) AS STRING +REDIM SHARED ResolveStaticFunction_Name(1 TO 100) AS STRING +REDIM SHARED ResolveStaticFunction_Method(1 TO 100) AS LONG + + + + + +DIM SHARED Error_Happened AS LONG +DIM SHARED Error_Message AS STRING + +DIM SHARED os AS STRING +os$ = "WIN" +IF INSTR(_OS$, "[LINUX]") THEN os$ = "LNX" + +DIM SHARED MacOSX AS LONG +IF INSTR(_OS$, "[MACOSX]") THEN MacOSX = 1 + +DIM SHARED inline_DATA +IF MacOSX THEN inline_DATA = 1 + +DIM SHARED BATCHFILE_EXTENSION AS STRING +BATCHFILE_EXTENSION = ".bat" +IF os$ = "LNX" THEN BATCHFILE_EXTENSION = ".sh" +IF MacOSX THEN BATCHFILE_EXTENSION = ".command" + + +DIM inlinedatastr(255) AS STRING +FOR i = 0 TO 255 + inlinedatastr(i) = str2$(i) + "," +NEXT + + +DIM SHARED extension AS STRING +DIM SHARED path.exe$, path.source$, lastBinaryGenerated$ +extension$ = ".exe" +IF os$ = "LNX" THEN extension$ = "" 'no extension under Linux + +DIM SHARED pathsep AS STRING * 1 +pathsep$ = "\" +IF os$ = "LNX" THEN pathsep$ = "/" +'note: QB64 handles OS specific path separators automatically except under SHELL calls + +ON ERROR GOTO qberror_test + +DIM SHARED tmpdir AS STRING, tmpdir2 AS STRING +IF os$ = "WIN" THEN tmpdir$ = ".\internal\temp\": tmpdir2$ = "..\\temp\\" +IF os$ = "LNX" THEN tmpdir$ = "./internal/temp/": tmpdir2$ = "../temp/" + +IF NOT _DIREXISTS(tmpdir$) THEN MKDIR tmpdir$ + +DECLARE LIBRARY + FUNCTION getpid& () +END DECLARE + +thisinstancepid = getpid& +DIM SHARED tempfolderindex + +IF INSTR(_OS$, "LINUX") THEN + fh = FREEFILE + OPEN ".\internal\temp\tempfoldersearch.bin" FOR RANDOM AS #fh LEN = LEN(tempfolderindex) + tempfolderrecords = LOF(fh) / LEN(tempfolderindex) + i = 1 + IF tempfolderrecords = 0 THEN + 'first run ever? + PUT #fh, 1, thisinstancepid + ELSE + FOR i = 1 TO tempfolderrecords + 'check if any of the temp folders is being used = pid still active + GET #fh, i, tempfoldersearch + + SHELL _HIDE "ps -p " + STR$(tempfoldersearch) + " > /dev/null 2>&1; echo $? > internal/temp/checkpid.bin" + fh2 = FREEFILE + OPEN "internal/temp/checkpid.bin" FOR BINARY AS #fh2 + LINE INPUT #fh2, checkpid$ + CLOSE #fh2 + IF VAL(checkpid$) = 1 THEN + 'This temp folder was locked by an instance that's no longer active, so + 'this will be our temp folder + PUT #fh, i, thisinstancepid + EXIT FOR + END IF + NEXT + IF i > tempfolderrecords THEN + 'All indexes were busy. Let's initiate a new one: + PUT #fh, i, thisinstancepid + END IF + END IF + CLOSE #fh + IF i > 1 THEN + tmpdir$ = "./internal/temp" + str2$(i) + "/": tmpdir2$ = "../temp" + str2$(i) + "/" + IF _DIREXISTS(tmpdir$) = 0 THEN + MKDIR tmpdir$ + END IF + END IF + OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 +ELSE + ON ERROR GOTO qberror_test + E = 0 + i = 1 + OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 + DO WHILE E + i = i + 1 + IF i = 1000 THEN PRINT "Unable to locate the 'internal' folder": END 1 + MKDIR ".\internal\temp" + str2$(i) + IF os$ = "WIN" THEN tmpdir$ = ".\internal\temp" + str2$(i) + "\": tmpdir2$ = "..\\temp" + str2$(i) + "\\" + IF os$ = "LNX" THEN tmpdir$ = "./internal/temp" + str2$(i) + "/": tmpdir2$ = "../temp" + str2$(i) + "/" + E = 0 + OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 + LOOP +END IF + + +'temp folder established +tempfolderindex = i +IF i > 1 THEN + 'create modified version of qbx.cpp + OPEN ".\internal\c\qbx" + str2$(i) + ".cpp" FOR OUTPUT AS #2 + OPEN ".\internal\c\qbx.cpp" FOR BINARY AS #1 + DO UNTIL EOF(1) + LINE INPUT #1, a$ + x = INSTR(a$, "..\\temp\\"): IF x THEN a$ = LEFT$(a$, x - 1) + "..\\temp" + str2$(i) + "\\" + RIGHT$(a$, LEN(a$) - (x + 9)) + x = INSTR(a$, "../temp/"): IF x THEN a$ = LEFT$(a$, x - 1) + "../temp" + str2$(i) + "/" + RIGHT$(a$, LEN(a$) - (x + 7)) + PRINT #2, a$ + LOOP + CLOSE #1, #2 +END IF + +IF Debug THEN OPEN tmpdir$ + "debug.txt" FOR OUTPUT AS #9 + +ON ERROR GOTO qberror + + + +DIM SHARED tempfolderindexstr AS STRING 'appended to "Untitled" +DIM SHARED tempfolderindexstr2 AS STRING +IF tempfolderindex <> 1 THEN tempfolderindexstr$ = "(" + str2$(tempfolderindex) + ")": tempfolderindexstr2$ = str2$(tempfolderindex) + + +DIM SHARED idedebuginfo +DIM SHARED seperateargs_error +DIM SHARED seperateargs_error_message AS STRING + +DIM SHARED compfailed + +DIM SHARED reginternalsubfunc +DIM SHARED reginternalvariable + + +DIM SHARED symboltype_size +symboltype_size = 0 + +DIM SHARED use_global_byte_elements +use_global_byte_elements = 0 + +'compiler-side IDE data & definitions +'SHARED variables "passed" to/from the compiler & IDE +DIM SHARED idecommand AS STRING 'a 1 byte message-type code, followed by optional string data +DIM SHARED idereturn AS STRING 'used to pass formatted-lines and return information back to the IDE +DIM SHARED ideerror AS LONG +DIM SHARED idecompiled AS LONG +DIM SHARED idemode '1 if using the IDE to compile +DIM SHARED ideerrorline AS LONG 'set by qb64-error(...) to the line number it would have reported, this number +'is later passed to the ide in message #8 +DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to be reported, this +'is later passed to the ide in message #8 + +DIM SHARED optionexplicit AS _BYTE +DIM SHARED optionexplicitarray AS _BYTE +DIM SHARED optionexplicit_cmd AS _BYTE +DIM SHARED ideStartAtLine AS LONG, errorLineInInclude AS LONG +DIM SHARED warningInInclude AS LONG, warningInIncludeLine AS LONG +DIM SHARED outputfile_cmd$ +DIM SHARED compilelog$ + +'$INCLUDE:'global\IDEsettings.bas' + +CMDLineFile = ParseCMDLineArgs$ + +IF ConsoleMode THEN + _DEST _CONSOLE +ELSE + _CONSOLE OFF + _SCREENSHOW + _ICON +END IF + +'the function ?=ide(?) should always be passed 0, it returns a message code number, any further information +'is passed back in idereturn + +'message code numbers: +'0 no ide present (auto defined array ide() return 0) + +'1 launch ide & with passed filename (compiler->ide) + +'2 begin new compilation with returned line of code (compiler<-ide) +' [2][line of code] + +'3 request next line (compiler->ide) +' [3] + +'4 next line of code returned (compiler<-ide) +' [4][line of code] + +'5 no more lines of code exist (compiler<-ide) +' [5] + +'6 code is OK/ready (compiler->ide) +' [6] + +'7 repass the code from the beginning (compiler->ide) +' [7] + +'8 an error has occurred with 'this' message on 'this' line(compiler->ide) +' [8][error message][line as LONG] + +'9 C++ compile (if necessary) and run with 'this' name (compiler<-ide) +' [9][name(no path, no .bas)] + +'10 The line requires more time to process +' Pass-back 'line of code' using method [4] when ready +' [10][line of code] + +'11 ".EXE file created" message + +'12 The name of the exe I'll create is '...' (compiler->ide) +' [12][exe name without .exe] + +'255 A qb error happened in the IDE (compiler->ide) +' note: detected by the fact that ideerror was not set to 0 +' [255] + +'hash table data +TYPE HashListItem + Flags AS LONG + Reference AS LONG + NextItem AS LONG + PrevItem AS LONG + LastItem AS LONG 'note: this value is only valid on the first item in the list + 'note: name is stored in a seperate array of strings +END TYPE +DIM SHARED HashFind_NextListItem AS LONG +DIM SHARED HashFind_Reverse AS LONG +DIM SHARED HashFind_SearchFlags AS LONG +DIM SHARED HashFind_Name AS STRING +DIM SHARED HashRemove_LastFound AS LONG +DIM SHARED HashListSize AS LONG +DIM SHARED HashListNext AS LONG +DIM SHARED HashListFreeSize AS LONG +DIM SHARED HashListFreeLast AS LONG +'hash lookup tables +DIM SHARED hash1char(255) AS INTEGER +DIM SHARED hash2char(65535) AS INTEGER +FOR x = 1 TO 26 + hash1char(64 + x) = x + hash1char(96 + x) = x +NEXT +hash1char(95) = 27 '_ +hash1char(48) = 28 '0 +hash1char(49) = 29 '1 +hash1char(50) = 30 '2 +hash1char(51) = 31 '3 +hash1char(52) = 23 '4 'note: x, y, z and beginning alphabet letters avoided because of common usage (eg. a2, y3) +hash1char(53) = 22 '5 +hash1char(54) = 20 '6 +hash1char(55) = 19 '7 +hash1char(56) = 18 '8 +hash1char(57) = 17 '9 +FOR c1 = 0 TO 255 + FOR c2 = 0 TO 255 + hash2char(c1 + c2 * 256) = hash1char(c1) + hash1char(c2) * 32 + NEXT +NEXT +'init +HashListSize = 65536 +HashListNext = 1 +HashListFreeSize = 1024 +HashListFreeLast = 0 +REDIM SHARED HashList(1 TO HashListSize) AS HashListItem +REDIM SHARED HashListName(1 TO HashListSize) AS STRING * 256 +REDIM SHARED HashListFree(1 TO HashListFreeSize) AS LONG +REDIM SHARED HashTable(16777215) AS LONG '64MB lookup table with indexes to the hashlist + +CONST HASHFLAG_LABEL = 2 +CONST HASHFLAG_TYPE = 4 +CONST HASHFLAG_RESERVED = 8 +CONST HASHFLAG_OPERATOR = 16 +CONST HASHFLAG_CUSTOMSYNTAX = 32 +CONST HASHFLAG_SUB = 64 +CONST HASHFLAG_FUNCTION = 128 +CONST HASHFLAG_UDT = 256 +CONST HASHFLAG_UDTELEMENT = 512 +CONST HASHFLAG_CONSTANT = 1024 +CONST HASHFLAG_VARIABLE = 2048 +CONST HASHFLAG_ARRAY = 4096 +CONST HASHFLAG_XELEMENTNAME = 8192 +CONST HASHFLAG_XTYPENAME = 16384 + +TYPE Label_Type + State AS _UNSIGNED _BYTE '0=label referenced, 1=label created + cn AS STRING * 256 + Scope AS LONG + Data_Offset AS _INTEGER64 'offset within data + Data_Referenced AS _UNSIGNED _BYTE 'set to 1 if data is referenced (data_offset will be used to create the data offset variable) + Error_Line AS LONG 'the line number to reference on errors + Scope_Restriction AS LONG 'cannot exist inside this scope (post checked) + SourceLineNumber AS LONG +END TYPE +DIM SHARED nLabels, Labels_Ubound +Labels_Ubound = 100 +REDIM SHARED Labels(1 TO Labels_Ubound) AS Label_Type +DIM SHARED Empty_Label AS Label_Type + +DIM SHARED PossibleSubNameLabels AS STRING 'format: name+sp+name+sp+name <-ucase$'d +DIM SHARED SubNameLabels AS STRING 'format: name+sp+name+sp+name <-ucase$'d +DIM SHARED CreatingLabel AS LONG + +DIM SHARED AllowLocalName AS LONG + +DIM SHARED DataOffset + +DIM SHARED prepass + + +DIM SHARED autoarray + +DIM SHARED ontimerid, onkeyid, onstrigid + +DIM SHARED revertmaymusthave(1 TO 10000) +DIM SHARED revertmaymusthaven + +DIM SHARED linecontinuation + +DIM SHARED dim2typepassback AS STRING 'passes back correct case sensitive version of type + + +DIM SHARED inclevel +DIM SHARED incname(100) AS STRING 'must be full path as given +DIM SHARED inclinenumber(100) AS LONG +DIM SHARED incerror AS STRING + + +DIM SHARED fix046 AS STRING +fix046$ = "__" + "ASCII" + "_" + "CHR" + "_" + "046" + "__" 'broken up to avoid detection for layout reversion + +DIM SHARED layout AS STRING 'passed to IDE +DIM SHARED layoutok AS LONG 'tracks status of entire line + +DIM SHARED layoutcomment AS STRING + +DIM SHARED tlayout AS STRING 'temporary layout string set by supporting functions +DIM SHARED layoutdone AS LONG 'tracks status of single command + + +DIM SHARED fooindwel + +DIM SHARED alphanumeric(255) +FOR i = 48 TO 57 + alphanumeric(i) = -1 +NEXT +FOR i = 65 TO 90 + alphanumeric(i) = -1 +NEXT +FOR i = 97 TO 122 + alphanumeric(i) = -1 +NEXT +'_ is treated as an alphabet letter +alphanumeric(95) = -1 + +DIM SHARED isalpha(255) +FOR i = 65 TO 90 + isalpha(i) = -1 +NEXT +FOR i = 97 TO 122 + isalpha(i) = -1 +NEXT +'_ is treated as an alphabet letter +isalpha(95) = -1 + +DIM SHARED isnumeric(255) +FOR i = 48 TO 57 + isnumeric(i) = -1 +NEXT + + +DIM SHARED lfsinglechar(255) +lfsinglechar(40) = 1 '( +lfsinglechar(41) = 1 ') +lfsinglechar(42) = 1 '* +lfsinglechar(43) = 1 '+ +lfsinglechar(45) = 1 '- +lfsinglechar(47) = 1 '/ +lfsinglechar(60) = 1 '< +lfsinglechar(61) = 1 '= +lfsinglechar(62) = 1 '> +lfsinglechar(92) = 1 '\ +lfsinglechar(94) = 1 '^ + +lfsinglechar(44) = 1 ', +lfsinglechar(46) = 1 '. +lfsinglechar(58) = 1 ': +lfsinglechar(59) = 1 '; + +lfsinglechar(35) = 1 '# (file no only) +lfsinglechar(36) = 1 '$ (metacommand only) +lfsinglechar(63) = 1 '? (print macro) +lfsinglechar(95) = 1 '_ + + + + + + + + + + +DIM SHARED nextrunlineindex AS LONG + +DIM SHARED lineinput3buffer AS STRING +DIM SHARED lineinput3index AS LONG + +DIM SHARED dimstatic AS LONG + +DIM SHARED staticarraylist AS STRING +DIM SHARED staticarraylistn AS LONG +DIM SHARED commonarraylist AS STRING +DIM SHARED commonarraylistn AS LONG + +'CONST support +DIM SHARED constmax AS LONG +constmax = 100 +DIM SHARED constlast AS LONG +constlast = -1 +REDIM SHARED constname(constmax) AS STRING +REDIM SHARED constcname(constmax) AS STRING +REDIM SHARED constnamesymbol(constmax) AS STRING 'optional name symbol +' `1 and `no-number must be handled correctly +'DIM SHARED constlastshared AS LONG 'so any defined inside a sub/function after this index can be "forgotten" when sub/function exits +'constlastshared = -1 +REDIM SHARED consttype(constmax) AS LONG 'variable type number +'consttype determines storage +REDIM SHARED constinteger(constmax) AS _INTEGER64 +REDIM SHARED constuinteger(constmax) AS _UNSIGNED _INTEGER64 +REDIM SHARED constfloat(constmax) AS _FLOAT +REDIM SHARED conststring(constmax) AS STRING +REDIM SHARED constsubfunc(constmax) AS LONG +REDIM SHARED constdefined(constmax) AS LONG + +'UDT +'names +DIM SHARED lasttype AS LONG +DIM SHARED lasttypeelement AS LONG + +TYPE idstruct + + n AS STRING * 256 'name + cn AS STRING * 256 'case sensitive version of n + + arraytype AS LONG 'similar to t + arrayelements AS INTEGER + staticarray AS INTEGER 'set for arrays declared in the main module with static elements + + mayhave AS STRING * 8 'mayhave and musthave are exclusive of each other + musthave AS STRING * 8 + t AS LONG 'type + + tsize AS LONG + + + subfunc AS INTEGER 'if function=1, sub=2 (max 100 arguments) + Dependency AS INTEGER + internal_subfunc AS INTEGER + + callname AS STRING * 256 + ccall AS INTEGER + overloaded AS _BYTE + args AS INTEGER + minargs AS INTEGER + arg AS STRING * 400 'similar to t + argsize AS STRING * 400 'similar to tsize (used for fixed length strings) + specialformat AS STRING * 256 + secondargmustbe AS STRING * 256 + secondargcantbe AS STRING * 256 + ret AS LONG 'the value it returns if it is a function (again like t) + + insubfunc AS STRING * 256 + insubfuncn AS LONG + + share AS INTEGER + nele AS STRING * 100 + nelereq AS STRING * 100 + linkid AS LONG + linkarg AS INTEGER + staticscope AS INTEGER + 'For variables which are arguments passed to a sub/function + sfid AS LONG 'id number of variable's parent sub/function + sfarg AS INTEGER 'argument/parameter # within call (1=first) + + hr_syntax AS STRING +END TYPE + +DIM SHARED id AS idstruct + +DIM SHARED idn AS LONG +DIM SHARED ids_max AS LONG +ids_max = 1024 +REDIM SHARED ids(1 TO ids_max) AS idstruct +REDIM SHARED cmemlist(1 TO ids_max + 1) AS INTEGER 'variables that must be in cmem +REDIM SHARED sfcmemargs(1 TO ids_max + 1) AS STRING * 100 's/f arg that must be in cmem +REDIM SHARED arrayelementslist(1 TO ids_max + 1) AS INTEGER 'arrayelementslist (like cmemlist) helps to resolve the number of elements in arrays with an unknown number of elements. Note: arrays with an unknown number of elements have .arrayelements=-1 + + +'create blank id template for idclear to copy (stops strings being set to chr$(0)) +DIM SHARED cleariddata AS idstruct +cleariddata.cn = "" +cleariddata.n = "" +cleariddata.mayhave = "" +cleariddata.musthave = "" +cleariddata.callname = "" +cleariddata.arg = "" +cleariddata.argsize = "" +cleariddata.specialformat = "" +cleariddata.secondargmustbe = "" +cleariddata.secondargcantbe = "" +cleariddata.insubfunc = "" +cleariddata.nele = "" +cleariddata.nelereq = "" + +DIM SHARED ISSTRING AS LONG +DIM SHARED ISFLOAT AS LONG +DIM SHARED ISUNSIGNED AS LONG +DIM SHARED ISPOINTER AS LONG +DIM SHARED ISFIXEDLENGTH AS LONG +DIM SHARED ISINCONVENTIONALMEMORY AS LONG +DIM SHARED ISOFFSETINBITS AS LONG +DIM SHARED ISARRAY AS LONG +DIM SHARED ISREFERENCE AS LONG +DIM SHARED ISUDT AS LONG +DIM SHARED ISOFFSET AS LONG + +DIM SHARED STRINGTYPE AS LONG +DIM SHARED BITTYPE AS LONG +DIM SHARED UBITTYPE AS LONG +DIM SHARED BYTETYPE AS LONG +DIM SHARED UBYTETYPE AS LONG +DIM SHARED INTEGERTYPE AS LONG +DIM SHARED UINTEGERTYPE AS LONG +DIM SHARED LONGTYPE AS LONG +DIM SHARED ULONGTYPE AS LONG +DIM SHARED INTEGER64TYPE AS LONG +DIM SHARED UINTEGER64TYPE AS LONG +DIM SHARED SINGLETYPE AS LONG +DIM SHARED DOUBLETYPE AS LONG +DIM SHARED FLOATTYPE AS LONG +DIM SHARED OFFSETTYPE AS LONG +DIM SHARED UOFFSETTYPE AS LONG +DIM SHARED UDTTYPE AS LONG + +DIM SHARED gosubid AS LONG +DIM SHARED redimoption AS INTEGER +DIM SHARED dimoption AS INTEGER +DIM SHARED arraydesc AS INTEGER +DIM SHARED qberrorhappened AS INTEGER +DIM SHARED qberrorcode AS INTEGER +DIM SHARED qberrorline AS INTEGER +'COMMON SHARED defineaz() AS STRING +'COMMON SHARED defineextaz() AS STRING + +DIM SHARED sourcefile AS STRING 'the full path and filename +DIM SHARED file AS STRING 'name of the file (without .bas or path) + +'COMMON SHARED separgs() AS STRING + +DIM SHARED constequation AS INTEGER +DIM SHARED DynamicMode AS INTEGER +DIM SHARED findidsecondarg AS STRING +DIM SHARED findanotherid AS INTEGER +DIM SHARED findidinternal AS LONG +DIM SHARED currentid AS LONG 'is the index of the last ID accessed +DIM SHARED linenumber AS LONG, reallinenumber AS LONG, totallinenumber AS LONG, definingtypeerror AS LONG +DIM SHARED wholeline AS STRING +DIM SHARED firstLineNumberLabelvWatch AS LONG, lastLineNumberLabelvWatch AS LONG +DIM SHARED vWatchUsedLabels AS STRING, vWatchUsedSkipLabels AS STRING +DIM SHARED linefragment AS STRING +'COMMON SHARED bitmask() AS _INTEGER64 +'COMMON SHARED bitmaskinv() AS _INTEGER64 + +DIM SHARED arrayprocessinghappened AS INTEGER +DIM SHARED stringprocessinghappened AS INTEGER +DIM SHARED cleanupstringprocessingcall AS STRING +DIM SHARED inputfunctioncalled AS _BYTE +DIM SHARED recompile AS INTEGER 'forces recompilation +'COMMON SHARED cmemlist() AS INTEGER +DIM SHARED optionbase AS INTEGER + +DIM SHARED addmetastatic AS INTEGER +DIM SHARED addmetadynamic AS INTEGER +DIM SHARED addmetainclude AS STRING + +DIM SHARED closedmain AS INTEGER +DIM SHARED module AS STRING + +DIM SHARED subfunc AS STRING +DIM SHARED subfuncn AS LONG +DIM SHARED closedsubfunc AS _BYTE +DIM SHARED subfuncid AS LONG + +DIM SHARED defdatahandle AS INTEGER +DIM SHARED dimsfarray AS INTEGER +DIM SHARED dimshared AS INTEGER + +'Allows passing of known elements to recompilation +DIM SHARED sflistn AS INTEGER +'COMMON SHARED sfidlist() AS LONG +'COMMON SHARED sfarglist() AS INTEGER +'COMMON SHARED sfelelist() AS INTEGER +DIM SHARED glinkid AS LONG +DIM SHARED glinkarg AS INTEGER +DIM SHARED typname2typsize AS LONG +DIM SHARED uniquenumbern AS LONG + +'CLEAR , , 16384 + + +DIM SHARED bitmask(1 TO 64) AS _INTEGER64 +DIM SHARED bitmaskinv(1 TO 64) AS _INTEGER64 + +DIM SHARED defineextaz(1 TO 27) AS STRING +DIM SHARED defineaz(1 TO 27) AS STRING '27 is an underscore + +ISSTRING = 1073741824 +ISFLOAT = 536870912 +ISUNSIGNED = 268435456 +ISPOINTER = 134217728 +ISFIXEDLENGTH = 67108864 'only set for strings with pointer flag +ISINCONVENTIONALMEMORY = 33554432 +ISOFFSETINBITS = 16777216 +ISARRAY = 8388608 +ISREFERENCE = 4194304 +ISUDT = 2097152 +ISOFFSET = 1048576 + +STRINGTYPE = ISSTRING + ISPOINTER +BITTYPE = 1& + ISPOINTER + ISOFFSETINBITS +UBITTYPE = 1& + ISPOINTER + ISUNSIGNED + ISOFFSETINBITS 'QB64 will also support BIT*n, eg. DIM bitarray[10] AS _UNSIGNED _BIT*10 +BYTETYPE = 8& + ISPOINTER +UBYTETYPE = 8& + ISPOINTER + ISUNSIGNED +INTEGERTYPE = 16& + ISPOINTER +UINTEGERTYPE = 16& + ISPOINTER + ISUNSIGNED +LONGTYPE = 32& + ISPOINTER +ULONGTYPE = 32& + ISPOINTER + ISUNSIGNED +INTEGER64TYPE = 64& + ISPOINTER +UINTEGER64TYPE = 64& + ISPOINTER + ISUNSIGNED +SINGLETYPE = 32& + ISFLOAT + ISPOINTER +DOUBLETYPE = 64& + ISFLOAT + ISPOINTER +FLOATTYPE = 256& + ISFLOAT + ISPOINTER '8-32 bytes +OFFSETTYPE = 64& + ISOFFSET + ISPOINTER: IF OS_BITS = 32 THEN OFFSETTYPE = 32& + ISOFFSET + ISPOINTER +UOFFSETTYPE = 64& + ISOFFSET + ISUNSIGNED + ISPOINTER: IF OS_BITS = 32 THEN UOFFSETTYPE = 32& + ISOFFSET + ISUNSIGNED + ISPOINTER +UDTTYPE = ISUDT + ISPOINTER + + + + + + +DIM SHARED statementn AS LONG +DIM SHARED everycasenewcase AS LONG + + + + +DIM SHARED controllevel AS INTEGER '0=not in a control block +DIM SHARED controltype(1000) AS INTEGER +'1=IF (awaiting END IF) +'2=FOR (awaiting NEXT) +'3=DO (awaiting LOOP [UNTIL|WHILE param]) +'4=DO WHILE/UNTIL (awaiting LOOP) +'5=WHILE (awaiting WEND) +'6=$IF (precompiler) +'10=SELECT CASE qbs (awaiting END SELECT/CASE) +'11=SELECT CASE int64 (awaiting END SELECT/CASE) +'12=SELECT CASE uint64 (awaiting END SELECT/CASE) +'13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) +'14=SELECT CASE float ... +'15=SELECT CASE double +'16=SELECT CASE int32 +'17=SELECT CASE uint32 +'18=CASE (awaiting END SELECT/CASE/CASE ELSE) +'19=CASE ELSE (awaiting END SELECT) +'32=SUB/FUNCTION (awaiting END SUB/FUNCTION) +DIM controlid(1000) AS LONG +DIM controlvalue(1000) AS LONG +DIM controlstate(1000) AS INTEGER +DIM SHARED controlref(1000) AS LONG 'the line number the control was created on + + + + + +ON ERROR GOTO qberror + +i2&& = 1 +FOR i&& = 1 TO 64 + bitmask(i&&) = i2&& + bitmaskinv(i&&) = NOT i2&& + i2&& = i2&& + 2 ^ i&& +NEXT + +DIM id2 AS idstruct + +cleanupstringprocessingcall$ = "qbs_cleanup(qbs_tmp_base," + +DIM SHARED sfidlist(1000) AS LONG +DIM SHARED sfarglist(1000) AS INTEGER +DIM SHARED sfelelist(1000) AS INTEGER + + + + + + + + + + + + + + + +'----------------ripgl.bas-------------------------------------------------------------------------------- +gl_scan_header +'----------------ripgl.bas-------------------------------------------------------------------------------- + + + + + + + +'-----------------------QB64 COMPILER ONCE ONLY SETUP CODE ENDS HERE--------------------------------------- + +IF NoIDEMode THEN IDE_AutoPosition = 0: GOTO noide +DIM FileDropEnabled AS _BYTE +IF FileDropEnabled = 0 THEN FileDropEnabled = -1: _ACCEPTFILEDROP + +IF IDE_AutoPosition AND NOT IDE_BypassAutoPosition THEN _SCREENMOVE IDE_LeftPosition, IDE_TopPosition +idemode = 1 +sendc$ = "" 'no initial message +IF CMDLineFile <> "" THEN sendc$ = CHR$(1) + CMDLineFile +sendcommand: +idecommand$ = sendc$ +C = ide(0) +ideerror = 0 +IF C = 0 THEN idemode = 0: GOTO noide +c$ = idereturn$ + +IF C = 2 THEN 'begin + ideerrorline = 0 'addresses invalid prepass error line numbers being reported + idepass = 1 + GOTO fullrecompile + ideret1: + wholeline$ = c$ + GOTO ideprepass + ideret2: + IF lastLineReturn THEN GOTO lastLineReturn + sendc$ = CHR$(3) 'request next line + GOTO sendcommand +END IF + +IF C = 4 THEN 'next line + IF idepass = 1 THEN + wholeline$ = c$ + GOTO ideprepass + '(returns to ideret2: above) + END IF + 'assume idepass>1 + a3$ = c$ + continuelinefrom = 0 + GOTO ide4 + ideret4: + IF lastLineReturn THEN GOTO lastLineReturn + sendc$ = CHR$(3) 'request next line + GOTO sendcommand +END IF + +IF C = 5 THEN 'end of program reached + + lastLine = 1 + lastLineReturn = 1 + IF idepass = 1 THEN + wholeline$ = "" + GOTO ideprepass + '(returns to ideret2: above, then to lastLinePrepassReturn below) + END IF + 'idepass>1 + a3$ = "" + continuelinefrom = 0 + GOTO ide4 'returns to ideret4, then to lastLinePrepassReturn below + lastLineReturn: + lastLineReturn = 0 + lastLine = 0 + + IF idepass = 1 THEN + 'prepass complete + idepass = 2 + GOTO ide3 + ideret3: + sendc$ = CHR$(7) 'repass request + firstLine = 1 + GOTO sendcommand + END IF + 'assume idepass=2 + 'finalize program + GOTO ide5 + ideret5: 'note: won't return here if a recompile was required! + sendc$ = CHR$(6) 'ready + idecompiled = 0 + GOTO sendcommand +END IF + +IF C = 9 THEN 'run + + IF idecompiled = 0 THEN 'exe needs to be compiled + file$ = c$ + + 'locate accessible file and truncate + f$ = file$ + + path.exe$ = "" + IF SaveExeWithSource THEN + IF LEN(ideprogname) THEN path.exe$ = idepath$ + pathsep$ + END IF + + i = 1 + nextexeindex: + IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN + E = 0 + ON ERROR GOTO qberror_test + KILL path.exe$ + file$ + extension$ + ON ERROR GOTO qberror + IF E = 1 THEN + i = i + 1 + file$ = f$ + "(" + str2$(i) + ")" + GOTO nextexeindex + END IF + END IF + + 'inform IDE of name change if necessary (IDE will respond with message 9 and corrected name) + IF i <> 1 THEN + sendc$ = CHR$(12) + file$ + GOTO sendcommand + END IF + + ideerrorline = 0 'addresses C++ comp. error's line number + GOTO ide6 + ideret6: + idecompiled = 1 + END IF + + IF iderunmode = 2 THEN + sendc$ = CHR$(11) '.EXE file created + GOTO sendcommand + END IF + + 'execute program + + + + + IF iderunmode = 1 THEN + IF NoExeSaved THEN + 'This is the section which deals with if the user selected to run the program without + 'saving an EXE file to the disk. + 'We start off by first running the EXE, and then we delete it from the drive. + 'making it a temporary file when all is said and done. + IF os$ = "WIN" THEN + SHELL QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ 'run the newly created program + SHELL _HIDE _DONTWAIT "del " + QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) 'kill it + END IF + IF path.exe$ = "" THEN path.exe$ = "./" + IF os$ = "LNX" THEN + IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN + SHELL QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ + KILL lastBinaryGenerated$ + ELSE + SHELL QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ + KILL path.exe$ + lastBinaryGenerated$ + END IF + END IF + IF path.exe$ = "./" THEN path.exe$ = "" + NoExeSaved = 0 'reset the flag for a temp EXE + sendc$ = CHR$(6) 'ready + GOTO sendcommand + END IF + + + + IF os$ = "WIN" THEN SHELL _DONTWAIT QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ + IF path.exe$ = "" THEN path.exe$ = "./" + IF os$ = "LNX" THEN + IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN + SHELL _DONTWAIT QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ + ELSE + SHELL _DONTWAIT QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ + END IF + END IF + IF path.exe$ = "./" THEN path.exe$ = "" + ELSE + IF os$ = "WIN" THEN SHELL QuotedFilename$(CHR$(34) + lastBinaryGenerated$ + CHR$(34)) + ModifyCOMMAND$ + IF path.exe$ = "" THEN path.exe$ = "./" + IF os$ = "LNX" THEN + IF LEFT$(lastBinaryGenerated$, LEN(path.exe$)) = path.exe$ THEN + SHELL QuotedFilename$(lastBinaryGenerated$) + ModifyCOMMAND$ + ELSE + SHELL QuotedFilename$(path.exe$ + lastBinaryGenerated$) + ModifyCOMMAND$ + END IF + END IF + IF path.exe$ = "./" THEN path.exe$ = "" + DO: LOOP UNTIL INKEY$ = "" + DO: LOOP UNTIL _KEYHIT = 0 + END IF + + IF idemode THEN + 'Darken fg/bg colors + dummy = DarkenFGBG(0) + END IF + + IF vWatchOn THEN + sendc$ = CHR$(254) 'launch debug interface + ELSE + sendc$ = CHR$(6) 'ready + END IF + GOTO sendcommand +END IF + +PRINT "Invalid IDE message": END + +ideerror: +IF INSTR(idemessage$, sp$) THEN + 'Something went wrong here, so let's give a generic error message to the user. + '(No error message should contain sp$ - that is, CHR$(13), when not in Debug mode) + terrmsg$ = _ERRORMESSAGE$ + IF terrmsg$ = "No error" THEN terrmsg$ = "Internal error" + idemessage$ = "Compiler error (check for syntax errors) (" + terrmsg$ + ":" + IF ERR THEN idemessage$ = idemessage$ + str2$(ERR) + "-" + IF _ERRORLINE THEN idemessage$ = idemessage$ + str2$(_ERRORLINE) + IF _INCLERRORLINE THEN idemessage$ = idemessage$ + "-" + _INCLERRORFILE$ + "-" + str2$(_INCLERRORLINE) + idemessage$ = idemessage$ + ")" + IF inclevel > 0 THEN idemessage$ = idemessage$ + incerror$ +END IF + +sendc$ = CHR$(8) + idemessage$ + MKL$(ideerrorline) +GOTO sendcommand + + +noide: +IF (qb64versionprinted = 0 OR ConsoleMode = 0) AND NOT QuietMode THEN + qb64versionprinted = -1 + PRINT "QB64-PE Compiler V" + Version$ +END IF + +IF CMDLineFile = "" THEN + LINE INPUT ; "COMPILE (.bas)>", f$ +ELSE + f$ = CMDLineFile +END IF + +f$ = LTRIM$(RTRIM$(f$)) + +IF FileHasExtension(f$) = 0 THEN f$ = f$ + ".bas" + +sourcefile$ = f$ +CMDLineFile = sourcefile$ +'derive name from sourcefile +f$ = RemoveFileExtension$(f$) + +path.exe$ = "" +currentdir$ = _CWD$ +path.source$ = getfilepath$(sourcefile$) +IF LEN(path.source$) THEN + IF _DIREXISTS(path.source$) = 0 THEN + PRINT + PRINT "Cannot locate source file: " + sourcefile$ + IF ConsoleMode THEN SYSTEM 1 + END 1 + END IF + CHDIR path.source$ + path.source$ = _CWD$ + IF RIGHT$(path.source$, 1) <> pathsep$ THEN path.source$ = path.source$ + pathsep$ + CHDIR currentdir$ +END IF +IF SaveExeWithSource THEN path.exe$ = path.source$ + +FOR x = LEN(f$) TO 1 STEP -1 + a$ = MID$(f$, x, 1) + IF a$ = "/" OR a$ = "\" THEN + f$ = RIGHT$(f$, LEN(f$) - x) + EXIT FOR + END IF +NEXT +file$ = f$ + +'if cmemlist(currentid+1)<>0 before calling regid the variable +'MUST be defined in cmem! + +fullrecompile: + +BU_DEPENDENCY_CONSOLE_ONLY = DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) +FOR i = 1 TO UBOUND(DEPENDENCY): DEPENDENCY(i) = 0: NEXT +DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) = BU_DEPENDENCY_CONSOLE_ONLY AND 2 'Restore -g switch if used + +Error_Happened = 0 + +FOR closeall = 1 TO 255: CLOSE closeall: NEXT + +OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock + +fh = FREEFILE: OPEN tmpdir$ + "dyninfo.txt" FOR OUTPUT AS #fh: CLOSE #fh + +IF Debug THEN CLOSE #9: OPEN tmpdir$ + "debug.txt" FOR OUTPUT AS #9 + +FOR i = 1 TO ids_max + 1 + arrayelementslist(i) = 0 + cmemlist(i) = 0 + sfcmemargs(i) = "" +NEXT + +'erase cmemlist +'erase sfcmemargs + +lastunresolved = -1 'first pass +sflistn = -1 'no entries + +SubNameLabels = sp 'QB64 will perform a repass to resolve sub names used as labels + +vWatchDesiredState = 0 +vWatchRecompileAttempts = 0 + +qb64prefix_set_desiredState = 0 +qb64prefix_set_recompileAttempts = 0 + +opex_desiredState = 0 +opex_recompileAttempts = 0 + +opexarray_desiredState = 0 +opexarray_recompileAttempts = 0 + +recompile: +vWatchOn = vWatchDesiredState +vWatchVariable "", -1 'reset internal variables list + +qb64prefix_set = qb64prefix_set_desiredState +qb64prefix$ = "_" + +optionexplicit = opex_desiredState +IF optionexplicit_cmd = -1 AND NoIDEMode = 1 THEN optionexplicit = -1 +optionexplicitarray = opexarray_desiredState + +lastLineReturn = 0 +lastLine = 0 +firstLine = 1 + +Resize = 0 +Resize_Scale = 0 + +UseGL = 0 + +Error_Happened = 0 + +HashClear 'clear the hash table + +'add reserved words to hashtable + +f = HASHFLAG_TYPE + HASHFLAG_RESERVED +HashAdd "_UNSIGNED", f, 0 +HashAdd "_BIT", f, 0 +HashAdd "_BYTE", f, 0 +HashAdd "INTEGER", f, 0 +HashAdd "LONG", f, 0 +HashAdd "_INTEGER64", f, 0 +HashAdd "_OFFSET", f, 0 +HashAdd "SINGLE", f, 0 +HashAdd "DOUBLE", f, 0 +HashAdd "_FLOAT", f, 0 +HashAdd "STRING", f, 0 +HashAdd "ANY", f, 0 + +f = HASHFLAG_OPERATOR + HASHFLAG_RESERVED +HashAdd "NOT", f, 0 +HashAdd "IMP", f, 0 +HashAdd "EQV", f, 0 +HashAdd "AND", f, 0 +HashAdd "OR", f, 0 +HashAdd "XOR", f, 0 +HashAdd "MOD", f, 0 + +f = HASHFLAG_RESERVED + HASHFLAG_CUSTOMSYNTAX +HashAdd "LIST", f, 0 +HashAdd "BASE", f, 0 +HashAdd "_EXPLICIT", f, 0 +HashAdd "AS", f, 0 +HashAdd "IS", f, 0 +HashAdd "OFF", f, 0 +HashAdd "ON", f, 0 +HashAdd "STOP", f, 0 +HashAdd "TO", f, 0 +HashAdd "USING", f, 0 +'PUT(graphics) statement: +HashAdd "PRESET", f, 0 +HashAdd "PSET", f, 0 +'OPEN statement: +HashAdd "FOR", f, 0 +HashAdd "OUTPUT", f, 0 +HashAdd "RANDOM", f, 0 +HashAdd "BINARY", f, 0 +HashAdd "APPEND", f, 0 +HashAdd "SHARED", f, 0 +HashAdd "ACCESS", f, 0 +HashAdd "LOCK", f, 0 +HashAdd "READ", f, 0 +HashAdd "WRITE", f, 0 +'LINE statement: +HashAdd "STEP", f, 0 +'WIDTH statement: +HashAdd "LPRINT", f, 0 +'VIEW statement: +HashAdd "PRINT", f, 0 + +f = HASHFLAG_RESERVED + HASHFLAG_XELEMENTNAME + HASHFLAG_XTYPENAME +'A +'B +'C +HashAdd "COMMON", f, 0 +HashAdd "CALL", f, 0 +HashAdd "CASE", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "COM", f, 0 '(ON...) +HashAdd "CONST", f, 0 +'D +HashAdd "DATA", f, 0 +HashAdd "DECLARE", f, 0 +HashAdd "DEF", f, 0 +HashAdd "DEFDBL", f, 0 +HashAdd "DEFINT", f, 0 +HashAdd "DEFLNG", f, 0 +HashAdd "DEFSNG", f, 0 +HashAdd "DEFSTR", f, 0 +HashAdd "DIM", f, 0 +HashAdd "DO", f - HASHFLAG_XELEMENTNAME, 0 +'E +HashAdd "ERROR", f - HASHFLAG_XELEMENTNAME, 0 '(ON ...) +HashAdd "ELSE", f, 0 +HashAdd "ELSEIF", f, 0 +HashAdd "ENDIF", f, 0 +HashAdd "EXIT", f - HASHFLAG_XELEMENTNAME, 0 +'F +HashAdd "FIELD", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "FUNCTION", f, 0 +'G +HashAdd "GOSUB", f, 0 +HashAdd "GOTO", f, 0 +'H +'I +HashAdd "INPUT", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(INPUT$ function exists, so conflicts if allowed as custom syntax) +HashAdd "IF", f, 0 +'K +HashAdd "KEY", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) +'L +HashAdd "LET", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "LOOP", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "LEN", f - HASHFLAG_XELEMENTNAME, 0 '(LEN function exists, so conflicts if allowed as custom syntax) +'M +'N +HashAdd "NEXT", f - HASHFLAG_XELEMENTNAME, 0 +'O +'P +HashAdd "PLAY", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) +HashAdd "PEN", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) +'Q +'R +HashAdd "REDIM", f, 0 +HashAdd "REM", f, 0 +HashAdd "RESTORE", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "RESUME", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "RETURN", f - HASHFLAG_XELEMENTNAME, 0 +HashAdd "RUN", f - HASHFLAG_XELEMENTNAME, 0 +'S +HashAdd "STATIC", f, 0 +HashAdd "STRIG", f, 0 '(ON...) +HashAdd "SEG", f, 0 +HashAdd "SELECT", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 +HashAdd "SUB", f, 0 +HashAdd "SCREEN", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 +'T +HashAdd "THEN", f, 0 +HashAdd "TIMER", f - HASHFLAG_XELEMENTNAME - HASHFLAG_XTYPENAME, 0 '(ON...) +HashAdd "TYPE", f - HASHFLAG_XELEMENTNAME, 0 +'U +HashAdd "UNTIL", f, 0 +HashAdd "UEVENT", f, 0 +'V +'W +HashAdd "WEND", f, 0 +HashAdd "WHILE", f, 0 +'X +'Y +'Z + + + + + + + +'clear/init variables +Console = 0 +ScreenHide = 0 +Asserts = 0 +ResolveStaticFunctions = 0 +dynamiclibrary = 0 +dimsfarray = 0 +dimstatic = 0 +AllowLocalName = 0 +PossibleSubNameLabels = sp 'QB64 will perform a repass to resolve sub names used as labels +use_global_byte_elements = 0 +dimshared = 0: dimmethod = 0: dimoption = 0: redimoption = 0: commonoption = 0 +mylib$ = "": mylibopt$ = "" +declaringlibrary = 0 +nLabels = 0 +dynscope = 0 +elsefollowup = 0 +ontimerid = 0: onkeyid = 0: onstrigid = 0 +commonarraylist = "": commonarraylistn = 0 +staticarraylist = "": staticarraylistn = 0 +fooindwel = 0 +layout = "" +layoutok = 0 +NoChecks = 0 +inclevel = 0 +errorLineInInclude = 0 +addmetainclude$ = "" +nextrunlineindex = 1 +lasttype = 0 +lasttypeelement = 0 +REDIM SHARED udtxname(1000) AS STRING * 256 +REDIM SHARED udtxcname(1000) AS STRING * 256 +REDIM SHARED udtxsize(1000) AS LONG +REDIM SHARED udtxbytealign(1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 +REDIM SHARED udtxnext(1000) AS LONG +REDIM SHARED udtxvariable(1000) AS INTEGER 'true if the udt contains variable length elements +'elements +REDIM SHARED udtename(1000) AS STRING * 256 +REDIM SHARED udtecname(1000) AS STRING * 256 +REDIM SHARED udtebytealign(1000) AS INTEGER +REDIM SHARED udtesize(1000) AS LONG +REDIM SHARED udtetype(1000) AS LONG +REDIM SHARED udtetypesize(1000) AS LONG +REDIM SHARED udtearrayelements(1000) AS LONG +REDIM SHARED udtenext(1000) AS LONG +definingtype = 0 +definingtypeerror = 0 +constlast = -1 +'constlastshared = -1 +defdatahandle = 18 +closedmain = 0 +addmetastatic = 0 +addmetadynamic = 0 +DynamicMode = 0 +optionbase = 0 +ExeIconSet = 0 +VersionInfoSet = 0 +viFileVersionNum$ = "": viProductVersionNum$ = "": viCompanyName$ = "" +viFileDescription$ = "": viFileVersion$ = "": viInternalName$ = "" +viLegalCopyright$ = "": viLegalTrademarks$ = "": viOriginalFilename$ = "" +viProductName$ = "": viProductVersion$ = "": viComments$ = "": viWeb$ = "" +DataOffset = 0 +statementn = 0 +everycasenewcase = 0 +qberrorhappened = 0: qberrorcode = 0: qberrorline = 0 +FOR i = 1 TO 27: defineaz(i) = "SINGLE": defineextaz(i) = "!": NEXT +controllevel = 0 +findidsecondarg$ = "": findanotherid = 0: findidinternal = 0: currentid = 0 +linenumber = 0 +wholeline$ = "" +linefragment$ = "" +idn = 0 +arrayprocessinghappened = 0 +stringprocessinghappened = 0 +inputfunctioncalled = 0 +subfuncn = 0 +closedsubfunc = 0 +subfunc = "" +SelectCaseCounter = 0 +ExecCounter = 0 +UserDefineCount = 7 +totalVariablesCreated = 0 +typeDefinitions$ = "" +totalMainVariablesCreated = 0 +REDIM SHARED usedVariableList(1000) AS usedVarList +totalWarnings = 0 +duplicateConstWarning = 0 +emptySCWarning = 0 +warningListItems = 0 +lastWarningHeader = "" +vWatchUsedLabels = SPACE$(1000) +vWatchUsedSkipLabels = SPACE$(1000) +firstLineNumberLabelvWatch = 0 +REDIM SHARED warning$(1000) +REDIM SHARED warningLines(1000) AS LONG +REDIM SHARED warningIncLines(1000) AS LONG +REDIM SHARED warningIncFiles(1000) AS STRING +maxLineNumber = 0 +uniquenumbern = 0 + + +''create a type for storing memory blocks +''UDT +''names +'DIM SHARED lasttype AS LONG +'DIM SHARED udtxname(1000) AS STRING * 256 +'DIM SHARED udtxcname(1000) AS STRING * 256 +'DIM SHARED udtxsize(1000) AS LONG +'DIM SHARED udtxbytealign(1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 +'DIM SHARED udtxnext(1000) AS LONG +''elements +'DIM SHARED lasttypeelement AS LONG +'DIM SHARED udtename(1000) AS STRING * 256 +'DIM SHARED udtecname(1000) AS STRING * 256 +'DIM SHARED udtebytealign(1000) AS INTEGER +'DIM SHARED udtesize(1000) AS LONG +'DIM SHARED udtetype(1000) AS LONG +'DIM SHARED udtetypesize(1000) AS LONG +'DIM SHARED udtearrayelements(1000) AS LONG +'DIM SHARED udtenext(1000) AS LONG + +'import _MEM type +ptrsz = OS_BITS \ 8 + +lasttype = lasttype + 1: i = lasttype +udtxname(i) = "_MEM" +udtxcname(i) = "_MEM" +udtxsize(i) = ((ptrsz) * 5 + (4) * 2 + (8) * 1) * 8 +udtxbytealign(i) = 1 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "OFFSET" +udtecname(i2) = "OFFSET" +udtebytealign(i2) = 1 +udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 +udtetypesize(i2) = 0 'tsize +udtxnext(i) = i2 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "SIZE" +udtecname(i2) = "SIZE" +udtebytealign(i2) = 1 +udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "$_LOCK_ID" +udtecname(i2) = "$_LOCK_ID" +udtebytealign(i2) = 1 +udtetype(i2) = INTEGER64TYPE: udtesize(i2) = 64 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "$_LOCK_OFFSET" +udtecname(i2) = "$_LOCK_OFFSET" +udtebytealign(i2) = 1 +udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "TYPE" +udtecname(i2) = "TYPE" +udtebytealign(i2) = 1 +udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "ELEMENTSIZE" +udtecname(i2) = "ELEMENTSIZE" +udtebytealign(i2) = 1 +udtetype(i2) = OFFSETTYPE: udtesize(i2) = ptrsz * 8 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +udtenext(i2) = 0 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "IMAGE" +udtecname(i2) = "IMAGE" +udtebytealign(i2) = 1 +udtetype(i2) = LONGTYPE: udtesize(i2) = 32 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +udtenext(i2) = 0 +i3 = i2 +lasttypeelement = lasttypeelement + 1: i2 = lasttypeelement +udtename(i2) = "SOUND" +udtecname(i2) = "SOUND" +udtebytealign(i2) = 1 +udtetype(i2) = LONGTYPE: udtesize(i2) = 32 +udtetypesize(i2) = 0 'tsize +udtenext(i3) = i2 +udtenext(i2) = 0 + + + + + + + + + + +'begin compilation +FOR closeall = 1 TO 255: CLOSE closeall: NEXT +OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock + +ff = FREEFILE: OPEN tmpdir$ + "icon.rc" FOR OUTPUT AS #ff: CLOSE #ff + +IF Debug THEN CLOSE #9: OPEN tmpdir$ + "debug.txt" FOR APPEND AS #9 + +IF idemode = 0 THEN + qberrorhappened = -1 + OPEN sourcefile$ FOR INPUT AS #1 + qberrorhappened1: + IF qberrorhappened = 1 THEN + PRINT + PRINT "Cannot locate source file: " + sourcefile$ + IF ConsoleMode THEN SYSTEM 1 + END 1 + ELSE + CLOSE #1 + END IF + qberrorhappened = 0 +END IF + +reginternal + +IF qb64prefix_set THEN + qb64prefix$ = "" + + 're-add internal keywords without the "_" prefix + reginternal + + f = HASHFLAG_TYPE + HASHFLAG_RESERVED + HashAdd "UNSIGNED", f, 0 + HashAdd "BIT", f, 0 + HashAdd "BYTE", f, 0 + HashAdd "INTEGER64", f, 0 + HashAdd "OFFSET", f, 0 + HashAdd "FLOAT", f, 0 + + f = HASHFLAG_RESERVED + HASHFLAG_CUSTOMSYNTAX + HashAdd "EXPLICIT", f, 0 +END IF + +OPEN tmpdir$ + "global.txt" FOR OUTPUT AS #18 + +IF iderecompile THEN + iderecompile = 0 + idepass = 1 'prepass must be done again + sendc$ = CHR$(7) 'repass request + GOTO sendcommand +END IF + +IF idemode THEN GOTO ideret1 + +IF NOT QuietMode THEN + PRINT + PRINT "Beginning C++ output from QB64 code... " +END IF + +lineinput3load sourcefile$ + +DO + + '### STEVE EDIT FOR CONST EXPANSION 10/11/2013 + + wholeline$ = lineinput3$ + IF wholeline$ = CHR$(13) THEN EXIT DO + + ideprepass: + prepassLastLine: + + IF lastLine <> 0 OR firstLine <> 0 THEN + lineBackup$ = wholeline$ 'backup the real line (will be blank when lastline is set) + forceIncludeFromRoot$ = "" + IF vWatchOn THEN + addingvWatch = 1 + IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bi" + IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bm" + ELSE + 'IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bi" + IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bm" + END IF + firstLine = 0: lastLine = 0 + IF LEN(forceIncludeFromRoot$) THEN GOTO forceInclude_prepass + forceIncludeCompleted_prepass: + addingvWatch = 0 + wholeline$ = lineBackup$ + END IF + + wholestv$ = wholeline$ '### STEVE EDIT FOR CONST EXPANSION 10/11/2013 + + prepass = 1 + layout = "" + layoutok = 0 + + linenumber = linenumber + 1 + reallinenumber = reallinenumber + 1 + + DO UNTIL linenumber < UBOUND(InValidLine) 'color information flag for each line + REDIM _PRESERVE InValidLine(UBOUND(InValidLine) + 1000) AS _BYTE + LOOP + InValidLine(linenumber) = 0 + + IF LEN(wholeline$) THEN + + IF UCASE$(_TRIM$(wholeline$)) = "$NOPREFIX" THEN + qb64prefix_set_desiredState = 1 + IF qb64prefix_set = 0 THEN + IF qb64prefix_set_recompileAttempts = 0 THEN + qb64prefix_set_recompileAttempts = qb64prefix_set_recompileAttempts + 1 + GOTO do_recompile + END IF + END IF + END IF + + wholeline$ = lineformat(wholeline$) + IF Error_Happened THEN GOTO errmes + + + temp$ = LTRIM$(RTRIM$(UCASE$(wholestv$))) + + IF temp$ = "$COLOR:0" THEN + IF qb64prefix_set THEN + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0_noprefix.bi" + ELSE + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0.bi" + END IF + GOTO finishedlinepp + END IF + + IF temp$ = "$COLOR:32" THEN + IF qb64prefix_set THEN + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32_noprefix.bi" + ELSE + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32.bi" + END IF + GOTO finishedlinepp + END IF + + IF temp$ = "$DEBUG" THEN + vWatchDesiredState = 1 + IF vWatchOn = 0 THEN + IF vWatchRecompileAttempts = 0 THEN + 'this is the first time a conflict has occurred, so react immediately with a full recompilation using the desired state + vWatchRecompileAttempts = vWatchRecompileAttempts + 1 + GOTO do_recompile + ELSE + 'continue compilation to retrieve the final state requested and act on that as required + END IF + END IF + END IF + + IF LEFT$(temp$, 4) = "$IF " THEN + IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$IF without THEN": GOTO errmes + temp$ = LTRIM$(MID$(temp$, 4)) 'strip off the $IF and extra spaces + temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces + temp = INSTR(temp$, "=") + ExecCounter = ExecCounter + 1 + ExecLevel(ExecCounter) = -1 'default to a skip value + DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level + result = EvalPreIF(temp$, a$) + IF a$ <> "" THEN GOTO errmes + IF result <> 0 THEN + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above + IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found + END IF + GOTO finishedlinepp 'and then we're finished -- and at this point we didn't make a match so we exit with a DONT READ type flag on our code. + END IF + + IF temp$ = "$ELSE" THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes + IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes + DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block + IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here + ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above + ELSE + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED + END IF + GOTO finishedlinepp + END IF + + IF LEFT$(temp$, 5) = "$ELSE" THEN 'looking for $ELSE IF + temp$ = LTRIM$(MID$(temp$, 6)) + IF LEFT$(temp$, 3) = "IF " THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes + IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes + IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes + IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here + ExecLevel(ExecCounter) = -1 + GOTO finishedlinepp + END IF + temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces + temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces + result = EvalPreIF(temp$, a$) + IF a$ <> "" THEN GOTO errmes + IF result <> 0 THEN + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above + IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found + END IF + GOTO finishedlinepp 'and then we're finished -- and at this point we didn't make a match so we exit with a DONT READ type flag on our code. + END IF + END IF + + IF temp$ = "$END IF" OR temp$ = "$ENDIF" THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes + DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level + ExecCounter = ExecCounter - 1 + GOTO finishedlinepp + END IF + + IF ExecLevel(ExecCounter) THEN + DO UNTIL linenumber < UBOUND(InValidLine) + REDIM _PRESERVE InValidLine(UBOUND(InValidLine) + 1000) AS _BYTE + LOOP + + InValidLine(linenumber) = -1 + GOTO finishedlinepp 'we don't check for anything inside lines that we've marked for skipping + END IF + + IF LEFT$(temp$, 7) = "$ERROR " THEN + temp$ = LTRIM$(MID$(temp$, 7)) + a$ = "Compilation check failed: " + temp$ + GOTO errmes + END IF + + IF LEFT$(temp$, 5) = "$LET " THEN + temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse + 'For starters, let's make certain that we have 3 elements to deal with + temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side + IF temp = 0 THEN a$ = "Invalid Syntax. $LET = ": GOTO errmes + l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) + 'then validate to make certain the left side looks proper + IF validname(l$) = 0 THEN a$ = "Invalid flag name": GOTO errmes + IF LEFT$(r$, 1) = CHR$(34) THEN r$ = LTRIM$(MID$(r$, 2)) + IF RIGHT$(r$, 1) = CHR$(34) THEN r$ = RTRIM$(LEFT$(r$, LEN(r$) - 1)) + IF LEFT$(r$, 1) = "-" THEN + r1$ = "-" + r$ = LTRIM$(MID$(r$, 2)) + ELSE + r1$ = "" + END IF + 'then validate to make certain the left side looks proper + FOR i = 1 TO LEN(r$) + a = ASC(r$, i) + SELECT CASE a + CASE 32 + CASE 46 'periods are fine. + r1$ = r1$ + "." + CASE IS < 48, IS > 90 + a$ = "Invalid value": GOTO errmes + CASE ELSE + r1$ = r1$ + CHR$(a) + END SELECT + NEXT + r$ = r1$ + 'First look to see if we have an existing setting like this and if so, update it + FOR i = 8 TO UserDefineCount 'UserDefineCount 1-7 are reserved for automatic OS/BIT detection & version + IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishedlinepp + NEXT + 'Otherwise create a new setting and set the initial value for it + UserDefineCount = UserDefineCount + 1 + IF UserDefineCount > UBOUND(UserDefine, 2) THEN + REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it + END IF + UserDefine(0, UserDefineCount) = l$ + UserDefine(1, UserDefineCount) = r$ + GOTO finishedlinepp + END IF + + + cwholeline$ = wholeline$ + wholeline$ = eleucase$(wholeline$) '********REMOVE THIS LINE LATER******** + + + addmetadynamic = 0: addmetastatic = 0 + wholelinen = numelements(wholeline$) + + IF wholelinen THEN + + wholelinei = 1 + + 'skip line number? + e$ = getelement$(wholeline$, 1) + IF (ASC(e$) >= 48 AND ASC(e$) <= 59) OR ASC(e$) = 46 THEN wholelinei = 2: GOTO ppskpl + + 'skip 'POSSIBLE' line label? + IF wholelinen >= 2 THEN + x2 = INSTR(wholeline$, sp + ":" + sp): x3 = x2 + 2 + IF x2 = 0 THEN + IF RIGHT$(wholeline$, 2) = sp + ":" THEN x2 = LEN(wholeline$) - 1: x3 = x2 + 1 + END IF + + IF x2 THEN + e$ = LEFT$(wholeline$, x2 - 1) + IF validlabel(e$) THEN + wholeline$ = RIGHT$(wholeline$, LEN(wholeline$) - x3) + cwholeline$ = RIGHT$(cwholeline$, LEN(wholeline$) - x3) + wholelinen = numelements(wholeline$) + GOTO ppskpl + END IF 'valid + END IF 'includes ":" + END IF 'wholelinen>=2 + + ppskpl: + IF wholelinei <= wholelinen THEN + '---------------------------------------- + a$ = "" + ca$ = "" + ppblda: + e$ = getelement$(wholeline$, wholelinei) + ce$ = getelement$(cwholeline$, wholelinei) + IF e$ = ":" OR e$ = "ELSE" OR e$ = "THEN" OR e$ = "" THEN + IF LEN(a$) THEN + IF Debug THEN PRINT #9, "PP[" + a$ + "]" + n = numelements(a$) + firstelement$ = getelement(a$, 1) + secondelement$ = getelement(a$, 2) + thirdelement$ = getelement(a$, 3) + '======================================== + + IF n = 2 AND firstelement$ = "END" AND (secondelement$ = "SUB" OR secondelement$ = "FUNCTION") THEN + closedsubfunc = -1 + END IF + + 'declare library + IF declaringlibrary THEN + + IF firstelement$ = "END" THEN + IF n <> 2 OR secondelement$ <> "DECLARE" THEN a$ = "Expected END DECLARE": GOTO errmes + declaringlibrary = 0 + GOTO finishedlinepp + END IF 'end declare + + declaringlibrary = 2 + + IF firstelement$ = "SUB" OR firstelement$ = "FUNCTION" THEN subfuncn = subfuncn - 1: GOTO declaresubfunc + + a$ = "Expected SUB/FUNCTION definition or END DECLARE (#2)": GOTO errmes + END IF + + 'UDT TYPE definition + IF definingtype THEN + i = definingtype + + IF n >= 1 THEN + IF firstelement$ = "END" THEN + IF n <> 2 OR secondelement$ <> "TYPE" THEN a$ = "Expected END TYPE": GOTO errmes + IF udtxnext(i) = 0 THEN a$ = "No elements defined in TYPE": GOTO errmes + definingtype = 0 + + 'create global buffer for SWAP space + siz$ = str2$(udtxsize(i) \ 8) + PRINT #18, "char *g_tmp_udt_" + RTRIM$(udtxname(i)) + "=(char*)malloc(" + siz$ + ");" + + 'print "END TYPE";udtxsize(i);udtxbytealign(i) + GOTO finishedlinepp + END IF + END IF + + IF n < 3 THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes + n$ = firstelement$ + + IF n$ <> "AS" THEN + 'traditional variable-name AS type syntax, single-element + lasttypeelement = lasttypeelement + 1 + i2 = lasttypeelement + WHILE i2 > UBOUND(udtenext): increaseUDTArrays: WEND + udtenext(i2) = 0 + + ii = 2 + + udtearrayelements(i2) = 0 + + IF ii >= n OR getelement$(a$, ii) <> "AS" THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes + t$ = getelements$(a$, ii + 1, n) + + IF t$ = RTRIM$(udtxname(definingtype)) THEN a$ = "Invalid self-reference": GOTO errmes + typ = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF typ = 0 THEN a$ = "Undefined type": GOTO errmes + typsize = typname2typsize + + IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes + udtename(i2) = n$ + udtecname(i2) = getelement$(ca$, 1) + NormalTypeBlock: + typeDefinitions$ = typeDefinitions$ + MKL$(i2) + MKL$(LEN(n$)) + n$ + udtetype(i2) = typ + udtetypesize(i2) = typsize + + hashname$ = n$ + + 'check for name conflicts (any similar reserved or element from current UDT) + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_UDTELEMENT + hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF hashresflags AND HASHFLAG_UDTELEMENT THEN + IF hashresref = i THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + END IF + IF hashresflags AND HASHFLAG_RESERVED THEN + IF hashresflags AND (HASHFLAG_TYPE + HASHFLAG_CUSTOMSYNTAX + HASHFLAG_OPERATOR + HASHFLAG_XELEMENTNAME) THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + 'add to hash table + HashAdd hashname$, HASHFLAG_UDTELEMENT, i + + 'Calculate element's size + IF typ AND ISUDT THEN + u = typ AND 511 + udtesize(i2) = udtxsize(u) + IF udtxbytealign(u) THEN udtxbytealign(i) = 1: udtebytealign(i2) = 1 + IF udtxvariable(u) THEN udtxvariable(i) = -1 + ELSE + IF (typ AND ISSTRING) THEN + IF (typ AND ISFIXEDLENGTH) = 0 THEN + udtesize(i2) = OFFSETTYPE AND 511 + udtxvariable(i) = -1 + ELSE + udtesize(i2) = typsize * 8 + END IF + udtxbytealign(i) = 1: udtebytealign(i2) = 1 + ELSE + udtesize(i2) = typ AND 511 + IF (typ AND ISOFFSETINBITS) = 0 THEN udtxbytealign(i) = 1: udtebytealign(i2) = 1 + END IF + END IF + + 'Increase block size + IF udtebytealign(i2) THEN + IF udtxsize(i) MOD 8 THEN + udtxsize(i) = udtxsize(i) + (8 - (udtxsize(i) MOD 8)) + END IF + END IF + udtxsize(i) = udtxsize(i) + udtesize(i2) + + 'Link element to previous element + IF udtxnext(i) = 0 THEN + udtxnext(i) = i2 + ELSE + udtenext(i2 - 1) = i2 + END IF + + 'print "+"+rtrim$(udtename(i2));udtetype(i2);udtesize(i2);udtebytealign(i2);udtxsize(i) + IF newAsTypeBlockSyntax THEN RETURN + GOTO finishedlinepp + ELSE + 'new AS type variable-list syntax, multiple elements + ii = 2 + + IF ii >= n THEN a$ = "Expected element-name AS type, AS type element-list, or END TYPE": GOTO errmes + previousElement$ = "" + t$ = "" + lastElement$ = "" + buildTypeName: + lastElement$ = getelement$(a$, ii) + IF lastElement$ <> "," AND lastElement$ <> "" THEN + n$ = lastElement$ + cn$ = getelement$(ca$, ii) + IF LEN(previousElement$) THEN t$ = t$ + previousElement$ + " " + previousElement$ = n$ + lastElement$ = "" + ii = ii + 1 + GOTO buildTypeName + END IF + + t$ = RTRIM$(t$) + IF t$ = RTRIM$(udtxname(definingtype)) THEN a$ = "Invalid self-reference": GOTO errmes + typ = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF typ = 0 THEN a$ = "Undefined type": GOTO errmes + typsize = typname2typsize + + previousElement$ = lastElement$ + nexttypeelement: + lasttypeelement = lasttypeelement + 1 + i2 = lasttypeelement + WHILE i2 > UBOUND(udtenext): increaseUDTArrays: WEND + udtenext(i2) = 0 + udtearrayelements(i2) = 0 + + udtename(i2) = n$ + udtecname(i2) = cn$ + + IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes + + newAsTypeBlockSyntax = -1 + GOSUB NormalTypeBlock + newAsTypeBlockSyntax = 0 + + getNextElement: + ii = ii + 1 + lastElement$ = getelement$(a$, ii) + IF lastElement$ = "" THEN GOTO finishedlinepp + IF ii = n AND lastElement$ = "," THEN a$ = "Expected element-name": GOTO errmes + IF lastElement$ = "," THEN + IF previousElement$ = "," THEN a$ = "Expected element-name": GOTO errmes + previousElement$ = lastElement$ + GOTO getNextElement + END IF + n$ = lastElement$ + IF previousElement$ <> "," THEN a$ = "Expected ,": GOTO errmes + previousElement$ = lastElement$ + cn$ = getelement$(ca$, ii) + GOTO nexttypeelement + END IF + END IF 'definingtype + + IF definingtype AND n >= 1 THEN a$ = "Expected END TYPE": GOTO errmes + + IF n >= 1 THEN + IF firstelement$ = "TYPE" THEN + IF n <> 2 THEN a$ = "Expected TYPE typename": GOTO errmes + lasttype = lasttype + 1 + typeDefinitions$ = typeDefinitions$ + MKL$(-1) + MKL$(lasttype) + definingtype = lasttype + i = definingtype + WHILE i > UBOUND(udtenext): increaseUDTArrays: WEND + IF validname(secondelement$) = 0 THEN a$ = "Invalid name": GOTO errmes + typeDefinitions$ = typeDefinitions$ + MKL$(LEN(secondelement$)) + secondelement$ + udtxname(i) = secondelement$ + udtxcname(i) = getelement(ca$, 2) + udtxnext(i) = 0 + udtxsize(i) = 0 + udtxvariable(i) = 0 + + hashname$ = secondelement$ + hashflags = HASHFLAG_UDT + 'check for name conflicts (any similar reserved/sub/function/UDT name) + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_UDT + hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + allow = 0 + IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN + allow = 1 + END IF + IF hashresflags AND HASHFLAG_RESERVED THEN + IF (hashresflags AND (HASHFLAG_TYPE + HASHFLAG_OPERATOR + HASHFLAG_CUSTOMSYNTAX + HASHFLAG_XTYPENAME)) = 0 THEN allow = 1 + END IF + IF allow = 0 THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + + 'add to hash table + HashAdd hashname$, hashflags, i + + GOTO finishedlinepp + END IF + END IF + + + + + + IF n >= 1 AND firstelement$ = "CONST" THEN + 'l$ = "CONST" + 'DEF... do not change type, the expression is stored in a suitable type + 'based on its value if type isn't forced/specified + + IF subfuncn > 0 AND closedsubfunc <> 0 THEN a$ = "Statement cannot be placed between SUB/FUNCTIONs": GOTO errmes + + 'convert periods to _046_ + i2 = INSTR(a$, sp + "." + sp) + IF i2 THEN + DO + a$ = LEFT$(a$, i2 - 1) + fix046$ + RIGHT$(a$, LEN(a$) - i2 - 2) + ca$ = LEFT$(ca$, i2 - 1) + fix046$ + RIGHT$(ca$, LEN(ca$) - i2 - 2) + i2 = INSTR(a$, sp + "." + sp) + LOOP UNTIL i2 = 0 + n = numelements(a$) + firstelement$ = getelement(a$, 1): secondelement$ = getelement(a$, 2): thirdelement$ = getelement(a$, 3) + END IF + + IF n < 3 THEN a$ = "Expected CONST name = value/expression": GOTO errmes + i = 2 + constdefpendingpp: + pending = 0 + + n$ = getelement$(ca$, i): i = i + 1 + typeoverride = 0 + s$ = removesymbol$(n$) + IF Error_Happened THEN GOTO errmes + IF s$ <> "" THEN + typeoverride = typname2typ(s$) + IF Error_Happened THEN GOTO errmes + IF typeoverride AND ISFIXEDLENGTH THEN a$ = "Invalid constant type": GOTO errmes + IF typeoverride = 0 THEN a$ = "Invalid constant type": GOTO errmes + END IF + + IF getelement$(a$, i) <> "=" THEN a$ = "Expected =": GOTO errmes + i = i + 1 + + 'get expression + e$ = "" + readable_e$ = "" + B = 0 + FOR i2 = i TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN + pending = 1 + i = i2 + 1 + IF i > n - 2 THEN a$ = "Expected CONST ... , name = value/expression": GOTO errmes + EXIT FOR + END IF + IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + + e3$ = e2$ + IF LEN(e2$) > 1 THEN + IF ASC(e2$, 1) = 34 THEN + removeComma = _INSTRREV(e2$, ",") + e3$ = LEFT$(e2$, removeComma - 1) + ELSE + removeComma = INSTR(e2$, ",") + e3$ = MID$(e2$, removeComma + 1) + END IF + END IF + + IF LEN(readable_e$) = 0 THEN + readable_e$ = e3$ + ELSE + readable_e$ = readable_e$ + " " + e3$ + END IF + NEXT + + 'intercept current expression and pass it through Evaluate_Expression$ + '(unless it is a literal string) + IF LEFT$(readable_e$, 1) <> CHR$(34) THEN + temp1$ = _TRIM$(Evaluate_Expression$(readable_e$)) + IF LEFT$(temp1$, 5) <> "ERROR" AND e$ <> temp1$ THEN + e$ = lineformat(temp1$) 'retrieve parseable format + ELSE + IF temp1$ = "ERROR - Division By Zero" THEN a$ = temp1$: GOTO errmes + IF INSTR(temp1$, "Improper operations") THEN + a$ = "Invalid CONST expression.14": GOTO errmes + END IF + END IF + END IF + + 'Proceed as usual + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + + e$ = evaluateconst(e$, t) + IF Error_Happened THEN GOTO errmes + + IF t AND ISSTRING THEN 'string type + + IF typeoverride THEN + IF (typeoverride AND ISSTRING) = 0 THEN a$ = "Type mismatch": GOTO errmes + END IF + + ELSE 'not a string type + + IF typeoverride THEN + IF typeoverride AND ISSTRING THEN a$ = "Type mismatch": GOTO errmes + END IF + + IF t AND ISFLOAT THEN + constval## = _CV(_FLOAT, e$) + constval&& = constval## + constval~&& = constval&& + ELSE + IF (t AND ISUNSIGNED) AND (t AND 511) = 64 THEN + constval~&& = _CV(_UNSIGNED _INTEGER64, e$) + constval&& = constval~&& + constval## = constval&& + ELSE + constval&& = _CV(_INTEGER64, e$) + constval## = constval&& + constval~&& = constval&& + END IF + END IF + + 'override type? + IF typeoverride THEN + 'range check required here (noted in todo) + t = typeoverride + END IF + + END IF 'not a string type + + constlast = constlast + 1 + IF constlast > constmax THEN + constmax = constmax * 2 + REDIM _PRESERVE constname(constmax) AS STRING + REDIM _PRESERVE constcname(constmax) AS STRING + REDIM _PRESERVE constnamesymbol(constmax) AS STRING 'optional name symbol + REDIM _PRESERVE consttype(constmax) AS LONG 'variable type number + REDIM _PRESERVE constinteger(constmax) AS _INTEGER64 + REDIM _PRESERVE constuinteger(constmax) AS _UNSIGNED _INTEGER64 + REDIM _PRESERVE constfloat(constmax) AS _FLOAT + REDIM _PRESERVE conststring(constmax) AS STRING + REDIM _PRESERVE constsubfunc(constmax) AS LONG + REDIM _PRESERVE constdefined(constmax) AS LONG + END IF + + i2 = constlast + + constsubfunc(i2) = subfuncn + 'IF subfunc = "" THEN constlastshared = i2 + + IF validname(n$) = 0 THEN a$ = "Invalid name": GOTO errmes + constname(i2) = UCASE$(n$) + + hashname$ = n$ + 'check for name conflicts (any similar: reserved, sub, function, constant) + + allow = 0 + const_recheck: + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_CONSTANT + hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF hashresflags AND HASHFLAG_CONSTANT THEN + IF constsubfunc(hashresref) = subfuncn THEN + 'If merely redefining a CONST with same value + 'just issue a warning instead of an error + issueWarning = 0 + IF t AND ISSTRING THEN + IF conststring(hashresref) = e$ THEN issueWarning = -1: thisconstval$ = e$ + ELSE + IF t AND ISFLOAT THEN + IF constfloat(hashresref) = constval## THEN issueWarning = -1: thisconstval$ = STR$(constval##) + ELSE + IF t AND ISUNSIGNED THEN + IF constuinteger(hashresref) = constval~&& THEN issueWarning = -1: thisconstval$ = STR$(constval~&&) + ELSE + IF constinteger(hashresref) = constval&& THEN issueWarning = -1: thisconstval$ = STR$(constval&&) + END IF + END IF + END IF + IF issueWarning THEN + IF NOT IgnoreWarnings THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "duplicate constant definition", n$ + " =" + thisconstval$ + END IF + GOTO constAddDone + ELSE + a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + END IF + END IF + END IF + IF hashresflags AND HASHFLAG_RESERVED THEN + a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + END IF + IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN + IF ids(hashresref).internal_subfunc = 0 OR RTRIM$(ids(hashresref).musthave) <> "$" THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + IF t AND ISSTRING THEN a$ = "Name already in use (" + hashname$ + ")": GOTO errmes + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + + 'add to hash table + HashAdd hashname$, HASHFLAG_CONSTANT, i2 + + + + + + constdefined(i2) = 1 + constcname(i2) = n$ + constnamesymbol(i2) = typevalue2symbol$(t) + IF Error_Happened THEN GOTO errmes + consttype(i2) = t + IF t AND ISSTRING THEN + conststring(i2) = e$ + ELSE + IF t AND ISFLOAT THEN + constfloat(i2) = constval## + ELSE + IF t AND ISUNSIGNED THEN + constuinteger(i2) = constval~&& + ELSE + constinteger(i2) = constval&& + END IF + END IF + END IF + + constAddDone: + + IF pending THEN + 'l$ = l$ + sp2 + "," + GOTO constdefpendingpp + END IF + + 'layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedlinepp + END IF + + + + 'DEFINE + d = 0 + IF firstelement$ = "DEFINT" THEN d = 1 + IF firstelement$ = "DEFLNG" THEN d = 1 + IF firstelement$ = "DEFSNG" THEN d = 1 + IF firstelement$ = "DEFDBL" THEN d = 1 + IF firstelement$ = "DEFSTR" THEN d = 1 + IF firstelement$ = "_DEFINE" OR (firstelement$ = "DEFINE" AND qb64prefix_set = 1) THEN d = 1 + IF d THEN + predefining = 1: GOTO predefine + predefined: predefining = 0 + GOTO finishedlinepp + END IF + + 'declare library + IF firstelement$ = "DECLARE" THEN + IF secondelement$ = "LIBRARY" OR secondelement$ = "DYNAMIC" OR secondelement$ = "CUSTOMTYPE" OR secondelement$ = "STATIC" THEN + declaringlibrary = 1 + indirectlibrary = 0 + IF secondelement$ = "CUSTOMTYPE" OR secondelement$ = "DYNAMIC" THEN indirectlibrary = 1 + GOTO finishedlinepp + END IF + END IF + + 'SUB/FUNCTION + dynamiclibrary = 0 + declaresubfunc: + firstelement$ = getelement$(a$, 1) + sf = 0 + IF firstelement$ = "FUNCTION" THEN sf = 1 + IF firstelement$ = "SUB" THEN sf = 2 + IF sf THEN + + subfuncn = subfuncn + 1 + closedsubfunc = 0 + + IF n = 1 THEN a$ = "Expected name after SUB/FUNCTION": GOTO errmes + + 'convert periods to _046_ + i2 = INSTR(a$, sp + "." + sp) + IF i2 THEN + DO + a$ = LEFT$(a$, i2 - 1) + fix046$ + RIGHT$(a$, LEN(a$) - i2 - 2) + ca$ = LEFT$(ca$, i2 - 1) + fix046$ + RIGHT$(ca$, LEN(ca$) - i2 - 2) + i2 = INSTR(a$, sp + "." + sp) + LOOP UNTIL i2 = 0 + n = numelements(a$) + firstelement$ = getelement(a$, 1): secondelement$ = getelement(a$, 2): thirdelement$ = getelement(a$, 3) + END IF + + n$ = getelement$(ca$, 2) + symbol$ = removesymbol$(n$) + IF Error_Happened THEN GOTO errmes + IF sf = 2 AND symbol$ <> "" THEN a$ = "Type symbols after a SUB name are invalid": GOTO errmes + + 'remove STATIC (which is ignored) + e$ = getelement$(a$, n): IF e$ = "STATIC" THEN a$ = LEFT$(a$, LEN(a$) - 7): ca$ = LEFT$(ca$, LEN(ca$) - 7): n = n - 1 + + 'check for ALIAS + aliasname$ = n$ 'use given name by default + IF n > 2 THEN + e$ = getelement$(a$, 3) + IF e$ = "ALIAS" THEN + IF declaringlibrary = 0 THEN a$ = "ALIAS can only be used with DECLARE LIBRARY": GOTO errmes + IF n = 3 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes + e$ = getelement$(ca$, 4) + 'strip string content (optional) + IF LEFT$(e$, 1) = CHR$(34) THEN + e$ = RIGHT$(e$, LEN(e$) - 1) + x = INSTR(e$, CHR$(34)): IF x = 0 THEN a$ = "Expected " + CHR$(34): GOTO errmes + e$ = LEFT$(e$, x - 1) + END IF + 'strip fix046$ (created by unquoted periods) + DO WHILE INSTR(e$, fix046$) + x = INSTR(e$, fix046$): e$ = LEFT$(e$, x - 1) + "." + RIGHT$(e$, LEN(e$) - x + 1 - LEN(fix046$)) + LOOP + 'validate alias name + IF LEN(e$) = 0 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes + FOR x = 1 TO LEN(e$) + a = ASC(e$, x) + IF alphanumeric(a) = 0 AND a <> ASC_FULLSTOP AND a <> ASC_COLON THEN a$ = "Expected ALIAS name-in-library": GOTO errmes + NEXT + aliasname$ = e$ + 'remove ALIAS section from line + IF n <= 4 THEN a$ = getelements(a$, 1, 2) + IF n >= 5 THEN a$ = getelements(a$, 1, 2) + sp + getelements(a$, 5, n) + IF n <= 4 THEN ca$ = getelements(ca$, 1, 2) + IF n >= 5 THEN ca$ = getelements(ca$, 1, 2) + sp + getelements(ca$, 5, n) + n = n - 2 + END IF + END IF + + IF declaringlibrary THEN + IF indirectlibrary THEN + aliasname$ = n$ 'override the alias name + END IF + END IF + + params = 0 + params$ = "" + paramsize$ = "" + nele$ = "" + nelereq$ = "" + IF n > 2 THEN + e$ = getelement$(a$, 3) + IF e$ <> "(" THEN a$ = "Expected (": GOTO errmes + e$ = getelement$(a$, n) + IF e$ <> ")" THEN a$ = "Expected )": GOTO errmes + IF n < 4 THEN a$ = "Expected ( ... )": GOTO errmes + IF n = 4 THEN GOTO nosfparams + B = 0 + a2$ = "" + FOR i = 4 TO n - 1 + e$ = getelement$(a$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN B = B - 1 + IF e$ = "," AND B = 0 THEN + IF i = n - 1 THEN a$ = "Expected , ... )": GOTO errmes + getlastparam: + IF a2$ = "" THEN a$ = "Expected ... ,": GOTO errmes + a2$ = LEFT$(a2$, LEN(a2$) - 1) + 'possible format: [BYVAL]a[%][(1)][AS][type] + n2 = numelements(a2$) + array = 0 + t2$ = "" + + i2 = 1 + e$ = getelement$(a2$, i2): i2 = i2 + 1 + + byvalue = 0 + IF e$ = "BYVAL" THEN + IF declaringlibrary = 0 THEN a$ = "BYVAL can currently only be used with DECLARE LIBRARY": GOTO errmes + e$ = getelement$(a2$, i2): i2 = i2 + 1: byvalue = 1 + END IF + + n2$ = e$ + symbol2$ = removesymbol$(n2$) + IF validname(n2$) = 0 THEN a$ = "Invalid name": GOTO errmes + + IF Error_Happened THEN GOTO errmes + m = 0 + FOR i2 = i2 TO n2 + e$ = getelement$(a2$, i2) + IF e$ = "(" THEN + IF m <> 0 THEN a$ = "Syntax error - too many opening brackets": GOTO errmes + m = 1 + array = 1 + GOTO gotaa + END IF + IF e$ = ")" THEN + IF m <> 1 THEN a$ = "Syntax error - closing bracket without opening bracket": GOTO errmes + m = 2 + GOTO gotaa + END IF + IF e$ = "AS" THEN + IF m <> 0 AND m <> 2 THEN a$ = "Syntax error - check your brackets": GOTO errmes + m = 3 + GOTO gotaa + END IF + IF m = 1 THEN GOTO gotaa 'ignore contents of bracket + IF m <> 3 THEN a$ = "Syntax error - check your brackets": GOTO errmes + IF t2$ = "" THEN t2$ = e$ ELSE t2$ = t2$ + " " + e$ + gotaa: + NEXT i2 + + params = params + 1: IF params > 100 THEN a$ = "SUB/FUNCTION exceeds 100 parameter limit": GOTO errmes + + argnelereq = 0 + + IF symbol2$ <> "" AND t2$ <> "" THEN a$ = "Syntax error - check parameter types": GOTO errmes + IF t2$ = "" AND e$ = "AS" THEN a$ = "Expected AS type": GOTO errmes + IF t2$ = "" THEN t2$ = symbol2$ + IF t2$ = "" THEN + IF LEFT$(n2$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n2$)) - 64 + t2$ = defineaz(v) + END IF + + paramsize = 0 + IF array = 1 THEN + t = typname2typ(t2$) + IF Error_Happened THEN GOTO errmes + IF t = 0 THEN a$ = "Illegal SUB/FUNCTION parameter": GOTO errmes + IF (t AND ISFIXEDLENGTH) THEN paramsize = typname2typsize + t = t + ISARRAY + 'check for recompilation override + FOR i10 = 0 TO sflistn + IF sfidlist(i10) = idn + 1 THEN + IF sfarglist(i10) = params THEN + argnelereq = sfelelist(i10) + END IF + END IF + NEXT + ELSE + t = typname2typ(t2$) + IF Error_Happened THEN GOTO errmes + IF t = 0 THEN a$ = "Illegal SUB/FUNCTION parameter": GOTO errmes + IF (t AND ISFIXEDLENGTH) THEN paramsize = typname2typsize + + IF byvalue THEN + IF t AND ISPOINTER THEN t = t - ISPOINTER + END IF + + END IF + nelereq$ = nelereq$ + CHR$(argnelereq) + + 'consider changing 0 in following line too! + nele$ = nele$ + CHR$(0) + + paramsize$ = paramsize$ + MKL$(paramsize) + params$ = params$ + MKL$(t) + a2$ = "" + ELSE + a2$ = a2$ + e$ + sp + IF i = n - 1 THEN GOTO getlastparam + END IF + NEXT i + END IF 'n>2 + nosfparams: + + IF sf = 1 THEN + 'function + clearid + id.n = n$ + id.subfunc = 1 + + id.callname = "FUNC_" + UCASE$(n$) + IF declaringlibrary THEN + id.ccall = 1 + IF indirectlibrary = 0 THEN id.callname = aliasname$ + END IF + id.args = params + id.arg = params$ + id.argsize = paramsize$ + id.nele = nele$ + id.nelereq = nelereq$ + IF symbol$ <> "" THEN + id.ret = typname2typ(symbol$) + IF Error_Happened THEN GOTO errmes + ELSE + IF LEFT$(n$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n$)) - 64 + symbol$ = defineaz(v) + id.ret = typname2typ(symbol$) + IF Error_Happened THEN GOTO errmes + END IF + IF id.ret = 0 THEN a$ = "Invalid FUNCTION return type": GOTO errmes + + IF declaringlibrary THEN + + ctype$ = typ2ctyp$(id.ret, "") + IF Error_Happened THEN GOTO errmes + IF ctype$ = "qbs" THEN ctype$ = "char*" + id.callname = "( " + ctype$ + " )" + RTRIM$(id.callname) + + END IF + + s$ = LEFT$(symbol$, 1) + IF s$ <> "~" AND s$ <> "`" AND s$ <> "%" AND s$ <> "&" AND s$ <> "!" AND s$ <> "#" AND s$ <> "$" THEN + symbol$ = type2symbol$(symbol$) + IF Error_Happened THEN GOTO errmes + END IF + id.mayhave = symbol$ + IF id.ret AND ISPOINTER THEN + IF (id.ret AND ISSTRING) = 0 THEN id.ret = id.ret - ISPOINTER + END IF + regid + IF Error_Happened THEN GOTO errmes + ELSE + 'sub + clearid + id.n = n$ + id.subfunc = 2 + id.callname = "SUB_" + UCASE$(n$) + IF declaringlibrary THEN + id.ccall = 1 + IF indirectlibrary = 0 THEN id.callname = aliasname$ + END IF + id.args = params + id.arg = params$ + id.argsize = paramsize$ + id.nele = nele$ + id.nelereq = nelereq$ + + IF UCASE$(n$) = "_GL" AND params = 0 AND UseGL = 0 THEN reginternalsubfunc = 1: UseGL = 1: id.n = "_GL": DEPENDENCY(DEPENDENCY_GL) = 1 + regid + reginternalsubfunc = 0 + + IF Error_Happened THEN GOTO errmes + END IF + + + END IF + + '======================================== + finishedlinepp: + firstLine = 0 + END IF + a$ = "" + ca$ = "" + ELSE + IF a$ = "" THEN a$ = e$: ca$ = ce$ ELSE a$ = a$ + sp + e$: ca$ = ca$ + sp + ce$ + END IF + IF wholelinei <= wholelinen THEN wholelinei = wholelinei + 1: GOTO ppblda + '---------------------------------------- + END IF 'wholelinei<=wholelinen + END IF 'wholelinen + END IF 'len(wholeline$) + + 'Include Manager #1 + + + + IF LEN(addmetainclude$) THEN + IF Debug THEN PRINT #9, "Pre-pass:INCLUDE$-ing file:'" + addmetainclude$ + "':On line"; linenumber + a$ = addmetainclude$: addmetainclude$ = "" 'read/clear message + + IF inclevel = 0 THEN + includingFromRoot = 0 + forceIncludingFile = 0 + forceInclude_prepass: + IF forceIncludeFromRoot$ <> "" THEN + a$ = forceIncludeFromRoot$ + forceIncludeFromRoot$ = "" + forceIncludingFile = 1 + includingFromRoot = 1 + END IF + END IF + + IF inclevel = 100 THEN a$ = "Too many indwelling INCLUDE files": GOTO errmes + '1. Verify file exists (location is either (a)relative to source file or (b)absolute) + fh = 99 + inclevel + 1 + + firstTryMethod = 1 + IF includingFromRoot <> 0 AND inclevel = 0 THEN firstTryMethod = 2 + FOR try = firstTryMethod TO 2 'if including file from root, do not attempt including from relative location + IF try = 1 THEN + IF inclevel = 0 THEN + IF idemode THEN p$ = idepath$ + pathsep$ ELSE p$ = getfilepath$(sourcefile$) + ELSE + p$ = getfilepath$(incname(inclevel)) + END IF + f$ = p$ + a$ + END IF + IF try = 2 THEN f$ = a$ + IF _FILEEXISTS(f$) THEN + qberrorhappened = -3 + 'We're using the faster LINE INPUT, which requires a BINARY open. + OPEN f$ FOR BINARY AS #fh + 'And another line below edited + qberrorhappened3: + IF qberrorhappened = -3 THEN EXIT FOR + END IF + qberrorhappened = 0 + NEXT + IF qberrorhappened <> -3 THEN qberrorhappened = 0: a$ = "File " + a$ + " not found": GOTO errmes + inclevel = inclevel + 1: incname$(inclevel) = f$: inclinenumber(inclevel) = 0 + END IF 'fall through to next section... + '-------------------- + DO WHILE inclevel + + fh = 99 + inclevel + '2. Feed next line + IF EOF(fh) = 0 THEN + LINE INPUT #fh, x$ + + wholeline$ = x$ + inclinenumber(inclevel) = inclinenumber(inclevel) + 1 + 'create extended error string 'incerror$' + errorLineInInclude = inclinenumber(inclevel) + e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" + IF inclevel > 1 THEN + e$ = e$ + " (through " + FOR x = 1 TO inclevel - 1 STEP 1 + e$ = e$ + incname$(x) + IF x < inclevel - 1 THEN 'a sep is req + IF x = inclevel - 2 THEN + e$ = e$ + " then " + ELSE + e$ = e$ + ", " + END IF + END IF + NEXT + e$ = e$ + ")" + END IF + incerror$ = e$ + linenumber = linenumber - 1 'lower official linenumber to counter later increment + + IF Debug THEN PRINT #9, "Pre-pass:Feeding INCLUDE$ line:[" + wholeline$ + "]" + + IF idemode THEN sendc$ = CHR$(10) + wholeline$: GOTO sendcommand 'passback + GOTO ideprepass + END IF + '3. Close & return control + CLOSE #fh + inclevel = inclevel - 1 + IF forceIncludingFile = 1 AND inclevel = 0 THEN + forceIncludingFile = 0 + GOTO forceIncludeCompleted_prepass + END IF + LOOP + '(end manager) + + IF idemode THEN GOTO ideret2 +LOOP + +'add final line +IF lastLineReturn = 0 THEN + lastLineReturn = 1 + lastLine = 1 + wholeline$ = "" + GOTO prepassLastLine +END IF + +IF definingtype THEN definingtype = 0 'ignore this error so that auto-formatting can be performed and catch it again later +IF declaringlibrary THEN declaringlibrary = 0 'ignore this error so that auto-formatting can be performed and catch it again later + +totallinenumber = reallinenumber + +'IF idemode = 0 AND NOT QuietMode THEN PRINT "first pass finished.": PRINT "Translating code... " + +'prepass finished + +lineinput3index = 1 'reset input line + +'ide specific +ide3: + +addmetainclude$ = "" 'reset stray meta-includes + +'reset altered variables +DataOffset = 0 +inclevel = 0 +subfuncn = 0 +lastLineReturn = 0 +lastLine = 0 +firstLine = 1 +UserDefineCount = 7 + +FOR i = 0 TO constlast: constdefined(i) = 0: NEXT 'undefine constants + +FOR i = 1 TO 27: defineaz(i) = "SINGLE": defineextaz(i) = "!": NEXT + +OPEN tmpdir$ + "data.bin" FOR OUTPUT AS #16: CLOSE #16 +OPEN tmpdir$ + "data.bin" FOR BINARY AS #16 + + +OPEN tmpdir$ + "main.txt" FOR OUTPUT AS #12 +OPEN tmpdir$ + "maindata.txt" FOR OUTPUT AS #13 + +OPEN tmpdir$ + "regsf.txt" FOR OUTPUT AS #17 + +OPEN tmpdir$ + "mainfree.txt" FOR OUTPUT AS #19 +OPEN tmpdir$ + "runline.txt" FOR OUTPUT AS #21 + +OPEN tmpdir$ + "mainerr.txt" FOR OUTPUT AS #14 'main error handler +'i. check the value of error_line +'ii. jump to the appropriate label +errorlabels = 0 +PRINT #14, "if (error_occurred){ error_occurred=0;" + +OPEN tmpdir$ + "chain.txt" FOR OUTPUT AS #22: CLOSE #22 'will be appended to as necessary +OPEN tmpdir$ + "inpchain.txt" FOR OUTPUT AS #23: CLOSE #23 'will be appended to as necessary +'*** #22 & #23 are reserved for usage by chain & inpchain *** + +OPEN tmpdir$ + "ontimer.txt" FOR OUTPUT AS #24 +OPEN tmpdir$ + "ontimerj.txt" FOR OUTPUT AS #25 + +'*****#26 used for locking qb64pe + +OPEN tmpdir$ + "onkey.txt" FOR OUTPUT AS #27 +OPEN tmpdir$ + "onkeyj.txt" FOR OUTPUT AS #28 + +OPEN tmpdir$ + "onstrig.txt" FOR OUTPUT AS #29 +OPEN tmpdir$ + "onstrigj.txt" FOR OUTPUT AS #30 + +gosubid = 1 +'to be included whenever return without a label is called + +'return [label] in QBASIC was not possible in a sub/function, but QB64 will support this +'special codes will represent special return conditions: +'0=return from main to calling sub/function/proc by return [NULL]; +'1... a global number representing a return point after a gosub +'note: RETURN [label] should fail if a "return [NULL];" type return is required +OPEN tmpdir$ + "ret0.txt" FOR OUTPUT AS #15 +PRINT #15, "if (next_return_point){" +PRINT #15, "next_return_point--;" +PRINT #15, "switch(return_point[next_return_point]){" +PRINT #15, "case 0:" + +PRINT #15, "return;" + +PRINT #15, "break;" + +continueline = 0 +endifs = 0 +lineelseused = 0 +continuelinefrom = 0 +linenumber = 0 +reallinenumber = 0 +declaringlibrary = 0 + +PRINT #12, "S_0:;" 'note: REQUIRED by run statement + +IF UseGL THEN gl_include_content + + +'ide specific +IF idemode THEN GOTO ideret3 + +DO + ide4: + includeline: + mainpassLastLine: + + IF lastLine <> 0 OR firstLine <> 0 THEN + lineBackup$ = a3$ 'backup the real first line (will be blank when lastline is set) + forceIncludeFromRoot$ = "" + IF vWatchOn THEN + addingvWatch = 1 + IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bi" + IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch.bm" + ELSE + 'IF firstLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bi" + IF lastLine <> 0 THEN forceIncludeFromRoot$ = "internal\support\vwatch\vwatch_stub.bm" + END IF + firstLine = 0: lastLine = 0 + IF LEN(forceIncludeFromRoot$) THEN GOTO forceInclude + forceIncludeCompleted: + addingvWatch = 0 + a3$ = lineBackup$ + END IF + + prepass = 0 + + stringprocessinghappened = 0 + + IF continuelinefrom THEN + start = continuelinefrom + continuelinefrom = 0 + GOTO contline + END IF + + 'begin a new line + + impliedendif = 0 + THENGOTO = 0 + continueline = 0 + endifs = 0 + lineelseused = 0 + newif = 0 + + 'apply metacommands from previous line + IF addmetadynamic = 1 THEN addmetadynamic = 0: DynamicMode = 1 + IF addmetastatic = 1 THEN addmetastatic = 0: DynamicMode = 0 + + 'a3$ is passed in idemode and when using $include + IF idemode = 0 AND inclevel = 0 THEN a3$ = lineinput3$ + IF a3$ = CHR$(13) THEN EXIT DO + linenumber = linenumber + 1 + reallinenumber = reallinenumber + 1 + + IF InValidLine(linenumber) THEN + layoutok = 1 + layout$ = SPACE$(controllevel + 1) + LTRIM$(RTRIM$(a3$)) + IF idemode GOTO ideret4 ELSE GOTO skipide4 + END IF + + layout = "" + layoutok = 1 + + IF idemode = 0 AND NOT QuietMode THEN + 'IF LEN(a3$) THEN + ' dotlinecount = dotlinecount + 1: IF dotlinecount >= 100 THEN dotlinecount = 0: PRINT "."; + 'END IF + maxprogresswidth = 50 'arbitrary + percentage = INT(reallinenumber / totallinenumber * 100) + percentagechars = INT(maxprogresswidth * reallinenumber / totallinenumber) + IF percentage <> prevpercentage AND percentagechars <> prevpercentagechars THEN + prevpercentage = percentage + prevpercentagechars = percentagechars + IF ConsoleMode THEN + PRINT "[" + STRING$(percentagechars, ".") + SPACE$(maxprogresswidth - percentagechars) + "]" + STR$(percentage) + "%"; + IF os$ = "LNX" THEN + PRINT CHR$(27) + "[A" + ELSE + PRINT CHR$(13); + END IF + ELSE + LOCATE , 1 + PRINT STRING$(percentagechars, 219) + STRING$(maxprogresswidth - percentagechars, 176) + STR$(percentage) + "%"; + END IF + END IF + END IF + + a3$ = LTRIM$(RTRIM$(a3$)) + wholeline = a3$ + + layoutoriginal$ = a3$ + layoutcomment$ = "" 'clear any previous layout comment + lhscontrollevel = controllevel + + linefragment = "[INFORMATION UNAVAILABLE]" + IF LEN(a3$) = 0 THEN GOTO finishednonexec + IF Debug THEN PRINT #9, "########" + a3$ + "########" + + layoutdone = 1 'validates layout of any following goto finishednonexec/finishedline + + 'We've already figured out in the prepass which lines are invalidated by the precompiler + 'No need to go over those lines again. + 'IF InValidLine(linenumber) THEN goto skipide4 'layoutdone = 0: GOTO finishednonexec + + a3u$ = UCASE$(a3$) + + 'QB64 Metacommands + IF ASC(a3$) = 36 THEN '$ + + 'precompiler commands should always be executed FIRST. + IF a3u$ = "$END IF" OR a3u$ = "$ENDIF" THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes + DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level + ExecCounter = ExecCounter - 1 + layout$ = SCase$("$End If") + controltype(controllevel) = 0 + controllevel = controllevel - 1 + GOTO finishednonexec + END IF + + IF LEFT$(a3u$, 4) = "$IF " THEN + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + temp$ = LTRIM$(MID$(a3u$, 4)) 'strip off the $IF and extra spaces + temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces + temp = 0 + IF temp = 0 THEN tempOp$ = "<=": temp = INSTR(temp$, tempOp$) + IF temp = 0 THEN tempOp$ = "=<": temp = INSTR(temp$, tempOp$): tempOp$ = "<=" + IF temp = 0 THEN tempOp$ = ">=": temp = INSTR(temp$, tempOp$) + IF temp = 0 THEN tempOp$ = "=>": temp = INSTR(temp$, tempOp$): tempOp$ = ">=" + IF temp = 0 THEN tempOp$ = "<>": temp = INSTR(temp$, tempOp$) + IF temp = 0 THEN tempOp$ = "><": temp = INSTR(temp$, tempOp$): tempOp$ = "<>" + IF temp = 0 THEN tempOp$ = "=": temp = INSTR(temp$, tempOp$) + IF temp = 0 THEN tempOp$ = ">": temp = INSTR(temp$, tempOp$) + IF temp = 0 THEN tempOp$ = "<": temp = INSTR(temp$, tempOp$) + + ExecCounter = ExecCounter + 1 + ExecLevel(ExecCounter) = -1 'default to a skip value + DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level + result = EvalPreIF(temp$, a$) + IF a$ <> "" THEN GOTO errmes + IF result <> 0 THEN + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above + IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found + END IF + + controllevel = controllevel + 1 + controltype(controllevel) = 6 + IF temp = 0 THEN layout$ = SCase$("$If ") + temp$ + SCase$(" Then"): GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag + l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + LEN(tempOp$))) + layout$ = SCase$("$If ") + l$ + " " + tempOp$ + " " + r$ + SCase$(" Then") + GOTO finishednonexec + END IF + + IF a3u$ = "$ELSE" THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes + IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes + DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block + IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here + ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above + ELSE + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED + END IF + layout$ = SCase$("$Else") + lhscontrollevel = lhscontrollevel - 1 + GOTO finishednonexec + END IF + + IF LEFT$(a3u$, 5) = "$ELSE" THEN + temp$ = LTRIM$(MID$(a3u$, 6)) + IF LEFT$(temp$, 3) = "IF " THEN + IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes + IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes + IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes + temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces + temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces + IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here + ExecLevel(ExecCounter) = -1 + ELSE + result = EvalPreIF(temp$, a$) + IF a$ <> "" THEN GOTO errmes + IF result <> 0 THEN + ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above + IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found + END IF + END IF + + + lhscontrollevel = lhscontrollevel - 1 + temp = INSTR(temp$, "=") + IF temp = 0 THEN layout$ = SCase$("$ElseIf ") + temp$ + SCase$(" Then"): GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag + l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) + layout$ = SCase$("$ElseIf ") + l$ + " = " + r$ + SCase$(" Then") + GOTO finishednonexec + END IF + END IF + + IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler + layoutdone = 0 + GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping + END IF + + IF LEFT$(a3u$, 5) = "$LET " THEN + temp$ = a3u$ + temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse + 'For starters, let's make certain that we have 3 elements to deal with + temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side + l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) + layout$ = SCase$("$Let ") + l$ + " = " + r$ + 'First look to see if we have an existing setting like this and if so, update it + FOR i = 7 TO UserDefineCount 'UserDefineCount 1-7 are reserved for automatic OS/BIT detection & version + IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishednonexec + NEXT + 'Otherwise create a new setting and set the initial value for it + UserDefineCount = UserDefineCount + 1 + IF UserDefineCount > UBOUND(UserDefine, 2) THEN + REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it + END IF + UserDefine(0, UserDefineCount) = l$ + UserDefine(1, UserDefineCount) = r$ + GOTO finishednonexec + END IF + + IF a3u$ = "$COLOR:0" THEN + layout$ = SCase$("$Color:0") + IF qb64prefix_set THEN + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0_noprefix.bi" + ELSE + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color0.bi" + END IF + layoutdone = 1 + GOTO finishednonexec + END IF + + IF a3u$ = "$COLOR:32" THEN + layout$ = SCase$("$Color:32") + IF qb64prefix_set THEN + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32_noprefix.bi" + ELSE + addmetainclude$ = getfilepath$(COMMAND$(0)) + "internal" + pathsep$ + "support" + pathsep$ + "color" + pathsep$ + "color32.bi" + END IF + layoutdone = 1 + GOTO finishednonexec + END IF + + IF a3u$ = "$NOPREFIX" THEN + 'already set in prepass + layout$ = SCase$("$NoPrefix") + GOTO finishednonexec + END IF + + IF a3u$ = "$VIRTUALKEYBOARD:ON" THEN + 'Deprecated; does nothing. + layout$ = SCase$("$VirtualKeyboard:On") + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Deprecated feature", "$VirtualKeyboard" + GOTO finishednonexec + END IF + + IF a3u$ = "$VIRTUALKEYBOARD:OFF" THEN + 'Deprecated; does nothing. + layout$ = SCase$("$VirtualKeyboard:Off") + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Deprecated feature", "$VirtualKeyboard" + GOTO finishednonexec + END IF + + IF a3u$ = "$DEBUG" THEN + layout$ = SCase$("$Debug") + IF NoIDEMode THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "$Debug", "$Debug features only work from the IDE" + END IF + GOTO finishednonexec + END IF + + IF a3u$ = "$CHECKING:OFF" THEN + layout$ = SCase$("$Checking:Off") + NoChecks = 1 + IF vWatchOn <> 0 AND NoIDEMode = 0 AND inclevel = 0 THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "$Debug", "$Debug features won't work in $Checking:Off blocks" + END IF + GOTO finishednonexec + END IF + + IF a3u$ = "$CHECKING:ON" THEN + layout$ = SCase$("$Checking:On") + NoChecks = 0 + GOTO finishednonexec + END IF + + IF a3u$ = "$CONSOLE" THEN + layout$ = SCase$("$Console") + Console = 1 + GOTO finishednonexec + END IF + + IF a3u$ = "$CONSOLE:ONLY" THEN + layout$ = SCase$("$Console:Only") + DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) = DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) OR 1 + Console = 1 + IF prepass = 0 THEN + IF NoChecks = 0 THEN PRINT #12, "do{" + PRINT #12, "sub__dest(func__console());" + PRINT #12, "sub__source(func__console());" + GOTO finishedline2 + ELSE + GOTO finishednonexec + END IF + END IF + + IF a3u$ = "$ASSERTS" THEN + layout$ = SCase$("$Asserts") + Asserts = 1 + GOTO finishednonexec + END IF + + IF a3u$ = "$ASSERTS:CONSOLE" THEN + layout$ = SCase$("$Asserts:Console") + Asserts = 1 + Console = 1 + GOTO finishednonexec + END IF + + IF a3u$ = "$SCREENHIDE" THEN + layout$ = SCase$("$ScreenHide") + ScreenHide = 1 + GOTO finishednonexec + END IF + IF a3u$ = "$SCREENSHOW" THEN + layout$ = SCase$("$ScreenShow") + ScreenHide = 0 + GOTO finishednonexec + END IF + + IF a3u$ = "$RESIZE:OFF" THEN + layout$ = SCase$("$Resize:Off") + Resize = 0: Resize_Scale = 0 + GOTO finishednonexec + END IF + IF a3u$ = "$RESIZE:ON" THEN + layout$ = SCase$("$Resize:On") + Resize = 1: Resize_Scale = 0 + GOTO finishednonexec + END IF + + IF a3u$ = "$RESIZE:STRETCH" THEN + layout$ = SCase$("$Resize:Stretch") + Resize = 1: Resize_Scale = 1 + GOTO finishednonexec + END IF + IF a3u$ = "$RESIZE:SMOOTH" THEN + layout$ = SCase$("$Resize:Smooth") + Resize = 1: Resize_Scale = 2 + GOTO finishednonexec + END IF + + IF LEFT$(a3u$, 12) = "$VERSIONINFO" THEN + 'Embed version info into the final binary (Windows only) + FirstDelimiter = INSTR(a3u$, ":") + SecondDelimiter = INSTR(FirstDelimiter + 1, a3u$, "=") + IF FirstDelimiter = 0 OR SecondDelimiter = 0 OR SecondDelimiter = FirstDelimiter + 1 THEN + a$ = "Expected $VERSIONINFO:key=value": GOTO errmes + END IF + + VersionInfoKey$ = LTRIM$(RTRIM$(MID$(a3u$, FirstDelimiter + 1, SecondDelimiter - FirstDelimiter - 1))) + VersionInfoValue$ = StrReplace$(LTRIM$(RTRIM$(MID$(a3$, SecondDelimiter + 1))), CHR$(34), "'") + + SELECT CASE VersionInfoKey$ + CASE "FILEVERSION#" + GOSUB ValidateVersion + viFileVersionNum$ = VersionInfoValue$ + IF viFileVersion$ = "" THEN viFileVersion$ = viFileVersionNum$ + layout$ = SCase$("$VersionInfo:FILEVERSION#=") + VersionInfoValue$ + CASE "PRODUCTVERSION#" + GOSUB ValidateVersion + viProductVersionNum$ = VersionInfoValue$ + IF viProductVersion$ = "" THEN viProductVersion$ = viProductVersionNum$ + layout$ = SCase$("$VersionInfo:PRODUCTVERSION#=") + VersionInfoValue$ + CASE "COMPANYNAME" + viCompanyName$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "CompanyName=" + VersionInfoValue$ + CASE "FILEDESCRIPTION" + viFileDescription$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "FileDescription=" + VersionInfoValue$ + CASE "FILEVERSION" + viFileVersion$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "FileVersion=" + VersionInfoValue$ + CASE "INTERNALNAME" + viInternalName$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "InternalName=" + VersionInfoValue$ + CASE "LEGALCOPYRIGHT" + viLegalCopyright$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "LegalCopyright=" + VersionInfoValue$ + CASE "LEGALTRADEMARKS" + viLegalTrademarks$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "LegalTrademarks=" + VersionInfoValue$ + CASE "ORIGINALFILENAME" + viOriginalFilename$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "OriginalFilename=" + VersionInfoValue$ + CASE "PRODUCTNAME" + viProductName$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "ProductName=" + VersionInfoValue$ + CASE "PRODUCTVERSION" + viProductVersion$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "ProductVersion=" + VersionInfoValue$ + CASE "COMMENTS" + viComments$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "Comments=" + VersionInfoValue$ + CASE "WEB" + viWeb$ = VersionInfoValue$ + layout$ = SCase$("$VersionInfo:") + "Web=" + VersionInfoValue$ + CASE ELSE + a$ = "Invalid key. (Use FILEVERSION#, PRODUCTVERSION#, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Comments or Web)" + GOTO errmes + END SELECT + + VersionInfoSet = -1 + + GOTO finishednonexec + + ValidateVersion: + 'Check if only numbers and commas (4 comma-separated values) + IF LEN(VersionInfoValue$) = 0 THEN a$ = "Expected $VERSIONINFO:" + VersionInfoKey$ + "=#,#,#,# (4 comma-separated numeric values: major, minor, revision and build)": GOTO errmes + viCommas = 0 + FOR i = 1 TO LEN(VersionInfoValue$) + IF ASC(VersionInfoValue$, i) = 44 THEN viCommas = viCommas + 1 + IF INSTR("0123456789,", MID$(VersionInfoValue$, i, 1)) = 0 OR (i = LEN(VersionInfoValue$) AND viCommas <> 3) OR RIGHT$(VersionInfoValue$, 1) = "," THEN + a$ = "Expected $VERSIONINFO:" + VersionInfoKey$ + "=#,#,#,# (4 comma-separated numeric values: major, minor, revision and build)": GOTO errmes + END IF + NEXT + RETURN + END IF + + IF LEFT$(a3u$, 8) = "$EXEICON" THEN + 'Basic syntax check. Multi-platform. + IF ExeIconSet THEN a$ = "$EXEICON already defined": GOTO errmes + FirstDelimiter = INSTR(a3u$, "'") + IF FirstDelimiter = 0 THEN + a$ = "Expected $EXEICON:'filename'": GOTO errmes + ELSE + SecondDelimiter = INSTR(FirstDelimiter + 1, a3u$, "'") + IF SecondDelimiter = 0 THEN a$ = "Expected $EXEICON:'filename'": GOTO errmes + END IF + ExeIconFile$ = RTRIM$(LTRIM$(MID$(a3$, FirstDelimiter + 1, SecondDelimiter - FirstDelimiter - 1))) + IF LEN(ExeIconFile$) = 0 THEN a$ = "Expected $EXEICON:'filename'": GOTO errmes + layout$ = SCase$("$ExeIcon:'") + ExeIconFile$ + "'" + MID$(a3$, SecondDelimiter + 1) + + IconPath$ = "" + IF LEFT$(ExeIconFile$, 2) = "./" OR LEFT$(ExeIconFile$, 2) = ".\" THEN + 'Relative to source file's folder + IF NoIDEMode THEN + IconPath$ = path.source$ + IF LEN(IconPath$) > 0 AND RIGHT$(IconPath$, 1) <> pathsep$ THEN IconPath$ = IconPath$ + pathsep$ + ELSE + IF LEN(ideprogname) THEN IconPath$ = idepath$ + pathsep$ + END IF + + ExeIconFile$ = IconPath$ + MID$(ExeIconFile$, 3) + ELSEIF INSTR(ExeIconFile$, "/") OR INSTR(ExeIconFile$, "\") THEN + FOR i = LEN(ExeIconFile$) TO 1 STEP -1 + IF MID$(ExeIconFile$, i, 1) = "/" OR MID$(ExeIconFile$, i, 1) = "\" THEN + IconPath$ = LEFT$(ExeIconFile$, i) + ExeIconFileOnly$ = MID$(ExeIconFile$, i + 1) + + IF _DIREXISTS(IconPath$) = 0 THEN a$ = "File '" + ExeIconFileOnly$ + "' not found": GOTO errmes + + currentdir$ = _CWD$ + CHDIR IconPath$ + IconPath$ = _CWD$ + CHDIR currentdir$ + + ExeIconFile$ = IconPath$ + pathsep$ + ExeIconFileOnly$ + EXIT FOR + END IF + NEXT + END IF + + IF _FILEEXISTS(ExeIconFile$) = 0 THEN a$ = "File '" + ExeIconFile$ + "' not found": GOTO errmes + + ExeIconSet = linenumber + SetDependency DEPENDENCY_ICON + IF NoChecks = 0 THEN PRINT #12, "do{" + PRINT #12, "sub__icon(NULL,NULL,0);" + GOTO finishedline2 + END IF + + END IF 'QB64 Metacommands + + IF ExecLevel(ExecCounter) THEN + layoutdone = 0 + GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping + END IF + + + linedataoffset = DataOffset + + entireline$ = lineformat(a3$): IF LEN(entireline$) = 0 THEN GOTO finishednonexec + IF Error_Happened THEN GOTO errmes + u$ = UCASE$(entireline$) + + newif = 0 + + 'Convert "CASE ELSE" to "CASE C-EL" to avoid confusing compiler + 'note: CASE does not have to begin on a new line + s = 1 + i = INSTR(s, u$, "CASE" + sp + "ELSE") + DO WHILE i + skip = 0 + IF i <> 1 THEN + IF MID$(u$, i - 1, 1) <> sp THEN skip = 1 + END IF + IF i <> LEN(u$) - 8 THEN + IF MID$(u$, i + 9, 1) <> sp THEN skip = 1 + END IF + IF skip = 0 THEN + MID$(entireline$, i) = "CASE" + sp + "C-EL" + u$ = UCASE$(entireline$) + END IF + s = i + 9 + i = INSTR(s, u$, "CASE" + sp + "ELSE") + LOOP + + n = numelements(entireline$) + + 'line number? + a = ASC(entireline$) + IF (a >= 48 AND a <= 57) OR a = 46 THEN 'numeric + label$ = getelement(entireline$, 1) + IF validlabel(label$) THEN + + IF closedmain <> 0 AND subfunc = "" THEN a$ = "Labels cannot be placed between SUB/FUNCTIONs": GOTO errmes + + v = HashFind(label$, HASHFLAG_LABEL, ignore, r) + addlabchk100: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + IF Labels(r).State = 1 THEN a$ = "Duplicate label (" + RTRIM$(Labels(r).cn) + ")": GOTO errmes + 'aquire state 0 types + tlayout$ = RTRIM$(Labels(r).cn) + GOTO addlabaq100 + END IF 'same scope + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO addlabchk100 + END IF + + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd label$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + addlabaq100: + Labels(r).State = 1 + Labels(r).Data_Offset = linedataoffset + + layout$ = tlayout$ + PRINT #12, "LABEL_" + label$ + ":;" + + + IF INSTR(label$, "p") THEN MID$(label$, INSTR(label$, "p"), 1) = "." + IF RIGHT$(label$, 1) = "d" OR RIGHT$(label$, 1) = "s" THEN label$ = LEFT$(label$, LEN(label$) - 1) + PRINT #12, "last_line=" + label$ + ";" + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + inclinenump$ = "," + str2$(inclinenumber(inclevel)) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) + END IF + IF NoChecks = 0 THEN + IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" + PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}" + END IF + IF n = 1 THEN GOTO finishednonexec + entireline$ = getelements(entireline$, 2, n): u$ = UCASE$(entireline$): n = n - 1 + 'note: fall through, numeric labels can be followed by alphanumeric label + END IF 'validlabel + END IF 'numeric + 'it wasn't a line number + + 'label? + 'note: ignores possibility that this could be a single command SUB/FUNCTION (as in QBASIC?) + IF n >= 2 THEN + x2 = INSTR(entireline$, sp + ":") + IF x2 THEN + IF x2 = LEN(entireline$) - 1 THEN x3 = x2 + 1 ELSE x3 = x2 + 2 + a$ = LEFT$(entireline$, x2 - 1) + + CreatingLabel = 1 + IF validlabel(a$) THEN + + IF validname(a$) = 0 THEN a$ = "Invalid name": GOTO errmes + + IF closedmain <> 0 AND subfunc = "" THEN a$ = "Labels cannot be placed between SUB/FUNCTIONs": GOTO errmes + + v = HashFind(a$, HASHFLAG_LABEL, ignore, r) + addlabchk: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + IF Labels(r).State = 1 THEN a$ = "Duplicate label (" + RTRIM$(Labels(r).cn) + ")": GOTO errmes + 'aquire state 0 types + tlayout$ = RTRIM$(Labels(r).cn) + GOTO addlabaq + END IF 'same scope + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO addlabchk + END IF + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + addlabaq: + Labels(r).State = 1 + Labels(r).Data_Offset = linedataoffset + Labels(r).SourceLineNumber = linenumber + + IF LEN(layout$) THEN layout$ = layout$ + sp + tlayout$ + ":" ELSE layout$ = tlayout$ + ":" + + PRINT #12, "LABEL_" + a$ + ":;" + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + inclinenump$ = "," + str2$(inclinenumber(inclevel)) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) + END IF + IF NoChecks = 0 THEN + IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" + PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}" + END IF + entireline$ = RIGHT$(entireline$, LEN(entireline$) - x3): u$ = UCASE$(entireline$) + n = numelements(entireline$): IF n = 0 THEN GOTO finishednonexec + END IF 'valid + END IF 'includes sp+":" + END IF 'n>=2 + + 'remove leading ":" + DO WHILE ASC(u$) = 58 '":" + IF LEN(layout$) THEN layout$ = layout$ + sp2 + ":" ELSE layout$ = ":" + IF LEN(u$) = 1 THEN GOTO finishednonexec + entireline$ = getelements(entireline$, 2, n): u$ = UCASE$(entireline$): n = n - 1 + LOOP + + 'ELSE at the beginning of a line + IF ASC(u$) = 69 THEN '"E" + + e1$ = getelement(u$, 1) + + IF e1$ = "ELSE" THEN + a$ = "ELSE" + IF n > 1 THEN continuelinefrom = 2 + GOTO gotcommand + END IF + + IF e1$ = "ELSEIF" THEN + IF n < 3 THEN a$ = "Expected ... THEN": GOTO errmes + IF getelement(u$, n) = "THEN" THEN a$ = entireline$: GOTO gotcommand + FOR i = 3 TO n - 1 + IF getelement(u$, i) = "THEN" THEN + a$ = getelements(entireline$, 1, i) + continuelinefrom = i + 1 + GOTO gotcommand + END IF + NEXT + a$ = "Expected THEN": GOTO errmes + END IF + + END IF '"E" + + start = 1 + + GOTO skipcontinit + + contline: + + n = numelements(entireline$) + u$ = UCASE$(entireline$) + + skipcontinit: + + 'jargon: + 'lineelseused - counts how many line ELSEs can POSSIBLY follow + 'endifs - how many C++ endifs "}" need to be added at the end of the line + 'lineelseused - counts the number of indwelling ELSE statements on a line + 'impliedendif - stops autoformat from adding "END IF" + + a$ = "" + + FOR i = start TO n + e$ = getelement(u$, i) + + + IF e$ = ":" THEN + IF i = start THEN + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp2 + ":" ELSE layout$ = ":" + IF i <> n THEN continuelinefrom = i + 1 + GOTO finishednonexec + END IF + IF i <> n THEN continuelinefrom = i + GOTO gotcommand + END IF + + + 'begin scanning an 'IF' statement + IF e$ = "IF" AND a$ = "" THEN newif = 1 + + + IF e$ = "THEN" OR (e$ = "GOTO" AND newif = 1) THEN + IF newif = 0 THEN a$ = "THEN without IF": GOTO errmes + newif = 0 + IF lineelseused > 0 THEN lineelseused = lineelseused - 1 + IF e$ = "GOTO" THEN + IF i = n THEN a$ = "Expected IF expression GOTO label": GOTO errmes + i = i - 1 + END IF + a$ = a$ + sp + e$ '+"THEN"/"GOTO" + IF i <> n THEN continuelinefrom = i + 1: endifs = endifs + 1 + GOTO gotcommand + END IF + + + IF e$ = "ELSE" THEN + + IF start = i THEN + IF lineelseused >= 1 THEN + 'note: more than one else used (in a row) on this line, so close first if with an 'END IF' first + 'note: parses 'END IF' then (after continuelinefrom) parses 'ELSE' + 'consider the following: (square brackets make reading easier) + 'eg. if a=1 then [if b=2 then c=2 else d=2] else e=3 + impliedendif = 1: a$ = "END" + sp + "IF" + endifs = endifs - 1 + continuelinefrom = i + lineelseused = lineelseused - 1 + GOTO gotcommand + END IF + 'follow up previously encountered 'ELSE' by applying 'ELSE' + a$ = "ELSE": continuelinefrom = i + 1 + lineelseused = lineelseused + 1 + GOTO gotcommand + END IF 'start=i + + 'apply everything up to (but not including) 'ELSE' + continuelinefrom = i + GOTO gotcommand + END IF '"ELSE" + + + e$ = getelement(entireline$, i): IF a$ = "" THEN a$ = e$ ELSE a$ = a$ + sp + e$ + NEXT + + + 'we're reached the end of the line + IF endifs > 0 THEN + endifs = endifs - 1 + impliedendif = 1: entireline$ = entireline$ + sp + ":" + sp + "END" + sp + "IF": n = n + 3 + i = i + 1 'skip the ":" (i is now equal to n+2) + continuelinefrom = i + GOTO gotcommand + END IF + + + gotcommand: + + dynscope = 0 + + ca$ = a$ + a$ = eleucase$(ca$) '***REVISE THIS SECTION LATER*** + + + layoutdone = 0 + + linefragment = a$ + IF Debug THEN PRINT #9, a$ + n = numelements(a$) + IF n = 0 THEN GOTO finishednonexec + + 'convert non-UDT dimensioned periods to _046_ + IF INSTR(ca$, sp + "." + sp) THEN + a3$ = getelement(ca$, 1) + except = 0 + aa$ = a3$ + sp 'rebuilt a$ (always has a trailing spacer) + lastfuse = -1 + FOR x = 2 TO n + a2$ = getelement(ca$, x) + IF except = 1 THEN except = 2: GOTO udtperiod 'skip element name + IF a2$ = "." AND x <> n THEN + IF except = 2 THEN except = 1: GOTO udtperiod 'sub-element of UDT + + IF a3$ = ")" THEN + 'assume it was something like typevar(???).x and treat as a UDT + except = 1 + GOTO udtperiod + END IF + + 'find an ID of that type + try = findid(UCASE$(a3$)) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF ((id.t AND ISUDT) <> 0) OR ((id.arraytype AND ISUDT) <> 0) THEN + except = 1 + GOTO udtperiod + END IF + IF try = 2 THEN findanotherid = 1: try = findid(UCASE$(a3$)) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + 'not a udt; fuse lhs & rhs with _046_ + IF isalpha(ASC(a3$)) = 0 AND lastfuse <> x - 2 THEN a$ = "Invalid '.'": GOTO errmes + aa$ = LEFT$(aa$, LEN(aa$) - 1) + fix046$ + lastfuse = x + GOTO periodfused + END IF '"." + except = 0 + udtperiod: + aa$ = aa$ + a2$ + sp + periodfused: + a3$ = a2$ + NEXT + a$ = LEFT$(aa$, LEN(aa$) - 1) + ca$ = a$ + a$ = eleucase$(ca$) + n = numelements(a$) + END IF + + arrayprocessinghappened = 0 + + firstelement$ = getelement(a$, 1) + secondelement$ = getelement(a$, 2) + thirdelement$ = getelement(a$, 3) + + 'non-executable section + + IF n = 1 THEN + IF firstelement$ = "'" THEN layoutdone = 1: GOTO finishednonexec 'nop + END IF + + IF n <= 2 THEN + IF firstelement$ = "DATA" THEN + l$ = SCase$("Data") + IF n = 2 THEN + + e$ = SPACE$((LEN(secondelement$) - 1) \ 2) + FOR x = 1 TO LEN(e$) + v1 = ASC(secondelement$, x * 2) + v2 = ASC(secondelement$, x * 2 + 1) + IF v1 < 65 THEN v1 = v1 - 48 ELSE v1 = v1 - 55 + IF v2 < 65 THEN v2 = v2 - 48 ELSE v2 = v2 - 55 + ASC(e$, x) = v1 + v2 * 16 + NEXT + l$ = l$ + sp + e$ + END IF 'n=2 + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + + GOTO finishednonexec + END IF + END IF + + + + 'declare library + IF declaringlibrary THEN + + IF firstelement$ = "END" THEN + IF n <> 2 OR secondelement$ <> "DECLARE" THEN a$ = "Expected END DECLARE": GOTO errmes + declaringlibrary = 0 + l$ = SCase$("End" + sp + "Declare") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec + END IF 'end declare + + declaringlibrary = 2 + + IF firstelement$ = "SUB" OR firstelement$ = "FUNCTION" THEN + GOTO declaresubfunc2 + END IF + + a$ = "Expected SUB/FUNCTION definition or END DECLARE": GOTO errmes + END IF 'declaringlibrary + + 'check TYPE declarations (created on prepass) + IF definingtype THEN + + IF firstelement$ = "END" THEN + IF n <> 2 OR secondelement$ <> "TYPE" THEN a$ = "Expected END TYPE": GOTO errmes + definingtype = 0 + l$ = SCase$("End" + sp + "Type") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec + END IF + + 'IF n < 3 THEN definingtypeerror = linenumber: a$ = "Expected element-name AS type or AS type element-list": GOTO errmes + IF n < 3 THEN a$ = "Expected element-name AS type or AS type element-list": GOTO errmes + definingtype = 2 + IF firstelement$ = "AS" THEN + l$ = SCase$("As") + t$ = "" + wordsInTypeName = 0 + DO + nextElement$ = getelement$(a$, 2 + wordsInTypeName) + IF nextElement$ = "," THEN + 'element-list + wordsInTypeName = wordsInTypeName - 2 + EXIT DO + END IF + + wordsInTypeName = wordsInTypeName + 1 + IF wordsInTypeName = n - 2 THEN + 'single element in line + wordsInTypeName = wordsInTypeName - 1 + EXIT DO + END IF + LOOP + + t$ = getelements$(a$, 2, 2 + wordsInTypeName) + typ = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF typ = 0 THEN a$ = "Undefined type": GOTO errmes + IF typ AND ISUDT THEN + IF UCASE$(RTRIM$(t$)) = "MEM" AND RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND qb64prefix_set = 1 THEN + t$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) + ELSE + t$ = RTRIM$(udtxcname(typ AND 511)) + END IF + l$ = l$ + sp + t$ + ELSE + l$ = l$ + sp + SCase2$(t$) + END IF + + 'Now add each variable: + FOR i = 3 + wordsInTypeName TO n + thisElement$ = getelement$(ca$, i) + IF thisElement$ = "," THEN + l$ = l$ + thisElement$ + ELSE + l$ = l$ + sp + thisElement$ + END IF + NEXT + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + ELSE + l$ = getelement(ca$, 1) + sp + SCase$("As") + t$ = getelements$(a$, 3, n) + typ = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF typ = 0 THEN a$ = "Undefined type": GOTO errmes + IF typ AND ISUDT THEN + IF UCASE$(RTRIM$(t$)) = "MEM" AND RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND qb64prefix_set = 1 THEN + t$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) + ELSE + t$ = RTRIM$(udtxcname(typ AND 511)) + END IF + l$ = l$ + sp + t$ + ELSE + l$ = l$ + sp + SCase2$(t$) + END IF + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + END IF + GOTO finishednonexec + + END IF 'defining type + + IF firstelement$ = "TYPE" THEN + IF n <> 2 THEN a$ = "Expected TYPE type-name": GOTO errmes + l$ = SCase$("Type") + sp + getelement(ca$, 2) + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + definingtype = 1 + definingtypeerror = linenumber + GOTO finishednonexec + END IF + + 'skip DECLARE SUB/FUNCTION + IF n >= 1 THEN + IF firstelement$ = "DECLARE" THEN + + IF secondelement$ = "LIBRARY" OR secondelement$ = "DYNAMIC" OR secondelement$ = "CUSTOMTYPE" OR secondelement$ = "STATIC" THEN + + declaringlibrary = 1 + dynamiclibrary = 0 + customtypelibrary = 0 + indirectlibrary = 0 + staticlinkedlibrary = 0 + + x = 3 + l$ = SCase$("Declare" + sp + "Library") + + IF secondelement$ = "DYNAMIC" THEN + e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + dynamiclibrary = 1 + x = 4 + l$ = SCase$("Declare" + sp + "Dynamic" + sp + "Library") + IF n = 3 THEN a$ = "Expected DECLARE DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + indirectlibrary = 1 + END IF + + IF secondelement$ = "CUSTOMTYPE" THEN + e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected CUSTOMTYPE LIBRARY": GOTO errmes + customtypelibrary = 1 + x = 4 + l$ = SCase$("Declare" + sp + "CustomType" + sp + "Library") + indirectlibrary = 1 + END IF + + IF secondelement$ = "STATIC" THEN + e$ = getelement$(a$, 3): IF e$ <> "LIBRARY" THEN a$ = "Expected STATIC LIBRARY": GOTO errmes + x = 4 + l$ = SCase$("Declare" + sp + "Static" + sp + "Library") + staticlinkedlibrary = 1 + END IF + + sfdeclare = 0: sfheader = 0 + + IF n >= x THEN + + sfdeclare = 1 + + addlibrary: + + libname$ = "" + headername$ = "" + + + 'assume library name in double quotes follows + 'assume library is in main qb64pe folder + x$ = getelement$(ca$, x) + IF ASC(x$) <> 34 THEN a$ = "Expected LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + x$ = RIGHT$(x$, LEN(x$) - 1) + z = INSTR(x$, CHR$(34)) + IF z = 0 THEN a$ = "Expected LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + x$ = LEFT$(x$, z - 1) + + IF dynamiclibrary <> 0 AND LEN(x$) = 0 THEN a$ = "Expected DECLARE DYNAMIC LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + IF customtypelibrary <> 0 AND LEN(x$) = 0 THEN a$ = "Expected DECLARE CUSTOMTYPE LIBRARY " + CHR$(34) + "..." + CHR$(34): GOTO errmes + + + + + + + + + + + + + + 'convert '\\' to '\' + WHILE INSTR(x$, "\\") + z = INSTR(x$, "\\") + x$ = LEFT$(x$, z - 1) + RIGHT$(x$, LEN(x$) - z) + WEND + + autoformat_x$ = x$ 'used for autolayout purposes + + 'Remove version number from library name + 'Eg. libname:1.0 becomes libname <-> 1.0 which later becomes libname.so.1.0 + v$ = "" + striplibver: + FOR z = LEN(x$) TO 1 STEP -1 + a = ASC(x$, z) + IF a = ASC_BACKSLASH OR a = ASC_FORWARDSLASH THEN EXIT FOR + IF a = ASC_FULLSTOP OR a = ASC_COLON THEN + IF isuinteger(RIGHT$(x$, LEN(x$) - z)) THEN + IF LEN(v$) THEN v$ = RIGHT$(x$, LEN(x$) - z) + "." + v$ ELSE v$ = RIGHT$(x$, LEN(x$) - z) + x$ = LEFT$(x$, z - 1) + IF a = ASC_COLON THEN EXIT FOR + GOTO striplibver + ELSE + EXIT FOR + END IF + END IF + NEXT + libver$ = v$ + + + IF os$ = "WIN" THEN + 'convert forward-slashes to back-slashes + DO WHILE INSTR(x$, "/") + z = INSTR(x$, "/") + x$ = LEFT$(x$, z - 1) + "\" + RIGHT$(x$, LEN(x$) - z) + LOOP + END IF + + IF os$ = "LNX" THEN + 'convert any back-slashes to forward-slashes + DO WHILE INSTR(x$, "\") + z = INSTR(x$, "\") + x$ = LEFT$(x$, z - 1) + "/" + RIGHT$(x$, LEN(x$) - z) + LOOP + END IF + + 'Separate path from name + libpath$ = "" + FOR z = LEN(x$) TO 1 STEP -1 + a = ASC(x$, z) + IF a = 47 OR a = 92 THEN '\ or / + libpath$ = LEFT$(x$, z) + x$ = RIGHT$(x$, LEN(x$) - z) + EXIT FOR + END IF + NEXT + + 'Accept ./ and .\ as a reference to the source file + 'folder, replacing it with the actual full path, if available + IF libpath$ = "./" OR libpath$ = ".\" THEN + libpath$ = "" + IF NoIDEMode THEN + libpath$ = path.source$ + IF LEN(libpath$) > 0 AND RIGHT$(libpath$, 1) <> pathsep$ THEN libpath$ = libpath$ + pathsep$ + ELSE + IF LEN(ideprogname) THEN libpath$ = idepath$ + pathsep$ + END IF + END IF + + 'Create a path which can be used for inline code (uses \\ instead of \) + libpath_inline$ = "" + FOR z = 1 TO LEN(libpath$) + a = ASC(libpath$, z) + libpath_inline$ = libpath_inline$ + CHR$(a) + IF a = 92 THEN libpath_inline$ = libpath_inline$ + "\" + NEXT + + IF LEN(x$) THEN + IF dynamiclibrary = 0 THEN + 'Static library + + IF os$ = "WIN" THEN + 'check for .lib + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + x$ + ".lib") THEN + libname$ = libpath$ + x$ + ".lib" + inlinelibname$ = libpath_inline$ + x$ + ".lib" + END IF + END IF + 'check for .a + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + x$ + ".a") THEN + libname$ = libpath$ + x$ + ".a" + inlinelibname$ = libpath_inline$ + x$ + ".a" + END IF + END IF + 'check for .o + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + x$ + ".o") THEN + libname$ = libpath$ + x$ + ".o" + inlinelibname$ = libpath_inline$ + x$ + ".o" + END IF + END IF + 'check for .lib + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(x$ + ".lib") THEN + libname$ = x$ + ".lib" + inlinelibname$ = x$ + ".lib" + END IF + END IF + 'check for .a + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(x$ + ".a") THEN + libname$ = x$ + ".a" + inlinelibname$ = x$ + ".a" + END IF + END IF + 'check for .o + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(x$ + ".o") THEN + libname$ = x$ + ".o" + inlinelibname$ = x$ + ".o" + END IF + END IF + END IF 'Windows + + IF os$ = "LNX" THEN + IF staticlinkedlibrary = 0 THEN + + IF MacOSX THEN 'dylib support + 'check for .dylib (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = libpath$ + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".dylib") THEN + libname$ = libpath$ + "lib" + x$ + ".dylib" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".dylib" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + END IF + + 'check for .so (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so." + libver$ + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so") THEN + libname$ = libpath$ + "lib" + x$ + ".so" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath " + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + END IF + 'check for .a (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".a") THEN + libname$ = libpath$ + "lib" + x$ + ".a" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".a" + END IF + END IF + 'check for .o (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".o") THEN + libname$ = libpath$ + "lib" + x$ + ".o" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".o" + END IF + END IF + IF staticlinkedlibrary = 0 THEN + 'check for .so (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " + END IF + END IF + END IF + 'check for .a (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".a") THEN + libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".a" + inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".a" + END IF + END IF + IF staticlinkedlibrary = 0 THEN + + IF MacOSX THEN 'dylib support + 'check for .dylib (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".dylib") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".dylib" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".dylib" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + END IF + + 'check for .so (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so" + IF LEN(libpath$) THEN mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/" + libpath$ + " " ELSE mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + END IF + 'check for .a (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".a") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".a" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".a" + END IF + END IF + '--------------------------(without path)------------------------------ + IF staticlinkedlibrary = 0 THEN + + IF MacOSX THEN 'dylib support + 'check for .dylib (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "lib" + x$ + "." + libver$ + ".dylib" + mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".dylib") THEN + libname$ = "lib" + x$ + ".dylib" + inlinelibname$ = "lib" + x$ + ".dylib" + mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + END IF + + 'check for .so (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".so." + libver$) THEN + libname$ = "lib" + x$ + ".so." + libver$ + inlinelibname$ = "lib" + x$ + ".so." + libver$ + mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".so") THEN + libname$ = "lib" + x$ + ".so" + inlinelibname$ = "lib" + x$ + ".so" + mylibopt$ = mylibopt$ + " -Wl,-rpath ./ " + END IF + END IF + END IF + 'check for .a (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".a") THEN + libname$ = "lib" + x$ + ".a" + inlinelibname$ = "lib" + x$ + ".a" + END IF + END IF + 'check for .o (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".o") THEN + libname$ = "lib" + x$ + ".o" + inlinelibname$ = "lib" + x$ + ".o" + END IF + END IF + IF staticlinkedlibrary = 0 THEN + 'check for .so (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ + mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib64/" + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so" + mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib64/ " + END IF + END IF + END IF + 'check for .a (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".a") THEN + libname$ = "/usr/lib64/" + "lib" + x$ + ".a" + inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".a" + END IF + END IF + IF staticlinkedlibrary = 0 THEN + + IF MacOSX THEN 'dylib support + 'check for .dylib (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".dylib") THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".dylib" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".dylib" + mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + END IF + + 'check for .so (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so" + mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + END IF + 'check for .a (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".a") THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".a" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".a" + mylibopt$ = mylibopt$ + " -Wl,-rpath /usr/lib/ " + END IF + END IF + END IF 'Linux + + + 'check for header + IF LEN(headername$) = 0 THEN + IF os$ = "WIN" THEN + IF _FILEEXISTS(libpath$ + x$ + ".h") THEN + headername$ = libpath_inline$ + x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS(libpath$ + x$ + ".hpp") THEN + headername$ = libpath_inline$ + x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + '--------------------------(without path)------------------------------ + IF _FILEEXISTS(x$ + ".h") THEN + headername$ = x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS(x$ + ".hpp") THEN + headername$ = x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + END IF 'Windows + + IF os$ = "LNX" THEN + IF _FILEEXISTS(libpath$ + x$ + ".h") THEN + headername$ = libpath_inline$ + x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS(libpath$ + x$ + ".hpp") THEN + headername$ = libpath_inline$ + x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS("/usr/include/" + libpath$ + x$ + ".h") THEN + headername$ = "/usr/include/" + libpath_inline$ + x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS("/usr/include/" + libpath$ + x$ + ".hpp") THEN + headername$ = "/usr/include/" + libpath_inline$ + x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + '--------------------------(without path)------------------------------ + IF _FILEEXISTS(x$ + ".h") THEN + headername$ = x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS(x$ + ".hpp") THEN + headername$ = x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS("/usr/include/" + x$ + ".h") THEN + headername$ = "/usr/include/" + x$ + ".h" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + IF _FILEEXISTS("/usr/include/" + x$ + ".hpp") THEN + headername$ = "/usr/include/" + x$ + ".hpp" + IF customtypelibrary = 0 THEN sfdeclare = 0 + sfheader = 1 + GOTO GotHeader + END IF + END IF 'Linux + + GotHeader: + END IF + + ELSE + 'dynamic library + + IF os$ = "WIN" THEN + 'check for .dll (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + x$ + ".dll") THEN + libname$ = libpath$ + x$ + ".dll" + inlinelibname$ = libpath_inline$ + x$ + ".dll" + END IF + END IF + 'check for .dll (system32) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(ENVIRON$("SYSTEMROOT") + "\System32\" + libpath$ + x$ + ".dll") THEN + libname$ = libpath$ + x$ + ".dll" + inlinelibname$ = libpath_inline$ + x$ + ".dll" + END IF + END IF + '--------------------------(without path)------------------------------ + 'check for .dll (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(x$ + ".dll") THEN + libname$ = x$ + ".dll" + inlinelibname$ = x$ + ".dll" + END IF + END IF + 'check for .dll (system32) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(ENVIRON$("SYSTEMROOT") + "\System32\" + x$ + ".dll") THEN + libname$ = x$ + ".dll" + inlinelibname$ = x$ + ".dll" + END IF + END IF + END IF 'Windows + + IF os$ = "LNX" THEN + 'Note: STATIC libraries (.a/.o) cannot be loaded as dynamic objects + + + IF MacOSX THEN 'dylib support + 'check for .dylib (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = libpath$ + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" + IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".dylib") THEN + libname$ = libpath$ + "lib" + x$ + ".dylib" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".dylib" + IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + END IF + + 'check for .so (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so." + libver$ + IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS(libpath$ + "lib" + x$ + ".so") THEN + libname$ = libpath$ + "lib" + x$ + ".so" + inlinelibname$ = libpath_inline$ + "lib" + x$ + ".so" + IF LEFT$(libpath$, 1) <> "/" THEN libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + 'check for .so (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + libpath$ + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib64/" + libpath$ + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib64/" + libpath_inline$ + "lib" + x$ + ".so" + END IF + END IF + + IF MacOSX THEN 'dylib support + 'check for .dylib (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + "." + libver$ + ".dylib" + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".dylib") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".dylib" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".dylib" + END IF + END IF + END IF + + 'check for .so (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so." + libver$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + libpath$ + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib/" + libpath$ + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib/" + libpath_inline$ + "lib" + x$ + ".so" + END IF + END IF + '--------------------------(without path)------------------------------ + IF MacOSX THEN 'dylib support + 'check for .dylib (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "lib" + x$ + "." + libver$ + ".dylib" + libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".dylib") THEN + libname$ = "lib" + x$ + ".dylib" + inlinelibname$ = "lib" + x$ + ".dylib" + libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + END IF + + 'check for .so (direct) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".so." + libver$) THEN + libname$ = "lib" + x$ + ".so." + libver$ + inlinelibname$ = "lib" + x$ + ".so." + libver$ + libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("lib" + x$ + ".so") THEN + libname$ = "lib" + x$ + ".so" + inlinelibname$ = "lib" + x$ + ".so" + libname$ = "./" + libname$: inlinelibname$ = "./" + inlinelibname$ + END IF + END IF + 'check for .so (usr/lib64) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so." + libver$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib64/" + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib64/" + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib64/" + "lib" + x$ + ".so" + END IF + END IF + + IF MacOSX THEN 'dylib support + 'check for .dylib (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib") THEN + libname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + "." + libver$ + ".dylib" + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".dylib") THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".dylib" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".dylib" + END IF + END IF + END IF + + 'check for .so (usr/lib) + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so." + libver$) THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so." + libver$ + END IF + END IF + IF LEN(libname$) = 0 THEN + IF _FILEEXISTS("/usr/lib/" + "lib" + x$ + ".so") THEN + libname$ = "/usr/lib/" + "lib" + x$ + ".so" + inlinelibname$ = "/usr/lib/" + "lib" + x$ + ".so" + END IF + END IF + END IF 'Linux + + END IF 'Dynamic + + 'library found? + IF dynamiclibrary <> 0 AND LEN(libname$) = 0 THEN a$ = "DYNAMIC LIBRARY not found": GOTO errmes + IF LEN(libname$) = 0 AND LEN(headername$) = 0 THEN a$ = "LIBRARY not found": GOTO errmes + + '***actual method should cull redundant header and library entries*** + + IF dynamiclibrary = 0 THEN + + 'static + IF LEN(libname$) THEN + IF os$ = "WIN" THEN + IF MID$(libname$, 2, 1) = ":" OR LEFT$(libname$, 1) = "\" THEN + mylib$ = mylib$ + " " + libname$ + " " + ELSE + mylib$ = mylib$ + " ..\..\" + libname$ + " " + END IF + END IF + IF os$ = "LNX" THEN + IF LEFT$(libname$, 1) = "/" THEN + mylib$ = mylib$ + " " + libname$ + " " + ELSE + mylib$ = mylib$ + " ../../" + libname$ + " " + END IF + END IF + + END IF + + ELSE + + 'dynamic + IF LEN(headername$) = 0 THEN 'no header + + IF subfuncn THEN + f = FREEFILE + OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f + ELSE + f = 13 + END IF + + 'make name a C-appropriate variable name + 'by converting everything except numbers and + 'letters to underscores + x2$ = x$ + FOR x2 = 1 TO LEN(x2$) + IF ASC(x2$, x2) < 48 THEN ASC(x2$, x2) = 95 + IF ASC(x2$, x2) > 57 AND ASC(x2$, x2) < 65 THEN ASC(x2$, x2) = 95 + IF ASC(x2$, x2) > 90 AND ASC(x2$, x2) < 97 THEN ASC(x2$, x2) = 95 + IF ASC(x2$, x2) > 122 THEN ASC(x2$, x2) = 95 + NEXT + DLLname$ = x2$ + + IF sfdeclare THEN + + IF os$ = "WIN" THEN + PRINT #17, "HINSTANCE DLL_" + x2$ + "=NULL;" + PRINT #f, "if (!DLL_" + x2$ + "){" + PRINT #f, "DLL_" + x2$ + "=LoadLibrary(" + CHR$(34) + inlinelibname$ + CHR$(34) + ");" + PRINT #f, "if (!DLL_" + x2$ + ") error(259);" + PRINT #f, "}" + END IF + + IF os$ = "LNX" THEN + PRINT #17, "void *DLL_" + x2$ + "=NULL;" + PRINT #f, "if (!DLL_" + x2$ + "){" + PRINT #f, "DLL_" + x2$ + "=dlopen(" + CHR$(34) + inlinelibname$ + CHR$(34) + ",RTLD_LAZY);" + PRINT #f, "if (!DLL_" + x2$ + ") error(259);" + PRINT #f, "}" + END IF + + + END IF + + IF subfuncn THEN CLOSE #f + + END IF 'no header + + END IF 'dynamiclibrary + + IF LEN(headername$) THEN + IF os$ = "WIN" THEN + IF MID$(headername$, 2, 1) = ":" OR LEFT$(headername$, 1) = "\" THEN + PRINT #17, "#include " + CHR$(34) + headername$ + CHR$(34) + ELSE + PRINT #17, "#include " + CHR$(34) + "..\\..\\" + headername$ + CHR$(34) + END IF + END IF + IF os$ = "LNX" THEN + + IF LEFT$(headername$, 1) = "/" THEN + PRINT #17, "#include " + CHR$(34) + headername$ + CHR$(34) + ELSE + PRINT #17, "#include " + CHR$(34) + "../../" + headername$ + CHR$(34) + END IF + + END IF + END IF + + END IF + + l$ = l$ + sp + CHR$(34) + autoformat_x$ + CHR$(34) + + IF n > x THEN + IF dynamiclibrary THEN a$ = "Cannot specify multiple DYNAMIC LIBRARY names in a single DECLARE statement": GOTO errmes + x = x + 1: x2$ = getelement$(a$, x): IF x2$ <> "," THEN a$ = "Expected ,": GOTO errmes + l$ = l$ + sp2 + "," + x = x + 1: IF x > n THEN a$ = "Expected , ...": GOTO errmes + GOTO addlibrary + END IF + + END IF 'n>=x + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec + END IF + + GOTO finishednonexec 'note: no layout required + END IF + END IF + + 'begin SUB/FUNCTION + IF n >= 1 THEN + dynamiclibrary = 0 + declaresubfunc2: + sf = 0 + IF firstelement$ = "FUNCTION" THEN sf = 1 + IF firstelement$ = "SUB" THEN sf = 2 + IF sf THEN + + IF declaringlibrary = 0 THEN + IF LEN(subfunc) THEN a$ = "Expected END SUB/FUNCTION before " + firstelement$: GOTO errmes + END IF + + IF n = 1 THEN a$ = "Expected name after SUB/FUNCTION": GOTO errmes + e$ = getelement$(ca$, 2) + symbol$ = removesymbol$(e$) '$,%,etc. + IF Error_Happened THEN GOTO errmes + IF sf = 2 AND symbol$ <> "" THEN a$ = "Type symbols after a SUB name are invalid": GOTO errmes + try = findid(e$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = sf THEN GOTO createsf + IF try = 2 THEN findanotherid = 1: try = findid(e$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + a$ = "Unregistered SUB/FUNCTION encountered": GOTO errmes + createsf: + IF UCASE$(e$) = "_GL" THEN e$ = "_GL" + IF firstelement$ = "SUB" THEN + l$ = SCase$("Sub") + sp + e$ + symbol$ + ELSE + l$ = SCase$("Function") + sp + e$ + symbol$ + END IF + id2 = id + targetid = currentid + + 'check for ALIAS + aliasname$ = RTRIM$(id.cn) + IF n > 2 THEN + ee$ = getelement$(a$, 3) + IF ee$ = "ALIAS" THEN + IF declaringlibrary = 0 THEN a$ = "ALIAS can only be used with DECLARE LIBRARY": GOTO errmes + IF n = 3 THEN a$ = "Expected ALIAS name-in-library": GOTO errmes + ee$ = getelement$(ca$, 4) + + 'strip string content (optional) + IF LEFT$(ee$, 1) = CHR$(34) THEN + ee$ = RIGHT$(ee$, LEN(ee$) - 1) + x = INSTR(ee$, CHR$(34)): IF x = 0 THEN a$ = "Expected " + CHR$(34): GOTO errmes + ee$ = LEFT$(ee$, x - 1) + l$ = l$ + sp + SCase$("Alias") + sp + CHR_QUOTE + ee$ + CHR_QUOTE + ELSE + l$ = l$ + sp + SCase$("Alias") + sp + ee$ + END IF + + 'strip fix046$ (created by unquoted periods) + DO WHILE INSTR(ee$, fix046$) + x = INSTR(ee$, fix046$): ee$ = LEFT$(ee$, x - 1) + "." + RIGHT$(ee$, LEN(ee$) - x + 1 - LEN(fix046$)) + LOOP + aliasname$ = ee$ + 'remove ALIAS section from line + IF n <= 4 THEN a$ = getelements(a$, 1, 2) + IF n >= 5 THEN a$ = getelements(a$, 1, 2) + sp + getelements(a$, 5, n) + IF n <= 4 THEN ca$ = getelements(ca$, 1, 2) + IF n >= 5 THEN ca$ = getelements(ca$, 1, 2) + sp + getelements(ca$, 5, n) + n = n - 2 + END IF + END IF + + IF declaringlibrary THEN GOTO declibjmp1 + + + IF closedmain = 0 THEN closemain + + 'check for open controls (copy #2) + IF controllevel <> 0 AND controltype(controllevel) <> 6 THEN 'It's OK for subs to be inside $IF blocks + a$ = "Unidentified open control block" + SELECT CASE controltype(controllevel) + CASE 1: a$ = "IF without END IF" + CASE 2: a$ = "FOR without NEXT" + CASE 3, 4: a$ = "DO without LOOP" + CASE 5: a$ = "WHILE without WEND" + CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" + END SELECT + linenumber = controlref(controllevel) + GOTO errmes + END IF + + IF ideindentsubs THEN + controllevel = controllevel + 1 + controltype(controllevel) = 32 + controlref(controllevel) = linenumber + END IF + + subfunc = RTRIM$(id.callname) 'SUB_..." + IF id.subfunc = 1 THEN subfuncoriginalname$ = "FUNCTION " ELSE subfuncoriginalname$ = "SUB " + subfuncoriginalname$ = subfuncoriginalname$ + RTRIM$(id.cn) + subfuncn = subfuncn + 1 + closedsubfunc = 0 + subfuncid = targetid + + subfuncret$ = "" + + CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #13 + CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #19 + CLOSE #15: OPEN tmpdir$ + "ret" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #15 + PRINT #15, "if (next_return_point){" + PRINT #15, "next_return_point--;" + PRINT #15, "switch(return_point[next_return_point]){" + PRINT #15, "case 0:" + PRINT #15, "error(3);" 'return without gosub! + PRINT #15, "break;" + defdatahandle = 13 + + declibjmp1: + + IF declaringlibrary THEN + IF sfdeclare = 0 AND indirectlibrary = 0 THEN + CLOSE #17 + OPEN tmpdir$ + "regsf_ignore.txt" FOR OUTPUT AS #17 + END IF + IF sfdeclare = 1 AND customtypelibrary = 0 AND dynamiclibrary = 0 AND indirectlibrary = 0 THEN + PRINT #17, "#include " + CHR$(34) + "externtype" + str2(ResolveStaticFunctions + 1) + ".txt" + CHR$(34) + fh = FREEFILE: OPEN tmpdir$ + "externtype" + str2(ResolveStaticFunctions + 1) + ".txt" FOR OUTPUT AS #fh: CLOSE #fh + END IF + END IF + + + + + IF sf = 1 THEN + rettyp = id.ret + t$ = typ2ctyp$(id.ret, "") + IF Error_Happened THEN GOTO errmes + IF t$ = "qbs" THEN t$ = "qbs*" + + IF declaringlibrary THEN + IF rettyp AND ISSTRING THEN + t$ = "char*" + END IF + END IF + + IF declaringlibrary <> 0 AND dynamiclibrary <> 0 THEN + IF os$ = "WIN" THEN + PRINT #17, "typedef " + t$ + " (CALLBACK* DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; + END IF + IF os$ = "LNX" THEN + PRINT #17, "typedef " + t$ + " (*DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; + END IF + ELSEIF declaringlibrary <> 0 AND customtypelibrary <> 0 THEN + PRINT #17, "typedef " + t$ + " CUSTOMCALL_" + removecast$(RTRIM$(id.callname)) + "("; + ELSE + PRINT #17, t$ + " " + removecast$(RTRIM$(id.callname)) + "("; + END IF + IF declaringlibrary THEN GOTO declibjmp2 + PRINT #12, t$ + " " + removecast$(RTRIM$(id.callname)) + "("; + + 'create variable to return result + 'if type wasn't specified, define it + IF symbol$ = "" THEN + a = ASC(UCASE$(e$)): IF a = 95 THEN a = 91 + a = a - 64 'so A=1, Z=27 and _=28 + symbol$ = defineextaz(a) + END IF + reginternalvariable = 1 + ignore = dim2(e$, symbol$, 0, "") + IF Error_Happened THEN GOTO errmes + reginternalvariable = 0 + 'the following line stops the return variable from being free'd before being returned + CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR OUTPUT AS #19 + 'create return + IF (rettyp AND ISSTRING) THEN + r$ = refer$(str2$(currentid), id.t, 1) + IF Error_Happened THEN GOTO errmes + subfuncret$ = subfuncret$ + "qbs_maketmp(" + r$ + ");" + subfuncret$ = subfuncret$ + "return " + r$ + ";" + ELSE + r$ = refer$(str2$(currentid), id.t, 0) + IF Error_Happened THEN GOTO errmes + subfuncret$ = "return " + r$ + ";" + END IF + ELSE + + IF declaringlibrary <> 0 AND dynamiclibrary <> 0 THEN + IF os$ = "WIN" THEN + PRINT #17, "typedef void (CALLBACK* DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; + END IF + IF os$ = "LNX" THEN + PRINT #17, "typedef void (*DLLCALL_" + removecast$(RTRIM$(id.callname)) + ")("; + END IF + ELSEIF declaringlibrary <> 0 AND customtypelibrary <> 0 THEN + PRINT #17, "typedef void CUSTOMCALL_" + removecast$(RTRIM$(id.callname)) + "("; + ELSE + PRINT #17, "void " + removecast$(RTRIM$(id.callname)) + "("; + END IF + IF declaringlibrary THEN GOTO declibjmp2 + PRINT #12, "void " + removecast$(RTRIM$(id.callname)) + "("; + END IF + declibjmp2: + + addstatic2layout = 0 + staticsf = 0 + e$ = getelement$(a$, n) + IF e$ = "STATIC" THEN + IF declaringlibrary THEN a$ = "STATIC cannot be used in a library declaration": GOTO errmes + addstatic2layout = 1 + staticsf = 2 + a$ = LEFT$(a$, LEN(a$) - 7): n = n - 1 'remove STATIC + END IF + + 'check items to pass + params = 0 + AllowLocalName = 1 + IF n > 2 THEN + e$ = getelement$(a$, 3) + IF e$ <> "(" THEN a$ = "Expected (": GOTO errmes + e$ = getelement$(a$, n) + IF e$ <> ")" THEN a$ = "Expected )": GOTO errmes + l$ = l$ + sp + "(" + IF n = 4 THEN GOTO nosfparams2 + IF n < 4 THEN a$ = "Expected ( ... )": GOTO errmes + B = 0 + a2$ = "" + FOR i = 4 TO n - 1 + e$ = getelement$(ca$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN B = B - 1 + IF e$ = "," AND B = 0 THEN + IF i = n - 1 THEN a$ = "Expected , ... )": GOTO errmes + getlastparam2: + IF a2$ = "" THEN a$ = "Expected ... ,": GOTO errmes + a2$ = LEFT$(a2$, LEN(a2$) - 1) + 'possible format: [BYVAL]a[%][(1)][AS][type] + params = params + 1 + glinkid = targetid + glinkarg = params + + + + IF params > 1 THEN + PRINT #17, ","; + + IF declaringlibrary = 0 THEN + PRINT #12, ","; + END IF + + END IF + n2 = numelements(a2$) + array = 0 + t2$ = "" + e$ = getelement$(a2$, 1) + + byvalue = 0 + IF UCASE$(e$) = "BYVAL" THEN + IF declaringlibrary = 0 THEN a$ = "BYVAL can only be used with DECLARE LIBRARY": GOTO errmes + byvalue = 1: a2$ = RIGHT$(a2$, LEN(a2$) - 6) + IF RIGHT$(l$, 1) = "(" THEN l$ = l$ + sp2 + SCase$("ByVal") ELSE l$ = l$ + sp + SCase$("Byval") + n2 = numelements(a2$): e$ = getelement$(a2$, 1) + END IF + + IF RIGHT$(l$, 1) = "(" THEN l$ = l$ + sp2 + e$ ELSE l$ = l$ + sp + e$ + + n2$ = e$ + dimmethod = 0 + + + symbol2$ = removesymbol$(n2$) + IF validname(n2$) = 0 THEN a$ = "Invalid name": GOTO errmes + + IF Error_Happened THEN GOTO errmes + IF symbol2$ <> "" THEN dimmethod = 1 + m = 0 + FOR i2 = 2 TO n2 + e$ = getelement$(a2$, i2) + IF e$ = "(" THEN + IF m <> 0 THEN a$ = "Syntax error - too many opening brackets": GOTO errmes + m = 1 + array = 1 + l$ = l$ + sp2 + "(" + GOTO gotaa2 + END IF + IF e$ = ")" THEN + IF m <> 1 THEN a$ = "Syntax error - closing bracket without opening bracket": GOTO errmes + m = 2 + l$ = l$ + sp2 + ")" + GOTO gotaa2 + END IF + IF UCASE$(e$) = "AS" THEN + IF m <> 0 AND m <> 2 THEN a$ = "Syntax error - check your brackets": GOTO errmes + m = 3 + l$ = l$ + sp + SCase$("As") + GOTO gotaa2 + END IF + IF m = 1 THEN l$ = l$ + sp + e$: GOTO gotaa2 'ignore contents of option bracket telling how many dimensions (add to layout as is) + IF m <> 3 THEN a$ = "Syntax error - check your brackets": GOTO errmes + IF t2$ = "" THEN t2$ = e$ ELSE t2$ = t2$ + " " + e$ + gotaa2: + NEXT i2 + IF m = 1 THEN a$ = "Syntax error - check your brackets": GOTO errmes + IF symbol2$ <> "" AND t2$ <> "" THEN a$ = "Syntax error - check parameter types": GOTO errmes + + + IF LEN(t2$) THEN 'add type-name after AS + t2$ = UCASE$(t2$) + t3$ = t2$ + typ = typname2typ(t3$) + IF Error_Happened THEN GOTO errmes + IF typ = 0 THEN a$ = "Undefined type": GOTO errmes + IF typ AND ISUDT THEN + IF RTRIM$(udtxcname(typ AND 511)) = "_MEM" AND UCASE$(t3$) = "MEM" AND qb64prefix_set = 1 THEN + t3$ = MID$(RTRIM$(udtxcname(typ AND 511)), 2) + ELSE + t3$ = RTRIM$(udtxcname(typ AND 511)) + END IF + l$ = l$ + sp + t3$ + ELSE + FOR t3i = 1 TO LEN(t3$) + IF ASC(t3$, t3i) = 32 THEN ASC(t3$, t3i) = ASC(sp) + NEXT + t3$ = SCase2$(t3$) + l$ = l$ + sp + t3$ + END IF + END IF + + IF t2$ = "" THEN t2$ = symbol2$ + IF t2$ = "" THEN + IF LEFT$(n2$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n2$)) - 64 + t2$ = defineaz(v) + dimmethod = 1 + END IF + + + + + IF array = 1 THEN + IF declaringlibrary THEN a$ = "Arrays cannot be passed to a library": GOTO errmes + dimsfarray = 1 + 'note: id2.nele is currently 0 + nelereq = ASC(MID$(id2.nelereq, params, 1)) + IF nelereq THEN + nele = nelereq + MID$(id2.nele, params, 1) = CHR$(nele) + + ids(targetid) = id2 + + ignore = dim2(n2$, t2$, dimmethod, str2$(nele)) + IF Error_Happened THEN GOTO errmes + ELSE + nele = 1 + MID$(id2.nele, params, 1) = CHR$(nele) + + ids(targetid) = id2 + + ignore = dim2(n2$, t2$, dimmethod, "?") + IF Error_Happened THEN GOTO errmes + END IF + + dimsfarray = 0 + r$ = refer$(str2$(currentid), id.t, 1) + IF Error_Happened THEN GOTO errmes + PRINT #17, "ptrszint*" + r$; + PRINT #12, "ptrszint*" + r$; + ELSE + + IF declaringlibrary THEN + 'is it a udt? + FOR xx = 1 TO lasttype + IF t2$ = RTRIM$(udtxname(xx)) THEN + PRINT #17, "void*" + GOTO decudt + ELSEIF RTRIM$(udtxname(xx)) = "_MEM" AND t2$ = "MEM" AND qb64prefix_set = 1 THEN + PRINT #17, "void*" + GOTO decudt + END IF + NEXT + t$ = typ2ctyp$(0, t2$) + + IF Error_Happened THEN GOTO errmes + IF t$ = "qbs" THEN + t$ = "char*" + IF byvalue = 1 THEN a$ = "STRINGs cannot be passed using BYVAL": GOTO errmes + byvalue = 1 'use t$ as is + END IF + IF byvalue THEN PRINT #17, t$; ELSE PRINT #17, t$ + "*"; + decudt: + GOTO declibjmp3 + END IF + + dimsfarray = 1 + ignore = dim2(n2$, t2$, dimmethod, "") + IF Error_Happened THEN GOTO errmes + + + dimsfarray = 0 + t$ = "" + typ = id.t 'the typ of the ID created by dim2 + + t$ = typ2ctyp$(typ, "") + IF Error_Happened THEN GOTO errmes + + + + IF t$ = "" THEN a$ = "Cannot find C type to return array data": GOTO errmes + 'searchpoint + 'get the name of the variable + r$ = refer$(str2$(currentid), id.t, 1) + IF Error_Happened THEN GOTO errmes + PRINT #17, t$ + "*" + r$; + PRINT #12, t$ + "*" + r$; + IF t$ = "qbs" THEN + u$ = str2$(uniquenumber) + PRINT #13, "qbs*oldstr" + u$ + "=NULL;" + PRINT #13, "if(" + r$ + "->tmp||" + r$ + "->fixed||" + r$ + "->readonly){" + PRINT #13, "oldstr" + u$ + "=" + r$ + ";" + + PRINT #13, "if (oldstr" + u$ + "->cmem_descriptor){" + PRINT #13, r$ + "=qbs_new_cmem(oldstr" + u$ + "->len,0);" + PRINT #13, "}else{" + PRINT #13, r$ + "=qbs_new(oldstr" + u$ + "->len,0);" + PRINT #13, "}" + + PRINT #13, "memcpy(" + r$ + "->chr,oldstr" + u$ + "->chr,oldstr" + u$ + "->len);" + PRINT #13, "}" + + PRINT #19, "if(oldstr" + u$ + "){" + PRINT #19, "if(oldstr" + u$ + "->fixed)qbs_set(oldstr" + u$ + "," + r$ + ");" + PRINT #19, "qbs_free(" + r$ + ");" + PRINT #19, "}" + END IF + END IF + declibjmp3: + IF i <> n - 1 THEN l$ = l$ + sp2 + "," + + a2$ = "" + ELSE + a2$ = a2$ + e$ + sp + IF i = n - 1 THEN GOTO getlastparam2 + END IF + NEXT i + nosfparams2: + l$ = l$ + sp2 + ")" + END IF 'n>2 + AllowLocalName = 0 + + IF addstatic2layout THEN l$ = l$ + sp + SCase$("Static") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + + PRINT #17, ");" + + IF declaringlibrary THEN GOTO declibjmp4 + + PRINT #12, "){" + PRINT #12, "qbs *tqbs;" + PRINT #12, "ptrszint tmp_long;" + PRINT #12, "int32 tmp_fileno;" + PRINT #12, "uint32 qbs_tmp_base=qbs_tmp_list_nexti;" + PRINT #12, "uint8 *tmp_mem_static_pointer=mem_static_pointer;" + PRINT #12, "uint32 tmp_cmem_sp=cmem_sp;" + PRINT #12, "#include " + CHR$(34) + "data" + str2$(subfuncn) + ".txt" + CHR$(34) + + 'create new _MEM lock for this scope + PRINT #12, "mem_lock *sf_mem_lock;" 'MUST not be static for recursion reasons + PRINT #12, "new_mem_lock();" + PRINT #12, "sf_mem_lock=mem_lock_tmp;" + PRINT #12, "sf_mem_lock->type=3;" + + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL+ 1 ;" + IF subfunc <> "SUB_VWATCH" THEN + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = "(" + thisincname$ + "," + STR$(inclinenumber(inclevel)) + ") " + END IF + + PRINT #12, "qbs_set(__STRING_VWATCH_SUBNAME,qbs_new_txt_len(" + CHR$(34) + inclinenump$ + subfuncoriginalname$ + CHR$(34) + "," + str2$(LEN(inclinenump$ + subfuncoriginalname$)) + "));" + PRINT #12, "qbs_cleanup(qbs_tmp_base,0);" + PRINT #12, "qbs_set(__STRING_VWATCH_INTERNALSUBNAME,qbs_new_txt_len(" + CHR$(34) + subfunc + CHR$(34) + "," + str2$(LEN(subfunc)) + "));" + PRINT #12, "qbs_cleanup(qbs_tmp_base,0);" + PRINT #12, "*__LONG_VWATCH_LINENUMBER=-2; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + END IF + + PRINT #12, "if (new_error) goto exit_subfunc;" + + 'statementn = statementn + 1 + 'if nochecks=0 then PRINT #12, "S_" + str2$(statementn) + ":;" + + dimstatic = staticsf + + declibjmp4: + + IF declaringlibrary THEN + + IF customtypelibrary THEN + + callname$ = removecast$(RTRIM$(id2.callname)) + + PRINT #17, "CUSTOMCALL_" + callname$ + " *" + callname$ + "=NULL;" + + IF subfuncn THEN + f = FREEFILE + OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f + ELSE + f = 13 + END IF + + + PRINT #f, callname$ + "=(CUSTOMCALL_" + callname$ + "*)&" + aliasname$ + ";" + + IF subfuncn THEN CLOSE #f + + 'if no header exists to make the external function available, the function definition must be found + IF sfheader = 0 AND sfdeclare <> 0 THEN + ResolveStaticFunctions = ResolveStaticFunctions + 1 + 'expand array if necessary + IF ResolveStaticFunctions > UBOUND(ResolveStaticFunction_Name) THEN + REDIM _PRESERVE ResolveStaticFunction_Name(1 TO ResolveStaticFunctions + 100) AS STRING + REDIM _PRESERVE ResolveStaticFunction_File(1 TO ResolveStaticFunctions + 100) AS STRING + REDIM _PRESERVE ResolveStaticFunction_Method(1 TO ResolveStaticFunctions + 100) AS LONG + END IF + ResolveStaticFunction_File(ResolveStaticFunctions) = libname$ + ResolveStaticFunction_Name(ResolveStaticFunctions) = aliasname$ + ResolveStaticFunction_Method(ResolveStaticFunctions) = 1 + END IF 'sfheader=0 + + END IF + + IF dynamiclibrary THEN + IF sfdeclare THEN + + PRINT #17, "DLLCALL_" + removecast$(RTRIM$(id2.callname)) + " " + removecast$(RTRIM$(id2.callname)) + "=NULL;" + + IF subfuncn THEN + f = FREEFILE + OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #f + ELSE + f = 13 + END IF + + PRINT #f, "if (!" + removecast$(RTRIM$(id2.callname)) + "){" + IF os$ = "WIN" THEN + PRINT #f, removecast$(RTRIM$(id2.callname)) + "=(DLLCALL_" + removecast$(RTRIM$(id2.callname)) + ")GetProcAddress(DLL_" + DLLname$ + "," + CHR$(34) + aliasname$ + CHR$(34) + ");" + PRINT #f, "if (!" + removecast$(RTRIM$(id2.callname)) + ") error(260);" + END IF + IF os$ = "LNX" THEN + PRINT #f, removecast$(RTRIM$(id2.callname)) + "=(DLLCALL_" + removecast$(RTRIM$(id2.callname)) + ")dlsym(DLL_" + DLLname$ + "," + CHR$(34) + aliasname$ + CHR$(34) + ");" + PRINT #f, "if (dlerror()) error(260);" + END IF + PRINT #f, "}" + + IF subfuncn THEN CLOSE #f + + END IF 'sfdeclare + END IF 'dynamic + + IF sfdeclare = 1 AND customtypelibrary = 0 AND dynamiclibrary = 0 AND indirectlibrary = 0 THEN + ResolveStaticFunctions = ResolveStaticFunctions + 1 + 'expand array if necessary + IF ResolveStaticFunctions > UBOUND(ResolveStaticFunction_Name) THEN + REDIM _PRESERVE ResolveStaticFunction_Name(1 TO ResolveStaticFunctions + 100) AS STRING + REDIM _PRESERVE ResolveStaticFunction_File(1 TO ResolveStaticFunctions + 100) AS STRING + REDIM _PRESERVE ResolveStaticFunction_Method(1 TO ResolveStaticFunctions + 100) AS LONG + END IF + ResolveStaticFunction_File(ResolveStaticFunctions) = libname$ + ResolveStaticFunction_Name(ResolveStaticFunctions) = aliasname$ + ResolveStaticFunction_Method(ResolveStaticFunctions) = 2 + END IF + + IF sfdeclare = 0 AND indirectlibrary = 0 THEN + CLOSE #17 + OPEN tmpdir$ + "regsf.txt" FOR APPEND AS #17 + END IF + + END IF 'declaring library + + GOTO finishednonexec + END IF + END IF + + 'END SUB/FUNCTION + IF n = 2 THEN + IF firstelement$ = "END" THEN + sf = 0 + IF secondelement$ = "FUNCTION" THEN sf = 1 + IF secondelement$ = "SUB" THEN sf = 2 + IF sf THEN + + IF LEN(subfunc) = 0 THEN a$ = "END " + secondelement$ + " without " + secondelement$: GOTO errmes + + 'check for open controls (copy #3) + IF controllevel <> 0 AND controltype(controllevel) <> 6 AND controltype(controllevel) <> 32 THEN 'It's OK for subs to be inside $IF blocks + a$ = "Unidentified open control block" + SELECT CASE controltype(controllevel) + CASE 1: a$ = "IF without END IF" + CASE 2: a$ = "FOR without NEXT" + CASE 3, 4: a$ = "DO without LOOP" + CASE 5: a$ = "WHILE without WEND" + CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" + END SELECT + linenumber = controlref(controllevel) + GOTO errmes + END IF + + IF controltype(controllevel) = 32 AND ideindentsubs THEN + controltype(controllevel) = 0 + controllevel = controllevel - 1 + END IF + + IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = SCase$("Sub") ELSE secondelement$ = SCase$("Function") + l$ = SCase$("End") + sp + secondelement$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + + IF vWatchOn = 1 THEN + vWatchVariable "", 1 + END IF + + staticarraylist = "": staticarraylistn = 0 'remove previously listed arrays + dimstatic = 0 + PRINT #12, "exit_subfunc:;" + IF vWatchOn = 1 THEN + IF NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + vWatchAddLabel 0, -1 + END IF + PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" + + IF inclinenumber(inclevel) = 0 AND firstLineNumberLabelvWatch > 0 THEN + PRINT #12, "goto VWATCH_SKIPSETNEXTLINE;" + PRINT #12, "VWATCH_SETNEXTLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + WHILE i > LEN(vWatchUsedLabels) + vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) + vWatchUsedSkipLabels = vWatchUsedSkipLabels + SPACE$(1000) + WEND + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case " + str2$(i) + ":" + PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, " default:" + PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" + PRINT #12, " goto VWATCH_SETNEXTLINE;" + PRINT #12, "}" + + PRINT #12, "VWATCH_SKIPLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedSkipLabels, i) = 1 THEN + PRINT #12, " case -" + str2$(i) + ":" + PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, "}" + + PRINT #12, "VWATCH_SKIPSETNEXTLINE:;" + END IF + firstLineNumberLabelvWatch = 0 + END IF + + 'release _MEM lock for this scope + PRINT #12, "free_mem_lock(sf_mem_lock);" + + PRINT #12, "#include " + CHR$(34) + "free" + str2$(subfuncn) + ".txt" + CHR$(34) + PRINT #12, "if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;" + PRINT #12, "cmem_sp=tmp_cmem_sp;" + IF subfuncret$ <> "" THEN PRINT #12, subfuncret$ + + PRINT #12, "}" 'skeleton sub + 'ret???.txt + PRINT #15, "}" 'end case + PRINT #15, "}" + PRINT #15, "error(3);" 'no valid return possible + subfunc = "" + closedsubfunc = -1 + + 'unshare temp. shared variables + FOR i = 1 TO idn + IF ids(i).share AND 2 THEN ids(i).share = ids(i).share - 2 + NEXT + + FOR i = 1 TO revertmaymusthaven + x = revertmaymusthave(i) + SWAP ids(x).musthave, ids(x).mayhave + NEXT + revertmaymusthaven = 0 + + 'undeclare constants in sub/function's scope + 'constlast = constlastshared + GOTO finishednonexec + + END IF + END IF + END IF + + + + IF n >= 1 AND firstelement$ = "CONST" THEN + l$ = SCase$("Const") + 'DEF... do not change type, the expression is stored in a suitable type + 'based on its value if type isn't forced/specified + IF n < 3 THEN a$ = "Expected CONST name = value/expression": GOTO errmes + i = 2 + + constdefpending: + pending = 0 + + n$ = getelement$(ca$, i): i = i + 1 + l$ = l$ + sp + n$ + sp + "=" + typeoverride = 0 + s$ = removesymbol$(n$) + IF Error_Happened THEN GOTO errmes + IF s$ <> "" THEN + typeoverride = typname2typ(s$) + IF Error_Happened THEN GOTO errmes + IF typeoverride AND ISFIXEDLENGTH THEN a$ = "Invalid constant type": GOTO errmes + IF typeoverride = 0 THEN a$ = "Invalid constant type": GOTO errmes + END IF + + IF getelement$(a$, i) <> "=" THEN a$ = "Expected =": GOTO errmes + i = i + 1 + + 'get expression + e$ = "" + B = 0 + FOR i2 = i TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN + pending = 1 + i = i2 + 1 + IF i > n - 2 THEN a$ = "Expected CONST ... , name = value/expression": GOTO errmes + EXIT FOR + END IF + IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + NEXT + + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + + 'Note: Actual CONST definition handled in prepass + + 'Set CONST as defined + hashname$ = n$ + hashchkflags = HASHFLAG_CONSTANT + hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF constsubfunc(hashresref) = subfuncn THEN constdefined(hashresref) = 1: EXIT DO + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + + IF pending THEN l$ = l$ + sp2 + ",": GOTO constdefpending + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + + GOTO finishednonexec + END IF + + predefine: + IF n >= 2 THEN + asreq = 0 + IF firstelement$ = "DEFINT" THEN l$ = SCase$("DefInt"): a$ = a$ + sp + "AS" + sp + "INTEGER": n = n + 2: GOTO definetype + IF firstelement$ = "DEFLNG" THEN l$ = SCase$("DefLng"): a$ = a$ + sp + "AS" + sp + "LONG": n = n + 2: GOTO definetype + IF firstelement$ = "DEFSNG" THEN l$ = SCase$("DefSng"): a$ = a$ + sp + "AS" + sp + "SINGLE": n = n + 2: GOTO definetype + IF firstelement$ = "DEFDBL" THEN l$ = SCase$("DefDbl"): a$ = a$ + sp + "AS" + sp + "DOUBLE": n = n + 2: GOTO definetype + IF firstelement$ = "DEFSTR" THEN l$ = SCase$("DefStr"): a$ = a$ + sp + "AS" + sp + "STRING": n = n + 2: GOTO definetype + IF firstelement$ = "_DEFINE" OR (firstelement$ = "DEFINE" AND qb64prefix_set = 1) THEN + asreq = 1 + IF firstelement$ = "_DEFINE" THEN l$ = SCase$("_Define") ELSE l$ = SCase$("Define") + definetype: + 'get type from rhs + typ$ = "" + typ2$ = "" + t$ = "" + FOR i = n TO 2 STEP -1 + t$ = getelement$(a$, i) + IF t$ = "AS" THEN EXIT FOR + typ$ = t$ + " " + typ$ + typ2$ = t$ + sp + typ2$ + NEXT + typ$ = RTRIM$(typ$) + IF t$ <> "AS" THEN a$ = qb64prefix$ + "DEFINE: Expected ... AS ...": GOTO errmes + IF i = n OR i = 2 THEN a$ = qb64prefix$ + "DEFINE: Expected ... AS ...": GOTO errmes + + + n = i - 1 + 'the data is from element 2 to element n + i = 2 - 1 + definenext: + 'expects an alphabet letter or underscore + i = i + 1: e$ = getelement$(a$, i): E = ASC(UCASE$(e$)) + IF LEN(e$) > 1 THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes + IF E <> 95 AND (E > 90 OR E < 65) THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes + IF E = 95 THEN E = 27 ELSE E = E - 64 + defineaz(E) = typ$ + defineextaz(E) = type2symbol(typ$) + IF Error_Happened THEN GOTO errmes + firste = E + l$ = l$ + sp + e$ + + IF i = n THEN + IF predefining = 1 THEN GOTO predefined + IF asreq THEN l$ = l$ + sp + SCase$("As") + sp + typ2$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec + END IF + + 'expects "-" or "," + i = i + 1: e$ = getelement$(a$, i) + IF e$ <> "-" AND e$ <> "," THEN a$ = qb64prefix$ + "DEFINE: Expected - or ,": GOTO errmes + IF e$ = "-" THEN + l$ = l$ + sp2 + "-" + IF i = n THEN a$ = qb64prefix$ + "DEFINE: Syntax incomplete": GOTO errmes + 'expects an alphabet letter or underscore + i = i + 1: e$ = getelement$(a$, i): E = ASC(UCASE$(e$)) + IF LEN(e$) > 1 THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes + IF E <> 95 AND (E > 90 OR E < 65) THEN a$ = qb64prefix$ + "DEFINE: Expected an alphabet letter or the underscore character (_)": GOTO errmes + IF E = 95 THEN E = 27 ELSE E = E - 64 + IF firste > E THEN SWAP E, firste + FOR e2 = firste TO E + defineaz(e2) = typ$ + defineextaz(e2) = type2symbol(typ$) + IF Error_Happened THEN GOTO errmes + NEXT + l$ = l$ + sp2 + e$ + IF i = n THEN + IF predefining = 1 THEN GOTO predefined + IF asreq THEN l$ = l$ + sp + SCase$("As") + sp + typ2$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec + END IF + 'expects "," + i = i + 1: e$ = getelement$(a$, i) + IF e$ <> "," THEN a$ = qb64prefix$ + "DEFINE: Expected ,": GOTO errmes + END IF + l$ = l$ + sp2 + "," + GOTO definenext + END IF '_DEFINE + END IF '2 + IF predefining = 1 THEN GOTO predefined + + IF closedmain <> 0 AND subfunc = "" THEN a$ = "Statement cannot be placed between SUB/FUNCTIONs": GOTO errmes + + 'executable section: + + statementn = statementn + 1 + + + IF n >= 1 THEN + IF firstelement$ = "NEXT" THEN + + l$ = SCase$("Next") + IF n = 1 THEN GOTO simplenext + v$ = "" + FOR i = 2 TO n + a2$ = getelement(ca$, i) + + IF a2$ = "," THEN + + lastnextele: + e$ = fixoperationorder(v$) + IF Error_Happened THEN GOTO errmes + IF LEN(l$) = 4 THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN + getid VAL(e$) + IF Error_Happened THEN GOTO errmes + IF (id.t AND ISPOINTER) THEN + IF (id.t AND ISSTRING) = 0 THEN + IF (id.t AND ISOFFSETINBITS) = 0 THEN + IF (id.t AND ISARRAY) = 0 THEN + GOTO fornextfoundvar2 + END IF + END IF + END IF + END IF + END IF + a$ = "Unsupported variable after NEXT": GOTO errmes + fornextfoundvar2: + simplenext: + IF controltype(controllevel) <> 2 THEN a$ = "NEXT without FOR": GOTO errmes + IF n <> 1 AND controlvalue(controllevel) <> currentid THEN a$ = "Incorrect variable after NEXT": GOTO errmes + PRINT #12, "fornext_continue_" + str2$(controlid(controllevel)) + ":;" + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + PRINT #12, "}" + PRINT #12, "fornext_exit_" + str2$(controlid(controllevel)) + ":;" + controllevel = controllevel - 1 + IF n = 1 THEN EXIT FOR + v$ = "" + + ELSE + + IF LEN(v$) THEN v$ = v$ + sp + a2$ ELSE v$ = a2$ + IF i = n THEN GOTO lastnextele + + END IF + + NEXT + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec '***no error causing code, event checking done by FOR*** + END IF + END IF + + + + IF n >= 1 THEN + IF firstelement$ = "WHILE" THEN + IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + controllevel = controllevel + 1 + controlref(controllevel) = linenumber + controltype(controllevel) = 5 + controlid(controllevel) = uniquenumber + IF n >= 2 THEN + e$ = fixoperationorder(getelements$(ca$, 2, n)) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("While") + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" + IF (typ AND ISSTRING) THEN a$ = "WHILE ERROR! Cannot accept a STRING type.": GOTO errmes + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + PRINT #12, "while((" + e$ + ")||new_error){" + ELSE + a$ = "WHILE ERROR! Expected expression after WHILE.": GOTO errmes + END IF + + GOTO finishedline + END IF + END IF + + IF n = 1 THEN + IF firstelement$ = "WEND" THEN + + + IF controltype(controllevel) <> 5 THEN a$ = "WEND without WHILE": GOTO errmes + PRINT #12, "ww_continue_" + str2$(controlid(controllevel)) + ":;" + PRINT #12, "}" + PRINT #12, "ww_exit_" + str2$(controlid(controllevel)) + ":;" + controllevel = controllevel - 1 + l$ = SCase$("Wend") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec '***no error causing code, event checking done by WHILE*** + END IF + END IF + + + + + + IF n >= 1 THEN + IF firstelement$ = "DO" THEN + IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + controllevel = controllevel + 1 + controlref(controllevel) = linenumber + l$ = SCase$("Do") + IF n >= 2 THEN + whileuntil = 0 + IF secondelement$ = "WHILE" THEN whileuntil = 1: l$ = l$ + sp + SCase$("While") + IF secondelement$ = "UNTIL" THEN whileuntil = 2: l$ = l$ + sp + SCase$("Until") + IF whileuntil = 0 THEN a$ = "DO ERROR! Expected WHILE or UNTIL after DO.": GOTO errmes + IF whileuntil > 0 AND n = 2 THEN a$ = "Condition expected after WHILE/UNTIL": GOTO errmes + e$ = fixoperationorder(getelements$(ca$, 3, n)) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" + IF (typ AND ISSTRING) THEN a$ = "DO ERROR! Cannot accept a STRING type.": GOTO errmes + IF whileuntil = 1 THEN PRINT #12, "while((" + e$ + ")||new_error){" ELSE PRINT #12, "while((!(" + e$ + "))||new_error){" + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + controltype(controllevel) = 4 + ELSE + controltype(controllevel) = 3 + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + ELSE + PRINT #12, "do{" + END IF + END IF + controlid(controllevel) = uniquenumber + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + + IF n >= 1 THEN + IF firstelement$ = "LOOP" THEN + l$ = SCase$("Loop") + IF controltype(controllevel) <> 3 AND controltype(controllevel) <> 4 THEN a$ = "PROGRAM FLOW ERROR!": GOTO errmes + IF n >= 2 THEN + IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + IF controltype(controllevel) = 4 THEN a$ = "PROGRAM FLOW ERROR!": GOTO errmes + whileuntil = 0 + IF secondelement$ = "WHILE" THEN whileuntil = 1: l$ = l$ + sp + SCase$("While") + IF secondelement$ = "UNTIL" THEN whileuntil = 2: l$ = l$ + sp + SCase$("Until") + IF whileuntil = 0 THEN a$ = "LOOP ERROR! Expected WHILE or UNTIL after LOOP.": GOTO errmes + IF whileuntil > 0 AND n = 2 THEN a$ = "Condition expected after WHILE/UNTIL": GOTO errmes + e$ = fixoperationorder(getelements$(ca$, 3, n)) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" + IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes + PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + IF whileuntil = 1 THEN PRINT #12, "}while((" + e$ + ")&&(!new_error));" ELSE PRINT #12, "}while((!(" + e$ + "))&&(!new_error));" + ELSE + PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" + + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + + IF controltype(controllevel) = 4 THEN + PRINT #12, "}" + ELSE + PRINT #12, "}while(1);" 'infinite loop! + END IF + END IF + PRINT #12, "dl_exit_" + str2$(controlid(controllevel)) + ":;" + controllevel = controllevel - 1 + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + IF n = 1 THEN GOTO finishednonexec '***no error causing code, event checking done by DO*** + GOTO finishedline + END IF + END IF + + + + + + + + + + IF n >= 1 THEN + IF firstelement$ = "FOR" THEN + IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + + l$ = SCase$("For") + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + controllevel = controllevel + 1 + controlref(controllevel) = linenumber + controltype(controllevel) = 2 + controlid(controllevel) = uniquenumber + + v$ = "" + startvalue$ = "" + p3$ = "1": stepused = 0 + p2$ = "" + mode = 0 + E = 0 + FOR i = 2 TO n + e$ = getelement$(a$, i) + IF e$ = "=" THEN + IF mode <> 0 THEN E = 1: EXIT FOR + mode = 1 + v$ = getelements$(ca$, 2, i - 1) + equpos = i + END IF + IF e$ = "TO" THEN + IF mode <> 1 THEN E = 1: EXIT FOR + mode = 2 + startvalue$ = getelements$(ca$, equpos + 1, i - 1) + topos = i + END IF + IF e$ = "STEP" THEN + IF mode <> 2 THEN E = 1: EXIT FOR + mode = 3 + stepused = 1 + p2$ = getelements$(ca$, topos + 1, i - 1) + p3$ = getelements$(ca$, i + 1, n) + EXIT FOR + END IF + NEXT + IF mode < 2 THEN E = 1 + IF p2$ = "" THEN p2$ = getelements$(ca$, topos + 1, n) + IF LEN(v$) = 0 OR LEN(startvalue$) = 0 OR LEN(p2$) = 0 THEN E = 1 + IF E <> 0 AND mode < 3 THEN a$ = "Expected FOR name = start TO end": GOTO errmes + IF E THEN a$ = "Expected FOR name = start TO end STEP increment": GOTO errmes + + e$ = fixoperationorder(v$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN + getid VAL(e$) + IF Error_Happened THEN GOTO errmes + IF (id.t AND ISPOINTER) THEN + IF (id.t AND ISSTRING) = 0 THEN + IF (id.t AND ISOFFSETINBITS) = 0 THEN + IF (id.t AND ISARRAY) = 0 THEN + GOTO fornextfoundvar + END IF + END IF + END IF + END IF + END IF + a$ = "Unsupported variable used in FOR statement": GOTO errmes + fornextfoundvar: + controlvalue(controllevel) = currentid + v$ = e$ + + 'find C++ datatype to match variable + 'markup to cater for greater range/accuracy + ctype$ = "" + ctyp = typ - ISPOINTER + bits = typ AND 511 + IF (typ AND ISFLOAT) THEN + IF bits = 32 THEN ctype$ = "double": ctyp = 64& + ISFLOAT + IF bits = 64 THEN ctype$ = "long double": ctyp = 256& + ISFLOAT + IF bits = 256 THEN ctype$ = "long double": ctyp = 256& + ISFLOAT + ELSE + IF bits = 8 THEN ctype$ = "int16": ctyp = 16& + IF bits = 16 THEN ctype$ = "int32": ctyp = 32& + IF bits = 32 THEN ctype$ = "int64": ctyp = 64& + IF bits = 64 THEN ctype$ = "int64": ctyp = 64& + END IF + IF ctype$ = "" THEN a$ = "Unsupported variable used in FOR statement": GOTO errmes + u$ = str2(uniquenumber) + + IF subfunc = "" THEN + PRINT #13, "static " + ctype$ + " fornext_value" + u$ + ";" + PRINT #13, "static " + ctype$ + " fornext_finalvalue" + u$ + ";" + PRINT #13, "static " + ctype$ + " fornext_step" + u$ + ";" + PRINT #13, "static uint8 fornext_step_negative" + u$ + ";" + ELSE + PRINT #13, ctype$ + " fornext_value" + u$ + ";" + PRINT #13, ctype$ + " fornext_finalvalue" + u$ + ";" + PRINT #13, ctype$ + " fornext_step" + u$ + ";" + PRINT #13, "uint8 fornext_step_negative" + u$ + ";" + END IF + + 'calculate start + e$ = fixoperationorder$(startvalue$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + "=" + sp + tlayout$ + e$ = evaluatetotyp$(e$, ctyp) + IF Error_Happened THEN GOTO errmes + PRINT #12, "fornext_value" + u$ + "=" + e$ + ";" + + 'final + e$ = fixoperationorder$(p2$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + SCase$("To") + sp + tlayout$ + e$ = evaluatetotyp(e$, ctyp) + IF Error_Happened THEN GOTO errmes + PRINT #12, "fornext_finalvalue" + u$ + "=" + e$ + ";" + + 'step + e$ = fixoperationorder$(p3$) + IF Error_Happened THEN GOTO errmes + IF stepused = 1 THEN l$ = l$ + sp + SCase$("Step") + sp + tlayout$ + e$ = evaluatetotyp(e$, ctyp) + IF Error_Happened THEN GOTO errmes + + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + + PRINT #12, "fornext_step" + u$ + "=" + e$ + ";" + PRINT #12, "if (fornext_step" + u$ + "<0) fornext_step_negative" + u$ + "=1; else fornext_step_negative" + u$ + "=0;" + + PRINT #12, "if (new_error) goto fornext_error" + u$ + ";" + PRINT #12, "goto fornext_entrylabel" + u$ + ";" + PRINT #12, "while(1){" + typbak = typ + PRINT #12, "fornext_value" + u$ + "=fornext_step" + u$ + "+(" + refer$(v$, typ, 0) + ");" + IF Error_Happened THEN GOTO errmes + typ = typbak + PRINT #12, "fornext_entrylabel" + u$ + ":" + setrefer v$, typ, "fornext_value" + u$, 1 + IF Error_Happened THEN GOTO errmes + PRINT #12, "if (fornext_step_negative" + u$ + "){" + PRINT #12, "if (fornext_value" + u$ + "fornext_finalvalue" + u$ + ") break;" + PRINT #12, "}" + PRINT #12, "fornext_error" + u$ + ":;" + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + + GOTO finishedline + END IF + END IF + + + IF n = 1 THEN + IF firstelement$ = "ELSE" THEN + + 'Routine to add error checking for ELSE so we'll no longer be able to do things like the following: + 'IF x = 1 THEN + ' SELECT CASE s + ' CASE 1 + ' END SELECT ELSE y = 2 + 'END IF + 'Notice the ELSE with the SELECT CASE? Before this patch, commands like those were considered valid QB64 code. + temp$ = UCASE$(LTRIM$(RTRIM$(wholeline))) + 'IF NoIDEMode THEN + DO WHILE INSTR(temp$, CHR$(9)) + ASC(temp$, INSTR(temp$, CHR$(9))) = 32 + LOOP + 'END IF + goodelse = 0 'a check to see if it's a good else + IF LEFT$(temp$, 2) = "IF" THEN goodelse = -1: GOTO skipelsecheck 'If we have an IF, the else is probably good + IF LEFT$(temp$, 4) = "ELSE" THEN goodelse = -1: GOTO skipelsecheck 'If it's an else by itself,then we'll call it good too at this point and let the rest of the syntax checking check for us + DO + spacelocation = INSTR(temp$, " ") + IF spacelocation THEN temp$ = LEFT$(temp$, spacelocation - 1) + MID$(temp$, spacelocation + 1) + LOOP UNTIL spacelocation = 0 + IF INSTR(temp$, ":ELSE") OR INSTR(temp$, ":IF") THEN goodelse = -1: GOTO skipelsecheck 'I personally don't like the idea of a :ELSE statement, but this checks for that and validates it as well. YUCK! (I suppose this might be useful if there's a label where the ELSE is, like thisline: ELSE + count = 0 + DO + count = count + 1 + SELECT CASE MID$(temp$, count, 1) + CASE IS = "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ":" + CASE ELSE: EXIT DO + END SELECT + LOOP UNTIL count >= LEN(temp$) + IF MID$(temp$, count, 4) = "ELSE" OR MID$(temp$, count, 2) = "IF" THEN goodelse = -1 'We only had numbers before our else + IF NOT goodelse THEN a$ = "Invalid Syntax for ELSE": GOTO errmes + skipelsecheck: + 'End of ELSE Error checking + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 1 THEN + IF controlstate(controllevel) = 2 THEN a$ = "IF-THEN already contains an ELSE statement": GOTO errmes + PRINT #12, "}else{" + controlstate(controllevel) = 2 + IF lineelseused = 0 THEN lhscontrollevel = lhscontrollevel - 1 + l$ = SCase$("Else") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec '***no error causing code, event checking done by IF*** + END IF + NEXT + a$ = "ELSE without IF": GOTO errmes + END IF + END IF + + IF n >= 3 THEN + IF firstelement$ = "ELSEIF" THEN + IF NoChecks = 0 THEN + PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + END IF + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 1 THEN + IF controlstate(controllevel) = 2 THEN a$ = "ELSEIF invalid after ELSE": GOTO errmes + controlstate(controllevel) = 1 + controlvalue(controllevel) = controlvalue(controllevel) + 1 + e$ = getelement$(a$, n) + IF e$ <> "THEN" THEN a$ = "Expected ELSEIF expression THEN": GOTO errmes + PRINT #12, "}else{" + e$ = fixoperationorder$(getelements$(ca$, 2, n - 1)) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("ElseIf") + sp + tlayout$ + sp + SCase$("Then") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF typ AND ISSTRING THEN + a$ = "Expected ELSEIF LEN(stringexpression) THEN": GOTO errmes + END IF + IF stringprocessinghappened THEN + PRINT #12, "if (" + cleanupstringprocessingcall$ + e$ + ")){" + ELSE + PRINT #12, "if (" + e$ + "){" + END IF + lhscontrollevel = lhscontrollevel - 1 + GOTO finishedline + END IF + NEXT + a$ = "ELSEIF without IF": GOTO errmes + END IF + END IF + + IF n >= 3 THEN + IF firstelement$ = "IF" THEN + IF NoChecks = 0 THEN + PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + END IF + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + e$ = getelement(a$, n) + iftype = 0 + IF e$ = "THEN" THEN iftype = 1 + IF e$ = "GOTO" THEN iftype = 2 + IF iftype = 0 THEN a$ = "Expected IF expression THEN/GOTO": GOTO errmes + + controllevel = controllevel + 1 + controlref(controllevel) = linenumber + controltype(controllevel) = 1 + controlvalue(controllevel) = 0 'number of extra closing } required at END IF + controlstate(controllevel) = 0 + + e$ = fixoperationorder$(getelements(ca$, 2, n - 1)) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("If") + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer$(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + + IF typ AND ISSTRING THEN + a$ = "Expected IF LEN(stringexpression) THEN": GOTO errmes + END IF + + IF stringprocessinghappened THEN + PRINT #12, "if ((" + cleanupstringprocessingcall$ + e$ + "))||new_error){" + ELSE + PRINT #12, "if ((" + e$ + ")||new_error){" + END IF + + IF iftype = 1 THEN l$ = l$ + sp + SCase$("Then") 'note: 'GOTO' will be added when iftype=2 + layoutdone = 1: IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + + IF iftype = 2 THEN 'IF ... GOTO + GOTO finishedline + END IF + + THENGOTO = 1 'possible: IF a=1 THEN 10 + GOTO finishedline2 + END IF + END IF + + 'ENDIF + IF n = 1 AND getelement(a$, 1) = "ENDIF" THEN + IF controltype(controllevel) <> 1 THEN a$ = "END IF without IF": GOTO errmes + layoutdone = 1 + IF impliedendif = 0 THEN + l$ = SCase$("End If") + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + END IF + + PRINT #12, "}" + FOR i = 1 TO controlvalue(controllevel) + PRINT #12, "}" + NEXT + controllevel = controllevel - 1 + GOTO finishednonexec '***no error causing code, event checking done by IF*** + END IF + + + 'END IF + IF n = 2 THEN + IF getelement(a$, 1) = "END" AND getelement(a$, 2) = "IF" THEN + + + IF controltype(controllevel) <> 1 THEN a$ = "END IF without IF": GOTO errmes + layoutdone = 1 + IF impliedendif = 0 THEN + l$ = SCase$("End" + sp + "If") + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + END IF + + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + + PRINT #12, "}" + FOR i = 1 TO controlvalue(controllevel) + PRINT #12, "}" + NEXT + controllevel = controllevel - 1 + GOTO finishednonexec '***no error causing code, event checking done by IF*** + END IF + END IF + + + + 'SELECT CASE + IF n >= 1 THEN + IF firstelement$ = "SELECT" THEN + IF NoChecks = 0 THEN + PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + END IF + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + SelectCaseCounter = SelectCaseCounter + 1 + IF UBOUND(EveryCaseSet) <= SelectCaseCounter THEN REDIM _PRESERVE EveryCaseSet(SelectCaseCounter) + IF UBOUND(SelectCaseHasCaseBlock) <= SelectCaseCounter THEN REDIM _PRESERVE SelectCaseHasCaseBlock(SelectCaseCounter) + SelectCaseHasCaseBlock(SelectCaseCounter) = 0 + IF secondelement$ = "EVERYCASE" THEN + EveryCaseSet(SelectCaseCounter) = -1 + IF n = 2 THEN a$ = "Expected SELECT CASE expression": GOTO errmes + e$ = fixoperationorder(getelements$(ca$, 3, n)) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Select EveryCase ") + tlayout$ + ELSE + EveryCaseSet(SelectCaseCounter) = 0 + IF n = 1 OR secondelement$ <> "CASE" THEN a$ = "Expected CASE or EVERYCASE": GOTO errmes + IF n = 2 THEN a$ = "Expected SELECT CASE expression": GOTO errmes + e$ = fixoperationorder(getelements$(ca$, 3, n)) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Select Case ") + tlayout$ + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + u = uniquenumber + + controllevel = controllevel + 1 + controlvalue(controllevel) = 0 'id + + t$ = "" + IF (typ AND ISSTRING) THEN + t = 0 + IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN + controlvalue(controllevel) = VAL(e$) + ELSE + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + PRINT #13, "static qbs *sc_" + str2$(u) + "=qbs_new(0,0);" + PRINT #12, "qbs_set(sc_" + str2$(u) + "," + e$ + ");" + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + END IF + + ELSE + + IF (typ AND ISFLOAT) THEN + + IF (typ AND 511) > 64 THEN t = 3: t$ = "long double" + IF (typ AND 511) = 32 THEN t = 4: t$ = "float" + IF (typ AND 511) = 64 THEN t = 5: t$ = "double" + IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN + controlvalue(controllevel) = VAL(e$) + ELSE + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + + PRINT #13, "static " + t$ + " sc_" + str2$(u) + ";" + PRINT #12, "sc_" + str2$(u) + "=" + e$ + ";" + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + END IF + + ELSE + + 'non-float + t = 1: t$ = "int64" + IF (typ AND ISUNSIGNED) THEN + IF (typ AND 511) <= 32 THEN t = 7: t$ = "uint32" + IF (typ AND 511) > 32 THEN t = 2: t$ = "uint64" + ELSE + IF (typ AND 511) <= 32 THEN t = 6: t$ = "int32" + IF (typ AND 511) > 32 THEN t = 1: t$ = "int64" + END IF + IF (typ AND ISUDT) = 0 AND (typ AND ISARRAY) = 0 AND (typ AND ISREFERENCE) <> 0 THEN + controlvalue(controllevel) = VAL(e$) + ELSE + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + PRINT #13, "static " + t$ + " sc_" + str2$(u) + ";" + PRINT #12, "sc_" + str2$(u) + "=" + e$ + ";" + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + END IF + + END IF + END IF + + + + controlref(controllevel) = linenumber + controltype(controllevel) = 10 + t + controlid(controllevel) = u + IF EveryCaseSet(SelectCaseCounter) THEN PRINT #13, "int32 sc_" + str2$(controlid(controllevel)) + "_var;" + IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_var=0;" + GOTO finishedline + END IF + END IF + + + 'END SELECT + IF n = 2 THEN + IF firstelement$ = "END" AND secondelement$ = "SELECT" THEN + 'complete current case if necessary + '18=CASE (awaiting END SELECT/CASE/CASE ELSE) + '19=CASE ELSE (awaiting END SELECT) + IF controltype(controllevel) = 18 THEN + everycasenewcase = everycasenewcase + 1 + PRINT #12, "sc_ec_" + str2$(everycasenewcase) + "_end:;" + controllevel = controllevel - 1 + IF EveryCaseSet(SelectCaseCounter) = 0 THEN PRINT #12, "goto sc_" + str2$(controlid(controllevel)) + "_end;" + PRINT #12, "}" + END IF + IF controltype(controllevel) = 19 THEN + controllevel = controllevel - 1 + IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "} /* End of SELECT EVERYCASE ELSE */" + END IF + + PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_end:;" + IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes + + IF NoChecks = 0 AND vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + 'warn user of empty SELECT CASE block + IF NOT IgnoreWarnings THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "empty SELECT CASE block", "" + END IF + END IF + + controllevel = controllevel - 1 + SelectCaseCounter = SelectCaseCounter - 1 + l$ = SCase$("End" + sp + "Select") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec '***no error causing code, event checking done by SELECT CASE*** + END IF + END IF + + 'prevents code from being placed before 'CASE condition' in a SELECT CASE block + IF n >= 1 AND firstelement$ <> "CASE" AND SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN + a$ = "Expected CASE expression": GOTO errmes + END IF + + + 'CASE + IF n >= 1 THEN + IF firstelement$ = "CASE" THEN + + l$ = SCase$("Case") + 'complete current case if necessary + '18=CASE (awaiting END SELECT/CASE/CASE ELSE) + '19=CASE ELSE (awaiting END SELECT) + IF controltype(controllevel) = 19 THEN a$ = "Expected END SELECT": GOTO errmes + IF controltype(controllevel) = 18 THEN + lhscontrollevel = lhscontrollevel - 1 + controllevel = controllevel - 1 + everycasenewcase = everycasenewcase + 1 + PRINT #12, "sc_ec_" + str2$(everycasenewcase) + "_end:;" + IF EveryCaseSet(SelectCaseCounter) = 0 THEN + PRINT #12, "goto sc_" + str2$(controlid(controllevel)) + "_end;" + ELSE + PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_var=-1;" + END IF + PRINT #12, "}" + 'following line fixes problem related to RESUME after error + 'statementn = statementn + 1 + 'if nochecks=0 then PRINT #12, "S_" + str2$(statementn) + ":;" + END IF + + IF controltype(controllevel) <> 6 AND (controltype(controllevel) < 10 OR controltype(controllevel) > 17) THEN a$ = "CASE without SELECT CASE": GOTO errmes + IF n = 1 THEN a$ = "Expected CASE expression": GOTO errmes + SelectCaseHasCaseBlock(SelectCaseCounter) = -1 + + + 'upgrade: + '#1: variables can be referred to directly by storing an id in 'controlref' + ' (but not if part of an array etc.) + 'DIM controlvalue(1000) AS LONG + '#2: more types will be available + ' +SINGLE + ' +DOUBLE + ' -LONG DOUBLE + ' +INT32 + ' +UINT32 + '14=SELECT CASE float ... + '15=SELECT CASE double + '16=SELECT CASE int32 + '17=SELECT CASE uint32 + + '10=SELECT CASE qbs (awaiting END SELECT/CASE) + '11=SELECT CASE int64 (awaiting END SELECT/CASE) + '12=SELECT CASE uint64 (awaiting END SELECT/CASE) + '13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) + '14=SELECT CASE float ... + '15=SELECT CASE double + '16=SELECT CASE int32 + '17=SELECT CASE uint32 + + ' bits = targettyp AND 511 + ' IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" + ' IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" + ' IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" + + + t = controltype(controllevel) - 10 + 'get required type cast, and float options + flt = 0 + IF t = 0 THEN tc$ = "" + IF t = 1 THEN tc$ = "" + IF t = 2 THEN tc$ = "" + IF t = 3 THEN tc$ = "": flt = 1 + IF t = 4 THEN tc$ = "(float)": flt = 1 + IF t = 5 THEN tc$ = "(double)": flt = 1 + IF t = 6 THEN tc$ = "" + IF t = 7 THEN tc$ = "" + + n$ = "sc_" + str2$(controlid(controllevel)) + cv = controlvalue(controllevel) + IF cv THEN + n$ = refer$(str2$(cv), 0, 0) + IF Error_Happened THEN GOTO errmes + END IF + + 'CASE ELSE + IF n = 2 THEN + IF getelement$(a$, 2) = "C-EL" THEN + IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "if (sc_" + str2$(controlid(controllevel)) + "_var==0) {" + controllevel = controllevel + 1: controltype(controllevel) = 19 + controlref(controllevel) = controlref(controllevel - 1) + l$ = l$ + sp + SCase$("Else") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishednonexec '***no error causing code, event checking done by SELECT CASE*** + END IF + END IF + + IF NoChecks = 0 THEN + PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF + END IF + + + + f12$ = "" + + nexp = 0 + B = 0 + e$ = "" + FOR i = 2 TO n + e2$ = getelement$(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF i = n THEN e$ = e$ + sp + e2$ + IF i = n OR (e2$ = "," AND B = 0) THEN + IF nexp <> 0 THEN l$ = l$ + sp2 + ",": f12$ = f12$ + "||" + IF e$ = "" THEN a$ = "Expected expression": GOTO errmes + e$ = RIGHT$(e$, LEN(e$) - 1) + + + + 'TYPE 1? ... TO ... + n2 = numelements(e$) + b2 = 0 + el$ = "": er$ = "" + usedto = 0 + FOR i2 = 1 TO n2 + e3$ = getelement$(e$, i2) + IF e3$ = "(" THEN b2 = b2 + 1 + IF e3$ = ")" THEN b2 = b2 - 1 + IF b2 = 0 AND UCASE$(e3$) = "TO" THEN + usedto = 1 + ELSE + IF usedto = 0 THEN el$ = el$ + sp + e3$ ELSE er$ = er$ + sp + e3$ + END IF + NEXT + IF usedto = 1 THEN + IF el$ = "" OR er$ = "" THEN a$ = "Expected expression TO expression": GOTO errmes + el$ = RIGHT$(el$, LEN(el$) - 1): er$ = RIGHT$(er$, LEN(er$) - 1) + 'evaluate each side + FOR i2 = 1 TO 2 + IF i2 = 1 THEN e$ = el$ ELSE e$ = er$ + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + IF i2 = 1 THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + SCase$("To") + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF t = 0 THEN + IF (typ AND ISSTRING) = 0 THEN a$ = "Expected string expression": GOTO errmes + IF i2 = 1 THEN f12$ = f12$ + "(qbs_greaterorequal(" + n$ + "," + e$ + ")&&qbs_lessorequal(" + n$ + "," + IF i2 = 2 THEN f12$ = f12$ + e$ + "))" + ELSE + IF (typ AND ISSTRING) THEN a$ = "Expected numeric expression": GOTO errmes + 'round to integer? + IF (typ AND ISFLOAT) THEN + IF t = 1 THEN e$ = "qbr(" + e$ + ")" + IF t = 2 THEN e$ = "qbr_longdouble_to_uint64(" + e$ + ")" + IF t = 6 OR t = 7 THEN e$ = "qbr_double_to_long(" + e$ + ")" + END IF + 'cast result? + IF LEN(tc$) THEN e$ = tc$ + "(" + e$ + ")" + IF i2 = 1 THEN f12$ = f12$ + "((" + n$ + ">=(" + e$ + "))&&(" + n$ + "<=(" + IF i2 = 2 THEN f12$ = f12$ + e$ + ")))" + END IF + NEXT + GOTO addedexp + END IF + + '10=SELECT CASE qbs (awaiting END SELECT/CASE) + '11=SELECT CASE int64 (awaiting END SELECT/CASE) + '12=SELECT CASE uint64 (awaiting END SELECT/CASE) + '13=SELECT CASE LONG double (awaiting END SELECT/CASE/CASE ELSE) + '14=SELECT CASE float ... + '15=SELECT CASE double + '16=SELECT CASE int32 + '17=SELECT CASE uint32 + + ' bits = targettyp AND 511 + ' IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" + ' IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" + ' IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" + + + + + + + o$ = "==" 'used by type 3 + + 'TYPE 2? + x$ = getelement$(e$, 1) + IF isoperator(x$) THEN 'non-standard usage correction + IF x$ = "=" OR x$ = "<>" OR x$ = ">" OR x$ = "<" OR x$ = ">=" OR x$ = "<=" THEN + e$ = "IS" + sp + e$ + x$ = "IS" + END IF + END IF + IF UCASE$(x$) = "IS" THEN + n2 = numelements(e$) + IF n2 < 3 THEN a$ = "Expected IS =,<>,>,<,>=,<= expression": GOTO errmes + o$ = getelement$(e$, 2) + o2$ = o$ + o = 0 + IF o$ = "=" THEN o$ = "==": o = 1 + IF o$ = "<>" THEN o$ = "!=": o = 1 + IF o$ = ">" THEN o = 1 + IF o$ = "<" THEN o = 1 + IF o$ = ">=" THEN o = 1 + IF o$ = "<=" THEN o = 1 + IF o <> 1 THEN a$ = "Expected IS =,<>,>,<,>=,<= expression": GOTO errmes + l$ = l$ + sp + SCase$("Is") + sp + o2$ + e$ = getelements$(e$, 3, n2) + 'fall through to type 3 using modified e$ & o$ + END IF + + 'TYPE 3? simple expression + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + IF t = 0 THEN + 'string comparison + IF (typ AND ISSTRING) = 0 THEN a$ = "Expected string expression": GOTO errmes + IF o$ = "==" THEN o$ = "qbs_equal" + IF o$ = "!=" THEN o$ = "qbs_notequal" + IF o$ = ">" THEN o$ = "qbs_greaterthan" + IF o$ = "<" THEN o$ = "qbs_lessthan" + IF o$ = ">=" THEN o$ = "qbs_greaterorequal" + IF o$ = "<=" THEN o$ = "qbs_lessorequal" + f12$ = f12$ + o$ + "(" + n$ + "," + e$ + ")" + ELSE + 'numeric + IF (typ AND ISSTRING) THEN a$ = "Expected numeric expression": GOTO errmes + 'round to integer? + IF (typ AND ISFLOAT) THEN + IF t = 1 THEN e$ = "qbr(" + e$ + ")" + IF t = 2 THEN e$ = "qbr_longdouble_to_uint64(" + e$ + ")" + IF t = 6 OR t = 7 THEN e$ = "qbr_double_to_long(" + e$ + ")" + END IF + 'cast result? + IF LEN(tc$) THEN e$ = tc$ + "(" + e$ + ")" + f12$ = f12$ + "(" + n$ + o$ + "(" + e$ + "))" + END IF + + addedexp: + e$ = "" + nexp = nexp + 1 + ELSE + e$ = e$ + sp + e2$ + END IF + NEXT + + IF stringprocessinghappened THEN + PRINT #12, "if ((" + cleanupstringprocessingcall$ + f12$ + "))||new_error){" + ELSE + PRINT #12, "if ((" + f12$ + ")||new_error){" + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + controllevel = controllevel + 1 + controlref(controllevel) = controlref(controllevel - 1) + controltype(controllevel) = 18 + GOTO finishedline + END IF + END IF + + + + + + + + + + + + + 'static scope commands: + + IF NoChecks = 0 THEN + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + ELSE + PRINT #12, "do{" + END IF + 'PRINT #12, "S_" + str2$(statementn) + ":;" + END IF + + + IF n > 1 THEN + IF firstelement$ = "PALETTE" THEN + IF secondelement$ = "USING" THEN + l$ = SCase$("Palette" + sp + "Using" + sp) + IF n < 3 THEN a$ = "Expected PALETTE USING array-name": GOTO errmes + 'check array + e$ = getelement$(ca$, 3) + IF FindArray(e$) THEN + IF Error_Happened THEN GOTO errmes + z = 1 + t = id.arraytype + IF (t AND 511) <> 16 AND (t AND 511) <> 32 THEN z = 0 + IF t AND ISFLOAT THEN z = 0 + IF t AND ISOFFSETINBITS THEN z = 0 + IF t AND ISSTRING THEN z = 0 + IF t AND ISUDT THEN z = 0 + IF t AND ISUNSIGNED THEN z = 0 + IF z = 0 THEN a$ = "Array must be of type INTEGER or LONG": GOTO errmes + bits = t AND 511 + GOTO pu_gotarray + END IF + IF Error_Happened THEN GOTO errmes + a$ = "Expected PALETTE USING array-name": GOTO errmes + pu_gotarray: + 'add () if index not specified + IF n = 3 THEN + e$ = e$ + sp + "(" + sp + ")" + ELSE + IF n = 4 OR getelement$(a$, 4) <> "(" OR getelement$(a$, n) <> ")" THEN a$ = "Expected PALETTE USING array-name(...)": GOTO errmes + e$ = e$ + sp + getelements$(ca$, 4, n) + END IF + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + e$ = evaluatetotyp(e$, -2) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_paletteusing(" + e$ + "," + str2(bits) + ");" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF 'using + END IF 'palette + END IF 'n>1 + + + IF firstelement$ = "KEY" THEN + IF n = 1 THEN a$ = "Expected KEY ...": GOTO errmes + l$ = SCase$("KEY") + sp + IF secondelement$ = "OFF" THEN + IF n > 2 THEN a$ = "Expected KEY OFF only": GOTO errmes + l$ = l$ + SCase$("Off"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + PRINT #12, "key_off();" + GOTO finishedline + END IF + IF secondelement$ = "ON" THEN + IF n > 2 THEN a$ = "Expected KEY ON only": GOTO errmes + l$ = l$ + SCase$("On"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + PRINT #12, "key_on();" + GOTO finishedline + END IF + IF secondelement$ = "LIST" THEN + IF n > 2 THEN a$ = "Expected KEY LIST only": GOTO errmes + l$ = l$ + SCase$("List"): layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + PRINT #12, "key_list();" + GOTO finishedline + END IF + 'search for comma to indicate assignment + B = 0: e$ = "" + FOR i = 2 TO n + e2$ = getelement(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN + i = i + 1: GOTO key_assignment + END IF + IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ + NEXT + 'assume KEY(x) ON/OFF/STOP and handle as a sub + GOTO key_fallthrough + key_assignment: + 'KEY x, "string" + 'index + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + "," + sp + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "key_assign(" + e$ + ","; + 'string + e$ = getelements$(ca$, i, n) + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + e$ = evaluatetotyp(e$, ISSTRING) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ");" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF 'KEY + key_fallthrough: + + + + + IF firstelement$ = "FIELD" THEN + + 'get filenumber + B = 0: e$ = "" + FOR i = 2 TO n + e2$ = getelement(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN + i = i + 1: GOTO fieldgotfn + END IF + IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ + NEXT + GOTO fielderror + fieldgotfn: + IF e$ = "#" OR LEN(e$) = 0 THEN GOTO fielderror + IF LEFT$(e$, 2) = "#" + sp THEN e$ = RIGHT$(e$, LEN(e$) - 2): l$ = SCase$("Field") + sp + "#" + sp2 ELSE l$ = SCase$("Field") + sp + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + "," + sp + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "field_new(" + e$ + ");" + + fieldnext: + + 'get fieldwidth + IF i > n THEN GOTO fielderror + B = 0: e$ = "" + FOR i = i TO n + e2$ = getelement(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF UCASE$(e2$) = "AS" AND B = 0 THEN + i = i + 1: GOTO fieldgotfw + END IF + IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ + NEXT + GOTO fielderror + fieldgotfw: + IF LEN(e$) = 0 THEN GOTO fielderror + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp + SCase$("As") + sp + sizee$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + + 'get variable name + IF i > n THEN GOTO fielderror + B = 0: e$ = "" + FOR i = i TO n + e2$ = getelement(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF (i = n OR e2$ = ",") AND B = 0 THEN + IF e2$ = "," THEN i = i - 1 + IF i = n THEN + IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ + END IF + GOTO fieldgotfname + END IF + IF LEN(e$) THEN e$ = e$ + sp + e2$ ELSE e$ = e2$ + NEXT + GOTO fielderror + fieldgotfname: + IF LEN(e$) = 0 THEN GOTO fielderror + 'evaluate it to check it is a STRING + e$ = fixoperationorder(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF (typ AND ISSTRING) = 0 THEN GOTO fielderror + IF typ AND ISFIXEDLENGTH THEN a$ = "Fixed length strings cannot be used in a FIELD statement": GOTO errmes + IF (typ AND ISREFERENCE) = 0 THEN GOTO fielderror + e$ = refer(e$, typ, 0) + IF Error_Happened THEN GOTO errmes + PRINT #12, "field_add(" + e$ + "," + sizee$ + ");" + + IF i < n THEN + i = i + 1 + e$ = getelement(a$, i) + IF e$ <> "," THEN a$ = "Expected ,": GOTO errmes + l$ = l$ + sp2 + "," + sp + i = i + 1 + GOTO fieldnext + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + + fielderror: a$ = "Expected FIELD #filenumber, characters AS variable$, ...": GOTO errmes + END IF + + + + + + '1=IF (awaiting END IF) + '2=FOR (awaiting NEXT) + '3=DO (awaiting LOOP [UNTIL|WHILE param]) + '4=DO WHILE/UNTIL (awaiting LOOP) + '5=WHILE (awaiting WEND) + + IF n = 2 THEN + IF firstelement$ = "EXIT" THEN + + l$ = SCase$("Exit") + sp + + IF secondelement$ = "DO" THEN + 'scan backwards until previous control level reached + l$ = l$ + SCase$("Do") + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 3 OR t = 4 THEN + PRINT #12, "goto dl_exit_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "EXIT DO without DO": GOTO errmes + END IF + + IF secondelement$ = "FOR" THEN + 'scan backwards until previous control level reached + l$ = l$ + SCase$("For") + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 2 THEN + PRINT #12, "goto fornext_exit_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "EXIT FOR without FOR": GOTO errmes + END IF + + IF secondelement$ = "WHILE" THEN + 'scan backwards until previous control level reached + l$ = l$ + SCase$("While") + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 5 THEN + PRINT #12, "goto ww_exit_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "EXIT WHILE without WHILE": GOTO errmes + END IF + + IF secondelement$ = "SELECT" THEN + 'scan backwards until previous control level reached + l$ = l$ + SCase$("Select") + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 18 OR t = 19 THEN 'CASE/CASE ELSE + PRINT #12, "goto sc_" + str2$(controlid(i - 1)) + "_end;" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "EXIT SELECT without SELECT": GOTO errmes + END IF + + IF secondelement$ = "CASE" THEN + 'scan backwards until previous control level reached + l$ = l$ + SCase$("Case") + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 18 THEN 'CASE + PRINT #12, "goto sc_ec_" + str2$(everycasenewcase + 1) + "_end;" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSEIF t = 19 THEN 'CASE ELSE + PRINT #12, "goto sc_" + str2$(controlid(i - 1)) + "_end;" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "EXIT CASE without CASE": GOTO errmes + END IF + + END IF + END IF + + + + + + + + + IF n >= 2 THEN + IF firstelement$ = "ON" AND secondelement$ = "STRIG" THEN + DEPENDENCY(DEPENDENCY_DEVICEINPUT) = 1 + i = 3 + IF i > n THEN a$ = "Expected (": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes + l$ = SCase$("On" + sp + "Strig" + sp2 + "(") + IF i > n THEN a$ = "Expected ...": GOTO errmes + B = 0 + x = 0 + e2$ = "" + e3$ = "" + FOR i = i TO n + e$ = getelement$(ca$, i) + a = ASC(e$) + IF a = 40 THEN B = B + 1 + IF a = 41 THEN B = B - 1 + IF B = -1 THEN GOTO onstriggotarg + IF a = 44 AND B = 0 THEN + x = x + 1 + IF x > 1 THEN a$ = "Expected )": GOTO errmes + IF e2$ = "" THEN a$ = "Expected ... ,": GOTO errmes + e3$ = e2$ + e2$ = "" + ELSE + IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ + END IF + NEXT + a$ = "Expected )": GOTO errmes + onstriggotarg: + IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes + PRINT #12, "onstrig_setup("; + + 'sort scanned results + IF LEN(e3$) THEN + optI$ = e3$ + optController$ = e2$ + optPassed$ = "1" + ELSE + optI$ = e2$ + optController$ = "0" + optPassed$ = "0" + END IF + + 'i + e$ = fixoperationorder$(optI$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + tlayout$ + e$ = evaluatetotyp(e$, 32&): IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ","; + + 'controller , passed + IF optPassed$ = "1" THEN + e$ = fixoperationorder$(optController$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluatetotyp(e$, 32&): IF Error_Happened THEN GOTO errmes + ELSE + e$ = optController$ + END IF + PRINT #12, e$ + "," + optPassed$ + ","; + + l$ = l$ + sp2 + ")" + sp 'close brackets + + i = i + 1 + IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes + a2$ = getelement$(a$, i): i = i + 1 + onstrigid = onstrigid + 1 + PRINT #12, str2$(onstrigid) + ","; + + IF a2$ = "GOSUB" THEN + IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + + PRINT #12, "0);" + + IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk60z: + IF v THEN + s = Labels(r).Scope + IF s = 0 OR s = -1 THEN 'main scope? + IF s = -1 THEN Labels(r).Scope = 0 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Scope_Restriction = subfuncn + Labels(r).Error_Line = linenumber + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk60z + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = 0 + Labels(r).Error_Line = linenumber + Labels(r).Scope_Restriction = subfuncn + END IF 'x + l$ = l$ + SCase$("GoSub") + sp + tlayout$ + + PRINT #30, "if(strig_event_id==" + str2$(onstrigid) + ")goto LABEL_" + a2$ + ";" + + PRINT #29, "case " + str2$(onstrigid) + ":" + PRINT #29, "strig_event_occurred++;" + PRINT #29, "strig_event_id=" + str2$(onstrigid) + ";" + PRINT #29, "strig_event_occurred++;" + PRINT #29, "return_point[next_return_point++]=0;" + PRINT #29, "if (next_return_point>=return_points) more_return_points();" + PRINT #29, "QBMAIN(NULL);" + PRINT #29, "break;" + + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + + ELSE + + 'establish whether sub a2$ exists using try + x = 0 + try = findid(a2$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = 2 THEN x = 1: EXIT DO + IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes + + l$ = l$ + RTRIM$(id.cn) + + PRINT #29, "case " + str2$(onstrigid) + ":" + PRINT #29, RTRIM$(id.callname) + "("; + + IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes + + IF i > n THEN + + IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes + PRINT #12, "0);" + PRINT #29, ");" + + ELSE + + IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes + + t = CVL(id.arg) + B = t AND 511 + IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes + IF B = 8 THEN ct$ = "int8" + IF B = 16 THEN ct$ = "int16" + IF B = 32 THEN ct$ = "int32" + IF B = 64 THEN ct$ = "int64" + IF t AND ISOFFSET THEN ct$ = "ptrszint" + IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ + PRINT #29, "(" + ct$ + "*)&i64);" + + e$ = getelements$(ca$, i, n) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ");" + + END IF + + PRINT #29, "break;" + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + END IF + + END IF + END IF + + + + + + + + + + + + + IF n >= 2 THEN + IF firstelement$ = "ON" AND secondelement$ = "TIMER" THEN + i = 3 + IF i > n THEN a$ = "Expected (": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes + l$ = SCase$("On" + sp + "Timer" + sp2 + "(") + IF i > n THEN a$ = "Expected ...": GOTO errmes + B = 0 + x = 0 + e2$ = "" + e3$ = "" + FOR i = i TO n + e$ = getelement$(ca$, i) + a = ASC(e$) + IF a = 40 THEN B = B + 1 + IF a = 41 THEN B = B - 1 + IF B = -1 THEN GOTO ontimgotarg + IF a = 44 AND B = 0 THEN + x = x + 1 + IF x > 1 THEN a$ = "Expected )": GOTO errmes + IF e2$ = "" THEN a$ = "Expected ... ,": GOTO errmes + e3$ = e2$ + e2$ = "" + ELSE + IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ + END IF + NEXT + a$ = "Expected )": GOTO errmes + ontimgotarg: + IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes + PRINT #12, "ontimer_setup("; + 'i + IF LEN(e3$) THEN + e$ = fixoperationorder$(e3$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + tlayout$ + "," + sp + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ","; + ELSE + PRINT #12, "0,"; + l$ = l$ + sp2 + END IF + 'sec + e$ = fixoperationorder$(e2$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + ")" + sp + e$ = evaluatetotyp(e$, DOUBLETYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ","; + i = i + 1 + IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes + a2$ = getelement$(a$, i): i = i + 1 + ontimerid = ontimerid + 1 + PRINT #12, str2$(ontimerid) + ","; + + IF a2$ = "GOSUB" THEN + IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + + PRINT #12, "0);" + + IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk60: + IF v THEN + s = Labels(r).Scope + IF s = 0 OR s = -1 THEN 'main scope? + IF s = -1 THEN Labels(r).Scope = 0 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Scope_Restriction = subfuncn + Labels(r).Error_Line = linenumber + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk60 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = 0 + Labels(r).Error_Line = linenumber + Labels(r).Scope_Restriction = subfuncn + END IF 'x + l$ = l$ + SCase$("GoSub") + sp + tlayout$ + + PRINT #25, "if(timer_event_id==" + str2$(ontimerid) + ")goto LABEL_" + a2$ + ";" + + PRINT #24, "case " + str2$(ontimerid) + ":" + PRINT #24, "timer_event_occurred++;" + PRINT #24, "timer_event_id=" + str2$(ontimerid) + ";" + PRINT #24, "timer_event_occurred++;" + PRINT #24, "return_point[next_return_point++]=0;" + PRINT #24, "if (next_return_point>=return_points) more_return_points();" + PRINT #24, "QBMAIN(NULL);" + PRINT #24, "break;" + + + + 'call validlabel (to validate the label) [see goto] + 'increment ontimerid + 'use ontimerid to generate the jumper routine + 'etc. + + + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + ELSE + + 'establish whether sub a2$ exists using try + x = 0 + try = findid(a2$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = 2 THEN x = 1: EXIT DO + IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes + + l$ = l$ + RTRIM$(id.cn) + + PRINT #24, "case " + str2$(ontimerid) + ":" + PRINT #24, RTRIM$(id.callname) + "("; + + IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes + + IF i > n THEN + + IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes + PRINT #12, "0);" + PRINT #24, ");" + + ELSE + + IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes + + t = CVL(id.arg) + B = t AND 511 + IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes + IF B = 8 THEN ct$ = "int8" + IF B = 16 THEN ct$ = "int16" + IF B = 32 THEN ct$ = "int32" + IF B = 64 THEN ct$ = "int64" + IF t AND ISOFFSET THEN ct$ = "ptrszint" + IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ + PRINT #24, "(" + ct$ + "*)&i64);" + + e$ = getelements$(ca$, i, n) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ");" + + END IF + + PRINT #24, "break;" + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + END IF + + END IF + END IF + + + + + IF n >= 2 THEN + IF firstelement$ = "ON" AND secondelement$ = "KEY" THEN + i = 3 + IF i > n THEN a$ = "Expected (": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + IF a2$ <> "(" THEN a$ = "Expected (": GOTO errmes + l$ = SCase$("On" + sp + "Key" + sp2 + "(") + IF i > n THEN a$ = "Expected ...": GOTO errmes + B = 0 + x = 0 + e2$ = "" + FOR i = i TO n + e$ = getelement$(ca$, i) + a = ASC(e$) + + + IF a = 40 THEN B = B + 1 + IF a = 41 THEN B = B - 1 + IF B = -1 THEN EXIT FOR + IF LEN(e2$) THEN e2$ = e2$ + sp + e$ ELSE e2$ = e$ + NEXT + IF i = n + 1 THEN a$ = "Expected )": GOTO errmes + IF e2$ = "" THEN a$ = "Expected ... )": GOTO errmes + + e$ = fixoperationorder$(e2$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + ")" + sp + e$ = evaluatetotyp(e$, DOUBLETYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + PRINT #12, "onkey_setup(" + e$ + ","; + + i = i + 1 + IF i > n THEN a$ = "Expected GOSUB/sub-name": GOTO errmes + a2$ = getelement$(a$, i): i = i + 1 + onkeyid = onkeyid + 1 + PRINT #12, str2$(onkeyid) + ","; + + IF a2$ = "GOSUB" THEN + IF i > n THEN a$ = "Expected linenumber/label": GOTO errmes + a2$ = getelement$(ca$, i): i = i + 1 + + PRINT #12, "0);" + + IF validlabel(a2$) = 0 THEN a$ = "Invalid label": GOTO errmes + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk61: + IF v THEN + s = Labels(r).Scope + IF s = 0 OR s = -1 THEN 'main scope? + IF s = -1 THEN Labels(r).Scope = 0 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Scope_Restriction = subfuncn + Labels(r).Error_Line = linenumber + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk61 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = 0 + Labels(r).Error_Line = linenumber + Labels(r).Scope_Restriction = subfuncn + END IF 'x + l$ = l$ + SCase$("GoSub") + sp + tlayout$ + + PRINT #28, "if(key_event_id==" + str2$(onkeyid) + ")goto LABEL_" + a2$ + ";" + + PRINT #27, "case " + str2$(onkeyid) + ":" + PRINT #27, "key_event_occurred++;" + PRINT #27, "key_event_id=" + str2$(onkeyid) + ";" + PRINT #27, "key_event_occurred++;" + PRINT #27, "return_point[next_return_point++]=0;" + PRINT #27, "if (next_return_point>=return_points) more_return_points();" + PRINT #27, "QBMAIN(NULL);" + PRINT #27, "break;" + + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + ELSE + + 'establish whether sub a2$ exists using try + x = 0 + try = findid(a2$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = 2 THEN x = 1: EXIT DO + IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + IF x = 0 THEN a$ = "Expected GOSUB/sub": GOTO errmes + + l$ = l$ + RTRIM$(id.cn) + + PRINT #27, "case " + str2$(onkeyid) + ":" + PRINT #27, RTRIM$(id.callname) + "("; + + IF id.args > 1 THEN a$ = "SUB requires more than one argument": GOTO errmes + + IF i > n THEN + + IF id.args = 1 THEN a$ = "Expected argument after SUB": GOTO errmes + PRINT #12, "0);" + PRINT #27, ");" + + ELSE + + IF id.args = 0 THEN a$ = "SUB has no arguments": GOTO errmes + + t = CVL(id.arg) + B = t AND 511 + IF B = 0 OR (t AND ISARRAY) <> 0 OR (t AND ISFLOAT) <> 0 OR (t AND ISSTRING) <> 0 OR (t AND ISOFFSETINBITS) <> 0 THEN a$ = "Only SUB arguments of integer-type allowed": GOTO errmes + IF B = 8 THEN ct$ = "int8" + IF B = 16 THEN ct$ = "int16" + IF B = 32 THEN ct$ = "int32" + IF B = 64 THEN ct$ = "int64" + IF t AND ISOFFSET THEN ct$ = "ptrszint" + IF t AND ISUNSIGNED THEN ct$ = "u" + ct$ + PRINT #27, "(" + ct$ + "*)&i64);" + + e$ = getelements$(ca$, i, n) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluatetotyp(e$, INTEGER64TYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + PRINT #12, e$ + ");" + + END IF + + PRINT #27, "break;" + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + layoutdone = 1 + GOTO finishedline + END IF + + END IF + END IF + + + + + + + + + + + + + + + + + + + + + + + + + + + + 'SHARED (SUB) + IF n >= 1 THEN + IF firstelement$ = "SHARED" THEN + IF n = 1 THEN a$ = "Expected SHARED ...": GOTO errmes + i = 2 + IF subfuncn = 0 THEN a$ = "SHARED must be used within a SUB/FUNCTION": GOTO errmes + + + + l$ = SCase$("Shared") + subfuncshr: + + 'get variable name + n$ = getelement$(ca$, i): i = i + 1 + + IF n$ = "" THEN a$ = "Expected SHARED variable-name or SHARED AS type variable-list": GOTO errmes + + IF UCASE$(n$) <> "AS" THEN + 'traditional dim syntax for SHARED + newSharedSyntax = 0 + s$ = removesymbol(n$) + IF Error_Happened THEN GOTO errmes + l2$ = s$ 'either symbol or nothing + + 'array? + a = 0 + IF getelement$(a$, i) = "(" THEN + IF getelement$(a$, i + 1) <> ")" THEN a$ = "Expected ()": GOTO errmes + i = i + 2 + a = 1 + l2$ = l2$ + sp2 + "(" + sp2 + ")" + END IF + + method = 1 + + 'specific type? + t$ = "" + ts$ = "" + t3$ = "" + IF getelement$(a$, i) = "AS" THEN + l2$ = l2$ + sp + SCase$("As") + getshrtyp: + i = i + 1 + t2$ = getelement$(a$, i) + IF t2$ <> "," AND t2$ <> "" THEN + IF t$ = "" THEN t$ = t2$ ELSE t$ = t$ + " " + t2$ + IF t3$ = "" THEN t3$ = t2$ ELSE t3$ = t3$ + sp + t2$ + GOTO getshrtyp + END IF + IF t$ = "" THEN a$ = "Expected AS type": GOTO errmes + + t = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF t AND ISINCONVENTIONALMEMORY THEN t = t - ISINCONVENTIONALMEMORY + IF t AND ISPOINTER THEN t = t - ISPOINTER + IF t AND ISREFERENCE THEN t = t - ISREFERENCE + tsize = typname2typsize + method = 0 + IF (t AND ISUDT) = 0 THEN + ts$ = type2symbol$(t$) + l2$ = l2$ + sp + SCase2$(t3$) + ELSE + t3$ = RTRIM$(udtxcname(t AND 511)) + IF RTRIM$(udtxcname(t AND 511)) = "_MEM" AND UCASE$(t$) = "MEM" AND qb64prefix_set = 1 THEN + t3$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) + END IF + l2$ = l2$ + sp + t3$ + END IF + IF Error_Happened THEN GOTO errmes + + END IF 'as + + IF LEN(s$) <> 0 AND LEN(t$) <> 0 THEN a$ = "Expected symbol or AS type after variable name": GOTO errmes + + 'no symbol of type specified, apply default + IF s$ = "" AND t$ = "" THEN + IF LEFT$(n$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(n$)) - 64 + s$ = defineextaz(v) + END IF + + NormalSharedBlock: + 'switch to main module + oldsubfunc$ = subfunc$ + subfunc$ = "" + defdatahandle = 18 + CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 + CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 + + 'use 'try' to locate the variable (if it already exists) + n2$ = n$ + s$ + ts$ 'note: either ts$ or s$ will exist unless it is a UDT + try = findid(n2$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF a THEN + 'an array + + IF id.arraytype THEN + IF LEN(t$) = 0 THEN GOTO shrfound + t2 = id.arraytype: t2size = id.tsize + IF t2 AND ISINCONVENTIONALMEMORY THEN t2 = t2 - ISINCONVENTIONALMEMORY + IF t2 AND ISPOINTER THEN t2 = t2 - ISPOINTER + IF t2 AND ISREFERENCE THEN t2 = t2 - ISREFERENCE + IF t = t2 AND tsize = t2size THEN GOTO shrfound + END IF + + ELSE + 'not an array + + IF id.t THEN + IF LEN(t$) = 0 THEN GOTO shrfound + t2 = id.t: t2size = id.tsize + IF t2 AND ISINCONVENTIONALMEMORY THEN t2 = t2 - ISINCONVENTIONALMEMORY + IF t2 AND ISPOINTER THEN t2 = t2 - ISPOINTER + IF t2 AND ISREFERENCE THEN t2 = t2 - ISREFERENCE + + IF Debug THEN PRINT #9, "SHARED:comparing:"; t; t2, tsize; t2size + + IF t = t2 AND tsize = t2size THEN GOTO shrfound + END IF + + END IF + + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + 'unknown variable + IF a THEN a$ = "Array '" + n$ + "' not defined": GOTO errmes + 'create variable + IF LEN(s$) THEN typ$ = s$ ELSE typ$ = t$ + IF optionexplicit THEN a$ = "Variable '" + n$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": GOTO errmes + bypassNextVariable = -1 + retval = dim2(n$, typ$, method, "") + manageVariableList "", vWatchNewVariable$, 0, 2 + IF Error_Happened THEN GOTO errmes + 'note: variable created! + + shrfound: + IF newSharedSyntax = 0 THEN + l$ = l$ + sp + RTRIM$(id.cn) + l2$ + ELSE + IF sharedAsLayoutAdded = 0 THEN + sharedAsLayoutAdded = -1 + l$ = l$ + l2$ + sp$ + RTRIM$(id.cn) + l3$ + ELSE + l$ = l$ + sp$ + RTRIM$(id.cn) + l3$ + END IF + END IF + + ids(currentid).share = ids(currentid).share OR 2 'set as temporarily shared + + 'method must apply to the current sub/function regardless of how the variable was defined in 'main' + lmay = LEN(RTRIM$(id.mayhave)): lmust = LEN(RTRIM$(id.musthave)) + IF lmay <> 0 OR lmust <> 0 THEN + IF (method = 1 AND lmust = 0) OR (method = 0 AND lmay = 0) THEN + revertmaymusthaven = revertmaymusthaven + 1 + revertmaymusthave(revertmaymusthaven) = currentid + SWAP ids(currentid).musthave, ids(currentid).mayhave + END IF + END IF + + 'switch back to sub/func + subfunc$ = oldsubfunc$ + defdatahandle = 13 + CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR APPEND AS #13 + CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR APPEND AS #19 + + IF newSharedSyntax THEN RETURN + + IF getelement$(a$, i) = "," THEN i = i + 1: l$ = l$ + sp2 + ",": GOTO subfuncshr + IF getelement$(a$, i) <> "" THEN a$ = "Expected ,": GOTO errmes + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSE + 'new dim syntax for SHARED! + i = i - 1 'relocate back to "AS" + + 'estabilish the data type: + t$ = "" + ts$ = "" + t3$ = "" + n$ = "" + previousElement$ = "" + l2$ = sp + SCase$("As") + sharedAsLayoutAdded = 0 + getshrtyp2: + i = i + 1 + t2$ = getelement$(a$, i) + IF t2$ <> "," AND t2$ <> "(" AND t2$ <> "" THEN + 'get first variable name + n$ = getelement$(ca$, i) + + IF LEN(previousElement$) THEN + IF t$ = "" THEN t$ = previousElement$ ELSE t$ = t$ + " " + previousElement$ + IF t3$ = "" THEN t3$ = previousElement$ ELSE t3$ = t3$ + sp + previousElement$ + END IF + previousElement$ = t2$ + GOTO getshrtyp2 + END IF + IF t$ = "" THEN a$ = "Expected SHARED AS type variable-list or SHARED variable-name AS type": GOTO errmes + + t = typname2typ(t$) + IF Error_Happened THEN GOTO errmes + IF t AND ISINCONVENTIONALMEMORY THEN t = t - ISINCONVENTIONALMEMORY + IF t AND ISPOINTER THEN t = t - ISPOINTER + IF t AND ISREFERENCE THEN t = t - ISREFERENCE + tsize = typname2typsize + method = 0 + IF (t AND ISUDT) = 0 THEN + ts$ = type2symbol$(t$) + l2$ = l2$ + sp + SCase2$(t3$) + ELSE + t3$ = RTRIM$(udtxcname(t AND 511)) + IF RTRIM$(udtxcname(t AND 511)) = "_MEM" AND UCASE$(t$) = "MEM" AND qb64prefix_set = 1 THEN + t3$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) + END IF + l2$ = l2$ + sp + t3$ + END IF + IF Error_Happened THEN GOTO errmes + + subfuncshr2: + s$ = removesymbol(n$) + IF Error_Happened THEN GOTO errmes + IF s$ <> "" THEN + a$ = "Cannot use type symbol with SHARED AS type variable-list (" + s$ + ")" + GOTO errmes + END IF + + 'array? + a = 0 + l3$ = "" + IF getelement$(a$, i) = "(" THEN + IF getelement$(a$, i + 1) <> ")" THEN a$ = "Expected ()": GOTO errmes + i = i + 2 + a = 1 + l3$ = sp2 + "(" + sp2 + ")" + END IF + + newSharedSyntax = -1 + GOSUB NormalSharedBlock + newSharedSyntax = 0 + + IF getelement$(a$, i) = "," THEN + i = i + 1 + l$ = l$ + sp2 + "," + + 'get next variable name + n$ = getelement$(ca$, i): i = i + 1 + GOTO subfuncshr2 + END IF + IF getelement$(a$, i) <> "" THEN a$ = "Expected ,": GOTO errmes + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + END IF + + 'EXIT SUB/FUNCTION + IF n = 2 THEN + IF firstelement$ = "EXIT" THEN + sf = 0 + IF secondelement$ = "FUNCTION" THEN sf = 1 + IF secondelement$ = "SUB" THEN sf = 2 + IF sf THEN + + IF LEN(subfunc) = 0 THEN a$ = "EXIT " + secondelement$ + " must be used within a " + secondelement$: GOTO errmes + + PRINT #12, "goto exit_subfunc;" + IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = SCase$("Sub") ELSE secondelement$ = SCase$("Function") + l$ = SCase$("Exit") + sp + secondelement$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + END IF + + + '_ECHO checking + IF firstelement$ = "_ECHO" OR (firstelement$ = "ECHO" AND qb64prefix_set = 1) THEN + IF Console = 0 THEN + a$ = qb64prefix$ + "ECHO requires $CONSOLE or $CONSOLE:ONLY to be set first": GOTO errmes + END IF + END IF + + + 'ASC statement (fully inline) + IF n >= 1 THEN + IF firstelement$ = "ASC" THEN + IF getelement$(a$, 2) <> "(" THEN a$ = "Expected ( after ASC": GOTO errmes + + 'calculate 3 parts + useposition = 0 + part = 1 + i = 3 + a3$ = "" + stringvariable$ = "" + position$ = "" + B = 0 + DO + + IF i > n THEN 'got part 3 + IF part <> 3 OR LEN(a3$) = 0 THEN a$ = "Expected ASC ( ... , ... ) = ...": GOTO errmes + expression$ = a3$ + EXIT DO + END IF + + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + + IF B = -1 THEN + + IF part = 1 THEN 'eg. ASC(a$)=65 + IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected =": GOTO errmes + stringvariable$ = a3$ + position$ = "1" + part = 3: a3$ = "": i = i + 1: GOTO ascgotpart + END IF + + IF part = 2 THEN 'eg. ASC(a$,i)=65 + IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected =": GOTO errmes + useposition = 1 + position$ = a3$ + part = 3: a3$ = "": i = i + 1: GOTO ascgotpart + END IF + + 'fall through, already in part 3 + + END IF + + IF a2$ = "," AND B = 0 THEN + IF part = 1 THEN stringvariable$ = a3$: part = 2: a3$ = "": GOTO ascgotpart + END IF + + IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ + ascgotpart: + i = i + 1 + LOOP + IF LEN(stringvariable$) = 0 OR LEN(position$) = 0 THEN a$ = "Expected ASC ( ... , ... ) = ...": GOTO errmes + + 'validate stringvariable$ + stringvariable$ = fixoperationorder$(stringvariable$) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Asc") + sp2 + "(" + sp2 + tlayout$ + + e$ = evaluate(stringvariable$, sourcetyp) + IF Error_Happened THEN GOTO errmes + IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "Expected ASC ( string-variable , ...": GOTO errmes + stringvariable$ = evaluatetotyp(stringvariable$, ISSTRING) + IF Error_Happened THEN GOTO errmes + + + + IF position$ = "1" THEN + IF useposition THEN l$ = l$ + sp2 + "," + sp + "1" + sp2 + ")" + sp + "=" ELSE l$ = l$ + sp2 + ")" + sp + "=" + + PRINT #12, "tqbs=" + stringvariable$ + "; if (!new_error){" + e$ = fixoperationorder$(expression$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "tmp_long=" + e$ + "; if (!new_error){" + PRINT #12, "if (tqbs->len){tqbs->chr[0]=tmp_long;}else{error(5);}" + PRINT #12, "}}" + + ELSE + + PRINT #12, "tqbs=" + stringvariable$ + "; if (!new_error){" + e$ = fixoperationorder$(position$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + sp2 + ")" + sp + "=" + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "tmp_fileno=" + e$ + "; if (!new_error){" + e$ = fixoperationorder$(expression$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + e$ = evaluatetotyp(e$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "tmp_long=" + e$ + "; if (!new_error){" + PRINT #12, "if ((tmp_fileno>0)&&(tmp_fileno<=tqbs->len)){tqbs->chr[tmp_fileno-1]=tmp_long;}else{error(5);}" + PRINT #12, "}}}" + + END IF + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + + + + + 'MID$ statement + IF n >= 1 THEN + IF firstelement$ = "MID$" THEN + IF getelement$(a$, 2) <> "(" THEN a$ = "Expected ( after MID$": GOTO errmes + 'calculate 4 parts + length$ = "" + part = 1 + i = 3 + a3$ = "" + stringvariable$ = "" + start$ = "" + B = 0 + DO + IF i > n THEN + IF part <> 4 OR a3$ = "" THEN a$ = "Expected MID$(...)=...": GOTO errmes + stringexpression$ = a3$ + EXIT DO + END IF + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF B = -1 THEN + IF part = 2 THEN + IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected = after )": GOTO errmes + start$ = a3$: part = 4: a3$ = "": i = i + 1: GOTO midgotpart + END IF + IF part = 3 THEN + IF getelement$(a$, i + 1) <> "=" THEN a$ = "Expected = after )": GOTO errmes + IF a3$ = "" THEN a$ = "Omit , before ) if omitting length in MID$ statement": GOTO errmes + length$ = a3$: part = 4: a3$ = "": i = i + 1: GOTO midgotpart + END IF + END IF + IF a2$ = "," AND B = 0 THEN + IF part = 1 THEN stringvariable$ = a3$: part = 2: a3$ = "": GOTO midgotpart + IF part = 2 THEN start$ = a3$: part = 3: a3$ = "": GOTO midgotpart + END IF + IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ + midgotpart: + i = i + 1 + LOOP + IF stringvariable$ = "" THEN a$ = "Syntax error - first parameter must be a string variable/array-element": GOTO errmes + IF start$ = "" THEN a$ = "Syntax error - second parameter not optional": GOTO errmes + 'check if it is a valid source string + stringvariable$ = fixoperationorder$(stringvariable$) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Mid$") + sp2 + "(" + sp2 + tlayout$ + e$ = evaluate(stringvariable$, sourcetyp) + IF Error_Happened THEN GOTO errmes + IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "MID$ expects a string variable/array-element as its first argument": GOTO errmes + stringvariable$ = evaluatetotyp(stringvariable$, ISSTRING) + IF Error_Happened THEN GOTO errmes + + start$ = fixoperationorder$(start$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + start$ = evaluatetotyp((start$), 32&) + + stringexpression$ = fixoperationorder$(stringexpression$) + IF Error_Happened THEN GOTO errmes + l2$ = tlayout$ + stringexpression$ = evaluatetotyp(stringexpression$, ISSTRING) + IF Error_Happened THEN GOTO errmes + + IF LEN(length$) THEN + length$ = fixoperationorder$(length$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + length$ = evaluatetotyp(length$, 32&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_mid(" + stringvariable$ + "," + start$ + "," + length$ + "," + stringexpression$ + ",1);" + ELSE + PRINT #12, "sub_mid(" + stringvariable$ + "," + start$ + ",0," + stringexpression$ + ",0);" + END IF + + l$ = l$ + sp2 + ")" + sp + "=" + sp + l2$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + + + IF n >= 2 THEN + IF firstelement$ = "ERASE" THEN + i = 2 + l$ = SCase$("Erase") + erasenextarray: + var$ = getelement$(ca$, i) + x$ = var$: ls$ = removesymbol(x$) + IF Error_Happened THEN GOTO errmes + + IF FindArray(var$) THEN + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + RTRIM$(id.cn) + ls$ + 'erase the array + clearerase: + n$ = RTRIM$(id.callname) + bytesperelement$ = str2((id.arraytype AND 511) \ 8) + IF id.arraytype AND ISSTRING THEN bytesperelement$ = str2(id.tsize) + IF id.arraytype AND ISOFFSETINBITS THEN bytesperelement$ = str2((id.arraytype AND 511)) + "/8+1" + IF id.arraytype AND ISUDT THEN + bytesperelement$ = str2(udtxsize(id.arraytype AND 511) \ 8) + END IF + PRINT #12, "if (" + n$ + "[2]&1){" 'array is defined + PRINT #12, "if (" + n$ + "[2]&2){" 'array is static + IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN + PRINT #12, "tmp_long="; + FOR i2 = 1 TO ABS(id.arrayelements) + IF i2 <> 1 THEN PRINT #12, "*"; + PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; + NEXT + PRINT #12, ";" + PRINT #12, "while(tmp_long--){" + PRINT #12, "((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))->len=0;" + PRINT #12, "}" + ELSE + 'numeric + 'clear array + PRINT #12, "memset((void*)(" + n$ + "[0]),0,"; + FOR i2 = 1 TO ABS(id.arrayelements) + IF i2 <> 1 THEN PRINT #12, "*"; + PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; + NEXT + PRINT #12, "*" + bytesperelement$ + ");" + END IF + PRINT #12, "}else{" 'array is dynamic + '1. free memory & any allocated strings + IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN + 'free strings + PRINT #12, "tmp_long="; + FOR i2 = 1 TO ABS(id.arrayelements) + IF i2 <> 1 THEN PRINT #12, "*"; + PRINT #12, n$ + "[" + str2(i2 * 4 - 4 + 5) + "]"; + NEXT + PRINT #12, ";" + PRINT #12, "while(tmp_long--){" + PRINT #12, "qbs_free((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]));" + PRINT #12, "}" + 'free memory + PRINT #12, "free((void*)(" + n$ + "[0]));" + ELSE + 'free memory + PRINT #12, "if (" + n$ + "[2]&4){" 'cmem array + PRINT #12, "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" + PRINT #12, "}else{" 'non-cmem array + PRINT #12, "free((void*)(" + n$ + "[0]));" + PRINT #12, "}" + END IF + '2. set array (and its elements) as undefined + PRINT #12, n$ + "[2]^=1;" 'remove defined flag, keeping other flags (such as cmem) + 'set dimensions as undefined + FOR i2 = 1 TO ABS(id.arrayelements) + B = i2 * 4 + PRINT #12, n$ + "[" + str2(B) + "]=2147483647;" 'base + PRINT #12, n$ + "[" + str2(B + 1) + "]=0;" 'num. index + PRINT #12, n$ + "[" + str2(B + 2) + "]=0;" 'multiplier + NEXT + IF (id.arraytype AND ISSTRING) <> 0 AND (id.arraytype AND ISFIXEDLENGTH) = 0 THEN + PRINT #12, n$ + "[0]=(ptrszint)¬hingstring;" + ELSE + PRINT #12, n$ + "[0]=(ptrszint)nothingvalue;" + END IF + PRINT #12, "}" 'static/dynamic + PRINT #12, "}" 'array is defined + IF clearerasereturn = 1 THEN clearerasereturn = 0: GOTO clearerasereturned + GOTO erasedarray + END IF + IF Error_Happened THEN GOTO errmes + a$ = "Undefined array passed to ERASE": GOTO errmes + + erasedarray: + IF i < n THEN + i = i + 1: n$ = getelement$(a$, i): IF n$ <> "," THEN a$ = "Expected ,": GOTO errmes + l$ = l$ + sp2 + "," + i = i + 1: IF i > n THEN a$ = "Expected , ...": GOTO errmes + GOTO erasenextarray + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + + + 'DIM/REDIM/STATIC + IF n >= 2 THEN + dimoption = 0: redimoption = 0: commonoption = 0 + IF firstelement$ = "DIM" THEN l$ = SCase$("Dim"): dimoption = 1 + IF firstelement$ = "REDIM" THEN + l$ = SCase$("ReDim") + dimoption = 2: redimoption = 1 + IF secondelement$ = "_PRESERVE" OR (secondelement$ = "PRESERVE" AND qb64prefix_set = 1) THEN + redimoption = 2 + IF secondelement$ = "_PRESERVE" THEN + l$ = l$ + sp + SCase$("_Preserve") + ELSE + l$ = l$ + sp + SCase$("Preserve") + END IF + IF n = 2 THEN a$ = "Expected REDIM " + qb64prefix$ + "PRESERVE ...": GOTO errmes + END IF + END IF + IF firstelement$ = "STATIC" THEN l$ = SCase$("Static"): dimoption = 3 + IF firstelement$ = "COMMON" THEN l$ = SCase$("Common"): dimoption = 1: commonoption = 1 + IF dimoption THEN + + IF dimoption = 3 AND subfuncn = 0 THEN a$ = "STATIC must be used within a SUB/FUNCTION": GOTO errmes + IF commonoption = 1 AND subfuncn <> 0 THEN a$ = "COMMON cannot be used within a SUB/FUNCTION": GOTO errmes + + i = 2 + IF redimoption = 2 THEN i = 3 + + IF dimoption <> 3 THEN 'shared cannot be static + a2$ = getelement(a$, i) + IF a2$ = "SHARED" THEN + IF subfuncn <> 0 THEN a$ = "DIM/REDIM SHARED invalid within a SUB/FUNCTION": GOTO errmes + dimshared = 1 + i = i + 1 + l$ = l$ + sp + SCase$("Shared") + END IF + END IF + + IF dimoption = 3 THEN dimstatic = 1: AllowLocalName = 1 + + 'look for new dim syntax: DIM AS variabletype var1, var2, etc.... + e$ = getelement$(a$, i) + IF e$ <> "AS" THEN + 'no "AS", so this is the traditional dim syntax + dimnext: + newDimSyntax = 0 + notype = 0 + listarray = 0 + + + 'old chain code + 'chaincommonarray=0 + + varname$ = getelement(ca$, i): i = i + 1 + IF varname$ = "" THEN a$ = "Expected " + firstelement$ + " variable-name or " + firstelement$ + " AS type variable-list": GOTO errmes + + 'get the next element + IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 + + 'check if next element is a ( to create an array + elements$ = "" + + IF e$ = "(" THEN + B = 1 + FOR i = i TO n + e$ = getelement(ca$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN B = B - 1 + IF B = 0 THEN EXIT FOR + IF LEN(elements$) THEN elements$ = elements$ + sp + e$ ELSE elements$ = e$ + NEXT + IF B <> 0 THEN a$ = "Expected )": GOTO errmes + i = i + 1 'set i to point to the next element + + IF commonoption THEN elements$ = "?" + + + IF Debug THEN PRINT #9, "DIM2:array:elements$:[" + elements$ + "]" + + 'arrayname() means list array to it will automatically be static when it is formally dimensioned later + 'note: listed arrays are always created in dynamic memory, but their contents are not erased + ' this differs from static arrays from SUB...STATIC and the unique QB64 method -> STATIC arrayname(100) + IF dimoption = 3 THEN 'STATIC used + IF LEN(elements$) = 0 THEN 'nothing between brackets + listarray = 1 'add to static list + END IF + END IF + + 'last element was ")" + 'get next element + IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 + END IF 'e$="(" + d$ = e$ + + dimmethod = 0 + + appendname$ = "" 'the symbol to append to name returned by dim2 + appendtype$ = "" 'eg. sp+AS+spINTEGER + dim2typepassback$ = "" + + 'does varname have an appended symbol? + s$ = removesymbol$(varname$) + IF Error_Happened THEN GOTO errmes + IF validname(varname$) = 0 THEN a$ = "Invalid variable name": GOTO errmes + + IF s$ <> "" THEN + typ$ = s$ + dimmethod = 1 + appendname$ = typ$ + GOTO dimgottyp + END IF + + IF d$ = "AS" THEN + appendtype$ = sp + SCase$("As") + typ$ = "" + FOR i = i TO n + d$ = getelement(a$, i) + IF d$ = "," THEN i = i + 1: EXIT FOR + typ$ = typ$ + d$ + " " + appendtype$ = appendtype$ + sp + d$ + d$ = "" + NEXT + appendtype$ = SCase2$(appendtype$) 'capitalise default types (udt override this later if necessary) + typ$ = RTRIM$(typ$) + GOTO dimgottyp + END IF + + 'auto-define type based on name + notype = 1 + IF LEFT$(varname$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(varname$)) - 64 + typ$ = defineaz(v) + dimmethod = 1 + GOTO dimgottyp + + dimgottyp: + IF d$ <> "" AND d$ <> "," THEN a$ = "DIM: Expected ,": GOTO errmes + + 'In QBASIC, if no type info is given it can refer to an expeicit/formally defined array + IF notype <> 0 AND dimoption <> 3 AND dimoption <> 1 THEN 'not DIM or STATIC which only create new content + IF LEN(elements$) THEN 'an array + IF FindArray(varname$) THEN + IF LEN(RTRIM$(id.mayhave)) THEN 'explict/formally defined + typ$ = id2fulltypename$ 'adopt type + dimmethod = 0 'set as formally defined + END IF + END IF + END IF + END IF + + NormalDimBlock: + IF dimoption = 3 AND LEN(elements$) THEN 'eg. STATIC a(100) + 'does a conflicting array exist? (use findarray) if so again this should lead to duplicate definition + typ2$ = symbol2fulltypename$(typ$) + t = typname2typ(typ2$): ts = typname2typsize + 'try name without any extension + IF FindArray(varname$) THEN 'name without any symbol + IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static + IF LEN(RTRIM$(id.musthave)) THEN + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes + END IF + END IF + ELSE + IF dimmethod = 0 THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes 'explicit over explicit + ELSE + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes + END IF + END IF + END IF + END IF + END IF + END IF + 'add extension (if possible) + IF (t AND ISUDT) = 0 THEN + s2$ = type2symbol$(typ2$) + IF Error_Happened THEN GOTO errmes + IF FindArray(varname$ + s2$) THEN + IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static + IF LEN(RTRIM$(id.musthave)) THEN + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes + END IF + END IF + ELSE + IF dimmethod = 0 THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes 'explicit over explicit + ELSE + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes + END IF + END IF + END IF + END IF + END IF + END IF + END IF 'not a UDT + END IF + + IF listarray THEN 'eg. STATIC a() + 'note: list is cleared by END SUB/FUNCTION + + 'is a conflicting array already listed? if so this should cause a duplicate definition error + 'check for conflict within list: + xi = 1 + FOR x = 1 TO staticarraylistn + varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 + typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 + 'check if they are similar + IF UCASE$(varname$) = UCASE$(varname2$) THEN + IF dimmethod2 = 1 THEN + 'old using symbol + IF symbol2fulltypename$(typ$) = typ2$ THEN a$ = "Name already in use (" + varname$ + ")": GOTO errmes + ELSE + 'old using AS + IF dimmethod = 0 THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes + ELSE + IF symbol2fulltypename$(typ$) = typ2$ THEN a$ = "Name already in use (" + varname$ + ")": GOTO errmes + END IF + END IF + END IF + NEXT + + 'does a conflicting array exist? (use findarray) if so again this should lead to duplicate definition + typ2$ = symbol2fulltypename$(typ$) + t = typname2typ(typ2$): ts = typname2typsize + 'try name without any extension + IF FindArray(varname$) THEN 'name without any symbol + IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static + IF LEN(RTRIM$(id.musthave)) THEN + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes + END IF + END IF + ELSE + IF dimmethod = 0 THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes 'explicit over explicit + ELSE + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + ")": GOTO errmes + END IF + END IF + END IF + END IF + END IF + END IF + 'add extension (if possible) + IF (t AND ISUDT) = 0 THEN + s2$ = type2symbol$(typ2$) + IF Error_Happened THEN GOTO errmes + IF FindArray(varname$ + s2$) THEN + IF id.insubfuncn = subfuncn THEN 'global cannot conflict with static + IF LEN(RTRIM$(id.musthave)) THEN + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes + END IF + END IF + ELSE + IF dimmethod = 0 THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes 'explicit over explicit + ELSE + 'if types match then fail + IF (id.arraytype AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) = (t AND (ISFLOAT + ISUDT + 511 + ISUNSIGNED + ISSTRING + ISFIXEDLENGTH)) THEN + IF ts = id.tsize THEN + a$ = "Name already in use (" + varname$ + s2$ + ")": GOTO errmes + END IF + END IF + END IF + END IF + END IF + END IF + END IF 'not a UDT + + 'note: static list arrays cannot be created until they are formally [or informally] (RE)DIM'd later + IF LEN(staticarraylist) THEN staticarraylist = staticarraylist + sp + staticarraylist = staticarraylist + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) + IF Error_Happened THEN GOTO errmes + staticarraylistn = staticarraylistn + 1 + l$ = l$ + sp + varname$ + appendname$ + sp2 + "(" + sp2 + ")" + appendtype$ + 'note: none of the following code is run, dim2 call is also skipped + + ELSE + + olddimstatic = dimstatic + + 'check if varname is on the static list + IF LEN(elements$) THEN 'it's an array + IF subfuncn THEN 'it's in a sub/function + xi = 1 + FOR x = 1 TO staticarraylistn + varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 + typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 + 'check if they are similar + IF UCASE$(varname$) = UCASE$(varname2$) THEN + IF symbol2fulltypename$(typ$) = typ2$ THEN + IF Error_Happened THEN GOTO errmes + IF dimmethod = dimmethod2 THEN + 'match found! + varname$ = varname2$ + dimstatic = 3 + IF dimoption = 3 THEN a$ = "Array already listed as STATIC": GOTO errmes + END IF + END IF 'typ + END IF 'varname + NEXT + END IF + END IF + + 'COMMON exception + 'note: COMMON alone does not imply SHARED + ' if either(or both) COMMON & later DIM have SHARED, variable becomes shared + IF commonoption THEN + IF LEN(elements$) THEN + + 'add array to list + IF LEN(commonarraylist) THEN commonarraylist = commonarraylist + sp + 'note: dimmethod distinguishes between a%(...) vs a(...) AS INTEGER + commonarraylist = commonarraylist + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) + sp + str2(dimshared) + IF Error_Happened THEN GOTO errmes + commonarraylistn = commonarraylistn + 1 + IF Debug THEN PRINT #9, "common listed:" + varname$ + sp + symbol2fulltypename$(typ$) + sp + str2(dimmethod) + sp + str2(dimshared) + IF Error_Happened THEN GOTO errmes + + x = 0 + + v$ = varname$ + IF dimmethod = 1 THEN v$ = v$ + typ$ + try = findid(v$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.arraytype THEN + + t = typname2typ(typ$) + IF Error_Happened THEN GOTO errmes + s = typname2typsize + match = 1 + 'note: dimmethod 2 is already matched + IF dimmethod = 0 THEN + t2 = id.arraytype + s2 = id.tsize + IF (t AND ISFLOAT) <> (t2 AND ISFLOAT) THEN match = 0 + IF (t AND ISUNSIGNED) <> (t2 AND ISUNSIGNED) THEN match = 0 + IF (t AND ISSTRING) <> (t2 AND ISSTRING) THEN match = 0 + IF (t AND ISFIXEDLENGTH) <> (t2 AND ISFIXEDLENGTH) THEN match = 0 + IF (t AND ISOFFSETINBITS) <> (t2 AND ISOFFSETINBITS) THEN match = 0 + IF (t AND ISUDT) <> (t2 AND ISUDT) THEN match = 0 + IF (t AND 511) <> (t2 AND 511) THEN match = 0 + IF s <> s2 THEN match = 0 + 'check for implicit/explicit declaration match + oldmethod = 0: IF LEN(RTRIM$(id.musthave)) THEN oldmethod = 1 + IF oldmethod <> dimmethod THEN match = 0 + END IF + + IF match THEN + x = currentid + IF dimshared THEN ids(x).share = 1 'share if necessary + tlayout$ = RTRIM$(id.cn) + sp + "(" + sp2 + ")" + + IF dimmethod = 0 THEN + IF t AND ISUDT THEN + dim2typepassback$ = RTRIM$(udtxcname(t AND 511)) + IF UCASE$(typ$) = "MEM" AND qb64prefix_set = 1 AND RTRIM$(udtxcname(t AND 511)) = "_MEM" THEN + dim2typepassback$ = MID$(RTRIM$(udtxcname(t AND 511)), 2) + END IF + ELSE + dim2typepassback$ = typ$ + DO WHILE INSTR(dim2typepassback$, " ") + ASC(dim2typepassback$, INSTR(dim2typepassback$, " ")) = ASC(sp) + LOOP + dim2typepassback$ = SCase2$(dim2typepassback$) + END IF + END IF 'method 0 + + EXIT DO + END IF 'match + + END IF 'arraytype + IF try = 2 THEN findanotherid = 1: try = findid(v$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + + IF x = 0 THEN x = idn + 1 + + 'note: the following code only adds include directives, everything else is defered + OPEN tmpdir$ + "chain.txt" FOR APPEND AS #22 + 'include directive + PRINT #22, "#include " + CHR$(34) + "chain" + str2$(x) + ".txt" + CHR$(34) + CLOSE #22 + 'create/clear include file + OPEN tmpdir$ + "chain" + str2$(x) + ".txt" FOR OUTPUT AS #22: CLOSE #22 + + OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #22 + 'include directive + PRINT #22, "#include " + CHR$(34) + "inpchain" + str2$(x) + ".txt" + CHR$(34) + CLOSE #22 + 'create/clear include file + OPEN tmpdir$ + "inpchain" + str2$(x) + ".txt" FOR OUTPUT AS #22: CLOSE #22 + + 'note: elements$="?" + IF x <> idn + 1 THEN GOTO skipdim 'array already exists + GOTO dimcommonarray + + END IF + END IF + + 'is varname on common list? + '****** + IF LEN(elements$) THEN 'it's an array + IF subfuncn = 0 THEN 'not in a sub/function + + IF Debug THEN PRINT #9, "common checking:" + varname$ + + xi = 1 + FOR x = 1 TO commonarraylistn + varname2$ = getelement$(commonarraylist, xi): xi = xi + 1 + typ2$ = getelement$(commonarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + IF Debug THEN PRINT #9, "common checking against:" + varname2$ + sp + typ2$ + sp + str2(dimmethod2) + sp + str2(dimshared2) + 'check if they are similar + IF varname$ = varname2$ THEN + IF symbol2fulltypename$(typ$) = typ2$ THEN + IF Error_Happened THEN GOTO errmes + IF dimmethod = dimmethod2 THEN + + 'match found! + 'enforce shared status (if necessary) + IF dimshared2 THEN dimshared = dimshared OR 2 'temp force SHARED + + 'old chain code + 'chaincommonarray=x + + END IF 'method + END IF 'typ + END IF 'varname + NEXT + END IF + END IF + + dimcommonarray: + retval = dim2(varname$, typ$, dimmethod, elements$) + IF Error_Happened THEN GOTO errmes + skipdim: + IF dimshared >= 2 THEN dimshared = dimshared - 2 + + 'non-array COMMON variable + IF commonoption <> 0 AND LEN(elements$) = 0 THEN + + 'CHAIN.TXT (save) + + use_global_byte_elements = 1 + + 'switch output from main.txt to chain.txt + CLOSE #12 + OPEN tmpdir$ + "chain.txt" FOR APPEND AS #12 + l2$ = tlayout$ + + PRINT #12, "int32val=1;" 'simple variable + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + t = id.t + bits = t AND 511 + IF t AND ISUDT THEN bits = udtxsize(t AND 511) + IF t AND ISSTRING THEN + IF t AND ISFIXEDLENGTH THEN + bits = id.tsize * 8 + ELSE + PRINT #12, "int64val=__STRING_" + RTRIM$(id.n) + "->len*8;" + bits = 0 + END IF + END IF + + IF bits THEN + PRINT #12, "int64val=" + str2$(bits) + ";" 'size in bits + END IF + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + + 'put the variable + e$ = RTRIM$(id.n) + + IF (t AND ISUDT) = 0 THEN + IF t AND ISFIXEDLENGTH THEN + e$ = e$ + "$" + str2$(id.tsize) + ELSE + e$ = e$ + typevalue2symbol$(t) + IF Error_Happened THEN GOTO errmes + END IF + END IF + e$ = evaluatetotyp(fixoperationorder$(e$), -4) + IF Error_Happened THEN GOTO errmes + + PRINT #12, "sub_put(FF,NULL," + e$ + ",0);" + + tlayout$ = l2$ + 'revert output to main.txt + CLOSE #12 + OPEN tmpdir$ + "main.txt" FOR APPEND AS #12 + + + 'INPCHAIN.TXT (load) + + 'switch output from main.txt to chain.txt + CLOSE #12 + OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #12 + l2$ = tlayout$ + + + PRINT #12, "if (int32val==1){" + 'get the size in bits + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + '***assume correct size*** + + e$ = RTRIM$(id.n) + t = id.t + IF (t AND ISUDT) = 0 THEN + IF t AND ISFIXEDLENGTH THEN + e$ = e$ + "$" + str2$(id.tsize) + ELSE + e$ = e$ + typevalue2symbol$(t) + IF Error_Happened THEN GOTO errmes + END IF + END IF + + IF t AND ISSTRING THEN + IF (t AND ISFIXEDLENGTH) = 0 THEN + PRINT #12, "tqbs=qbs_new(int64val>>3,1);" + PRINT #12, "qbs_set(__STRING_" + RTRIM$(id.n) + ",tqbs);" + 'now that the string is the correct size, the following GET command will work correctly... + END IF + END IF + + e$ = evaluatetotyp(fixoperationorder$(e$), -4) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_get(FF,NULL," + e$ + ",0);" + + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" 'get next command + PRINT #12, "}" + + tlayout$ = l2$ + 'revert output to main.txt + CLOSE #12 + OPEN tmpdir$ + "main.txt" FOR APPEND AS #12 + + use_global_byte_elements = 0 + + END IF + + commonarraylisted: + + IF LEN(appendtype$) > 0 AND newDimSyntax = -1 THEN + IF LEN(dim2typepassback$) THEN appendtype$ = sp + SCase$("As") + sp + dim2typepassback$ + IF newDimSyntaxTypePassBack = 0 THEN + newDimSyntaxTypePassBack = -1 + l$ = l$ + appendtype$ + END IF + END IF + + n2 = numelements(tlayout$) + l$ = l$ + sp + getelement$(tlayout$, 1) + appendname$ + IF n2 > 1 THEN + l$ = l$ + sp2 + getelements$(tlayout$, 2, n2) + END IF + + IF LEN(appendtype$) > 0 AND newDimSyntax = 0 THEN + IF LEN(dim2typepassback$) THEN appendtype$ = sp + SCase$("As") + sp + dim2typepassback$ + l$ = l$ + appendtype$ + END IF + + 'modify first element name to include symbol + + dimstatic = olddimstatic + + END IF 'listarray=0 + + IF newDimSyntax THEN RETURN + + IF d$ = "," THEN l$ = l$ + sp2 + ",": GOTO dimnext + + dimoption = 0 + dimshared = 0 + redimoption = 0 + IF dimstatic = 1 THEN dimstatic = 0 + AllowLocalName = 0 + + layoutdone = 1 + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + + GOTO finishedline + ELSE + 'yes, this is the new dim syntax. + i = i + 1 'skip "AS" + newDimSyntaxTypePassBack = 0 + + 'estabilish the data type: + appendname$ = "" + appendtype$ = sp + SCase$("As") + typ$ = "" + varname$ = "" + previousElement$ = "" + FOR i = i TO n + d$ = getelement(a$, i) + IF d$ = "," OR d$ = "(" THEN EXIT FOR + varname$ = getelement(ca$, i) + IF LEN(previousElement$) THEN + typ$ = typ$ + previousElement$ + " " + appendtype$ = appendtype$ + sp + previousElement$ + END IF + previousElement$ = d$ + d$ = "" + NEXT + appendtype$ = SCase2$(appendtype$) 'capitalise default types (udt override this later if necessary) + typ$ = RTRIM$(typ$) + + dimnext2: + notype = 0 + listarray = 0 + + IF typ$ = "" OR varname$ = "" THEN a$ = "Expected " + firstelement$ + " AS type variable-list or " + firstelement$ + " variable-name AS type": GOTO errmes + + 'get the next element + IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 + + 'check if next element is a ( to create an array + elements$ = "" + + IF e$ = "(" THEN + B = 1 + FOR i = i TO n + e$ = getelement(ca$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN B = B - 1 + IF B = 0 THEN EXIT FOR + IF LEN(elements$) THEN elements$ = elements$ + sp + e$ ELSE elements$ = e$ + NEXT + IF B <> 0 THEN a$ = "Expected )": GOTO errmes + i = i + 1 'set i to point to the next element + + IF commonoption THEN elements$ = "?" + + + IF Debug THEN PRINT #9, "DIM2:array:elements$:[" + elements$ + "]" + + 'arrayname() means list array to it will automatically be static when it is formally dimensioned later + 'note: listed arrays are always created in dynamic memory, but their contents are not erased + ' this differs from static arrays from SUB...STATIC and the unique QB64 method -> STATIC arrayname(100) + IF dimoption = 3 THEN 'STATIC used + IF LEN(elements$) = 0 THEN 'nothing between brackets + listarray = 1 'add to static list + END IF + END IF + + 'last element was ")" + 'get next element + IF i >= n + 1 THEN e$ = "" ELSE e$ = getelement(a$, i): i = i + 1 + END IF 'e$="(" + d$ = e$ + + dimmethod = 0 + + dim2typepassback$ = "" + + 'does varname have an appended symbol? + s$ = removesymbol$(varname$) + IF Error_Happened THEN GOTO errmes + IF validname(varname$) = 0 THEN a$ = "Invalid variable name": GOTO errmes + + IF s$ <> "" THEN + a$ = "Cannot use type symbol with " + firstelement$ + " AS type variable-list (" + s$ + ")" + GOTO errmes + END IF + + IF d$ <> "" AND d$ <> "," THEN a$ = "DIM: Expected ,": GOTO errmes + + newDimSyntax = -1 + GOSUB NormalDimBlock + newDimSyntax = 0 + + IF d$ = "," THEN + l$ = l$ + sp2 + "," + varname$ = getelement(ca$, i): i = i + 1 + GOTO dimnext2 + END IF + + dimoption = 0 + dimshared = 0 + redimoption = 0 + IF dimstatic = 1 THEN dimstatic = 0 + AllowLocalName = 0 + + layoutdone = 1 + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + + GOTO finishedline + END IF + END IF + END IF + + + + + + + + + + + + 'THEN [GOTO] linenumber? + IF THENGOTO = 1 THEN + IF n = 1 THEN + l$ = "" + a = ASC(LEFT$(firstelement$, 1)) + IF a = 46 OR (a >= 48 AND a <= 57) THEN a2$ = ca$: GOTO THENGOTO + END IF + END IF + + 'goto + IF n = 2 THEN + IF getelement$(a$, 1) = "GOTO" THEN + l$ = SCase$("GoTo") + a2$ = getelement$(ca$, 2) + THENGOTO: + IF validlabel(a2$) = 0 THEN a$ = "Invalid label!": GOTO errmes + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk2: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk2 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + Labels(r).Error_Line = linenumber + END IF 'x + + IF LEN(l$) THEN l$ = l$ + sp + tlayout$ ELSE l$ = tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + PRINT #12, "goto LABEL_" + a2$ + ";" + GOTO finishedline + END IF + END IF + + IF n = 1 THEN + IF firstelement$ = "_CONTINUE" OR (firstelement$ = "CONTINUE" AND qb64prefix_set = 1) THEN + IF firstelement$ = "_CONTINUE" THEN l$ = SCase$("_Continue") ELSE l$ = SCase$("Continue") + 'scan backwards until previous control level reached + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 2 THEN 'for...next + PRINT #12, "goto fornext_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSEIF t = 3 OR t = 4 THEN 'do...loop + PRINT #12, "goto dl_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSEIF t = 5 THEN 'while...wend + PRINT #12, "goto ww_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = qb64prefix$ + "CONTINUE outside DO..LOOP/FOR..NEXT/WHILE..WEND block": GOTO errmes + END IF + END IF + + IF firstelement$ = "CHAIN" THEN + IF vWatchOn THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $Debug mode", "CHAIN" + END IF + END IF + + IF firstelement$ = "RUN" THEN 'RUN + IF vWatchOn THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $Debug mode", "RUN" + END IF + l$ = SCase$("Run") + IF n = 1 THEN + 'no parameters + PRINT #12, "sub_run_init();" 'note: called first to free up screen-locked image handles + PRINT #12, "sub_clear(NULL,NULL,NULL,NULL);" 'use functionality of CLEAR + IF LEN(subfunc$) THEN + PRINT #12, "QBMAIN(NULL);" + ELSE + PRINT #12, "goto S_0;" + END IF + ELSE + 'parameter passed + e$ = getelements$(ca$, 2, n) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l2$ = tlayout$ + ignore$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + IF n = 2 AND ((typ AND ISSTRING) = 0) THEN + 'assume it's a label or line number + lbl$ = getelement$(ca$, 2) + IF validlabel(lbl$) = 0 THEN a$ = "Invalid label!": GOTO errmes 'invalid label + + v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk501: + IF v THEN + s = Labels(r).Scope + IF s = 0 OR s = -1 THEN 'main scope? + IF s = -1 THEN Labels(r).Scope = 0 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Scope_Restriction = subfuncn + Labels(r).Error_Line = linenumber + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk501 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd lbl$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = 0 + Labels(r).Error_Line = linenumber + Labels(r).Scope_Restriction = subfuncn + END IF 'x + + l$ = l$ + sp + tlayout$ + PRINT #12, "sub_run_init();" 'note: called first to free up screen-locked image handles + PRINT #12, "sub_clear(NULL,NULL,NULL,NULL);" 'use functionality of CLEAR + IF LEN(subfunc$) THEN + PRINT #21, "if (run_from_line==" + str2(nextrunlineindex) + "){run_from_line=0;goto LABEL_" + lbl$ + ";}" + PRINT #12, "run_from_line=" + str2(nextrunlineindex) + ";" + nextrunlineindex = nextrunlineindex + 1 + PRINT #12, "QBMAIN(NULL);" + ELSE + PRINT #12, "goto LABEL_" + lbl$ + ";" + END IF + ELSE + 'assume it's a string containing a filename to execute + e$ = evaluatetotyp(e$, ISSTRING) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_run(" + e$ + ");" + l$ = l$ + sp + l2$ + END IF 'isstring + END IF 'n=1 + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF 'run + + + + + + IF firstelement$ = "END" THEN + l$ = SCase$("End") + IF n > 1 THEN + e$ = getelements$(ca$, 2, n) + e$ = fixoperationorder$(e$): IF Error_Happened THEN GOTO errmes + l2$ = tlayout$ + e$ = evaluatetotyp(e$, ISINTEGER64): IF Error_Happened THEN GOTO errmes + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + inclinenump$ = "," + str2$(inclinenumber(inclevel)) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) + END IF + IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" + PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors) + PRINT #12, "exit_code=" + e$ + ";" + l$ = l$ + sp + l2$ + END IF + xend + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + + IF firstelement$ = "SYSTEM" THEN + l$ = SCase$("System") + IF n > 1 THEN + e$ = getelements$(ca$, 2, n) + e$ = fixoperationorder$(e$): IF Error_Happened THEN GOTO errmes + l2$ = tlayout$ + e$ = evaluatetotyp(e$, ISINTEGER64): IF Error_Happened THEN GOTO errmes + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + inclinenump$ = "," + str2$(inclinenumber(inclevel)) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) + END IF + IF vWatchOn = 1 AND NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" + PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors) + PRINT #12, "exit_code=" + e$ + ";" + l$ = l$ + sp + l2$ + END IF + + + IF vWatchOn = 1 THEN + IF inclinenumber(inclevel) = 0 THEN + vWatchAddLabel linenumber, 0 + END IF + PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + PRINT #12, "if (sub_gl_called) error(271);" + PRINT #12, "close_program=1;" + PRINT #12, "end();" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + + IF n >= 1 THEN + IF firstelement$ = "STOP" THEN + l$ = SCase$("Stop") + IF n > 1 THEN + e$ = getelements$(ca$, 2, n) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Stop") + sp + tlayout$ + e$ = evaluatetotyp(e$, 64) + IF Error_Happened THEN GOTO errmes + 'note: this value is currently ignored but evaluated for checking reasons + END IF + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + IF vWatchOn = 1 AND NoChecks = 0 AND inclinenumber(inclevel) = 0 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + vWatchAddLabel linenumber, 0 + ELSE + PRINT #12, "close_program=1;" + PRINT #12, "end();" + END IF + GOTO finishedline + END IF + END IF + + IF n = 2 THEN + IF firstelement$ = "GOSUB" THEN + xgosub ca$ + IF Error_Happened THEN GOTO errmes + 'note: layout implemented in xgosub + GOTO finishedline + END IF + END IF + + IF n >= 1 THEN + IF firstelement$ = "RETURN" THEN + IF n = 1 THEN + PRINT #12, "#include " + CHR$(34) + "ret" + str2$(subfuncn) + ".txt" + CHR$(34) + l$ = SCase$("Return") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSE + 'label/linenumber follows + IF subfuncn <> 0 THEN a$ = "RETURN linelabel/linenumber invalid within a SUB/FUNCTION": GOTO errmes + IF n > 2 THEN a$ = "Expected linelabel/linenumber after RETURN": GOTO errmes + PRINT #12, "if (!next_return_point) error(3);" 'check return point available + PRINT #12, "next_return_point--;" 'destroy return point + a2$ = getelement$(ca$, 2) + IF validlabel(a2$) = 0 THEN a$ = "Invalid label!": GOTO errmes + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk505: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk505 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + Labels(r).Error_Line = linenumber + END IF 'x + + PRINT #12, "goto LABEL_" + a2$ + ";" + l$ = SCase$("Return") + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + END IF + + IF n >= 1 THEN + IF firstelement$ = "RESUME" THEN + l$ = SCase$("Resume") + IF n = 1 THEN + resumeprev: + + + PRINT #12, "if (!error_handling){error(20);}else{error_retry=1; qbevent=1; error_handling=0; error_err=0; return;}" + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + IF n > 2 THEN a$ = "Too many parameters": GOTO errmes + s$ = getelement$(ca$, 2) + IF UCASE$(s$) = "NEXT" THEN + + + PRINT #12, "if (!error_handling){error(20);}else{error_handling=0; error_err=0; return;}" + + l$ = l$ + sp + SCase$("Next") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + IF s$ = "0" THEN l$ = l$ + sp + "0": GOTO resumeprev + IF validlabel(s$) = 0 THEN a$ = "Invalid label passed to RESUME": GOTO errmes + + v = HashFind(s$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk506: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk506 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd s$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + Labels(r).Error_Line = linenumber + END IF 'x + + l$ = l$ + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + PRINT #12, "if (!error_handling){error(20);}else{error_handling=0; error_err=0; goto LABEL_" + s$ + ";}" + GOTO finishedline + END IF + END IF + + IF n = 4 THEN + IF getelements(a$, 1, 3) = "ON" + sp + "ERROR" + sp + "GOTO" THEN + l$ = SCase$("On" + sp + "Error" + sp + "GoTo") + lbl$ = getelement$(ca$, 4) + IF lbl$ = "0" THEN + PRINT #12, "error_goto_line=0;" + l$ = l$ + sp + "0" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + IF validlabel(lbl$) = 0 THEN a$ = "Invalid label": GOTO errmes + + v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk6: + IF v THEN + s = Labels(r).Scope + IF s = 0 OR s = -1 THEN 'main scope? + IF s = -1 THEN Labels(r).Scope = 0 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Scope_Restriction = subfuncn + Labels(r).Error_Line = linenumber + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk6 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd lbl$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = 0 + Labels(r).Error_Line = linenumber + Labels(r).Scope_Restriction = subfuncn + END IF 'x + + + l$ = l$ + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + errorlabels = errorlabels + 1 + PRINT #12, "error_goto_line=" + str2(errorlabels) + ";" + PRINT #14, "if (error_goto_line==" + str2(errorlabels) + "){error_handling=1; goto LABEL_" + lbl$ + ";}" + GOTO finishedline + END IF + END IF + + IF n >= 1 THEN + IF firstelement$ = "RESTORE" THEN + l$ = SCase$("Restore") + IF n = 1 THEN + PRINT #12, "data_offset=0;" + ELSE + IF n > 2 THEN a$ = "Syntax error - too many parameters (expected RESTORE label/line number)": GOTO errmes + lbl$ = getelement$(ca$, 2) + IF validlabel(lbl$) = 0 THEN a$ = "Invalid label": GOTO errmes + + 'rule: a RESTORE label has no scope, therefore, only one instance of that label may exist + 'how: enforced by a post check for duplicates + v = HashFind(lbl$, HASHFLAG_LABEL, ignore, r) + x = 1 + IF v THEN 'already defined + x = 0 + tlayout$ = RTRIM$(Labels(r).cn) + Labels(r).Data_Referenced = 1 'make sure the data referenced flag is set + IF Labels(r).Error_Line = 0 THEN Labels(r).Error_Line = linenumber + END IF + IF x THEN + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd lbl$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = -1 'modifyable scope + Labels(r).Error_Line = linenumber + Labels(r).Data_Referenced = 1 + END IF 'x + + l$ = l$ + sp + tlayout$ + PRINT #12, "data_offset=data_at_LABEL_" + lbl$ + ";" + END IF + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + + + + 'ON ... GOTO/GOSUB + IF n >= 1 THEN + IF firstelement$ = "ON" THEN + xongotogosub a$, ca$, n + IF Error_Happened THEN GOTO errmes + GOTO finishedline + END IF + END IF + + + '(_MEM) _MEMPUT _MEMGET + IF n >= 1 THEN + IF firstelement$ = "_MEMGET" OR (firstelement$ = "MEMGET" AND qb64prefix_set = 1) THEN + 'get expressions + e$ = "" + B = 0 + ne = 0 + FOR i2 = 2 TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN + ne = ne + 1 + IF ne = 1 THEN blk$ = e$: e$ = "" + IF ne = 2 THEN offs$ = e$: e$ = "" + IF ne = 3 THEN a$ = "Syntax error - too many parameters (Expected " + qb64prefix$ + "MEMGET mem-reference, offset, variable)": GOTO errmes + ELSE + IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + END IF + NEXT + var$ = e$ + IF e$ = "" OR ne <> 2 THEN a$ = "Expected " + qb64prefix$ + "MEMGET mem-reference, offset, variable": GOTO errmes + + IF firstelement$ = "_MEMGET" THEN l$ = SCase$("_MemGet") + sp ELSE l$ = SCase$("MemGet") + sp + + e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + + test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes + IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes + blkoffs$ = evaluatetotyp(e$, -6) + + ' IF typ AND ISREFERENCE THEN e$ = refer(e$, typ, 0) + + + 'PRINT #12, blkoffs$ '??? + + e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes + offs$ = e$ + 'PRINT #12, e$ '??? + + e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes + varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes + + + 'PRINT #12, varoffs$ '??? + 'PRINT #12, varsize$ '??? + + 'what do we do next + 'need to know offset of variable and its size + + 'known sizes will be handled by designated command casts, otherwise use memmove + s = 0 + IF varsize$ = "1" THEN s = 1: st$ = "int8" + IF varsize$ = "2" THEN s = 2: st$ = "int16" + IF varsize$ = "4" THEN s = 4: st$ = "int32" + IF varsize$ = "8" THEN s = 8: st$ = "int64" + + IF NoChecks THEN + 'fast version: + IF s THEN + PRINT #12, "*(" + st$ + "*)" + varoffs$ + "=*(" + st$ + "*)(" + offs$ + ");" + ELSE + PRINT #12, "memmove(" + varoffs$ + ",(void*)" + offs$ + "," + varsize$ + ");" + END IF + ELSE + 'safe version: + PRINT #12, "tmp_long=" + offs$ + ";" + 'is mem block init? + PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" + 'are region and id valid? + PRINT #12, "if (" + PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" + PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" + PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" + 'diagnose error + PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" + PRINT #12, "}else{" + IF s THEN + PRINT #12, "*(" + st$ + "*)" + varoffs$ + "=*(" + st$ + "*)tmp_long;" + ELSE + PRINT #12, "memmove(" + varoffs$ + ",(void*)tmp_long," + varsize$ + ");" + END IF + PRINT #12, "}" + PRINT #12, "}else error(309);" + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + + END IF + END IF + + + + + IF n >= 1 THEN + IF firstelement$ = "_MEMPUT" OR (firstelement$ = "MEMPUT" AND qb64prefix_set = 1) THEN + 'get expressions + typ$ = "" + e$ = "" + B = 0 + ne = 0 + FOR i2 = 2 TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF (e2$ = "," OR UCASE$(e2$) = "AS") AND B = 0 THEN + ne = ne + 1 + IF ne = 1 THEN blk$ = e$: e$ = "" + IF ne = 2 THEN offs$ = e$: e$ = "" + IF ne = 3 THEN var$ = e$: e$ = "" + IF (UCASE$(e2$) = "AS" AND ne <> 3) OR (ne = 3 AND UCASE$(e2$) <> "AS") OR ne = 4 THEN a$ = "Expected _MEMPUT mem-reference,offset,variable|value[AS type]": GOTO errmes + ELSE + IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + END IF + NEXT + IF ne < 2 OR e$ = "" THEN a$ = "Expected " + qb64prefix$ + "MEMPUT mem-reference, offset, variable|value[AS type]": GOTO errmes + IF ne = 2 THEN var$ = e$ ELSE typ$ = UCASE$(e$) + + IF firstelement$ = "_MEMPUT" THEN l$ = SCase$("_MemPut") + sp ELSE l$ = SCase$("MemPut") + sp + + e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + + test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes + IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes + blkoffs$ = evaluatetotyp(e$, -6) + + e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes + offs$ = e$ + + IF ne = 2 THEN + e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + + test$ = evaluate(e$, t): IF Error_Happened THEN GOTO errmes + IF (t AND ISREFERENCE) = 0 AND (t AND ISSTRING) THEN + PRINT #12, "g_tmp_str=" + test$ + ";" + varsize$ = "g_tmp_str->len" + varoffs$ = "g_tmp_str->chr" + ELSE + varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes + varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes + END IF + + 'known sizes will be handled by designated command casts, otherwise use memmove + s = 0 + IF varsize$ = "1" THEN s = 1: st$ = "int8" + IF varsize$ = "2" THEN s = 2: st$ = "int16" + IF varsize$ = "4" THEN s = 4: st$ = "int32" + IF varsize$ = "8" THEN s = 8: st$ = "int64" + + IF NoChecks THEN + 'fast version: + IF s THEN + PRINT #12, "*(" + st$ + "*)(" + offs$ + ")=*(" + st$ + "*)" + varoffs$ + ";" + ELSE + PRINT #12, "memmove((void*)" + offs$ + "," + varoffs$ + "," + varsize$ + ");" + END IF + ELSE + 'safe version: + PRINT #12, "tmp_long=" + offs$ + ";" + 'is mem block init? + PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" + 'are region and id valid? + PRINT #12, "if (" + PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" + PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" + PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" + 'diagnose error + PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" + PRINT #12, "}else{" + IF s THEN + PRINT #12, "*(" + st$ + "*)tmp_long=*(" + st$ + "*)" + varoffs$ + ";" + ELSE + PRINT #12, "memmove((void*)tmp_long," + varoffs$ + "," + varsize$ + ");" + END IF + PRINT #12, "}" + PRINT #12, "}else error(309);" + END IF + + ELSE + + '... AS type method + 'FUNCTION typname2typ& (t2$) + 'typname2typsize = 0 'the default + t = typname2typ(typ$) + IF t = 0 THEN a$ = "Invalid type": GOTO errmes + IF (t AND ISOFFSETINBITS) <> 0 OR (t AND ISUDT) <> 0 OR (t AND ISSTRING) THEN a$ = qb64prefix$ + "MEMPUT requires numeric type": GOTO errmes + IF (t AND ISPOINTER) THEN t = t - ISPOINTER + 'attempt conversion... + e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + sp + SCase$("As") + sp + typ$ + e$ = evaluatetotyp(e$, t): IF Error_Happened THEN GOTO errmes + st$ = typ2ctyp$(t, "") + varsize$ = str2((t AND 511) \ 8) + IF NoChecks THEN + 'fast version: + PRINT #12, "*(" + st$ + "*)(" + offs$ + ")=" + e$ + ";" + ELSE + 'safe version: + PRINT #12, "tmp_long=" + offs$ + ";" + 'is mem block init? + PRINT #12, "if ( ((mem_block*)(" + blkoffs$ + "))->lock_offset ){" + 'are region and id valid? + PRINT #12, "if (" + PRINT #12, "tmp_long < ((mem_block*)(" + blkoffs$ + "))->offset ||" + PRINT #12, "(tmp_long+(" + varsize$ + ")) > ( ((mem_block*)(" + blkoffs$ + "))->offset + ((mem_block*)(" + blkoffs$ + "))->size) ||" + PRINT #12, "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id ){" + 'diagnose error + PRINT #12, "if (" + "((mem_lock*)((mem_block*)(" + blkoffs$ + "))->lock_offset)->id != ((mem_block*)(" + blkoffs$ + "))->lock_id" + ") error(308); else error(300);" + PRINT #12, "}else{" + PRINT #12, "*(" + st$ + "*)tmp_long=" + e$ + ";" + PRINT #12, "}" + PRINT #12, "}else error(309);" + END IF + + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + + END IF + END IF + + + + + + IF n >= 1 THEN + IF firstelement$ = "_MEMFILL" OR (firstelement$ = "MEMFILL" AND qb64prefix_set = 1) THEN + 'get expressions + typ$ = "" + e$ = "" + B = 0 + ne = 0 + FOR i2 = 2 TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF (e2$ = "," OR UCASE$(e2$) = "AS") AND B = 0 THEN + ne = ne + 1 + IF ne = 1 THEN blk$ = e$: e$ = "" + IF ne = 2 THEN offs$ = e$: e$ = "" + IF ne = 3 THEN bytes$ = e$: e$ = "" + IF ne = 4 THEN var$ = e$: e$ = "" + IF (UCASE$(e2$) = "AS" AND ne <> 4) OR (ne = 4 AND UCASE$(e2$) <> "AS") OR ne = 5 THEN a$ = "Expected _MEMFILL mem-reference,offset,bytes,variable|value[AS type]": GOTO errmes + ELSE + IF LEN(e$) = 0 THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + END IF + NEXT + IF ne < 3 OR e$ = "" THEN a$ = "Expected " + qb64prefix$ + "MEMFILL mem-reference, offset, bytes, variable|value[AS type]": GOTO errmes + IF ne = 3 THEN var$ = e$ ELSE typ$ = UCASE$(e$) + + IF firstelement$ = "_MEMFILL" THEN l$ = SCase$("_MemFill") + sp ELSE l$ = SCase$("MemFill") + sp + + e$ = fixoperationorder$(blk$): IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + + test$ = evaluate(e$, typ): IF Error_Happened THEN GOTO errmes + IF (typ AND ISUDT) = 0 OR (typ AND 511) <> 1 THEN a$ = "Expected " + qb64prefix$ + "MEM type": GOTO errmes + blkoffs$ = evaluatetotyp(e$, -6) + + e$ = fixoperationorder$(offs$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes + offs$ = e$ + + e$ = fixoperationorder$(bytes$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluatetotyp(e$, OFFSETTYPE - ISPOINTER): IF Error_Happened THEN GOTO errmes + bytes$ = e$ + + IF ne = 3 THEN 'no AS + e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + test$ = evaluate(e$, t) + IF (t AND ISREFERENCE) = 0 AND (t AND ISSTRING) THEN + PRINT #12, "tmp_long=(ptrszint)" + test$ + ";" + varsize$ = "((qbs*)tmp_long)->len" + varoffs$ = "((qbs*)tmp_long)->chr" + ELSE + varsize$ = evaluatetotyp(e$, -5): IF Error_Happened THEN GOTO errmes + varoffs$ = evaluatetotyp(e$, -6): IF Error_Happened THEN GOTO errmes + END IF + + IF NoChecks THEN + PRINT #12, "sub__memfill_nochecks(" + offs$ + "," + bytes$ + ",(ptrszint)" + varoffs$ + "," + varsize$ + ");" + ELSE + PRINT #12, "sub__memfill((mem_block*)" + blkoffs$ + "," + offs$ + "," + bytes$ + ",(ptrszint)" + varoffs$ + "," + varsize$ + ");" + END IF + + ELSE + + '... AS type method + t = typname2typ(typ$) + IF t = 0 THEN a$ = "Invalid type": GOTO errmes + IF (t AND ISOFFSETINBITS) <> 0 OR (t AND ISUDT) <> 0 OR (t AND ISSTRING) THEN a$ = qb64prefix$ + "MEMFILL requires numeric type": GOTO errmes + IF (t AND ISPOINTER) THEN t = t - ISPOINTER + 'attempt conversion... + e$ = fixoperationorder$(var$): IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + sp + SCase$("As") + sp + typ$ + e$ = evaluatetotyp(e$, t): IF Error_Happened THEN GOTO errmes + + c$ = "sub__memfill_" + IF NoChecks THEN c$ = "sub__memfill_nochecks_" + IF t AND ISOFFSET THEN + c$ = c$ + "OFFSET" + ELSE + IF t AND ISFLOAT THEN + IF (t AND 511) = 32 THEN c$ = c$ + "SINGLE" + IF (t AND 511) = 64 THEN c$ = c$ + "DOUBLE" + IF (t AND 511) = 256 THEN c$ = c$ + "FLOAT" 'padded variable + ELSE + c$ = c$ + str2((t AND 511) \ 8) + END IF + END IF + c$ = c$ + "(" + IF NoChecks = 0 THEN c$ = c$ + "(mem_block*)" + blkoffs$ + "," + PRINT #12, c$ + offs$ + "," + bytes$ + "," + e$ + ");" + END IF + + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + + END IF + END IF + + + + + + + + + + + + + + 'note: ABSOLUTE cannot be used without CALL + cispecial = 0 + IF n > 1 THEN + IF firstelement$ = "INTERRUPT" OR firstelement$ = "INTERRUPTX" THEN + a$ = "CALL" + sp + firstelement$ + sp + "(" + sp + getelements$(a$, 2, n) + sp + ")" + ca$ = "CALL" + sp + firstelement$ + sp + "(" + sp + getelements$(ca$, 2, n) + sp + ")" + n = n + 3 + firstelement$ = "CALL" + cispecial = 1 + 'fall through + END IF + END IF + + usecall = 0 + IF firstelement$ = "CALL" THEN + usecall = 1 + IF n = 1 THEN a$ = "Expected CALL sub-name [(...)]": GOTO errmes + cn$ = getelement$(ca$, 2): n$ = UCASE$(cn$) + + IF n > 2 THEN + + IF n <= 4 THEN a$ = "Expected CALL sub-name (...)": GOTO errmes + IF getelement$(a$, 3) <> "(" OR getelement$(a$, n) <> ")" THEN a$ = "Expected CALL sub-name (...)": GOTO errmes + a$ = n$ + sp + getelements$(a$, 4, n - 1) + ca$ = cn$ + sp + getelements$(ca$, 4, n - 1) + + + IF n$ = "INTERRUPT" OR n$ = "INTERRUPTX" THEN 'assume CALL INTERRUPT[X] request + 'print "CI: call interrupt command reached":sleep 1 + IF n$ = "INTERRUPT" THEN PRINT #12, "call_interrupt("; ELSE PRINT #12, "call_interruptx("; + argn = 0 + n = numelements(a$) + B = 0 + e$ = "" + FOR i = 2 TO n + e2$ = getelement$(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF (e2$ = "," AND B = 0) OR i = n THEN + IF i = n THEN + IF e$ = "" THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + END IF + argn = argn + 1 + IF argn = 1 THEN 'interrupt number + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = SCase$("Call") + sp + n$ + sp2 + "(" + sp2 + tlayout$ + IF cispecial = 1 THEN l$ = n$ + sp + tlayout$ + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN GOTO errmes + 'print "CI: evaluated interrupt number as ["+e$+"]":sleep 1 + PRINT #12, e$; + END IF + IF argn = 2 OR argn = 3 THEN 'inregs, outregs + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e2$ = e$ + e$ = evaluatetotyp(e$, -2) 'offset+size + IF Error_Happened THEN GOTO errmes + 'print "CI: evaluated in/out regs ["+e2$+"] as ["+e$+"]":sleep 1 + PRINT #12, "," + e$; + END IF + e$ = "" + ELSE + IF e$ = "" THEN e$ = e2$ ELSE e$ = e$ + sp + e2$ + END IF + NEXT + IF argn <> 3 THEN a$ = "Expected CALL INTERRUPT (interrupt-no, inregs, outregs)": GOTO errmes + PRINT #12, ");" + IF cispecial = 0 THEN l$ = l$ + sp2 + ")" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + 'print "CI: done":sleep 1 + GOTO finishedline + END IF 'call interrupt + + + + + + + + + 'call to CALL ABSOLUTE beyond reasonable doubt + IF n$ = "ABSOLUTE" THEN + l$ = SCase$("Call" + sp + "Absolute" + sp2 + "(" + sp2) + argn = 0 + n = numelements(a$) + B = 0 + e$ = "" + FOR i = 2 TO n + e2$ = getelement$(ca$, i) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF (e2$ = "," AND B = 0) OR i = n THEN + IF i < n THEN + IF e$ = "" THEN a$ = "Expected expression before , or )": GOTO errmes + '1. variable or value? + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + "," + sp + ignore$ = evaluate(e$, typ) + IF Error_Happened THEN GOTO errmes + + IF (typ AND ISPOINTER) <> 0 AND (typ AND ISREFERENCE) <> 0 THEN + + 'assume standard variable + 'assume not string/array/udt/etc + e$ = "VARPTR" + sp + "(" + sp + e$ + sp + ")" + e$ = evaluatetotyp(e$, UINTEGERTYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + + ELSE + + 'assume not string + 'single, double or integer64? + IF typ AND ISFLOAT THEN + IF (typ AND 511) = 32 THEN + e$ = evaluatetotyp(e$, SINGLETYPE - ISPOINTER) + IF Error_Happened THEN GOTO errmes + v$ = "pass" + str2$(uniquenumber) + PRINT #defdatahandle, "float *" + v$ + "=NULL;" + PRINT #13, "if(" + v$ + "==NULL){" + PRINT #13, "cmem_sp-=4;" + PRINT #13, v$ + "=(float*)(dblock+cmem_sp);" + PRINT #13, "if (cmem_sp2 + + a$ = n$ + ca$ = cn$ + usecall = 2 + + END IF 'n>2 + + n = numelements(a$) + firstelement$ = getelement$(a$, 1) + + 'valid SUB name + validsub = 0 + findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) + try = findid(firstelement$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = 2 THEN validsub = 1: EXIT DO + IF try = 2 THEN + findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) + findanotherid = 1 + try = findid(firstelement$) + IF Error_Happened THEN GOTO errmes + ELSE + try = 0 + END IF + LOOP + IF validsub = 0 THEN a$ = "Expected CALL sub-name [(...)]": GOTO errmes + END IF + + 'sub? + IF n >= 1 THEN + + IF firstelement$ = "?" THEN firstelement$ = "PRINT" + + findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) + try = findid(firstelement$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.subfunc = 2 THEN + + 'check symbol + s$ = removesymbol$(firstelement$ + "") + IF Error_Happened THEN GOTO errmes + IF ASC(id.musthave) = 36 THEN '="$" + IF s$ <> "$" THEN GOTO notsubcall 'missing musthave "$" + ELSE + IF LEN(s$) THEN GOTO notsubcall 'unrequired symbol added + END IF + 'check for variable assignment + IF n > 1 THEN + IF ASC(id.specialformat) <> 61 THEN '<>"=" + IF ASC(getelement$(a$, 2)) = 61 THEN GOTO notsubcall 'assignment, not sub call + END IF + END IF + 'check for array assignment + IF n > 2 THEN + IF firstelement$ <> "PRINT" AND firstelement$ <> "LPRINT" THEN + IF getelement$(a$, 2) = "(" THEN + B = 1 + FOR i = 3 TO n + e$ = getelement$(a$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN + B = B - 1 + IF B = 0 THEN + IF i = n THEN EXIT FOR + IF getelement$(a$, i + 1) = "=" THEN GOTO notsubcall + END IF + END IF + NEXT + END IF + END IF + END IF + + + 'generate error on driect _GL call + IF firstelement$ = "_GL" THEN + a$ = "Cannot call SUB _GL directly": GOTO errmes + END IF + + IF firstelement$ = "VWATCH" THEN + a$ = "Cannot call SUB VWATCH directly": GOTO errmes + END IF + + IF firstelement$ = "OPEN" THEN + 'gwbasic or qbasic version? + B = 0 + FOR x = 2 TO n + a2$ = getelement$(a$, x) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF a2$ = "FOR" OR a2$ = "AS" THEN EXIT FOR 'qb style open verified + IF B = 0 AND a2$ = "," THEN 'the gwbasic version includes a comma after the first string expression + findanotherid = 1 + try = findid(firstelement$) 'id of sub_open_gwbasic + IF Error_Happened THEN GOTO errmes + EXIT FOR + END IF + NEXT + END IF + + + 'IF findid(firstelement$) THEN + 'IF id.subfunc = 2 THEN + + + IF firstelement$ = "CLOSE" OR firstelement$ = "RESET" THEN + IF firstelement$ = "RESET" THEN + IF n > 1 THEN a$ = "Syntax error - RESET takes no parameters": GOTO errmes + l$ = SCase$("Reset") + ELSE + l$ = SCase$("Close") + END IF + + IF n = 1 THEN + PRINT #12, "sub_close(NULL,0);" 'closes all files + ELSE + l$ = l$ + sp + B = 0 + s = 0 + a3$ = "" + FOR x = 2 TO n + a2$ = getelement$(ca$, x) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF a2$ = "#" AND B = 0 THEN + IF s = 0 THEN s = 1 ELSE a$ = "Unexpected #": GOTO errmes + l$ = l$ + "#" + sp2 + GOTO closenexta + END IF + + IF a2$ = "," AND B = 0 THEN + IF s = 2 THEN + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + sp2 + "," + sp + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_close(" + e$ + ",1);" + a3$ = "" + s = 0 + GOTO closenexta + ELSE + a$ = "Expected expression before ,": GOTO errmes + END IF + END IF + + s = 2 + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + + closenexta: + NEXT + + IF s = 2 THEN + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + tlayout$ + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_close(" + e$ + ",1);" + ELSE + l$ = LEFT$(l$, LEN(l$) - 1) + END IF + + END IF + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF 'close + + + + + + + + + + + + + + + + + 'data, restore, read + IF firstelement$ = "READ" THEN 'file input + xread ca$, n + IF Error_Happened THEN GOTO errmes + 'note: layout done in xread sub + GOTO finishedline + END IF 'read + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lineinput = 0 + IF n >= 2 THEN + IF firstelement$ = "LINE" AND secondelement$ = "INPUT" THEN + lineinput = 1 + a$ = RIGHT$(a$, LEN(a$) - 5): ca$ = RIGHT$(ca$, LEN(ca$) - 5): n = n - 1 'remove "LINE" + firstelement$ = "INPUT" + END IF + END IF + + IF firstelement$ = "INPUT" THEN 'file input + IF n > 1 THEN + IF getelement$(a$, 2) = "#" THEN + l$ = SCase$("Input") + sp + "#": IF lineinput THEN l$ = SCase$("Line") + sp + l$ + + u$ = str2$(uniquenumber) + 'which file? + IF n = 2 THEN a$ = "Expected # ... , ...": GOTO errmes + a3$ = "" + B = 0 + FOR i = 3 TO n + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF a2$ = "," AND B = 0 THEN + IF a3$ = "" THEN a$ = "Expected # ... , ...": GOTO errmes + GOTO inputgotfn + END IF + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + NEXT + inputgotfn: + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + tlayout$ + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN GOTO errmes + PRINT #12, "tmp_fileno=" + e$ + ";" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + i = i + 1 + IF i > n THEN a$ = "Expected , ...": GOTO errmes + a3$ = "" + B = 0 + FOR i = i TO n + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF i = n THEN + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + a2$ = ",": B = 0 + END IF + IF a2$ = "," AND B = 0 THEN + IF a3$ = "" THEN a$ = "Expected , ...": GOTO errmes + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp2 + "," + sp + tlayout$ + e$ = evaluate(e$, t) + IF Error_Happened THEN GOTO errmes + IF (t AND ISREFERENCE) = 0 THEN a$ = "Expected variable-name": GOTO errmes + IF (t AND ISSTRING) THEN + e$ = refer(e$, t, 0) + IF Error_Happened THEN GOTO errmes + IF lineinput THEN + PRINT #12, "sub_file_line_input_string(tmp_fileno," + e$ + ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + ELSE + PRINT #12, "sub_file_input_string(tmp_fileno," + e$ + ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + END IF + stringprocessinghappened = 1 + ELSE + IF lineinput THEN a$ = "Expected string-variable": GOTO errmes + + 'numeric variable + IF (t AND ISFLOAT) <> 0 OR (t AND 511) <> 64 THEN + IF (t AND ISOFFSETINBITS) THEN + setrefer e$, t, "((int64)func_file_input_float(tmp_fileno," + str2(t) + "))", 1 + IF Error_Happened THEN GOTO errmes + ELSE + setrefer e$, t, "func_file_input_float(tmp_fileno," + str2(t) + ")", 1 + IF Error_Happened THEN GOTO errmes + END IF + ELSE + IF t AND ISUNSIGNED THEN + setrefer e$, t, "func_file_input_uint64(tmp_fileno)", 1 + IF Error_Happened THEN GOTO errmes + ELSE + setrefer e$, t, "func_file_input_int64(tmp_fileno)", 1 + IF Error_Happened THEN GOTO errmes + END IF + END IF + + PRINT #12, "if (new_error) goto skip" + u$ + ";" + + END IF + IF i = n THEN EXIT FOR + IF lineinput THEN a$ = "Too many variables": GOTO errmes + a3$ = "": a2$ = "" + END IF + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + NEXT + PRINT #12, "skip" + u$ + ":" + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + END IF + END IF 'input# + + + IF firstelement$ = "INPUT" THEN + l$ = SCase$("Input"): IF lineinput THEN l$ = SCase$("Line") + sp + l$ + commaneeded = 0 + i = 2 + + newline = 1: IF getelement$(a$, i) = ";" THEN newline = 0: i = i + 1: l$ = l$ + sp + ";" + + a2$ = getelement$(ca$, i) + IF LEFT$(a2$, 1) = CHR$(34) THEN + e$ = fixoperationorder$(a2$): l$ = l$ + sp + tlayout$ + IF Error_Happened THEN GOTO errmes + PRINT #12, "qbs_print(qbs_new_txt_len(" + a2$ + "),0);" + i = i + 1 + 'MUST be followed by a ; or , + a2$ = getelement$(ca$, i) + i = i + 1 + l$ = l$ + sp2 + a2$ + IF a2$ = ";" THEN + IF lineinput THEN GOTO finishedpromptstring + PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "? " + CHR$(34) + "),0);" + GOTO finishedpromptstring + END IF + IF a2$ = "," THEN + GOTO finishedpromptstring + END IF + a$ = "Syntax error - Reference: INPUT [;] " + CHR$(34) + "[Question or statement text]" + CHR$(34) + "{,|;} variable[, ...] or INPUT ; variable[, ...]": GOTO errmes + END IF + 'there was no promptstring, so print a ? + IF lineinput = 0 THEN PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "? " + CHR$(34) + "),0);" + finishedpromptstring: + numvar = 0 + FOR i = i TO n + IF commaneeded = 1 THEN + a2$ = getelement$(ca$, i) + IF a2$ <> "," THEN a$ = "Syntax error - comma expected": GOTO errmes + ELSE + + B = 0 + e$ = "" + FOR i2 = i TO n + e2$ = getelement$(ca$, i2) + IF e2$ = "(" THEN B = B + 1 + IF e2$ = ")" THEN B = B - 1 + IF e2$ = "," AND B = 0 THEN i2 = i2 - 1: EXIT FOR + e$ = e$ + sp + e2$ + NEXT + i = i2: IF i > n THEN i = n + IF e$ = "" THEN a$ = "Expected variable": GOTO errmes + e$ = RIGHT$(e$, LEN(e$) - 1) + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$: IF i <> n THEN l$ = l$ + sp2 + "," + e$ = evaluate(e$, t) + IF Error_Happened THEN GOTO errmes + IF (t AND ISREFERENCE) = 0 THEN a$ = "Expected variable": GOTO errmes + + IF (t AND ISSTRING) THEN + e$ = refer(e$, t, 0) + IF Error_Happened THEN GOTO errmes + numvar = numvar + 1 + IF lineinput THEN + PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=ISSTRING+512;" + ELSE + PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=ISSTRING;" + END IF + PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + e$ + ";" + GOTO gotinputvar + END IF + + IF lineinput THEN a$ = "Expected string variable": GOTO errmes + IF (t AND ISARRAY) THEN + IF (t AND ISOFFSETINBITS) THEN + a$ = "INPUT cannot handle BIT array elements": GOTO errmes + END IF + END IF + e$ = "&(" + refer(e$, t, 0) + ")" + IF Error_Happened THEN GOTO errmes + + 'remove assumed/unnecessary flags + IF (t AND ISPOINTER) THEN t = t - ISPOINTER + IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY + IF (t AND ISREFERENCE) THEN t = t - ISREFERENCE + + 'IF (t AND ISOFFSETINBITS) THEN + 'numvar = numvar + 1 + 'consider storing the bit offset in unused bits of t + 'PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=" + str2(t) + ";" + 'PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + refer(ref$, typ, 1) + ";" + 'GOTO gotinputvar + 'END IF + + 'assume it is a regular variable + numvar = numvar + 1 + PRINT #12, "qbs_input_variabletypes[" + str2(numvar) + "]=" + str2$(t) + ";" + PRINT #12, "qbs_input_variableoffsets[" + str2(numvar) + "]=" + e$ + ";" + GOTO gotinputvar + + END IF + gotinputvar: + commaneeded = commaneeded + 1: IF commaneeded = 2 THEN commaneeded = 0 + NEXT + IF numvar = 0 THEN a$ = "Syntax error - Reference: INPUT [;] " + CHR$(34) + "[Question or statement text]" + CHR$(34) + "{,|;} variable[, ...] or INPUT ; variable[, ...]": GOTO errmes + IF lineinput = 1 AND numvar > 1 THEN a$ = "Too many variables": GOTO errmes + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + PRINT #12, "qbs_input(" + str2(numvar) + "," + str2$(newline) + ");" + PRINT #12, "if (stop_program) end();" + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + PRINT #12, cleanupstringprocessingcall$ + "0);" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + + + + IF firstelement$ = "WRITE" THEN 'file write + IF n > 1 THEN + IF getelement$(a$, 2) = "#" THEN + xfilewrite ca$, n + IF Error_Happened THEN GOTO errmes + GOTO finishedline + END IF '# + END IF 'n>1 + END IF '"write" + + IF firstelement$ = "WRITE" THEN 'write + xwrite ca$, n + IF Error_Happened THEN GOTO errmes + GOTO finishedline + END IF '"write" + + IF firstelement$ = "PRINT" THEN 'file print + IF n > 1 THEN + IF getelement$(a$, 2) = "#" THEN + xfileprint a$, ca$, n + IF Error_Happened THEN GOTO errmes + l$ = tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF '# + END IF 'n>1 + END IF '"print" + + IF firstelement$ = "PRINT" OR firstelement$ = "LPRINT" THEN + IF secondelement$ <> "USING" THEN 'check to see if we need to auto-add semicolons + elementon = 2 + redosemi: + FOR i = elementon TO n - 1 + nextchar$ = getelement$(a$, i + 1) + IF nextchar$ <> ";" AND nextchar$ <> "," AND nextchar$ <> "+" AND nextchar$ <> ")" THEN + temp1$ = getelement$(a$, i) + beginpoint = INSTR(beginpoint, temp1$, CHR$(34)) + endpoint = INSTR(beginpoint + 1, temp1$, CHR$(34) + ",") + IF beginpoint <> 0 AND endpoint <> 0 THEN 'if we have both positions + 'Quote without semicolon check (like PRINT "abc"123) + textlength = endpoint - beginpoint - 1 + textvalue$ = MID$(temp1$, endpoint + 2, LEN(LTRIM$(STR$(textlength)))) + IF VAL(textvalue$) = textlength THEN + insertelements a$, i, ";" + insertelements ca$, i, ";" + n = n + 1 + elementon = i + 2 'just a easy way to reduce redundant calls to the routine + GOTO redosemi + END IF + END IF + IF temp1$ <> "USING" THEN + IF LEFT$(LTRIM$(nextchar$), 1) = CHR$(34) THEN + IF temp1$ <> ";" AND temp1$ <> "," AND temp1$ <> "+" AND temp1$ <> "(" THEN + insertelements a$, i, ";" + insertelements ca$, i, ";" + n = n + 1 + elementon = i + 2 'just a easy way to reduce redundant calls to the routine + GOTO redosemi + END IF + END IF + END IF + END IF + NEXT + END IF + + xprint a$, ca$, n + IF Error_Happened THEN GOTO errmes + l$ = tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + + + + IF firstelement$ = "CLEAR" THEN + IF subfunc$ <> "" THEN a$ = "CLEAR cannot be used inside a SUB/FUNCTION": GOTO errmes + END IF + + 'LSET/RSET + IF firstelement$ = "LSET" OR firstelement$ = "RSET" THEN + IF n = 1 THEN a$ = "Expected " + firstelement$ + " ...": GOTO errmes + IF firstelement$ = "LSET" THEN l$ = SCase$("LSet") ELSE l$ = SCase$("RSet") + dest$ = "" + source$ = "" + part = 1 + i = 2 + a3$ = "" + B = 0 + DO + IF i > n THEN + IF part <> 2 OR a3$ = "" THEN a$ = "Expected LSET/RSET stringvariable=string": GOTO errmes + source$ = a3$ + EXIT DO + END IF + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN B = B + 1 + IF a2$ = ")" THEN B = B - 1 + IF a2$ = "=" AND B = 0 THEN + IF part = 1 THEN dest$ = a3$: part = 2: a3$ = "": GOTO lrsetgotpart + END IF + IF LEN(a3$) THEN a3$ = a3$ + sp + a2$ ELSE a3$ = a2$ + lrsetgotpart: + i = i + 1 + LOOP + IF dest$ = "" THEN a$ = "Expected LSET/RSET stringvariable=string": GOTO errmes + 'check if it is a valid source string + f$ = fixoperationorder$(dest$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + sp + "=" + e$ = evaluate(f$, sourcetyp) + IF Error_Happened THEN GOTO errmes + IF (sourcetyp AND ISREFERENCE) = 0 OR (sourcetyp AND ISSTRING) = 0 THEN a$ = "LSET/RSET expects a string variable/array-element as its first argument": GOTO errmes + dest$ = evaluatetotyp(f$, ISSTRING) + IF Error_Happened THEN GOTO errmes + source$ = fixoperationorder$(source$) + IF Error_Happened THEN GOTO errmes + l$ = l$ + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + source$ = evaluatetotyp(source$, ISSTRING) + IF Error_Happened THEN GOTO errmes + IF firstelement$ = "LSET" THEN + PRINT #12, "sub_lset(" + dest$ + "," + source$ + ");" + ELSE + PRINT #12, "sub_rset(" + dest$ + "," + source$ + ");" + END IF + GOTO finishedline + END IF + + 'SWAP + IF firstelement$ = "SWAP" THEN + IF n < 4 THEN a$ = "Expected SWAP ... , ...": GOTO errmes + B = 0 + ele = 1 + e1$ = "" + e2$ = "" + FOR i = 2 TO n + e$ = getelement$(ca$, i) + IF e$ = "(" THEN B = B + 1 + IF e$ = ")" THEN B = B - 1 + IF e$ = "," AND B = 0 THEN + IF ele = 2 THEN a$ = "Expected SWAP ... , ...": GOTO errmes + ele = 2 + ELSE + IF ele = 1 THEN e1$ = e1$ + sp + e$ ELSE e2$ = e2$ + sp + e$ + END IF + NEXT + IF e2$ = "" THEN a$ = "Expected SWAP ... , ...": GOTO errmes + e1$ = RIGHT$(e1$, LEN(e1$) - 1): e2$ = RIGHT$(e2$, LEN(e2$) - 1) + + e1$ = fixoperationorder(e1$) + IF Error_Happened THEN GOTO errmes + e1l$ = tlayout$ + e2$ = fixoperationorder(e2$) + IF Error_Happened THEN GOTO errmes + e2l$ = tlayout$ + e1$ = evaluate(e1$, e1typ): e2$ = evaluate(e2$, e2typ) + IF Error_Happened THEN GOTO errmes + IF (e1typ AND ISREFERENCE) = 0 OR (e2typ AND ISREFERENCE) = 0 THEN a$ = "Expected variable": GOTO errmes + + layoutdone = 1 + l$ = SCase$("Swap") + sp + e1l$ + sp2 + "," + sp + e2l$ + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + + 'swap strings? + IF (e1typ AND ISSTRING) THEN + IF (e2typ AND ISSTRING) = 0 THEN a$ = "Type mismatch": GOTO errmes + e1$ = refer(e1$, e1typ, 0): e2$ = refer(e2$, e2typ, 0) + IF Error_Happened THEN GOTO errmes + PRINT #12, "swap_string(" + e1$ + "," + e2$ + ");" + GOTO finishedline + END IF + + 'swap UDT? + 'note: entire UDTs, unlike thier elements cannot be swapped like standard variables + ' as UDT sizes may vary, and to avoid a malloc operation, QB64 should allocate a buffer + ' in global.txt for the purpose of swapping each UDT type + + IF e1typ AND ISUDT THEN + a$ = e1$ + 'retrieve ID + i = INSTR(a$, sp3) + IF i THEN + idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) + getid idnumber + IF Error_Happened THEN GOTO errmes + u = VAL(a$) + i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) + i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) + n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" + IF E = 0 THEN 'not an element of UDT u + lhsscope$ = scope$ + e$ = e2$: t2 = e2typ + IF (t2 AND ISUDT) = 0 THEN a$ = "Expected SWAP with similar user defined type": GOTO errmes + idnumber2 = VAL(e$) + getid idnumber2 + IF Error_Happened THEN GOTO errmes + n2$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n2$ = "ARRAY_" + n2$ + "[0]" + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): u2 = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): e2 = VAL(e$) + + i = INSTR(e$, sp3): o2$ = RIGHT$(e$, LEN(e$) - i) + 'WARNING: u2 may need minor modifications based on e to see if they are the same + IF u <> u2 OR e2 <> 0 THEN a$ = "Expected SWAP with similar user defined type": GOTO errmes + dst$ = "(((char*)" + lhsscope$ + n$ + ")+(" + o$ + "))" + src$ = "(((char*)" + scope$ + n2$ + ")+(" + o2$ + "))" + B = udtxsize(u) \ 8 + siz$ = str2$(B) + IF B = 1 THEN PRINT #12, "swap_8(" + src$ + "," + dst$ + ");" + IF B = 2 THEN PRINT #12, "swap_16(" + src$ + "," + dst$ + ");" + IF B = 4 THEN PRINT #12, "swap_32(" + src$ + "," + dst$ + ");" + IF B = 8 THEN PRINT #12, "swap_64(" + src$ + "," + dst$ + ");" + IF B <> 1 AND B <> 2 AND B <> 4 AND B <> 8 THEN PRINT #12, "swap_block(" + src$ + "," + dst$ + "," + siz$ + ");" + GOTO finishedline + END IF 'e=0 + END IF 'i + END IF 'isudt + + 'cull irrelavent flags to make comparison possible + e1typc = e1typ + IF e1typc AND ISPOINTER THEN e1typc = e1typc - ISPOINTER + IF e1typc AND ISINCONVENTIONALMEMORY THEN e1typc = e1typc - ISINCONVENTIONALMEMORY + IF e1typc AND ISARRAY THEN e1typc = e1typc - ISARRAY + IF e1typc AND ISUNSIGNED THEN e1typc = e1typc - ISUNSIGNED + IF e1typc AND ISUDT THEN e1typc = e1typc - ISUDT + e2typc = e2typ + IF e2typc AND ISPOINTER THEN e2typc = e2typc - ISPOINTER + IF e2typc AND ISINCONVENTIONALMEMORY THEN e2typc = e2typc - ISINCONVENTIONALMEMORY + IF e2typc AND ISARRAY THEN e2typc = e2typc - ISARRAY + IF e2typc AND ISUNSIGNED THEN e2typc = e2typc - ISUNSIGNED + IF e2typc AND ISUDT THEN e2typc = e2typc - ISUDT + IF e1typc <> e2typc THEN a$ = "Type mismatch": GOTO errmes + t = e1typ + IF t AND ISOFFSETINBITS THEN a$ = "Cannot SWAP bit-length variables": GOTO errmes + B = t AND 511 + t$ = str2$(B): IF B > 64 THEN t$ = "longdouble" + PRINT #12, "swap_" + t$ + "(&" + refer(e1$, e1typ, 0) + ",&" + refer(e2$, e2typ, 0) + ");" + IF Error_Happened THEN GOTO errmes + GOTO finishedline + END IF + + IF firstelement$ = "OPTION" THEN + IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" + IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" + IF n = 1 THEN a$ = "Expected OPTION BASE" + e$: GOTO errmes + e$ = getelement$(a$, 2) + SELECT CASE e$ + CASE "BASE" + l$ = getelement$(a$, 3) + IF l$ <> "0" AND l$ <> "1" THEN a$ = "Expected OPTION BASE 0 or 1": GOTO errmes + IF l$ = "1" THEN optionbase = 1 ELSE optionbase = 0 + l$ = SCase$("Option" + sp + "Base") + sp + l$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + CASE "EXPLICIT", "_EXPLICIT" + IF e$ = "EXPLICIT" AND qb64prefix$ = "_" THEN + IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" + IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" + a$ = "Expected OPTION BASE" + e$: GOTO errmes + END IF + + opex_desiredState = -1 + IF optionexplicit = 0 THEN + IF opex_recompileAttempts = 0 THEN + opex_recompileAttempts = opex_recompileAttempts + 1 + GOTO do_recompile + END IF + END IF + + l$ = SCase$("Option") + sp + IF e$ = "EXPLICIT" THEN l$ = l$ + SCase$("Explicit") ELSE l$ = l$ + SCase$("_Explicit") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + CASE "EXPLICITARRAY", "_EXPLICITARRAY" + IF e$ = "EXPLICITARRAY" AND qb64prefix$ = "_" THEN + IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" + IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" + a$ = "Expected OPTION BASE" + e$: GOTO errmes + END IF + + opexarray_desiredState = -1 + IF optionexplicitarray = 0 THEN + IF opexarray_recompileAttempts = 0 THEN + opexarray_recompileAttempts = opexarray_recompileAttempts + 1 + GOTO do_recompile + END IF + END IF + + l$ = SCase$("Option") + sp + IF e$ = "EXPLICITARRAY" THEN l$ = l$ + SCase$("ExplicitArray") ELSE l$ = l$ + SCase$("_ExplicitArray") + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + CASE ELSE + IF optionexplicit = 0 THEN e$ = " or OPTION " + qb64prefix$ + "EXPLICIT" ELSE e$ = "" + IF optionexplicitarray = 0 THEN e$ = e$ + " or OPTION " + qb64prefix$ + "EXPLICITARRAY" + a$ = "Expected OPTION BASE" + e$: GOTO errmes + END SELECT + END IF + + 'any other "unique" subs can be processed above + + id2 = id + + targetid = currentid + + IF RTRIM$(id2.callname) = "sub_stub" THEN a$ = "Command not implemented": GOTO errmes + + IF n > 1 THEN + IF id2.args = 0 THEN a$ = "SUB does not require any arguments": GOTO errmes + END IF + + SetDependency id2.Dependency + + seperateargs_error = 0 + passedneeded = seperateargs(getelements(a$, 2, n), getelements(ca$, 2, n), passed&) + IF seperateargs_error THEN a$ = seperateargs_error_message: GOTO errmes + + 'backup args to local string array space before calling evaluate + FOR i = 1 TO OptMax: separgs2(i) = "": NEXT 'save space! + FOR i = 1 TO OptMax + 1: separgslayout2(i) = "": NEXT + FOR i = 1 TO id2.args: separgs2(i) = separgs(i): NEXT + FOR i = 1 TO id2.args + 1: separgslayout2(i) = separgslayout(i): NEXT + + + + IF Debug THEN + PRINT #9, "separgs:": FOR i = 1 TO id2.args: PRINT #9, i, separgs2(i): NEXT + PRINT #9, "separgslayout:": FOR i = 1 TO id2.args + 1: PRINT #9, i, separgslayout2(i): NEXT + END IF + + + + 'note: seperateargs finds the arguments to pass and sets passed& as necessary + ' FIXOPERTIONORDER is not called on these args yet + ' what we need it to do is build a second array of layout info at the same time + ' ref:DIM SHARED separgslayout(100) AS STRING + ' the above array stores what layout info (if any) goes BEFORE the arg in question + ' it has one extra index which is the arg after + + IF usecall THEN + IF id.internal_subfunc THEN + IF usecall = 1 THEN l$ = SCase$("Call") + sp + SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp2 + "(" + sp2 + IF usecall = 2 THEN l$ = SCase$("Call") + sp + SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp 'sp at end for easy parsing + ELSE + IF usecall = 1 THEN l$ = SCase$("Call") + sp + RTRIM$(id.cn) + RTRIM$(id.musthave) + sp2 + "(" + sp2 + IF usecall = 2 THEN l$ = SCase$("Call") + sp + RTRIM$(id.cn) + RTRIM$(id.musthave) + sp 'sp at end for easy parsing + END IF + ELSE + IF id.internal_subfunc THEN + l$ = SCase$(RTRIM$(id.cn)) + RTRIM$(id.musthave) + sp + ELSE + l$ = RTRIM$(id.cn) + RTRIM$(id.musthave) + sp + END IF + END IF + + subcall$ = RTRIM$(id.callname) + "(" + addedlayout = 0 + + fieldcall = 0 + 'GET/PUT field exception + IF RTRIM$(id2.callname) = "sub_get" OR RTRIM$(id2.callname) = "sub_put" THEN + IF passed AND 2 THEN + 'regular GET/PUT call with variable provided + passed = passed - 2 'for complience with existing methods, remove 'passed' flag for the passing of a variable + ELSE + 'FIELD GET/PUT call with variable omited + IF RTRIM$(id2.callname) = "sub_get" THEN + fieldcall = 1 + subcall$ = "field_get(" + ELSE + fieldcall = 2 + subcall$ = "field_put(" + END IF + END IF + END IF 'field exception + + IF RTRIM$(id2.callname) = "sub_timer" OR RTRIM$(id2.callname) = "sub_key" THEN 'spacing exception + IF usecall = 0 THEN + l$ = LEFT$(l$, LEN(l$) - 1) + sp2 + END IF + END IF + + FOR i = 1 TO id2.args + targettyp = CVL(MID$(id2.arg, -3 + i * 4, 4)) + nele = ASC(MID$(id2.nele, i, 1)) + nelereq = ASC(MID$(id2.nelereq, i, 1)) + + addlayout = 1 'omits option values in layout (eg. BINARY="2") + convertspacing = 0 'if an 'equation' is next, it will be preceeded by a space + x$ = separgslayout2$(i) + DO WHILE LEN(x$) + x = ASC(x$) + IF x THEN + convertspacing = 0 + x2$ = MID$(x$, 2, x) + x$ = RIGHT$(x$, LEN(x$) - x - 1) + + s = 0 + an = 0 + x3$ = RIGHT$(l$, 1) + IF x3$ = sp THEN s = 1 + IF x3$ = sp2 THEN + s = 2 + IF alphanumeric(ASC(RIGHT$(l$, 2))) THEN an = 1 + ELSE + IF alphanumeric(ASC(x3$)) THEN an = 1 + END IF + s1 = s + + IF alphanumeric(ASC(x2$)) THEN convertspacing = 1 + + + IF x2$ = "LPRINT" THEN + + 'x2$="LPRINT" + 'x$=CHR$(0) + 'x3$=[sp] from WIDTH[sp] + 'therefore... + 's=1 + 'an=0 + 'convertspacing=1 + + + 'if debug=1 then + 'print #9,"LPRINT:" + 'print #9,s + 'print #9,an + 'print #9,l$ + 'print #9,x2$ + 'end if + + END IF + + + + + IF (an = 1 OR addedlayout = 1) AND alphanumeric(ASC(x2$)) <> 0 THEN + + + + s = 1 'force space + x2$ = x2$ + sp2 + GOTO customlaychar + END IF + + IF x2$ = "=" THEN + s = 1 + x2$ = x2$ + sp + GOTO customlaychar + END IF + + IF x2$ = "#" THEN + s = 1 + x2$ = x2$ + sp2 + GOTO customlaychar + END IF + + IF x2$ = "," THEN x2$ = x2$ + sp: GOTO customlaychar + + + IF x$ = CHR$(0) THEN 'substitution + IF x2$ = "STEP" THEN x2$ = x2$ + sp2: GOTO customlaychar + x2$ = x2$ + sp: GOTO customlaychar + END IF + + 'default solution sp2+?+sp2 + x2$ = x2$ + sp2 + + + + + + customlaychar: + IF s = 0 THEN s = 2 + IF s <> s1 THEN + IF s1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + IF s = 1 THEN l$ = l$ + sp + IF s = 2 THEN l$ = l$ + sp2 + END IF + + IF (RTRIM$(id2.callname) = "sub_timer" OR RTRIM$(id2.callname) = "sub_key") AND i = id2.args THEN 'spacing exception + IF x2$ <> ")" + sp2 THEN + l$ = LEFT$(l$, LEN(l$) - 1) + sp + END IF + END IF + + l$ = l$ + x2$ + + ELSE + addlayout = 0 + x$ = RIGHT$(x$, LEN(x$) - 1) + END IF + addedlayout = 0 + LOOP + + + + '---better sub syntax checking begins here--- + + + + IF targettyp = -3 THEN + IF separgs2(i) = "N-LL" THEN a$ = "Expected array name": GOTO errmes + 'names of numeric arrays have ( ) automatically appended (nothing else) + e$ = separgs2(i) + + IF INSTR(e$, sp) = 0 THEN 'one element only + try_string$ = e$ + try = findid(try_string$) + IF Error_Happened THEN GOTO errmes + DO + IF try THEN + IF id.arraytype THEN + IF (id.arraytype AND ISSTRING) = 0 THEN + e$ = e$ + sp + "(" + sp + ")" + EXIT DO + END IF + END IF + '--- + IF try = 2 THEN findanotherid = 1: try = findid(try_string$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + END IF 'if try + IF try = 0 THEN 'add symbol? + IF LEN(removesymbol$(try_string$)) = 0 THEN + IF Error_Happened THEN GOTO errmes + a = ASC(try_string$) + IF a >= 97 AND a <= 122 THEN a = a - 32 + IF a = 95 THEN a = 91 + a = a - 64 + IF LEN(defineextaz(a)) THEN try_string$ = try_string$ + defineextaz(a): try = findid(try_string$) + IF Error_Happened THEN GOTO errmes + END IF + END IF 'try=0 + LOOP UNTIL try = 0 + END IF 'one element only + + + + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp + IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 + e$ = evaluatetotyp(e$, -2) + IF Error_Happened THEN GOTO errmes + GOTO sete + END IF '-3 + + + IF targettyp = -2 THEN + e$ = fixoperationorder$(e$) + IF Error_Happened THEN GOTO errmes + IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp + IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 + e$ = evaluatetotyp(e$, -2) + IF Error_Happened THEN GOTO errmes + GOTO sete + END IF '-2 + + IF targettyp = -4 THEN + + IF fieldcall THEN + i = id2.args + 1 + EXIT FOR + END IF + + IF separgs2(i) = "N-LL" THEN a$ = "Expected variable name/array element": GOTO errmes + e$ = fixoperationorder$(separgs2(i)) + IF Error_Happened THEN GOTO errmes + IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp + IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 + + 'GET/PUT RANDOM-ACCESS override + IF firstelement$ = "GET" OR firstelement$ = "PUT" THEN + e2$ = e$ 'backup + e$ = evaluate(e$, sourcetyp) + IF Error_Happened THEN GOTO errmes + IF (sourcetyp AND ISSTRING) THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + 'replace name of sub to call + subcall$ = RIGHT$(subcall$, LEN(subcall$) - 7) 'delete original name + 'note: GET2 & PUT2 take differing input, following code is correct + IF firstelement$ = "GET" THEN + subcall$ = "sub_get2" + subcall$ + e$ = refer(e$, sourcetyp, 0) 'pass a qbs pointer instead + IF Error_Happened THEN GOTO errmes + GOTO sete + ELSE + subcall$ = "sub_put2" + subcall$ + 'no goto sete required, fall through + END IF + END IF + END IF + e$ = e2$ 'restore + END IF 'override + + e$ = evaluatetotyp(e$, -4) + IF Error_Happened THEN GOTO errmes + GOTO sete + END IF '-4 + + IF separgs2(i) = "N-LL" THEN + e$ = "NULL" + ELSE + + e2$ = fixoperationorder$(separgs2(i)) + IF Error_Happened THEN GOTO errmes + IF convertspacing = 1 AND addlayout = 1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + sp + IF addlayout THEN l$ = l$ + tlayout$: addedlayout = 1 + + e$ = evaluate(e2$, sourcetyp) + IF Error_Happened THEN GOTO errmes + + IF sourcetyp AND ISOFFSET THEN + IF (targettyp AND ISOFFSET) = 0 THEN + IF id2.internal_subfunc = 0 THEN a$ = "Cannot convert _OFFSET type to other types": GOTO errmes + END IF + END IF + + IF RTRIM$(id2.callname) = "sub_paint" THEN + IF i = 3 THEN + IF (sourcetyp AND ISSTRING) THEN + targettyp = ISSTRING + END IF + END IF + END IF + + IF LEFT$(separgs2(i), 2) = "(" + sp THEN dereference = 1 ELSE dereference = 0 + + 'pass by reference + IF (targettyp AND ISPOINTER) THEN + IF dereference = 0 THEN 'check deferencing wasn't used + + 'note: array pointer + IF (targettyp AND ISARRAY) THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN a$ = "Expected arrayname()": GOTO errmes + IF (sourcetyp AND ISARRAY) = 0 THEN a$ = "Expected arrayname()": GOTO errmes + IF Debug THEN PRINT #9, "sub:array reference:[" + e$ + "]" + + 'check arrays are of same type + targettyp2 = targettyp: sourcetyp2 = sourcetyp + targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) + sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) + IF sourcetyp2 <> targettyp2 THEN a$ = "Incorrect array type passed to sub": GOTO errmes + + 'check arrayname was followed by '()' + IF targettyp AND ISUDT THEN + IF Debug THEN PRINT #9, "sub:array reference:udt reference:[" + e$ + "]" + 'get UDT info + udtrefid = VAL(e$) + getid udtrefid + IF Error_Happened THEN GOTO errmes + udtrefi = INSTR(e$, sp3) 'end of id + udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u + udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) + udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e + udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) + o$ = RIGHT$(e$, LEN(e$) - udtrefi3) + 'note: most of the UDT info above is not required + IF LEFT$(o$, 4) <> "(0)*" THEN a$ = "Expected arrayname()": GOTO errmes + ELSE + IF RIGHT$(e$, 2) <> sp3 + "0" THEN a$ = "Expected arrayname()": GOTO errmes + END IF + + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) + getid idnum + IF Error_Happened THEN GOTO errmes + + IF targettyp AND ISFIXEDLENGTH THEN + targettypsize = CVL(MID$(id2.argsize, i * 4 - 4 + 1, 4)) + IF id.tsize <> targettypsize THEN a$ = "Incorrect array type passed to sub": GOTO errmes + END IF + + IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + recompile = 1 + END IF + END IF + + IF id.linkid = 0 THEN + 'if id.linkid is 0, it means the number of array elements is definietly + 'known of the array being passed, this is not some "fake"/unknown array. + 'using the numer of array elements of a fake array would be dangerous! + + + IF nelereq = 0 THEN + 'only continue if the number of array elements required is unknown + 'and it needs to be set + + IF id.arrayelements > 0 THEN '2009 + + nelereq = id.arrayelements + MID$(id2.nelereq, i, 1) = CHR$(nelereq) + + END IF + + 'print rtrim$(id2.n)+">nelereq=";nelereq + + ids(targetid) = id2 + + ELSE + + 'the number of array elements required is known AND + 'the number of elements in the array to be passed is known + + IF id.arrayelements <> nelereq THEN a$ = "Passing arrays with a differing number of elements to a SUB/FUNCTION is not supported": GOTO errmes + + + END IF + END IF + + e$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN GOTO errmes + GOTO sete + + END IF 'target is an array + + 'note: not an array... + 'target is not an array + + IF (targettyp AND ISSTRING) = 0 THEN + IF (sourcetyp AND ISREFERENCE) THEN + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp + + targettyp2 = targettyp: sourcetyp2 = sourcetyp + + 'get info about source/target + arr = 0: IF (sourcetyp2 AND ISARRAY) THEN arr = 1 + passudtelement = 0: IF (targettyp2 AND ISUDT) = 0 AND (sourcetyp2 AND ISUDT) <> 0 THEN passudtelement = 1: sourcetyp2 = sourcetyp2 - ISUDT + + 'remove flags irrelevant for comparison... ISPOINTER,ISREFERENCE,ISINCONVENTIONALMEMORY,ISARRAY + targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) + sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) + + 'compare types + IF sourcetyp2 = targettyp2 THEN + + IF sourcetyp AND ISUDT THEN + 'udt/udt array + + 'get info + udtrefid = VAL(e$) + getid udtrefid + IF Error_Happened THEN GOTO errmes + udtrefi = INSTR(e$, sp3) 'end of id + udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u + udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) + udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e + udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) + o$ = RIGHT$(e$, LEN(e$) - udtrefi3) + 'note: most of the UDT info above is not required + + IF arr THEN + n$ = scope$ + "ARRAY_UDT_" + RTRIM$(id.n) + "[0]" + ELSE + n$ = scope$ + "UDT_" + RTRIM$(id.n) + END IF + + e$ = "(void*)( ((char*)(" + n$ + ")) + (" + o$ + ") )" + + 'convert void* to target type* + IF passudtelement THEN e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ + IF Error_Happened THEN GOTO errmes + + ELSE + 'not a udt + IF arr THEN + IF (sourcetyp2 AND ISOFFSETINBITS) THEN a$ = "Cannot pass BIT array offsets": GOTO errmes + e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" + IF Error_Happened THEN GOTO errmes + ELSE + e$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN GOTO errmes + END IF + + 'note: signed/unsigned mismatch requires casting + IF (sourcetyp AND ISUNSIGNED) <> (targettyp AND ISUNSIGNED) THEN + e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ + IF Error_Happened THEN GOTO errmes + END IF + + END IF 'udt? + + IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + recompile = 1 + END IF + END IF + + GOTO sete + END IF 'similar + END IF 'reference + ELSE 'not a string + 'its a string + IF (sourcetyp AND ISREFERENCE) THEN + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp + IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + recompile = 1 + END IF + END IF + END IF 'reference + END IF 'its a string + + END IF 'dereference check + END IF 'target is a pointer + + 'note: Target is not a pointer... + + 'String-numeric mismatch? + IF targettyp AND ISSTRING THEN + IF (sourcetyp AND ISSTRING) = 0 THEN + nth = i + IF ids(targetid).args = 1 THEN a$ = "String required for sub": GOTO errmes + a$ = str_nth$(nth) + " sub argument requires a string": GOTO errmes + END IF + END IF + IF (targettyp AND ISSTRING) = 0 THEN + IF sourcetyp AND ISSTRING THEN + nth = i + IF ids(targetid).args = 1 THEN a$ = "Number required for sub": GOTO errmes + a$ = str_nth$(nth) + " sub argument requires a number": GOTO errmes + END IF + END IF + + 'change to "non-pointer" value + IF (sourcetyp AND ISREFERENCE) THEN + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN GOTO errmes + END IF + + IF explicitreference = 0 THEN + IF targettyp AND ISUDT THEN + nth = i + IF qb64prefix_set AND udtxcname(targettyp AND 511) = "_MEM" THEN + x$ = "'" + MID$(RTRIM$(udtxcname(targettyp AND 511)), 2) + "'" + ELSE + x$ = "'" + RTRIM$(udtxcname(targettyp AND 511)) + "'" + END IF + IF ids(targetid).args = 1 THEN a$ = "TYPE " + x$ + " required for sub": GOTO errmes + a$ = str_nth$(nth) + " sub argument requires TYPE " + x$: GOTO errmes + END IF + ELSE + IF sourcetyp AND ISUDT THEN a$ = "Number required for sub": GOTO errmes + END IF + + 'round to integer if required + IF (sourcetyp AND ISFLOAT) THEN + IF (targettyp AND ISFLOAT) = 0 THEN + '**32 rounding fix + bits = targettyp AND 511 + IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" + IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" + IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" + END IF + END IF + + IF (targettyp AND ISPOINTER) THEN 'pointer required + IF (targettyp AND ISSTRING) THEN GOTO sete 'no changes required + t$ = typ2ctyp$(targettyp, "") + IF Error_Happened THEN GOTO errmes + v$ = "pass" + str2$(uniquenumber) + 'assume numeric type + IF MID$(sfcmemargs(targetid), i, 1) = CHR$(1) THEN 'cmem required? + bytesreq = ((targettyp AND 511) + 7) \ 8 + PRINT #defdatahandle, t$ + " *" + v$ + "=NULL;" + PRINT #13, "if(" + v$ + "==NULL){" + PRINT #13, "cmem_sp-=" + str2(bytesreq) + ";" + PRINT #13, v$ + "=(" + t$ + "*)(dblock+cmem_sp);" + PRINT #13, "if (cmem_spchr" + END IF + + IF LTRIM$(RTRIM$(e$)) = "0" THEN e$ = "NULL" + + END IF + + IF i <> 1 THEN subcall$ = subcall$ + "," + subcall$ = subcall$ + e$ + NEXT + + 'note: i=id.args+1 + x$ = separgslayout2$(i) + DO WHILE LEN(x$) + x = ASC(x$) + IF x THEN + x2$ = MID$(x$, 2, x) + x$ = RIGHT$(x$, LEN(x$) - x - 1) + + s = 0 + an = 0 + x3$ = RIGHT$(l$, 1) + IF x3$ = sp THEN s = 1 + IF x3$ = sp2 THEN + s = 2 + IF alphanumeric(ASC(RIGHT$(l$, 2))) THEN an = 1 + 'if asc(right$(l$,2))=34 then an=1 + ELSE + IF alphanumeric(ASC(x3$)) THEN an = 1 + 'if asc(x3$)=34 then an=1 + END IF + s1 = s + + IF (an = 1 OR addedlayout = 1) AND alphanumeric(ASC(x2$)) <> 0 THEN + s = 1 'force space + x2$ = x2$ + sp2 + GOTO customlaychar2 + END IF + + IF x2$ = "=" THEN + s = 1 + x2$ = x2$ + sp + GOTO customlaychar2 + END IF + + IF x2$ = "#" THEN + s = 1 + x2$ = x2$ + sp2 + GOTO customlaychar2 + END IF + + IF x2$ = "," THEN x2$ = x2$ + sp: GOTO customlaychar2 + + IF x$ = CHR$(0) THEN 'substitution + IF x2$ = "STEP" THEN x2$ = SCase$("Step") + sp2: GOTO customlaychar2 + x2$ = x2$ + sp: GOTO customlaychar2 + END IF + + 'default solution sp2+?+sp2 + x2$ = x2$ + sp2 + customlaychar2: + IF s = 0 THEN s = 2 + IF s <> s1 THEN + IF s1 THEN l$ = LEFT$(l$, LEN(l$) - 1) + IF s = 1 THEN l$ = l$ + sp + IF s = 2 THEN l$ = l$ + sp2 + END IF + l$ = l$ + x2$ + + ELSE + addlayout = 0 + x$ = RIGHT$(x$, LEN(x$) - 1) + END IF + addedlayout = 0 + LOOP + + + + + + + IF passedneeded THEN + subcall$ = subcall$ + "," + str2$(passed&) + END IF + subcall$ = subcall$ + ");" + + IF firstelement$ = "SLEEP" THEN + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + END IF + + PRINT #12, subcall$ + + IF firstelement$ = "SLEEP" THEN + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + END IF + + subcall$ = "" + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + + layoutdone = 1 + x$ = RIGHT$(l$, 1): IF x$ = sp OR x$ = sp2 THEN l$ = LEFT$(l$, LEN(l$) - 1) + IF usecall = 1 THEN l$ = l$ + sp2 + ")" + IF Debug THEN PRINT #9, "SUB layout:[" + l$ + "]" + IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ + GOTO finishedline + + + END IF + + IF try = 2 THEN + findidsecondarg = "": IF n >= 2 THEN findidsecondarg = getelement$(a$, 2) + findanotherid = 1 + try = findid(firstelement$) + IF Error_Happened THEN GOTO errmes + ELSE + try = 0 + END IF + LOOP + + END IF + + notsubcall: + + IF n >= 1 THEN + IF firstelement$ = "LET" THEN + IF n = 1 THEN a$ = "Syntax error - Reference: LET variable = expression (tip: LET is entirely optional)": GOTO errmes + ca$ = RIGHT$(ca$, LEN(ca$) - 4) + n = n - 1 + l$ = SCase$("Let") + IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + 'note: layoutdone=1 will be set later + GOTO letused + END IF + END IF + + 'LET ???=??? + IF n >= 3 THEN + IF INSTR(a$, sp + "=" + sp) THEN + letused: + assign ca$, n + IF Error_Happened THEN GOTO errmes + layoutdone = 1 + IF LEN(layout$) = 0 THEN layout$ = tlayout$ ELSE layout$ = layout$ + sp + tlayout$ + GOTO finishedline + END IF + END IF '>=3 + IF RIGHT$(a$, 2) = sp + "=" THEN a$ = "Expected ... = expression": GOTO errmes + + 'Syntax error + a$ = "Syntax error": GOTO errmes + + finishedline: + THENGOTO = 0 + finishedline2: + + IF inputfunctioncalled THEN + inputfunctioncalled = 0 + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -5; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + END IF + + IF arrayprocessinghappened = 1 THEN arrayprocessinghappened = 0 + + inclinenump$ = "" + IF inclinenumber(inclevel) THEN + inclinenump$ = "," + str2$(inclinenumber(inclevel)) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34) + END IF + IF NoChecks = 0 THEN + IF vWatchOn AND inclinenumber(inclevel) = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = "" + IF dynscope THEN + dynscope = 0 + PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");if(r)goto S_" + str2$(statementn) + ";}" + ELSE + PRINT #12, "if(!qbevent)break;" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}while(r);" + END IF + END IF + + finishednonexec: + + firstLine = 0 + + IF layoutdone = 0 THEN layoutok = 0 'invalidate layout if not handled + + IF continuelinefrom = 0 THEN 'note: manager #2 requires this condition + + 'Include Manager #2 '*** + IF LEN(addmetainclude$) THEN + + IF inclevel = 0 THEN + 'backup line formatting + layoutcomment_backup$ = layoutcomment$ + layoutok_backup = layoutok + layout_backup$ = layout$ + END IF + + a$ = addmetainclude$: addmetainclude$ = "" 'read/clear message + + IF inclevel = 0 THEN + includingFromRoot = 0 + forceIncludingFile = 0 + forceInclude: + IF forceIncludeFromRoot$ <> "" THEN + a$ = forceIncludeFromRoot$ + forceIncludeFromRoot$ = "" + forceIncludingFile = 1 + includingFromRoot = 1 + END IF + END IF + + IF inclevel = 100 THEN a$ = "Too many indwelling INCLUDE files": GOTO errmes + '1. Verify file exists (location is either (a)relative to source file or (b)absolute) + fh = 99 + inclevel + 1 + + firstTryMethod = 1 + IF includingFromRoot <> 0 AND inclevel = 0 THEN firstTryMethod = 2 + FOR try = firstTryMethod TO 2 'if including file from root, do not attempt including from relative location + IF try = 1 THEN + IF inclevel = 0 THEN + IF idemode THEN p$ = idepath$ + pathsep$ ELSE p$ = getfilepath$(sourcefile$) + ELSE + p$ = getfilepath$(incname(inclevel)) + END IF + f$ = p$ + a$ + END IF + IF try = 2 THEN f$ = a$ + IF _FILEEXISTS(f$) THEN + qberrorhappened = -2 '*** + OPEN f$ FOR BINARY AS #fh + qberrorhappened2: '*** + IF qberrorhappened = -2 THEN EXIT FOR '*** + END IF + qberrorhappened = 0 + NEXT + IF qberrorhappened <> -2 THEN qberrorhappened = 0: a$ = "File " + a$ + " not found": GOTO errmes + inclevel = inclevel + 1: incname$(inclevel) = f$: inclinenumber(inclevel) = 0 + END IF 'fall through to next section... + '-------------------- + DO WHILE inclevel + fh = 99 + inclevel + '2. Feed next line + IF EOF(fh) = 0 THEN + LINE INPUT #fh, x$ + a3$ = x$ + continuelinefrom = 0 + inclinenumber(inclevel) = inclinenumber(inclevel) + 1 + 'create extended error string 'incerror$' + errorLineInInclude = inclinenumber(inclevel) + e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" + IF inclevel > 1 THEN + e$ = e$ + " (through " + FOR x = 1 TO inclevel - 1 STEP 1 + e$ = e$ + incname$(x) + IF x < inclevel - 1 THEN 'a sep is req + IF x = inclevel - 2 THEN + e$ = e$ + " then " + ELSE + e$ = e$ + ", " + END IF + END IF + NEXT + e$ = e$ + ")" + END IF + incerror$ = e$ + linenumber = linenumber - 1 'lower official linenumber to counter later increment + IF idemode THEN sendc$ = CHR$(10) + a3$: GOTO sendcommand 'passback + GOTO includeline + END IF + '3. Close & return control + CLOSE #fh + inclevel = inclevel - 1 + IF inclevel = 0 THEN + IF forceIncludingFile = 1 THEN + forceIncludingFile = 0 + GOTO forceIncludeCompleted + END IF + 'restore line formatting + layoutok = layoutok_backup + layout$ = layout_backup$ + layoutcomment$ = layoutcomment_backup$ + END IF + LOOP 'fall through to next section... + '(end manager) + + + + END IF 'continuelinefrom=0 + + + IF Debug THEN + PRINT #9, "[layout check]" + PRINT #9, "[" + layoutoriginal$ + "]" + PRINT #9, "[" + layout$ + "]" + PRINT #9, layoutok + PRINT #9, "[end layout check]" + END IF + + + + + IF idemode THEN + IF continuelinefrom <> 0 THEN GOTO ide4 'continue processing other commands on line + + IF LEN(layoutcomment$) THEN + IF LEN(layout$) THEN layout$ = layout$ + sp + layoutcomment$ ELSE layout$ = layoutcomment$ + END IF + + IF layoutok = 0 THEN + layout$ = layoutoriginal$ + ELSE + + 'reverse '046' changes present in autolayout + 'replace fix046$ with . + i = INSTR(layout$, fix046$) + DO WHILE i + layout$ = LEFT$(layout$, i - 1) + "." + RIGHT$(layout$, LEN(layout$) - (i + LEN(fix046$) - 1)) + i = INSTR(layout$, fix046$) + LOOP + + END IF + x = lhscontrollevel: IF controllevel < lhscontrollevel THEN x = controllevel + IF definingtype = 2 THEN x = x + 1 + IF definingtype > 0 THEN definingtype = 2 + IF declaringlibrary = 2 THEN x = x + 1 + IF declaringlibrary > 0 THEN declaringlibrary = 2 + layout$ = SPACE$(x) + layout$ + IF linecontinuation THEN layout$ = "" + + GOTO ideret4 'return control to IDE + END IF + + 'layout is not currently used by the compiler (as appose to the IDE), if it was it would be used here + skipide4: +LOOP + +'add final line +IF lastLineReturn = 0 THEN + lastLineReturn = 1 + lastLine = 1 + wholeline$ = "" + GOTO mainpassLastLine +END IF + +ide5: +linenumber = 0 + +IF closedmain = 0 THEN closemain + +IF definingtype THEN linenumber = definingtypeerror: a$ = "TYPE without END TYPE": GOTO errmes + +'check for open controls (copy #1) +IF controllevel THEN + a$ = "Unidentified open control block" + SELECT CASE controltype(controllevel) + CASE 1: a$ = "IF without END IF" + CASE 2: a$ = "FOR without NEXT" + CASE 3, 4: a$ = "DO without LOOP" + CASE 5: a$ = "WHILE without WEND" + CASE 6: a$ = "$IF without $END IF" + CASE 10 TO 19: a$ = "SELECT CASE without END SELECT" + CASE 32: a$ = "SUB/FUNCTION without END SUB/FUNCTION" + END SELECT + linenumber = controlref(controllevel) + GOTO errmes +END IF + +IF ideindentsubs = 0 THEN + IF LEN(subfunc) THEN a$ = "SUB/FUNCTION without END SUB/FUNCTION": GOTO errmes +END IF + +'close the error handler (cannot be put in 'closemain' because subs/functions can also add error jumps to this file) +PRINT #14, "exit(99);" 'in theory this line should never be run! +PRINT #14, "}" 'close error jump handler + +'create CLEAR method "CLEAR" +CLOSE #12 'close code handle +OPEN tmpdir$ + "clear.txt" FOR OUTPUT AS #12 'direct code to clear.txt + +FOR i = 1 TO idn + + IF ids(i).staticscope THEN 'static scope? + subfunc = RTRIM$(ids(i).insubfunc) 'set static scope + GOTO clearstaticscope + END IF + + a = ASC(ids(i).insubfunc) + IF a = 0 OR a = 32 THEN 'global scope? + subfunc = "" 'set global scope + clearstaticscope: + + IF ids(i).arraytype THEN 'an array + getid i + IF Error_Happened THEN GOTO errmes + IF id.arrayelements = -1 THEN GOTO clearerasereturned 'cannot erase non-existant array + IF INSTR(vWatchVariableExclusions$, "@" + RTRIM$(id.callname) + "@") > 0 THEN + GOTO clearerasereturned + END IF + clearerasereturn = 1: GOTO clearerase + END IF 'array + + IF ids(i).t THEN 'non-array variable + getid i + IF Error_Happened THEN GOTO errmes + bytes$ = variablesize$(-1) + IF Error_Happened THEN GOTO errmes + 'create a reference + typ = id.t + ISREFERENCE + IF typ AND ISUDT THEN + e$ = str2(i) + sp3 + str2(typ AND 511) + sp3 + "0" + sp3 + "0" + ELSE + e$ = str2(i) + END IF + e$ = refer$(e$, typ, 1) + IF Error_Happened THEN GOTO errmes + IF typ AND ISSTRING THEN + IF typ AND ISFIXEDLENGTH THEN + PRINT #12, "memset((void*)(" + e$ + "->chr),0," + bytes$ + ");" + GOTO cleared + ELSE + IF INSTR(vWatchVariableExclusions$, "@" + e$ + "@") = 0 AND LEFT$(e$, 12) <> "_SUB_VWATCH_" THEN + PRINT #12, e$ + "->len=0;" + END IF + GOTO cleared + END IF + END IF + IF typ AND ISUDT THEN + IF udtxvariable(typ AND 511) THEN + 'this next procedure resets values of UDT variables with variable-length strings + clear_udt_with_varstrings e$, typ AND 511, 12, 0 + ELSE + PRINT #12, "memset((void*)" + e$ + ",0," + bytes$ + ");" + END IF + ELSE + IF INSTR(vWatchVariableExclusions$, "@" + e$ + "@") = 0 AND LEFT$(e$, 12) <> "_SUB_VWATCH_" THEN + PRINT #12, "*" + e$ + "=0;" + END IF + END IF + GOTO cleared + END IF 'non-array variable + + END IF 'scope + + cleared: + clearerasereturned: +NEXT +CLOSE #12 + +IF Debug THEN + PRINT #9, "finished making program!" + PRINT #9, "recompile="; recompile +END IF + +'Set cmem flags for subs/functions requiring data passed in cmem +FOR i = 1 TO idn + IF cmemlist(i) THEN 'must be in cmem + + getid i + IF Error_Happened THEN GOTO errmes + + IF Debug THEN PRINT #9, "recompiling cmem sf! checking:"; RTRIM$(id.n) + + IF id.sfid THEN 'it is an argument of a sub/function + + IF Debug THEN PRINT #9, "recompiling cmem sf! It's a sub/func arg!" + + i2 = id.sfid + x = id.sfarg + + IF Debug THEN PRINT #9, "recompiling cmem sf! values:"; i2; x + + 'check if cmem flag is set, if not then set it & force recompile + IF MID$(sfcmemargs(i2), x, 1) <> CHR$(1) THEN + MID$(sfcmemargs(i2), x, 1) = CHR$(1) + + + IF Debug THEN PRINT #9, "recompiling cmem sf! setting:"; i2; x + + + recompile = 1 + END IF + END IF + END IF +NEXT i + +unresolved = 0 +FOR i = 1 TO idn + getid i + IF Error_Happened THEN GOTO errmes + + IF Debug THEN PRINT #9, "checking id named:"; id.n + + IF id.subfunc THEN + FOR i2 = 1 TO id.args + t = CVL(MID$(id.arg, i2 * 4 - 3, 4)) + IF t > 0 THEN + IF (t AND ISPOINTER) THEN + IF (t AND ISARRAY) THEN + + IF Debug THEN PRINT #9, "checking argument "; i2; " of "; id.args + + nele = ASC(MID$(id.nele, i2, 1)) + nelereq = ASC(MID$(id.nelereq, i2, 1)) + + IF Debug THEN PRINT #9, "nele="; nele + IF Debug THEN PRINT #9, "nelereq="; nelereq + + IF nele <> nelereq THEN + + IF Debug THEN PRINT #9, "mismatch detected!" + + unresolved = unresolved + 1 + sflistn = sflistn + 1 + sfidlist(sflistn) = i + sfarglist(sflistn) = i2 + sfelelist(sflistn) = nelereq '0 means still unknown + END IF + END IF + END IF + END IF + NEXT + END IF +NEXT + +'is recompilation required to resolve this? +IF unresolved > 0 THEN + IF lastunresolved = -1 THEN + 'first pass + recompile = 1 + IF Debug THEN + PRINT #9, "recompiling to resolve array elements (first time)" + PRINT #9, "sflistn="; sflistn + PRINT #9, "oldsflistn="; oldsflistn + END IF + ELSE + 'not first pass + IF unresolved < lastunresolved THEN + recompile = 1 + IF Debug THEN + PRINT #9, "recompiling to resolve array elements (not first time)" + PRINT #9, "sflistn="; sflistn + PRINT #9, "oldsflistn="; oldsflistn + END IF + END IF + END IF +END IF 'unresolved +lastunresolved = unresolved + +'IDEA! +'have a flag to record if anything gets resolved in a pass +'if not then it's time to stop +'the problem is the same amount of new problems may be created by a +'resolve as those that get fixed +'also/or.. could it be that previous fixes are overridden in a recompile +' by a new fix? if so, it would give these effects + + + +'could recompilation resolve this? +'IF sflistn <> -1 THEN +'IF sflistn <> oldsflistn THEN +'recompile = 1 +' +'if debug then +'print #9,"recompile set to 1 to resolve array elements" +'print #9,"sflistn=";sflistn +'print #9,"oldsflistn=";oldsflistn +'end if +' +'END IF +'END IF + +IF Debug THEN PRINT #9, "Beginning COMMON array list check..." +xi = 1 +FOR x = 1 TO commonarraylistn + varname$ = getelement$(commonarraylist, xi): xi = xi + 1 + typ$ = getelement$(commonarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + 'find the array ID (try method) + t = typname2typ(typ$) + IF Error_Happened THEN GOTO errmes + IF (t AND ISUDT) = 0 THEN varname$ = varname$ + type2symbol$(typ$) + IF Error_Happened THEN GOTO errmes + + IF Debug THEN PRINT #9, "Checking for array '" + varname$ + "'..." + + try = findid(varname$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.arraytype THEN GOTO foundcommonarray2 + IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + foundcommonarray2: + + IF Debug THEN PRINT #9, "Found array '" + varname$ + "!" + + IF id.arrayelements = -1 THEN + IF arrayelementslist(currentid) <> 0 THEN recompile = 1 + IF Debug THEN PRINT #9, "Recompiling to resolve elements of:" + varname$ + END IF +NEXT +IF Debug THEN PRINT #9, "Finished COMMON array list check!" + +IF vWatchDesiredState <> vWatchOn THEN + vWatchRecompileAttempts = vWatchRecompileAttempts + 1 + recompile = 1 +END IF + +IF recompile THEN + do_recompile: + IF Debug THEN PRINT #9, "Recompile required!" + recompile = 0 + IF idemode THEN iderecompile = 1 + FOR closeall = 1 TO 255: CLOSE closeall: NEXT + OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock + GOTO recompile +END IF + +IF Debug THEN PRINT #9, "Beginning label check..." +FOR r = 1 TO nLabels + + IF Labels(r).Scope_Restriction THEN + a$ = RTRIM$(Labels(r).cn) + ignore = validlabel(a$) + v = HashFind(a$, HASHFLAG_LABEL, ignore, r2) + addlabchk7: + IF v THEN + IF Labels(r2).Scope = Labels(r).Scope_Restriction THEN + linenumber = Labels(r).Error_Line: a$ = "Common label within a SUB/FUNCTION": GOTO errmes + END IF + IF v = 2 THEN v = HashFindCont(ignore, r2): GOTO addlabchk7 + END IF 'v + END IF 'restriction + + 'check for undefined labels + IF Labels(r).State = 0 THEN + + IF INSTR(PossibleSubNameLabels$, sp + UCASE$(RTRIM$(Labels(r).cn)) + sp) THEN + IF INSTR(SubNameLabels$, sp + UCASE$(RTRIM$(Labels(r).cn)) + sp) = 0 THEN 'not already added + SubNameLabels$ = SubNameLabels$ + UCASE$(RTRIM$(Labels(r).cn)) + sp + IF Debug THEN PRINT #9, "Recompiling to resolve label:"; RTRIM$(Labels(r).cn) + GOTO do_recompile + END IF + END IF + + linenumber = Labels(r).Error_Line: a$ = "Label '" + RTRIM$(Labels(r).cn) + "' not defined": GOTO errmes + END IF + + + IF Labels(r).Data_Referenced THEN + + 'check for ambiguous RESTORE reference + x = 0 + a$ = RTRIM$(Labels(r).cn) + ignore = validlabel(a$) + v = HashFind(a$, HASHFLAG_LABEL, ignore, r2) + addlabchk4: + IF v THEN + x = x + 1 + IF v = 2 THEN v = HashFindCont(ignore, r2): GOTO addlabchk4 + END IF 'v + IF x <> 1 THEN linenumber = Labels(r).Error_Line: a$ = "Ambiguous DATA label": GOTO errmes + + 'add global data offset variable + PRINT #18, "ptrszint data_at_LABEL_" + a$ + "=" + str2(Labels(r).Data_Offset) + ";" + + END IF 'data referenced + +NEXT +IF Debug THEN PRINT #9, "Finished check!" + + +'if targettyp=-4 or targettyp=-5 then '? -> byte_element(offset,element size in bytes) +' IF (sourcetyp AND ISREFERENCE) = 0 THEN a$ = "Expected variable name/array element": GOTO errmes + + +'create include files for COMMON arrays + +CLOSE #12 + +'return to 'main' +subfunc$ = "" +defdatahandle = 18 +CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 +CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 + +IF Console THEN + PRINT #18, "int32 console=1;" +ELSE + PRINT #18, "int32 console=0;" +END IF + +IF ScreenHide THEN + PRINT #18, "int32 screen_hide_startup=1;" +ELSE + PRINT #18, "int32 screen_hide_startup=0;" +END IF + +IF Asserts THEN + PRINT #18, "int32 asserts=1;" +ELSE + PRINT #18, "int32 asserts=0;" +END IF + +IF vWatchOn THEN + PRINT #18, "int32 vwatch=-1;" +ELSE + PRINT #18, "int32 vwatch=0;" +END IF + +fh = FREEFILE +OPEN tmpdir$ + "dyninfo.txt" FOR APPEND AS #fh +IF Resize THEN + PRINT #fh, "ScreenResize=1;" +END IF +IF Resize_Scale THEN + PRINT #fh, "ScreenResizeScale=" + str2(Resize_Scale) + ";" +END IF +CLOSE #fh + +IF vWatchOn = 1 THEN + vWatchVariable "", 1 +END IF + + +'DATA_finalize +PRINT #18, "ptrszint data_size=" + str2(DataOffset) + ";" +IF DataOffset = 0 THEN + + PRINT #18, "uint8 *data=(uint8*)calloc(1,1);" + +ELSE + + IF inline_DATA = 0 THEN + IF os$ = "WIN" THEN + IF OS_BITS = 32 THEN + x$ = CHR$(0): PUT #16, , x$ + PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #18, "extern char *binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + PRINT #18, "}" + PRINT #18, "uint8 *data=(uint8*)&binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + ELSE + x$ = CHR$(0): PUT #16, , x$ + PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #18, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + PRINT #18, "}" + PRINT #18, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + END IF + END IF + IF os$ = "LNX" THEN + x$ = CHR$(0): PUT #16, , x$ + PRINT #18, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #18, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + PRINT #18, "}" + PRINT #18, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" + END IF + ELSE + 'inline data + CLOSE #16 + ff = FREEFILE + OPEN tmpdir$ + "data.bin" FOR BINARY AS #ff + x$ = SPACE$(LOF(ff)) + GET #ff, , x$ + CLOSE #ff + x2$ = "uint8 inline_data[]={" + FOR i = 1 TO LEN(x$) + x2$ = x2$ + inlinedatastr$(ASC(x$, i)) + NEXT + x2$ = x2$ + "0};" + PRINT #18, x2$ + PRINT #18, "uint8 *data=&inline_data[0];" + x$ = "": x2$ = "" + END IF +END IF + +IF Debug THEN PRINT #9, "Beginning generation of code for saving/sharing common array data..." +use_global_byte_elements = 1 +ncommontmp = 0 +xi = 1 +FOR x = 1 TO commonarraylistn + varname$ = getelement$(commonarraylist, xi): xi = xi + 1 + typ$ = getelement$(commonarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + dimshared2 = VAL(getelement$(commonarraylist, xi)): xi = xi + 1 + + 'find the array ID (try method) + purevarname$ = varname$ + t = typname2typ(typ$) + IF Error_Happened THEN GOTO errmes + IF (t AND ISUDT) = 0 THEN varname$ = varname$ + type2symbol$(typ$) + IF Error_Happened THEN GOTO errmes + try = findid(varname$) + IF Error_Happened THEN GOTO errmes + DO WHILE try + IF id.arraytype THEN GOTO foundcommonarray + IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 + IF Error_Happened THEN GOTO errmes + LOOP + a$ = "COMMON array unlocatable": GOTO errmes 'should never happen + foundcommonarray: + IF Debug THEN PRINT #9, "Found common array '" + varname$ + "'!" + + i = currentid + arraytype = id.arraytype + arrayelements = id.arrayelements + e$ = RTRIM$(id.n) + IF (t AND ISUDT) = 0 THEN e$ = e$ + typevalue2symbol$(t) + IF Error_Happened THEN GOTO errmes + n$ = e$ + n2$ = RTRIM$(id.callname) + tsize = id.tsize + + 'select command + command = 3 'fixed length elements + IF t AND ISSTRING THEN + IF (t AND ISFIXEDLENGTH) = 0 THEN + command = 4 'var-len elements + END IF + END IF + + + 'if... + 'i) array elements are still undefined (ie. arrayelements=-1) pass the input content along + ' if any existed or an array-placeholder + 'ii) if the array's elements were defined, any input content would have been loaded so the + ' array (in whatever state it currently is) should be passed. If it is currently erased + ' then it should be passed as a placeholder + + IF arrayelements = -1 THEN + + 'load array (copies the array, if any, into a buffer for later) + + + + OPEN tmpdir$ + "inpchain" + str2$(i) + ".txt" FOR OUTPUT AS #12 + PRINT #12, "if (int32val==2){" 'array place-holder + 'create buffer to store array as-is in global.txt + x$ = str2$(uniquenumber) + x1$ = "chainarraybuf" + x$ + x2$ = "chainarraybufsiz" + x$ + PRINT #18, "static uint8 *" + x1$ + "=(uint8*)malloc(1);" + PRINT #18, "static int64 " + x2$ + "=0;" + 'read next command + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + IF command = 3 THEN PRINT #12, "if (int32val==3){" 'fixed-length-element array + IF command = 4 THEN PRINT #12, "if (int32val==4){" 'var-length-element array + PRINT #12, x2$ + "+=4; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int32*)(" + x1$ + "+" + x2$ + "-4)=int32val;" + + IF command = 3 THEN + 'read size in bits of one element, convert it to bytes + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val;" + PRINT #12, "bytes=int64val>>3;" + END IF 'com=3 + + IF command = 4 THEN PRINT #12, "bytes=1;" 'bytes used to calculate number of elements + + 'read number of dimensions + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + PRINT #12, x2$ + "+=4; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int32*)(" + x1$ + "+" + x2$ + "-4)=int32val;" + + 'read size of dimensions & calculate the size of the array in bytes + PRINT #12, "while(int32val--){" + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" 'lbound + PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val;" + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" 'ubound + PRINT #12, x2$ + "+=8; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + "); *(int64*)(" + x1$ + "+" + x2$ + "-8)=int64val2;" + PRINT #12, "bytes*=(int64val2-int64val+1);" + PRINT #12, "}" + + IF command = 3 THEN + 'read the array data + PRINT #12, x2$ + "+=bytes; " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + ");" + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)(" + x1$ + "+" + x2$ + "-bytes),bytes," + NewByteElement$ + "),0);" + END IF 'com=3 + + IF command = 4 THEN + PRINT #12, "bytei=0;" + PRINT #12, "while(bytei>3); " + x1$ + "=(uint8*)realloc(" + x1$ + "," + x2$ + ");" + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)(" + x1$ + "+" + x2$ + "-(int64val>>3)),(int64val>>3)," + NewByteElement$ + "),0);" + PRINT #12, "bytei++;" + PRINT #12, "}" + END IF + + 'get next command + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + PRINT #12, "}" 'command=3 or 4 + + PRINT #12, "}" 'array place-holder + CLOSE #12 + + + 'save array (saves the buffered data, if any, for later) + + OPEN tmpdir$ + "chain" + str2$(i) + ".txt" FOR OUTPUT AS #12 + PRINT #12, "int32val=2;" 'placeholder + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)" + x1$ + "," + x2$ + "," + NewByteElement$ + "),0);" + CLOSE #12 + + + + + ELSE + 'note: arrayelements<>-1 + + 'load array + + OPEN tmpdir$ + "inpchain" + str2$(i) + ".txt" FOR OUTPUT AS #12 + + PRINT #12, "if (int32val==2){" 'array place-holder + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + IF command = 3 THEN PRINT #12, "if (int32val==3){" 'fixed-length-element array + IF command = 4 THEN PRINT #12, "if (int32val==4){" 'var-length-element array + + IF command = 3 THEN + 'get size in bits + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + '***assume correct*** + END IF + + 'get number of elements + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + '***assume correct*** + + e$ = "" + IF command = 4 THEN PRINT #12, "bytes=1;" 'bytes counts the number of total elements + FOR x2 = 1 TO arrayelements + + 'create 'secret' variables to assist in passing common arrays + IF x2 > ncommontmp THEN + ncommontmp = ncommontmp + 1 + + IF Debug THEN PRINT #9, "Calling DIM2(...)..." + IF Error_Happened THEN GOTO errmes + retval = dim2("___RESERVED_COMMON_LBOUND" + str2$(ncommontmp), "_INTEGER64", 0, "") + IF Error_Happened THEN GOTO errmes + retval = dim2("___RESERVED_COMMON_UBOUND" + str2$(ncommontmp), "_INTEGER64", 0, "") + IF Error_Happened THEN GOTO errmes + IF Debug THEN PRINT #9, "Finished calling DIM2(...)!" + IF Error_Happened THEN GOTO errmes + + + END IF + + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + PRINT #12, "*__INTEGER64____RESERVED_COMMON_LBOUND" + str2$(x2) + "=int64val;" + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" + PRINT #12, "*__INTEGER64____RESERVED_COMMON_UBOUND" + str2$(x2) + "=int64val2;" + IF command = 4 THEN PRINT #12, "bytes*=(int64val2-int64val+1);" + IF x2 > 1 THEN e$ = e$ + sp + "," + sp + e$ = e$ + "___RESERVED_COMMON_LBOUND" + str2$(x2) + sp + "TO" + sp + "___RESERVED_COMMON_UBOUND" + str2$(x2) + NEXT + + IF Debug THEN PRINT #9, "Calling DIM2(" + purevarname$ + "," + typ$ + ",0," + e$ + ")..." + IF Error_Happened THEN GOTO errmes + 'Note: purevarname$ is simply varname$ without the type symbol after it + redimoption = 1 + retval = dim2(purevarname$, typ$, 0, e$) + IF Error_Happened THEN GOTO errmes + redimoption = 0 + IF Debug THEN PRINT #9, "Finished calling DIM2(" + purevarname$ + "," + typ$ + ",0," + e$ + ")!" + IF Error_Happened THEN GOTO errmes + + IF command = 3 THEN + 'use get to load in the array data + varname$ = varname$ + sp + "(" + sp + ")" + e$ = evaluatetotyp(fixoperationorder$(varname$), -4) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_get(FF,NULL," + e$ + ",0);" + END IF + + IF command = 4 THEN + PRINT #12, "bytei=0;" + PRINT #12, "while(bytei>3,1));" 'change string size + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)tqbs->chr,int64val>>3," + NewByteElement$ + "),0);" 'get size + PRINT #12, "bytei++;" + PRINT #12, "}" + END IF + + 'get next command + PRINT #12, "sub_get(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + PRINT #12, "}" + PRINT #12, "}" + CLOSE #12 + + 'save array + + OPEN tmpdir$ + "chain" + str2$(i) + ".txt" FOR OUTPUT AS #12 + + PRINT #12, "int32val=2;" 'placeholder + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + PRINT #12, "if (" + n2$ + "[2]&1){" 'don't add unless defined + + IF command = 3 THEN PRINT #12, "int32val=3;" + IF command = 4 THEN PRINT #12, "int32val=4;" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + IF command = 3 THEN + 'size of each element in bits + bits = t AND 511 + IF t AND ISUDT THEN bits = udtxsize(t AND 511) + IF t AND ISSTRING THEN bits = tsize * 8 + PRINT #12, "int64val=" + str2$(bits) + ";" 'size in bits + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + END IF 'com=3 + + PRINT #12, "int32val=" + str2$(arrayelements) + ";" 'number of dimensions + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int32val,4," + NewByteElement$ + "),0);" + + IF command = 3 THEN + + FOR x2 = 1 TO arrayelements + 'simulate calls to lbound/ubound + e$ = "LBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" + e$ = evaluatetotyp(fixoperationorder$(e$), 64) + IF Error_Happened THEN GOTO errmes + PRINT #12, "int64val=" + e$ + ";" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + e$ = "UBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" + e$ = evaluatetotyp(fixoperationorder$(e$), 64) + IF Error_Happened THEN GOTO errmes + PRINT #12, "int64val=" + e$ + ";" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + NEXT + + 'array data + e$ = evaluatetotyp(fixoperationorder$(n$ + sp + "(" + sp + ")"), -4) + IF Error_Happened THEN GOTO errmes + PRINT #12, "sub_put(FF,NULL," + e$ + ",0);" + + END IF 'com=3 + + IF command = 4 THEN + + 'store LBOUND/UBOUND values and calculate number of total elements/strings + PRINT #12, "bytes=1;" 'note: bytes is actually the total number of elements + FOR x2 = 1 TO arrayelements + e$ = "LBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" + e$ = evaluatetotyp(fixoperationorder$(e$), 64) + IF Error_Happened THEN GOTO errmes + PRINT #12, "int64val=" + e$ + ";" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" + e$ = "UBOUND" + sp + "(" + sp + n$ + sp + "," + sp + str2$(x2) + sp + ")" + e$ = evaluatetotyp(fixoperationorder$(e$), 64) + IF Error_Happened THEN GOTO errmes + PRINT #12, "int64val2=" + e$ + ";" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val2,8," + NewByteElement$ + "),0);" + PRINT #12, "bytes*=(int64val2-int64val+1);" + NEXT + + PRINT #12, "bytei=0;" + PRINT #12, "while(byteilen; int64val<<=3;" + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)&int64val,8," + NewByteElement$ + "),0);" 'size of element + PRINT #12, "sub_put(FF,NULL,byte_element((uint64)tqbs->chr,tqbs->len," + NewByteElement$ + "),0);" 'element data + PRINT #12, "bytei++;" + PRINT #12, "}" + + END IF 'com=4 + + PRINT #12, "}" 'don't add unless defined + + CLOSE #12 + + + + + 'if chaincommonarray then + 'l2$=tlayout$ + 'x=chaincommonarray + ' + ''chain???.txt + 'open tmpdir$ + "chain" + str2$(x) + ".txt" for append as #22 + 'if lof(22) then close #22: goto chaindone 'only add this once + ''***assume non-var-len-string array*** + 'print #22,"int32val=3;" 'non-var-len-element array + 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" + 't=id.arraytype + ''***check for UDT size if necessary*** + ''***check for string length if necessary*** + 'bits=t and 511 + 'print #22,"int64val="+str2$(bits)+";" 'size in bits + 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" + 'print #22,"int32val="+str2$(id.arrayelements)+";" 'number of elements + 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" + 'e$=rtrim$(id.n) + 'if (t and ISUDT)=0 then e$=e$+typevalue2symbol$(t) + 'n$=e$ + 'for x2=1 to id.arrayelements + ''simulate calls to lbound/ubound + 'e$="LBOUND"+sp+"("+sp+n$+sp+","+sp+str2$(x2)+sp+")" + 'e$=evaluatetotyp(fixoperationorder$(e$),64) + 'print #22,"int64val="+e$+";"'LBOUND + 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" + 'e$="UBOUND"+sp+"("+sp+n$+sp+","+sp+str2$(x2)+sp+")" + 'e$=evaluatetotyp(fixoperationorder$(e$),64) + 'print #22,"int64val="+e$+";"'LBOUND + 'print #22,"sub_put(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" + 'next + ''add array data + 'e$=evaluatetotyp(fixoperationorder$(n$+sp+"("+sp+")"),-4) + 'print #22,"sub_put(FF,NULL,"+e$+",0);" + 'close #22 + ' + ''inpchain???.txt + 'open tmpdir$ + "chain" + str2$(x) + ".txt" for append as #22 + 'print #22,"if (int32val==1){" 'common declaration of an array + 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" + 'print #22,"if (int32val==3){" 'fixed-length-element array + ' + 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int64val,8,"+NewByteElement$+"),0);" + ''***assume size correct and continue*** + ' + ''get number of elements + 'print #22,"sub_get(FF,NULL,byte_element((uint64)&int32val,4,"+NewByteElement$+"),0);" + ' + ''call dim2 and tell it to redim an array + ' + ''*********this should happen BEFORE the array (above) is actually dimensioned, + ''*********where the common() declaration is + ' + ''****although, if you never reference the array............. + ''****ARGH! you can access an undimmed array just like in a sub/function + ' + ' + ' + ' + 'print #22,"}" + 'print #22,"}" + 'close #22 + ' + 'chaindone: + 'tlayout$=l2$ + 'end if 'chaincommonarray + + + + + 'OPEN tmpdir$ + "chain.txt" FOR APPEND AS #22 + ''include directive + 'print #22, "#include " + CHR$(34) + "chain" + str2$(x) + ".txt" + CHR$(34) + 'close #22 + ''create/clear include file + 'open tmpdir$ + "chain" + str2$(x) + ".txt" for output as #22:close #22 + ' + 'OPEN tmpdir$ + "inpchain.txt" FOR APPEND AS #22 + ''include directive + 'print #22, "#include " + CHR$(34) + "inpchain" + str2$(x) + ".txt" + CHR$(34) + 'close #22 + ''create/clear include file + 'open tmpdir$ + "inpchain" + str2$(x) + ".txt" for output as #22:close #22 + + + + + + + END IF 'id.arrayelements=-1 + +NEXT +use_global_byte_elements = 0 +IF Debug THEN PRINT #9, "Finished generation of code for saving/sharing common array data!" + + +FOR closeall = 1 TO 255: CLOSE closeall: NEXT +OPEN tmpdir$ + "temp.bin" FOR OUTPUT LOCK WRITE AS #26 'relock + +compilelog$ = tmpdir$ + "compilelog.txt" + +OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log + +IF idemode = 0 AND NOT QuietMode THEN + IF ConsoleMode THEN + PRINT "[" + STRING$(maxprogresswidth, ".") + "] 100%" + ELSE + LOCATE , 1 + PRINT STRING$(maxprogresswidth, 219) + " 100%" + END IF +END IF + +IF NOT IgnoreWarnings THEN + totalUnusedVariables = 0 + FOR i = 1 TO totalVariablesCreated + IF usedVariableList(i).used = 0 THEN + totalUnusedVariables = totalUnusedVariables + 1 + END IF + NEXT + + IF totalUnusedVariables > 0 THEN + maxVarNameLen = 0 + FOR i = 1 TO totalVariablesCreated + IF usedVariableList(i).used = 0 THEN + IF LEN(usedVariableList(i).name) > maxVarNameLen THEN maxVarNameLen = LEN(usedVariableList(i).name) + END IF + NEXT + + header$ = "unused variable" 's (" + LTRIM$(STR$(totalUnusedVariables)) + ")" + FOR i = 1 TO totalVariablesCreated + IF usedVariableList(i).used = 0 THEN + addWarning usedVariableList(i).linenumber, usedVariableList(i).includeLevel, usedVariableList(i).includedLine, usedVariableList(i).includedFile, header$, usedVariableList(i).name + SPACE$((maxVarNameLen + 1) - LEN(usedVariableList(i).name)) + " " + usedVariableList(i).varType + END IF + NEXT + END IF +END IF + +IF idemode THEN GOTO ideret5 +ide6: + +IF idemode = 0 AND No_C_Compile_Mode = 0 THEN + IF NOT QuietMode THEN + PRINT + IF os$ = "LNX" THEN + PRINT "Compiling C++ code into executable..." + ELSE + PRINT "Compiling C++ code into EXE..." + END IF + END IF + IF LEN(outputfile_cmd$) THEN + 'resolve relative path for output file + path.out$ = getfilepath$(outputfile_cmd$) + f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1) + file$ = RemoveFileExtension$(f$) + IF LEN(path.out$) THEN + IF _DIREXISTS(path.out$) = 0 THEN + PRINT + PRINT "Can't create output executable - path not found: " + path.out$ + IF ConsoleMode THEN SYSTEM 1 + END 1 + END IF + currentdir$ = _CWD$ + CHDIR path.out$ + path.out$ = _CWD$ + CHDIR currentdir$ + IF RIGHT$(path.out$, 1) <> pathsep$ THEN path.out$ = path.out$ + pathsep$ + path.exe$ = path.out$ + SaveExeWithSource = -1 'Override the global setting if an output file was specified + END IF + END IF + t.path.exe$ = path.exe$ + IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN + E = 0 + ON ERROR GOTO qberror_test + KILL path.exe$ + file$ + extension$ + ON ERROR GOTO qberror + IF E = 1 THEN + a$ = "CANNOT CREATE " + CHR$(34) + file$ + extension$ + CHR$(34) + " BECAUSE THE FILE IS ALREADY IN USE!": GOTO errmes + END IF + END IF + path.exe$ = t.path.exe$ +END IF + +IF ExeIconSet THEN + linenumber = ExeIconSet 'on error, this allows reporting the linenumber where $EXEICON was used + wholeline = " $EXEICON:'" + ExeIconFile$ + "'" + + ' Copy icon file into temp directory with known name + ' This solves the problem of the resource file needing an absolute path + ON ERROR GOTO qberror_test + + DIM errNo AS LONG + errNo = CopyFile&(ExeIconFile$, tmpdir$ + "icon.ico") + IF errNo <> 0 THEN a$ = "Error copying " + QuotedFilename$(ExeIconFile$) + " to temp directory": GOTO errmes + + ON ERROR GOTO qberror +END IF + +IF VersionInfoSet THEN + manifest = FREEFILE + OPEN tmpdir$ + file$ + extension$ + ".manifest" FOR OUTPUT AS #manifest + PRINT #manifest, "" + PRINT #manifest, "" + PRINT #manifest, "" + PRINT #manifest, "" + viFileDescription$ + "" + PRINT #manifest, "" + PRINT #manifest, " " + PRINT #manifest, " " + PRINT #manifest, " " + PRINT #manifest, "" + PRINT #manifest, "" + CLOSE #manifest + + manifestembed = FREEFILE + OPEN tmpdir$ + "manifest.h" FOR OUTPUT AS #manifestembed + PRINT #manifestembed, "#ifndef RESOURCE_H" + PRINT #manifestembed, "#define RESOURCE_H" + PRINT #manifestembed, "#ifdef __cplusplus" + PRINT #manifestembed, "extern " + AddQuotes$("C") + " {" + PRINT #manifestembed, "#endif" + PRINT #manifestembed, "#ifdef __cplusplus" + PRINT #manifestembed, "}" + PRINT #manifestembed, "#endif" + PRINT #manifestembed, "#endif /* RESOURCE_H */" + PRINT #manifestembed, "#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 /*Defined manifest file*/" + PRINT #manifestembed, "#define RT_MANIFEST 24" + CLOSE #manifestembed +END IF + +IF VersionInfoSet OR ExeIconSet THEN + iconfilehandle = FREEFILE + OPEN tmpdir$ + "icon.rc" FOR OUTPUT AS #iconfilehandle + + IF ExeIconSet THEN + PRINT #iconfilehandle, "0 ICON " + AddQuotes$("icon.ico") + END IF + + IF VersionInfoSet THEN + PRINT #iconfilehandle, "" + PRINT #iconfilehandle, "#include " + AddQuotes$("manifest.h") + PRINT #iconfilehandle, "" + PRINT #iconfilehandle, "CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST " + AddQuotes$(file$ + extension$ + ".manifest") + PRINT #iconfilehandle, "" + PRINT #iconfilehandle, "1 VERSIONINFO" + IF LEN(viFileVersionNum$) THEN PRINT #iconfilehandle, "FILEVERSION "; viFileVersionNum$ + IF LEN(viProductVersionNum$) THEN PRINT #iconfilehandle, "PRODUCTVERSION "; viProductVersionNum$ + PRINT #iconfilehandle, "BEGIN" + PRINT #iconfilehandle, " BLOCK " + AddQuotes$("StringFileInfo") + PRINT #iconfilehandle, " BEGIN" + PRINT #iconfilehandle, " BLOCK " + AddQuotes$("040904E4") + PRINT #iconfilehandle, " BEGIN" + PRINT #iconfilehandle, " VALUE " + AddQuotes$("CompanyName") + "," + AddQuotes$(viCompanyName$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("FileDescription") + "," + AddQuotes$(viFileDescription$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("FileVersion") + "," + AddQuotes$(viFileVersion$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("InternalName") + "," + AddQuotes$(viInternalName$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("LegalCopyright") + "," + AddQuotes$(viLegalCopyright$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("LegalTrademarks") + "," + AddQuotes$(viLegalTrademarks$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("OriginalFilename") + "," + AddQuotes$(viOriginalFilename$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("ProductName") + "," + AddQuotes$(viProductName$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("ProductVersion") + "," + AddQuotes$(viProductVersion$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("Comments") + "," + AddQuotes$(viComments$ + "\0") + PRINT #iconfilehandle, " VALUE " + AddQuotes$("Web") + "," + AddQuotes$(viWeb$ + "\0") + PRINT #iconfilehandle, " END" + PRINT #iconfilehandle, " END" + PRINT #iconfilehandle, " BLOCK " + AddQuotes$("VarFileInfo") + PRINT #iconfilehandle, " BEGIN" + PRINT #iconfilehandle, " VALUE " + AddQuotes$("Translation") + ", 0x409, 0x04E4" + PRINT #iconfilehandle, " END" + PRINT #iconfilehandle, "END" + CLOSE #iconfilehandle + END IF +END IF + +'Update dependencies + +o$ = LCASE$(os$) +win = 0: IF os$ = "WIN" THEN win = 1 +lnx = 0: IF os$ = "LNX" THEN lnx = 1 +mac = 0: IF MacOSX THEN mac = 1: o$ = "osx" +ver$ = Version$ 'eg. "0.123" +libs$ = "" +makedeps$ = "" +make$ = GetMakeExecutable$ + +localpath$ = "internal\c\" + + +IF DEPENDENCY(DEPENDENCY_GL) THEN makedeps$ = makedeps$ + " DEP_GL=y" +IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENIMAGE=y" +IF DEPENDENCY(DEPENDENCY_IMAGE_CODEC) THEN makedeps$ = makedeps$ + " DEP_IMAGE_CODEC=y" +IF DEPENDENCY(DEPENDENCY_CONSOLE_ONLY) THEN makedeps$ = makedeps$ + " DEP_CONSOLE_ONLY=y" +IF DEPENDENCY(DEPENDENCY_SOCKETS) THEN makedeps$ = makedeps$ + " DEP_SOCKETS=y" +IF DEPENDENCY(DEPENDENCY_PRINTER) THEN makedeps$ = makedeps$ + " DEP_PRINTER=y" +IF DEPENDENCY(DEPENDENCY_ICON) THEN makedeps$ = makedeps$ + " DEP_ICON=y" +IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENIMAGE=y" +IF DEPENDENCY(DEPENDENCY_LOADFONT) THEN makedeps$ = makedeps$ + " DEP_FONT=y" +IF DEPENDENCY(DEPENDENCY_DEVICEINPUT) THEN makedeps$ = makedeps$ + " DEP_DEVICEINPUT=y" +IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) THEN makedeps$ = makedeps$ + " DEP_AUDIO_DECODE=y" +IF DEPENDENCY(DEPENDENCY_AUDIO_CONVERSION) THEN makedeps$ = makedeps$ + " DEP_AUDIO_CONVERSION=y" +IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) THEN makedeps$ = makedeps$ + " DEP_AUDIO_DECODE=y" +IF DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN makedeps$ = makedeps$ + " DEP_AUDIO_OUT=y" +IF DEPENDENCY(DEPENDENCY_ZLIB) THEN makedeps$ = makedeps$ + " DEP_ZLIB=y" +IF inline_DATA = 0 AND DataOffset THEN makedeps$ = makedeps$ + " DEP_DATA=y" +IF Console THEN makedeps$ = makedeps$ + " DEP_CONSOLE=y" +IF ExeIconSet OR VersionInfoSet THEN makedeps$ = makedeps$ + " DEP_ICON_RC=y" + +IF tempfolderindex > 1 THEN makedeps$ = makedeps$ + " TEMP_ID=" + str2$(tempfolderindex) + +CxxFlagsExtra$ = ExtraCppFlags +CxxLibsExtra$ = ExtraLinkerFlags + +' If debugging then use `-Og` rather than `-O2` +IF OptimizeCppProgram THEN + IF Include_GDB_Debugging_Info THEN + CxxFlagsExtra$ = CxxFlagsExtra$ + " -Og" + ELSE + CxxFlagsExtra$ = CxxFlagsExtra$ + " -O2" + END IF +ELSE + IF Include_GDB_Debugging_Info THEN + CxxFlagsExtra$ = CxxFlagsExtra$ + " -g" + END IF +END IF + +CxxLibsExtra$ = CxxLibsExtra$ + " " + mylib$ + " " + mylibopt$ + +' Make and the shell don't like certain characters in the file name, so we +' escape them to get them to handle them properly +escapedExe$ = StrReplace$(path.exe$ + file$ + extension$, " ", "\ ") +escapedExe$ = StrReplace$(escapedExe$, "$", "$$") + +makeline$ = make$ + makedeps$ + " EXE=" + AddQuotes$(escapedExe$) +makeline$ = makeline$ + " " + AddQuotes$("CXXFLAGS_EXTRA=" + CxxFlagsExtra$) +makeline$ = makeline$ + " " + AddQuotes$("CFLAGS_EXTRA=" + CxxFlagsExtra$) +makeline$ = makeline$ + " " + AddQuotes$("CXXLIBS_EXTRA=" + CxxLibsExtra$) +makeline$ = makeline$ + " -j" + AddQuotes$(str2$(MaxParallelProcesses)) + +IF NOT StripDebugSymbols THEN + makeline$ = makeline$ + " STRIP_SYMBOLS=n" +END IF + +IF os$ = "WIN" THEN + + makeline$ = makeline$ + " OS=win" + + 'resolve static function definitions and add to global.txt + FOR x = 1 TO ResolveStaticFunctions + IF LEN(ResolveStaticFunction_File(x)) THEN + + n = 0 + SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " --demangle -g >internal\temp\nm_output.txt" + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + "(" + OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname+LEFTBRACKET + x1 = INSTR(a$, s$) + IF x1 THEN + IF ResolveStaticFunction_Method(x) = 1 THEN + x1 = x1 + 1 + x2 = INSTR(x1, a$, ")") + fh2 = FREEFILE + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" + CLOSE #fh2 + END IF + n = n + 1 + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + + IF n = 0 THEN 'attempt to locate simple function name without brackets + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname + x1 = INSTR(a$, s$) + IF RIGHT$(a$, LEN(s$)) = s$ THEN + fh2 = FREEFILE + IF ResolveStaticFunction_Method(x) = 1 THEN + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #fh2, "extern void " + s$ + "(void);" + PRINT #fh2, "}" + ELSE + OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " + END IF + CLOSE #fh2 + n = n + 1 + EXIT DO + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + END IF + + IF n = 0 THEN 'a C++ dynamic object library? + SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " -D --demangle -g >.\internal\temp\nm_output_dynamic.txt" + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + "(" + OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname+LEFTBRACKET + x1 = INSTR(a$, s$) + IF x1 THEN + IF ResolveStaticFunction_Method(x) = 1 THEN + x1 = x1 + 1 + x2 = INSTR(x1, a$, ")") + fh2 = FREEFILE + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" + CLOSE #fh2 + END IF + n = n + 1 + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + END IF + + IF n = 0 THEN 'a C dynamic object library? + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname + x1 = INSTR(a$, s$) + IF RIGHT$(a$, LEN(s$)) = s$ THEN + fh2 = FREEFILE + IF ResolveStaticFunction_Method(x) = 1 THEN + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #fh2, "extern void " + s$ + "(void);" + PRINT #fh2, "}" + ELSE + OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " + END IF + CLOSE #fh2 + n = n + 1 + EXIT DO + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + IF n = 0 THEN a$ = "Could not find sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + END IF + + END IF + NEXT + + IF No_C_Compile_Mode = 0 THEN + SHELL _HIDE "cmd /c " + makeline$ + " 1>> " + compilelog$ + " 2>&1" + + IF idemode THEN + 'Restore fg/bg colors + dummy = DarkenFGBG(0) + END IF + END IF + + ffh = FREEFILE + OPEN tmpdir$ + "debug_win.bat" FOR OUTPUT AS #ffh + PRINT #ffh, "@echo off" + PRINT #ffh, "cd %0\..\" + PRINT #ffh, "cd ../.." + PRINT #ffh, "echo C++ Debugging: " + file$ + extension$ + " using gdb.exe" + PRINT #ffh, "echo Debugger commands:" + PRINT #ffh, "echo After the debugger launches type 'run' to start your program" + PRINT #ffh, "echo After your program crashes type 'list' to find where the problem is and fix/report it" + PRINT #ffh, "echo Type 'quit' to exit" + PRINT #ffh, "echo (the GDB debugger has many other useful commands, this advice is for beginners)" + PRINT #ffh, "pause" + PRINT #ffh, "internal\c\c_compiler\bin\gdb.exe " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) + PRINT #ffh, "pause" + CLOSE ffh +END IF + +IF os$ = "LNX" THEN + + IF INSTR(_OS$, "[MACOSX]") THEN + makeline$ = makeline$ + " OS=osx" + ELSE + makeline$ = makeline$ + " OS=lnx" + END IF + + FOR x = 1 TO ResolveStaticFunctions + IF LEN(ResolveStaticFunction_File(x)) THEN + + n = 0 + IF MacOSX = 0 THEN SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " --demangle -g >./internal/temp/nm_output.txt 2>./internal/temp/nm_error.txt" + IF MacOSX THEN SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " >./internal/temp/nm_output.txt 2>./internal/temp/nm_error.txt" + + IF MacOSX = 0 THEN 'C++ name demangling not supported in MacOSX + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + "(" + OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname+LEFTBRACKET + x1 = INSTR(a$, s$) + IF x1 THEN + IF ResolveStaticFunction_Method(x) = 1 THEN + x1 = x1 + 1 + x2 = INSTR(x1, a$, ")") + fh2 = FREEFILE + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" + CLOSE #fh2 + END IF + n = n + 1 + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + END IF 'macosx=0 + + IF n = 0 THEN 'attempt to locate simple function name without brackets + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x): s2$ = s$ + IF MacOSX THEN s$ = " _" + ResolveStaticFunction_Name(x) 'search for C mangled name + OPEN "internal\temp\nm_output.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname + x1 = INSTR(a$, s$) + IF RIGHT$(a$, LEN(s$)) = s$ THEN + fh2 = FREEFILE + IF ResolveStaticFunction_Method(x) = 1 THEN + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #fh2, "extern void " + s2$ + "(void);" + PRINT #fh2, "}" + ELSE + OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " + END IF + CLOSE #fh2 + n = n + 1 + EXIT DO + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + END IF + + IF n = 0 THEN 'a C++ dynamic object library? + IF MacOSX THEN GOTO macosx_libfind_failed + SHELL _HIDE "nm " + CHR$(34) + ResolveStaticFunction_File(x) + CHR$(34) + " -D --demangle -g >./internal/temp/nm_output_dynamic.txt 2>./internal/temp/nm_error.txt" + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + "(" + OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname+LEFTBRACKET + x1 = INSTR(a$, s$) + IF x1 THEN + IF ResolveStaticFunction_Method(x) = 1 THEN + x1 = x1 + 1 + x2 = INSTR(x1, a$, ")") + fh2 = FREEFILE + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern void " + MID$(a$, x1, x2 - x1 + 1) + ";" + CLOSE #fh2 + END IF + n = n + 1 + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + IF n > 1 THEN a$ = "Unable to resolve multiple instances of sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + END IF + + IF n = 0 THEN 'a C dynamic object library? + fh = FREEFILE + s$ = " " + ResolveStaticFunction_Name(x) + OPEN "internal\temp\nm_output_dynamic.txt" FOR BINARY AS #fh + DO UNTIL EOF(fh) + LINE INPUT #fh, a$ + IF LEN(a$) THEN + 'search for SPACE+functionname + x1 = INSTR(a$, s$) + IF RIGHT$(a$, LEN(s$)) = s$ THEN + fh2 = FREEFILE + IF ResolveStaticFunction_Method(x) = 1 THEN + OPEN tmpdir$ + "global.txt" FOR APPEND AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + "{" + PRINT #fh2, "extern void " + s$ + "(void);" + PRINT #fh2, "}" + ELSE + OPEN tmpdir$ + "externtype" + str2(x) + ".txt" FOR OUTPUT AS #fh2 + PRINT #fh2, "extern " + CHR$(34) + "C" + CHR$(34) + " " + END IF + CLOSE #fh2 + n = n + 1 + EXIT DO + END IF 'x1 + END IF '<>"" + LOOP + CLOSE #fh + macosx_libfind_failed: + IF n = 0 THEN a$ = "Could not find sub/function '" + ResolveStaticFunction_Name(x) + "' in '" + ResolveStaticFunction_File(x) + "'": GOTO errmes + END IF + + END IF + NEXT + + IF INSTR(_OS$, "[MACOSX]") THEN + + ffh = FREEFILE + OPEN tmpdir$ + "recompile_osx.command" FOR OUTPUT AS #ffh + PRINT #ffh, "cd " + CHR_QUOTE + "$(dirname " + CHR_QUOTE + "$0" + CHR_QUOTE + ")" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "Recompiling..." + CHR_QUOTE + CHR$(10); + PRINT #ffh, "cd ../c" + CHR$(10); + PRINT #ffh, makeline$ + CHR$(10); + PRINT #ffh, "read -p " + CHR_QUOTE + "Press ENTER to exit..." + CHR_QUOTE + CHR$(10); + CLOSE ffh + SHELL _HIDE "chmod +x " + tmpdir$ + "recompile_osx.command" + + ffh = FREEFILE + OPEN tmpdir$ + "debug_osx.command" FOR OUTPUT AS #ffh + PRINT #ffh, "cd " + CHR_QUOTE + "$(dirname " + CHR_QUOTE + "$0" + CHR_QUOTE + ")" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "Pause()" + CHR$(10); + PRINT #ffh, "{" + CHR$(10); + PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); + PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); + PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); + PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); + PRINT #ffh, "}" + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "C++ Debugging: " + file$ + extension$ + " using GDB" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "Debugger commands:" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "After the debugger launches type 'run' to start your program" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "After your program crashes type 'list' to find where the problem is and fix/report it" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "(the GDB debugger has many other useful commands, this advice is for beginners)" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "gdb " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) + CHR$(10); + PRINT #ffh, "Pause" + CHR$(10); + CLOSE ffh + SHELL _HIDE "chmod +x " + tmpdir$ + "debug_osx.command" + + ELSE + + ffh = FREEFILE + OPEN tmpdir$ + "recompile_lnx.sh" FOR OUTPUT AS #ffh + PRINT #ffh, "#!/bin/sh" + CHR$(10); + PRINT #ffh, "Pause()" + CHR$(10); + PRINT #ffh, "{" + CHR$(10); + PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); + PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); + PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); + PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); + PRINT #ffh, "}" + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "Recompiling..." + CHR_QUOTE + CHR$(10); + PRINT #ffh, "cd ../c" + CHR$(10); + PRINT #ffh, makeline$ + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "Press ENTER to exit..." + CHR_QUOTE + CHR$(10); + PRINT #ffh, "Pause" + CHR$(10); + CLOSE ffh + SHELL _HIDE "chmod +x " + tmpdir$ + "recompile_lnx.sh" + + ffh = FREEFILE + OPEN tmpdir$ + "debug_lnx.sh" FOR OUTPUT AS #ffh + PRINT #ffh, "#!/bin/sh" + CHR$(10); + PRINT #ffh, "Pause()" + CHR$(10); + PRINT #ffh, "{" + CHR$(10); + PRINT #ffh, "OLDCONFIG=`stty -g`" + CHR$(10); + PRINT #ffh, "stty -icanon -echo min 1 time 0" + CHR$(10); + PRINT #ffh, "dd count=1 2>/dev/null" + CHR$(10); + PRINT #ffh, "stty $OLDCONFIG" + CHR$(10); + PRINT #ffh, "}" + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "C++ Debugging: " + file$ + extension$ + " using GDB" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "Debugger commands:" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "After the debugger launches type 'run' to start your program" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "After your program crashes type 'list' to find where the problem is and fix/report it" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "echo " + CHR_QUOTE + "(the GDB debugger has many other useful commands, this advice is for beginners)" + CHR_QUOTE + CHR$(10); + PRINT #ffh, "gdb " + CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34) + CHR$(10); + PRINT #ffh, "Pause" + CHR$(10); + CLOSE ffh + SHELL _HIDE "chmod +x " + tmpdir$ + "debug_lnx.sh" + + END IF + + IF No_C_Compile_Mode = 0 THEN + SHELL _HIDE makeline$ + " 1>> " + compilelog$ + " 2>&1" + IF idemode THEN + 'Restore fg/bg colors + dummy = DarkenFGBG(0) + END IF + END IF + + IF INSTR(_OS$, "[MACOSX]") THEN + ff = FREEFILE + IF path.exe$ = "./" OR path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = "" + OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff + PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34); + PRINT #ff, CHR$(10); + PRINT #ff, "./" + file$ + extension$ + " &"; + PRINT #ff, CHR$(10); + PRINT #ff, "osascript -e 'tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to close (every window whose name contains " + CHR$(34) + file$ + extension$ + "_start.command" + CHR$(34) + ")' &"; + PRINT #ff, CHR$(10); + PRINT #ff, "osascript -e 'if (count the windows of application " + CHR$(34) + "Terminal" + CHR$(34) + ") is 0 then tell application " + CHR$(34) + "Terminal" + CHR$(34) + " to quit' &"; + PRINT #ff, CHR$(10); + PRINT #ff, "exit"; + PRINT #ff, CHR$(10); + CLOSE #ff + SHELL _HIDE "chmod +x " + path.exe$ + file$ + extension$ + "_start.command" + END IF + +END IF + +IF No_C_Compile_Mode THEN compfailed = 0: GOTO No_C_Compile +IF path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = "" +IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN + compfailed = 0 + lastBinaryGenerated$ = path.exe$ + file$ + extension$ +ELSE + compfailed = 1 'detect compilation failure +END IF + +IF compfailed THEN + IF idemode THEN + idemessage$ = "C++ Compilation failed " + CHR$(0) + "(Check " + _TRIM$(compilelog$) + ")" + GOTO ideerror + END IF + IF compfailed THEN + PRINT "ERROR: C++ compilation failed." + PRINT "Check " + compilelog$ + " for details." + END IF +ELSE + IF idemode = 0 AND NOT QuietMode THEN PRINT "Output: "; lastBinaryGenerated$ +END IF + +Skip_Build: + + + +IF idemode THEN GOTO ideret6 + +No_C_Compile: + +IF (compfailed <> 0 OR warningsissued <> 0) AND ConsoleMode = 0 THEN END 1 +IF compfailed <> 0 THEN SYSTEM 1 +SYSTEM 0 + +qberror_test: +E = 1 +RESUME NEXT + +qberror: +'_CONSOLE ON +'_ECHO "A QB error has occurred (and you have compiled in debugging support)." +'_ECHO "Some key information (qb64pe.bas):" +'_ECHO "Error" + STR$(ERR) +'_ECHO "Description: " + _ERRORMESSAGE$ +'_ECHO "Line" + STR$(_ERRORLINE) +'IF _INCLERRORLINE THEN +' _ECHO "Included line" + STR$(_INCLERRORLINE) +' _ECHO "Included file " + _INCLERRORFILE$ +'END IF +'_ECHO "" +'_ECHO "Loaded source file details:" +'_ECHO "ideerror =" + STR$(ideerror) + "; qberrorhappened =" + STR$(qberrorhappened) + "; qberrorhappenedvalue =" + STR$(qberrorhappenedvalue) + "; linenumber =" + STR$(linenumber) +'_ECHO "ca$ = {" + ca$ + "}, idecommand$ = {" + idecommand$ + "}" +'_ECHO "linefragment = {" + linefragment+ "}" + +IF Debug THEN 'A more in-your-face error handler + IF ConsoleMode THEN + PRINT + ELSE + _AUTODISPLAY + SCREEN _NEWIMAGE(80, 25, 0), , 0, 0 + COLOR 7, 0 + END IF + _CONTROLCHR OFF + PRINT "A QB error has occurred (and you have compiled in debugging support)." + PRINT "Some key information (qb64pe.bas):" + PRINT "Error"; ERR + PRINT "Description: "; _ERRORMESSAGE$ + PRINT "Line"; _ERRORLINE + IF _INCLERRORLINE THEN + PRINT "Included line"; _INCLERRORLINE + PRINT "Included file "; _INCLERRORFILE$ + END IF + PRINT + PRINT "Loaded source file details:" + PRINT "ideerror ="; ideerror; "qberrorhappened ="; qberrorhappened; "qberrorhappenedvalue ="; qberrorhappenedvalue; "linenumber ="; linenumber + PRINT "ca$ = {"; ca$; "}, idecommand$ = {"; idecommand$; "}" + PRINT "linefragment = {"; linefragment; "}" + END +END IF + +IF ideerror THEN 'error happened inside the IDE + fh = FREEFILE + OPEN "internal\temp\ideerror.txt" FOR APPEND AS #fh + PRINT #fh, DATE$; TIME$; "--------------------" + PRINT #fh, ERR + PRINT #fh, _ERRORMESSAGE$ + PRINT #fh, _ERRORLINE + PRINT #fh, _INCLERRORLINE + PRINT #fh, _INCLERRORFILE$ + CLOSE #fh + sendc$ = CHR$(255) 'a runtime error has occurred + RESUME sendcommand 'allow IDE to handle error recovery +END IF + +qberrorhappenedvalue = qberrorhappened +qberrorhappened = 1 + +IF Debug THEN PRINT #9, "QB ERROR!" +IF Debug THEN PRINT #9, "ERR="; ERR +IF Debug THEN PRINT #9, "ERL="; ERL + +IF idemode AND qberrorhappenedvalue >= 0 THEN + 'real qb error occurred + ideerrorline = linenumber + idemessage$ = "Compiler error (check for syntax errors) (" + _ERRORMESSAGE$ + ":" + IF ERR THEN idemessage$ = idemessage$ + str2$(ERR) + "-" + IF _ERRORLINE THEN idemessage$ = idemessage$ + str2$(_ERRORLINE) + IF _INCLERRORLINE THEN idemessage$ = idemessage$ + "-" + _INCLERRORFILE$ + "-" + str2$(_INCLERRORLINE) + idemessage$ = idemessage$ + ")" + IF inclevel > 0 THEN idemessage$ = idemessage$ + incerror$ + RESUME ideerror +END IF + +IF qberrorhappenedvalue >= 0 THEN + a$ = "UNEXPECTED INTERNAL COMPILER ERROR!": GOTO errmes 'internal comiler error +END IF + + +qberrorcode = ERR +qberrorline = ERL +IF qberrorhappenedvalue = -1 THEN RESUME qberrorhappened1 +IF qberrorhappenedvalue = -2 THEN RESUME qberrorhappened2 +IF qberrorhappenedvalue = -3 THEN RESUME qberrorhappened3 +END + +errmes: 'set a$ to message +IF Error_Happened THEN a$ = Error_Message: Error_Happened = 0 +layout$ = "": layoutok = 0 'invalidate layout + +IF forceIncludingFile THEN 'If we're to the point where we're adding the automatic QB64 includes, we don't need to report the $INCLUDE information + IF INSTR(a$, "END SUB/FUNCTION before") THEN a$ = "SUB without END SUB" 'Just a simple rewrite of the error message to be less confusing for SUB/FUNCTIONs +ELSE 'We want to let the user know which module the error occurred in + IF inclevel > 0 THEN a$ = a$ + incerror$ +END IF + +IF idemode THEN + ideerrorline = linenumber + idemessage$ = a$ + GOTO ideerror 'infinitely preferable to RESUME +END IF +'non-ide mode output +PRINT +IF NOT MonochromeLoggingMode THEN + IF INSTR(_OS$, "WIN") THEN + COLOR 4 + ELSE + COLOR 9 + END IF +END IF +PRINT a$ +IF NOT MonochromeLoggingMode THEN COLOR 7 +FOR i = 1 TO LEN(linefragment) + IF MID$(linefragment, i, 1) = sp$ THEN MID$(linefragment, i, 1) = " " +NEXT +FOR i = 1 TO LEN(wholeline) + IF MID$(wholeline, i, 1) = sp$ THEN MID$(wholeline, i, 1) = " " +NEXT +PRINT "Caused by (or after):" + linefragment +IF NOT MonochromeLoggingMode THEN COLOR 8 +PRINT "LINE "; +IF NOT MonochromeLoggingMode THEN COLOR 15 +PRINT str2(linenumber) + ":"; +IF NOT MonochromeLoggingMode THEN COLOR 7 +PRINT wholeline + +IF ConsoleMode THEN SYSTEM 1 +END 1 + +FUNCTION ParseCMDLineArgs$ () + 'Recall that COMMAND$ is a concatenation of argv[] elements, so we don't have + 'to worry about more than one space between things (unless they used quotes, + 'in which case they're simply asking for trouble). + FOR i = 1 TO _COMMANDCOUNT + token$ = COMMAND$(i) + IF LCASE$(token$) = "/?" OR LCASE$(token$) = "--help" OR LCASE$(token$) = "/help" THEN token$ = "-?" + SELECT CASE LCASE$(LEFT$(token$, 2)) + CASE "-?" 'Command-line help + _DEST _CONSOLE + IF qb64versionprinted = 0 THEN qb64versionprinted = -1: PRINT "QB64-PE Compiler V" + Version$ + PRINT + PRINT "Usage: qb64pe [switches] " + PRINT + PRINT "Options:" + PRINT " Source file to load" ' '80 columns + PRINT " -c Compile instead of edit" + PRINT " -o Write output executable to " + PRINT " -x Compile instead of edit and output the result to the" + PRINT " console" + PRINT " -w Show warnings" + PRINT " -q Quiet mode (does not inhibit warnings or errors)" + PRINT " -m Do not colorize compiler output (monochrome mode)" + PRINT " -e Enable OPTION _EXPLICIT, making variable declaration" + PRINT " mandatory (per-compilation; doesn't affect the" + PRINT " source file or global settings)" + PRINT " -s[:switch=true/false] View/edit compiler settings" + PRINT " -l: Start the IDE at the specified line number" + PRINT " -p Purge all pre-compiled content first" + PRINT " -z Generate C code without compiling to executable" + PRINT + SYSTEM + CASE "-u" 'Invoke "Update all pages" to populate internal/help files (hidden build option) + Help_Recaching = 2: Help_IgnoreCache = 1 + IF ideupdatehelpbox THEN + _DEST _CONSOLE + PRINT "Update failed: curl not found" + SYSTEM 1 + END IF + SYSTEM + CASE "-c" 'Compile instead of edit + NoIDEMode = 1 + cmdlineswitch = -1 + CASE "-o" 'Specify an output file + IF LEN(COMMAND$(i + 1)) > 0 THEN outputfile_cmd$ = COMMAND$(i + 1): i = i + 1 + cmdlineswitch = -1 + CASE "-x" 'Use the console + ConsoleMode = 1 + NoIDEMode = 1 'Implies -c + cmdlineswitch = -1 + CASE "-w" 'Show warnings + ShowWarnings = -1 + cmdlineswitch = -1 + CASE "-q" 'Quiet mode + QuietMode = -1 + cmdlineswitch = -1 + CASE "-m" 'Monochrome mode + MonochromeLoggingMode = -1 + cmdlineswitch = -1 + CASE "-e" 'Option Explicit + optionexplicit_cmd = -1 + cmdlineswitch = -1 + CASE "-s" 'Settings + settingsMode = -1 + _DEST _CONSOLE + IF qb64versionprinted = 0 THEN qb64versionprinted = -1: PRINT "QB64-PE Compiler V" + Version$ + SELECT CASE LCASE$(MID$(token$, 3)) + CASE "" + PRINT "debuginfo = "; + IF idedebuginfo THEN PRINT "true" ELSE PRINT "false" + PRINT "exewithsource = "; + IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false" + SYSTEM + CASE ":exewithsource" + PRINT "exewithsource = "; + IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false" + SYSTEM + CASE ":exewithsource=true" + WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "True" + PRINT "exewithsource = true" + SaveExeWithSource = -1 + CASE ":exewithsource=false" + WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "False" + PRINT "exewithsource = false" + SaveExeWithSource = 0 + CASE ":debuginfo" + PRINT "debuginfo = "; + IF idedebuginfo THEN PRINT "true" ELSE PRINT "false" + SYSTEM + CASE ":debuginfo=true" + PRINT "debuginfo = true" + WriteConfigSetting generalSettingsSection$, "DebugInfo", "True" + DebugInfoIniWarning$ + idedebuginfo = -1 + Include_GDB_Debugging_Info = idedebuginfo + PurgeTemporaryBuildFiles (os$), (MacOSX) + CASE ":debuginfo=false" + PRINT "debuginfo = false" + WriteConfigSetting generalSettingsSection$, "DebugInfo", "False" + DebugInfoIniWarning$ + idedebuginfo = 0 + Include_GDB_Debugging_Info = idedebuginfo + PurgeTemporaryBuildFiles (os$), (MacOSX) + CASE ELSE + PRINT "Invalid settings switch: "; token$ + PRINT + PRINT "Valid switches:" + PRINT " -s:debuginfo=true/false (Embed C++ debug info into .EXE)" + PRINT " -s:exewithsource=true/false (Save .EXE in the source folder)" + SYSTEM 1 + END SELECT + _DEST 0 + CASE "-l" 'goto line (ide mode only); -l: + IF MID$(token$, 3, 1) = ":" THEN ideStartAtLine = VAL(MID$(token$, 4)) + cmdlineswitch = -1 + CASE "-p" 'Purge + PurgeTemporaryBuildFiles (os$), (MacOSX) + cmdlineswitch = -1 + CASE "-z" 'Not compiling C code + No_C_Compile_Mode = 1 + ConsoleMode = 1 'Implies -x + NoIDEMode = 1 'Implies -c + cmdlineswitch = -1 + CASE ELSE 'Something we don't recognise, assume it's a filename + IF PassedFileName$ = "" THEN PassedFileName$ = token$ + END SELECT + NEXT i + + IF LEN(PassedFileName$) THEN + ParseCMDLineArgs$ = PassedFileName$ + ELSE + IF cmdlineswitch = 0 AND settingsMode = -1 THEN SYSTEM + END IF +END FUNCTION + +FUNCTION Type2MemTypeValue (t1) + t = 0 + IF t1 AND ISARRAY THEN t = t + 65536 + IF t1 AND ISUDT THEN + IF (t1 AND 511) = 1 THEN + t = t + 4096 '_MEM type + ELSE + t = t + 32768 + END IF + ELSE + IF t1 AND ISSTRING THEN + t = t + 512 'string + ELSE + IF t1 AND ISFLOAT THEN + t = t + 256 'float + ELSE + t = t + 128 'integer + IF t1 AND ISUNSIGNED THEN t = t + 1024 + IF t1 AND ISOFFSET THEN t = t + 8192 'offset type + END IF + t1s = (t1 AND 511) \ 8 + IF t1s = 1 THEN t = t + t1s + IF t1s = 2 THEN t = t + t1s + IF t1s = 4 THEN t = t + t1s + IF t1s = 8 THEN t = t + t1s + IF t1s = 16 THEN t = t + t1s + IF t1s = 32 THEN t = t + t1s + IF t1s = 64 THEN t = t + t1s + END IF + END IF + Type2MemTypeValue = t +END FUNCTION + +'udt is non-zero if this is an array of udt's, to allow examining each udt element +FUNCTION allocarray (n2$, elements$, elementsize, udt) + dimsharedlast = dimshared: dimshared = 0 + + IF autoarray = 1 THEN autoarray = 0: autoary = 1 'clear global value & set local value + + f12$ = "" + + 'changelog: + 'added 4 to [2] to indicate cmem array where appropriate + + e$ = elements$: n$ = n2$ + IF elementsize = -2147483647 THEN stringarray = 1: elementsize = 8 + + IF ASC(e$) = 63 THEN '? + l$ = "(" + sp2 + ")" + undefined = -1 + nume = 1 + IF LEN(e$) = 1 THEN GOTO undefinedarray + undefined = 1 + nume = VAL(RIGHT$(e$, LEN(e$) - 1)) + GOTO undefinedarray + END IF + + + 'work out how many elements there are (critical to later calculations) + nume = 1 + n = numelements(e$) + FOR i = 1 TO n + e2$ = getelement(e$, i) + IF e2$ = "(" THEN b = b + 1 + IF b = 0 AND e2$ = "," THEN nume = nume + 1 + IF e2$ = ")" THEN b = b - 1 + NEXT + IF Debug THEN PRINT #9, "numelements count:"; nume + + descstatic = 0 + IF arraydesc THEN + IF id.arrayelements <> nume THEN + + IF id.arrayelements = -1 THEN 'unknown + IF arrayelementslist(currentid) <> 0 AND nume <> arrayelementslist(currentid) THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION + IF nume = 1 THEN id.arrayelements = 1: ids(currentid).arrayelements = 1 'lucky guess! + arrayelementslist(currentid) = nume + ELSE + Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION + END IF + + END IF + IF id.staticarray THEN descstatic = 1 + END IF + + l$ = "(" + sp2 + + cr$ = CHR$(13) + CHR$(10) + sd$ = "" + constdimensions = 1 + ei = 4 + nume * 4 - 4 + cure = 1 + e3$ = "": e3base$ = "" + FOR i = 1 TO n + e2$ = getelement(e$, i) + IF e2$ = "(" THEN b = b + 1 + IF (e2$ = "," AND b = 0) OR i = n THEN + IF i = n THEN e3$ = e3$ + sp + e2$ + e3$ = RIGHT$(e3$, LEN(e3$) - 1) + IF e3base$ <> "" THEN e3base$ = RIGHT$(e3base$, LEN(e3base$) - 1) + 'PRINT e3base$ + "[TO]" + e3$ + 'set the base + + basegiven = 1 + IF e3base$ = "" THEN e3base$ = str2$(optionbase + 0): basegiven = 0 + constequation = 1 + + e3base$ = fixoperationorder$(e3base$) + IF Error_Happened THEN EXIT FUNCTION + IF basegiven THEN l$ = l$ + tlayout$ + sp + SCase$("To") + sp + e3base$ = evaluatetotyp$(e3base$, 64&) + IF Error_Happened THEN EXIT FUNCTION + + IF constequation = 0 THEN constdimensions = 0 + sd$ = sd$ + n$ + "[" + str2(ei) + "]=" + e3base$ + ";" + cr$ + 'set the number of indexes + constequation = 1 + + e3$ = fixoperationorder$(e3$) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + tlayout$ + sp2 + IF i = n THEN l$ = l$ + ")" ELSE l$ = l$ + "," + sp + e3$ = evaluatetotyp$(e3$, 64&) + IF Error_Happened THEN EXIT FUNCTION + + IF constequation = 0 THEN constdimensions = 0 + ei = ei + 1 + sd$ = sd$ + n$ + "[" + str2(ei) + "]=(" + e3$ + ")-" + n$ + "[" + str2(ei - 1) + "]+1;" + cr$ + ei = ei + 1 + 'calc muliplier + IF cure = 1 THEN + 'set only for the purpose of the calculating correct multipliers + sd$ = sd$ + n$ + "[" + str2(ei) + "]=1;" + cr$ + ELSE + sd$ = sd$ + n$ + "[" + str2(ei) + "]=" + n$ + "[" + str2(ei + 4) + "]*" + n$ + "[" + str2(ei + 3) + "];" + cr$ + END IF + ei = ei + 1 + ei = ei + 1 'skip reserved + ei = ei - 8 + cure = cure + 1 + e3$ = "": e3base$ = "" + GOTO aanexte + END IF + IF e2$ = ")" THEN b = b - 1 + IF UCASE$(e2$) = "TO" AND b = 0 THEN + e3base$ = e3$ + e3$ = "" + ELSE + e3$ = e3$ + sp + e2$ + END IF + aanexte: + NEXT + sd$ = LEFT$(sd$, LEN(sd$) - 2) + + undefinedarray: + + 'calc cmem + cmem = 0 + IF arraydesc = 0 THEN + IF cmemlist(idn + 1) THEN cmem = 1 + ELSE + IF cmemlist(arraydesc) THEN cmem = 1 + END IF + + staticarray = constdimensions + IF subfuncn <> 0 AND dimstatic = 0 THEN staticarray = 0 'arrays in SUBS/FUNCTIONS are DYNAMIC + IF dimstatic = 3 THEN staticarray = 0 'STATIC arrayname() listed arrays keep thier values but are dynamic in memory + IF DynamicMode THEN staticarray = 0 + IF redimoption THEN staticarray = 0 + IF dimoption = 3 THEN staticarray = 0 'STATIC a(100) arrays are still dynamic + + IF arraydesc THEN + IF staticarray = 1 THEN + IF descstatic THEN Give_Error "Cannot redefine a static array!": EXIT FUNCTION + staticarray = 0 + END IF + END IF + + + + + + + bytesperelement$ = str2(elementsize) + IF elementsize < 0 THEN + elementsize = -elementsize + bytesperelement$ = str2(elementsize) + "/8+1" + END IF + + + 'Begin creation of array descriptor (if array has not been defined yet) + IF arraydesc = 0 THEN + PRINT #defdatahandle, "ptrszint *" + n$ + "=NULL;" + PRINT #13, "if (!" + n$ + "){" + PRINT #13, n$ + "=(ptrszint*)mem_static_malloc(" + str2(4 * nume + 4 + 1) + "*ptrsz);" '+1 is for the lock + 'create _MEM lock + PRINT #13, "new_mem_lock();" + PRINT #13, "mem_lock_tmp->type=4;" + PRINT #13, "((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "]=(ptrszint)mem_lock_tmp;" + END IF + + 'generate sizestr$ & elesizestr$ (both are used in various places in following code) + sizestr$ = "" + FOR i = 1 TO nume + IF i <> 1 THEN sizestr$ = sizestr$ + "*" + sizestr$ = sizestr$ + n$ + "[" + str2(i * 4 - 4 + 5) + "]" + NEXT + elesizestr$ = sizestr$ 'elements in entire array + sizestr$ = sizestr$ + "*" + bytesperelement$ 'bytes in entire array + + + + '------------------STATIC ARRAY CREATION-------------------------------- + IF staticarray THEN + 'STATIC memory + PRINT #13, sd$ 'setup new array dimension ranges + 'Example of sd$ for DIM a(10): + '__ARRAY_SINGLE_A[4]= 0 ; + '__ARRAY_SINGLE_A[5]=( 10 )-__ARRAY_SINGLE_A[4]+1; + '__ARRAY_SINGLE_A[6]=1; + IF cmem AND stringarray = 0 THEN + 'Note: A string array's pointers are always stored in 64bit memory + '(static)CONVENTINAL memory + PRINT #13, n$ + "[0]=(ptrszint)cmem_static_pointer;" + 'alloc mem & check if static memory boundry has oversteped dynamic memory boundry + PRINT #13, "if ((cmem_static_pointer+=((" + sizestr$ + ")+15)&-16)>cmem_dynamic_base) error(257);" + '64K check + PRINT #13, "if ((" + sizestr$ + ")>65536) error(257);" + 'clear array + PRINT #13, "memset((void*)(" + n$ + "[0]),0," + sizestr$ + ");" + 'set flags + PRINT #13, n$ + "[2]=1+2+4;" 'init+static+cmem + ELSE + '64BIT MEMORY + PRINT #13, n$ + "[0]=(ptrszint)mem_static_malloc(" + sizestr$ + ");" + IF stringarray THEN + 'Init string pointers in the array + PRINT #13, "tmp_long=" + elesizestr$ + ";" + PRINT #13, "while(tmp_long--){" + IF cmem THEN + PRINT #13, "((uint64*)(" + n$ + "[0]))[tmp_long]=(uint64)qbs_new_cmem(0,0);" + ELSE + PRINT #13, "((uint64*)(" + n$ + "[0]))[tmp_long]=(uint64)qbs_new(0,0);" + END IF + PRINT #13, "}" + ELSE + 'clear array + PRINT #13, "memset((void*)(" + n$ + "[0]),0," + sizestr$ + ");" + END IF + PRINT #13, n$ + "[2]=1+2;" 'init+static + END IF + + IF udt > 0 AND udtxvariable(udt) THEN + PRINT #13, "tmp_long=" + elesizestr$ + ";" + PRINT #13, "while(tmp_long--){" + initialise_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ + PRINT #13, acc$ + PRINT #13, "}" + END IF + + 'Close static array desc + PRINT #13, "}" + allocarray = nume + 65536 + END IF + '------------------END OF STATIC ARRAY CREATION------------------------- + + '------------------DYNAMIC ARRAY CREATION------------------------------- + IF staticarray = 0 THEN + + IF undefined = 0 THEN + + + + 'Generate error if array is static + f12$ = f12$ + CRLF + "if (" + n$ + "[2]&2){" 'static array + f12$ = f12$ + CRLF + "error(10);" 'cannot redefine a static array! + f12$ = f12$ + CRLF + "}else{" + 'Note: Array is either undefined or dynamically defined at this point + + + 'REDIM (not DIM) must be used to redefine an array + IF redimoption = 0 THEN + f12$ = f12$ + CRLF + "if (" + n$ + "[2]&1){" 'array is defined + f12$ = f12$ + CRLF + "if (!error_occurred) error(10);" 'cannot redefine an array without using REDIM! + f12$ = f12$ + CRLF + "}else{" + ELSE + '--------ERASE EXISTING ARRAY IF NECESSARY-------- + + 'IMPORTANT: If array is not going to be preserved, it should be cleared before + ' creating the new array for memory considerations + + 'refresh lock ID (_MEM) + f12$ = f12$ + CRLF + "((mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "])->id=(++mem_lock_id);" + + IF redimoption = 2 THEN + f12$ = f12$ + CRLF + "static int32 preserved_elements;" 'must be put here for scope considerations + END IF + + 'If array is defined, it must be destroyed first + f12$ = f12$ + CRLF + "if (" + n$ + "[2]&1){" 'array is defined + + IF redimoption = 2 THEN + f12$ = f12$ + CRLF + "preserved_elements=" + elesizestr$ + ";" + GOTO skiperase + END IF + + 'Note: pointers to strings must be freed before array can be freed + IF stringarray THEN + f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" + f12$ = f12$ + CRLF + "while(tmp_long--) qbs_free((qbs*)((uint64*)(" + n$ + "[0]))[tmp_long]);" + END IF + 'As must any variable length strings in UDT's + IF udt > 0 AND udtxvariable(udt) THEN + f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" + f12$ = f12$ + CRLF + "while(tmp_long--) {" + free_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ + f12$ = f12$ + acc$ + "}" + END IF + + 'Free array's memory + IF stringarray THEN + 'Note: String arrays are never in cmem + f12$ = f12$ + CRLF + "free((void*)(" + n$ + "[0]));" + ELSE + 'Note: Array may be in cmem! + f12$ = f12$ + CRLF + "if (" + n$ + "[2]&4){" 'array is in cmem + f12$ = f12$ + CRLF + "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" + f12$ = f12$ + CRLF + "}else{" 'not in cmem + f12$ = f12$ + CRLF + "free((void*)(" + n$ + "[0]));" + f12$ = f12$ + CRLF + "}" + END IF + + skiperase: + + f12$ = f12$ + CRLF + "}" 'array was defined + IF redimoption = 2 THEN + f12$ = f12$ + CRLF + "else preserved_elements=0;" 'if array wasn't defined, no elements are preserved + END IF + + + '--------ERASED ARRAY AS NECESSARY-------- + END IF 'redim specified + + + '--------CREATE ARRAY & CLEAN-UP CODE-------- + 'Overwrite existing array dimension sizes/ranges + f12$ = f12$ + CRLF + sd$ + IF stringarray OR ((udt > 0) AND udtxvariable(udt)) THEN + + 'Note: String and variable-length udt arrays are always created in 64bit memory + + IF redimoption = 2 THEN + f12$ = f12$ + CRLF + "if (preserved_elements){" + + f12$ = f12$ + CRLF + "static ptrszint tmp_long2;" + + 'free any qbs strings which will be lost in the realloc + f12$ = f12$ + CRLF + "tmp_long2=" + elesizestr$ + ";" + f12$ = f12$ + CRLF + "if (tmp_long2 0 AND udtxvariable(udt) THEN + PRINT #19, "while(tmp_long--) {" + acc$ = "" + free_array_udt_varstrings n$, udt, 0, bytesperelement$, acc$ + PRINT #19, acc$ + "}" + ELSE + PRINT #19, "while(tmp_long--) qbs_free((qbs*)((uint64*)(" + n$ + "[0]))[tmp_long]);" + END IF + PRINT #19, "free((void*)(" + n$ + "[0]));" + PRINT #19, "}" + 'free lock (_MEM) + PRINT #19, "free_mem_lock( (mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * nume + 4 + 1 - 1) + "] );" + END IF + + + ELSE 'not string/var-udt array + + '1. Create array + f12$ = f12$ + CRLF + "if (" + n$ + "[2]&4){" 'array will be in cmem + + IF redimoption = 2 THEN + f12$ = f12$ + CRLF + "if (preserved_elements){" + + 'reallocation method + 'backup data + f12$ = f12$ + CRLF + "memcpy(redim_preserve_cmem_buffer,(void*)(" + n$ + "[0]),preserved_elements*" + bytesperelement$ + ");" + 'free old array + f12$ = f12$ + CRLF + "cmem_dynamic_free((uint8*)(" + n$ + "[0]));" + f12$ = f12$ + CRLF + "tmp_long=" + elesizestr$ + ";" + f12$ = f12$ + CRLF + n$ + "[0]=(ptrszint)cmem_dynamic_malloc(tmp_long*" + bytesperelement$ + ");" + f12$ = f12$ + CRLF + "memcpy((void*)(" + n$ + "[0]),redim_preserve_cmem_buffer,preserved_elements*" + bytesperelement$ + ");" + f12$ = f12$ + CRLF + "if (preserved_elements 0 AND elements <> arrayelementslist(currentid) THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION + IF elements = 1 THEN id2.arrayelements = 1: ids(currentid).arrayelements = 1 'lucky guess + arrayelementslist(currentid) = elements + ELSE + IF elements <> id2.arrayelements THEN Give_Error "Cannot change the number of elements an array has!": EXIT FUNCTION + END IF + + curarg = 1 + firsti = 1 + FOR i = 1 TO n + l$ = getelement(a$, i) + IF l$ = "(" THEN b = b + 1 + IF l$ = ")" THEN b = b - 1 + IF (l$ = "," AND b = 0) OR (i = n) THEN + IF i = n THEN + IF l$ = "," THEN Give_Error "Array index missing": EXIT FUNCTION + e$ = evaluatetotyp(getelements$(a$, firsti, i), 64&) + IF Error_Happened THEN EXIT FUNCTION + ELSE + e$ = evaluatetotyp(getelements$(a$, firsti, i - 1), 64&) + IF Error_Happened THEN EXIT FUNCTION + END IF + IF e$ = "" THEN Give_Error "Array index missing": EXIT FUNCTION + argi = (elements - curarg) * 4 + 4 + IF curarg = 1 THEN + IF NoChecks = 0 THEN + r$ = r$ + "array_check((" + e$ + ")-" + n$ + "[" + str2(argi) + "]," + n$ + "[" + str2(argi + 1) + "])+" + ELSE + r$ = r$ + "(" + e$ + ")-" + n$ + "[" + str2(argi) + "]+" + END IF + + ELSE + IF NoChecks = 0 THEN + r$ = r$ + "array_check((" + e$ + ")-" + n$ + "[" + str2(argi) + "]," + n$ + "[" + str2(argi + 1) + "])*" + n$ + "[" + str2(argi + 2) + "]+" + ELSE + r$ = r$ + "((" + e$ + ")-" + n$ + "[" + str2(argi) + "])*" + n$ + "[" + str2(argi + 2) + "]+" + END IF + END IF + firsti = i + 1 + curarg = curarg + 1 + END IF + NEXT + r$ = LEFT$(r$, LEN(r$) - 1) 'remove trailing + + gotarrayindex: + + r$ = idnumber$ + sp3 + r$ + arrayreference$ = r$ + 'PRINT "arrayreference returning:" + r$ + +END FUNCTION + +SUB assign (a$, n) + FOR i = 1 TO n + c = ASC(getelement$(a$, i)) + IF c = 40 THEN b = b + 1 '( + IF c = 41 THEN b = b - 1 ') + IF c = 61 AND b = 0 THEN '= + IF i = 1 THEN Give_Error "Expected ... =": EXIT SUB + IF i = n THEN Give_Error "Expected = ...": EXIT SUB + + a2$ = fixoperationorder(getelements$(a$, 1, i - 1)) + IF Error_Happened THEN EXIT SUB + l$ = tlayout$ + sp + "=" + sp + + 'note: evaluating a2$ will fail if it is setting a function's return value without this check (as the function, not the return-variable) will be found by evaluate) + IF i = 2 THEN 'lhs has only 1 element + try = findid(a2$) + IF Error_Happened THEN EXIT SUB + DO WHILE try + IF id.t THEN + IF subfuncn = id.insubfuncn THEN 'avoid global before local + IF (id.t AND ISUDT) = 0 THEN + makeidrefer a2$, typ + GOTO assignsimplevariable + END IF + END IF + END IF + IF try = 2 THEN findanotherid = 1: try = findid(a2$) ELSE try = 0 + IF Error_Happened THEN EXIT SUB + LOOP + END IF + + a2$ = evaluate$(a2$, typ): IF Error_Happened THEN EXIT SUB + assignsimplevariable: + IF (typ AND ISREFERENCE) = 0 THEN Give_Error "Expected variable =": EXIT SUB + setrefer a2$, typ, getelements$(a$, i + 1, n), 0 + IF Error_Happened THEN EXIT SUB + tlayout$ = l$ + tlayout$ + + EXIT SUB + + END IF '=,b=0 + NEXT + Give_Error "Expected =": EXIT SUB +END SUB + +SUB clearid + id = cleariddata +END SUB + +SUB vWatchVariable (this$, action AS _BYTE) + STATIC totalLocalVariables AS LONG, localVariablesList$ + STATIC totalMainModuleVariables AS LONG, mainModuleVariablesList$ + + SELECT CASE action + CASE -1 'reset + totalLocalVariables = 0 + localVariablesList$ = "" + totalMainModuleVariables = 0 + mainModuleVariablesList$ = "" + CASE 0 'add + IF INSTR(vWatchVariableExclusions$, "@" + this$ + "@") > 0 OR LEFT$(this$, 12) = "_SUB_VWATCH_" THEN + EXIT SUB + END IF + + vWatchNewVariable$ = this$ + IF subfunc = "" THEN + totalMainModuleVariables = totalMainModuleVariables + 1 + mainModuleVariablesList$ = mainModuleVariablesList$ + "vwatch_global_vars[" + str2$(totalMainModuleVariables - 1) + "] = &" + this$ + ";" + CRLF + manageVariableList id.cn, this$, totalMainModuleVariables - 1, 0 + ELSE + totalLocalVariables = totalLocalVariables + 1 + localVariablesList$ = localVariablesList$ + "vwatch_local_vars[" + str2$(totalLocalVariables - 1) + "] = &" + this$ + ";" + CRLF + manageVariableList id.cn, this$, totalLocalVariables - 1, 0 + END IF + CASE 1 'dump to data[].txt & reset + IF subfunc = "" THEN + IF totalMainModuleVariables > 0 THEN + PRINT #13, "void *vwatch_local_vars[0];" + PRINT #18, "void *vwatch_global_vars["; totalMainModuleVariables; "];" + PRINT #13, mainModuleVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" + PRINT #18, "void *vwatch_global_vars[0];" + END IF + + mainModuleVariablesList$ = "" + totalMainModuleVariables = 0 + ELSE + IF subfunc <> "SUB_VWATCH" THEN + IF totalLocalVariables > 0 THEN + PRINT #13, "void *vwatch_local_vars["; (totalLocalVariables); "];" + PRINT #13, localVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" + END IF + ELSE + PRINT #13, "void *vwatch_local_vars[0];" + END IF + + localVariablesList$ = "" + totalLocalVariables = 0 + END IF + END SELECT +END SUB + +SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) + STATIC prevLabel AS LONG, prevSkip AS LONG + + IF lastLine = 0 THEN + WHILE this > LEN(vWatchUsedLabels) + vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) + vWatchUsedSkipLabels = vWatchUsedSkipLabels + SPACE$(1000) + WEND + + IF firstLineNumberLabelvWatch = 0 THEN + firstLineNumberLabelvWatch = this + ELSE + IF prevSkip <> prevLabel THEN + ASC(vWatchUsedSkipLabels, prevLabel) = 1 + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + prevSkip = prevLabel + END IF + END IF + + IF prevLabel <> this THEN + ASC(vWatchUsedLabels, this) = 1 + PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;" + prevLabel = this + lastLineNumberLabelvWatch = this + END IF + ELSE + IF prevSkip <> prevLabel THEN + ASC(vWatchUsedSkipLabels, prevLabel) = 1 + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + prevSkip = prevLabel + END IF + END IF +END SUB + +SUB closemain + xend + + PRINT #12, "return;" + + IF vWatchOn AND firstLineNumberLabelvWatch > 0 THEN + PRINT #12, "VWATCH_SETNEXTLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case " + str2$(i) + ":" + PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, " default:" + PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" + PRINT #12, " goto VWATCH_SETNEXTLINE;" + PRINT #12, "}" + + PRINT #12, "VWATCH_SKIPLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedSkipLabels, i) = 1 THEN + PRINT #12, " case -" + str2$(i) + ":" + PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, "}" + + END IF + + PRINT #12, "}" + PRINT #15, "}" 'end case + PRINT #15, "}" + PRINT #15, "error(3);" 'no valid return possible + + closedmain = 1 + firstLineNumberLabelvWatch = 0 +END SUB + +FUNCTION countelements (a$) + n = numelements(a$) + c = 1 + FOR i = 1 TO n + e$ = getelement$(a$, i) + IF e$ = "(" THEN b = b + 1 + IF e$ = ")" THEN b = b - 1 + IF b < 0 THEN Give_Error "Unexpected ) encountered": EXIT FUNCTION + IF e$ = "," AND b = 0 THEN c = c + 1 + NEXT + countelements = c +END FUNCTION + + + +FUNCTION dim2 (varname$, typ2$, method, elements$) + + 'notes: (DO NOT REMOVE THESE IMPORTANT USAGE NOTES) + ' + '(shared)dimsfarray: Creates an ID only (no C++ code) + ' Adds an index/'link' to the sub/function's argument + ' ID.sfid=glinkid + ' ID.sfarg=glinkarg + ' Sets arrayelements=-1 'unknown' (if elements$="?") otherwise val(elements$) + ' ***Does not refer to arrayelementslist()*** + ' + '(argument)method: 0 being created by a DIM name AS type + ' 1 being created by a DIM name+symbol + ' or automatically without the use of DIM + ' + 'elements$="?": (see also dimsfarray for that special case) + ' Checks arrayelementslist() and; + ' if unknown(=0), creates an ID only + ' if known, creates a DYNAMIC array's C++ initialization code so it can be used later + + typ$ = typ2$ + dim2 = 1 'success + + IF Debug THEN PRINT #9, "dim2 called", method + + cvarname$ = varname$ + l$ = cvarname$ + varname$ = UCASE$(varname$) + + IF dimsfarray = 1 THEN f = 0 ELSE f = 1 + + IF dimstatic <> 0 AND dimshared = 0 THEN + 'name will have include the sub/func name in its scope + 'variable/array will be created in main on startup + defdatahandle = 18 'change from 13 to 18(global.txt) + CLOSE #13: OPEN tmpdir$ + "maindata.txt" FOR APPEND AS #13 + CLOSE #19: OPEN tmpdir$ + "mainfree.txt" FOR APPEND AS #19 + END IF + + + scope2$ = module$ + "_" + subfunc$ + "_" + 'Note: when REDIMing a SHARED array in dynamic memory scope2$ must be modified + + IF LEN(typ$) = 0 THEN Give_Error "DIM2: No type specified!": EXIT FUNCTION + + 'UDT + 'is it a udt? + FOR i = 1 TO lasttype + IF typ$ = RTRIM$(udtxname(i)) OR (typ$ = "MEM" AND RTRIM$(udtxname(i)) = "_MEM" AND qb64prefix_set = 1) THEN + dim2typepassback$ = RTRIM$(udtxcname(i)) + IF typ$ = "MEM" AND RTRIM$(udtxname(i)) = "_MEM" THEN + dim2typepassback$ = MID$(RTRIM$(udtxcname(i)), 2) + END IF + + n$ = "UDT_" + varname$ + + 'array of UDTs + IF elements$ <> "" THEN + arraydesc = 0 + IF f = 1 THEN + try = findid(varname$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(varname$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + bits = udtxsize(i) + IF udtxbytealign(i) THEN + IF bits MOD 8 THEN bits = bits + 8 - (bits MOD 8) + END IF + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, -bits, i) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = UDTTYPE + i + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + id.n = cvarname$ + + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + regid + vWatchVariable n$, 0 + IF Error_Happened THEN EXIT FUNCTION + GOTO dim2exitfunc + END IF + + 'not an array of UDTs + bits = udtxsize(i): bytes = bits \ 8 + IF bits MOD 8 THEN + bytes = bytes + 1 + END IF + n$ = scope2$ + n$ + IF f THEN PRINT #defdatahandle, "void *" + n$ + "=NULL;" + clearid + id.n = cvarname$ + id.t = UDTTYPE + i + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f THEN + PRINT #13, "if(" + n$ + "==NULL){" + PRINT #13, "cmem_sp-=" + str2(bytes) + ";" + PRINT #13, "if (cmem_sp 6 THEN + IF LEFT$(typ$, 9) <> "STRING * " THEN Give_Error "Expected STRING * number/constant": EXIT FUNCTION + + c$ = RIGHT$(typ$, LEN(typ$) - 9) + + 'constant check 2011 + hashfound = 0 + hashname$ = c$ + hashchkflags = HASHFLAG_CONSTANT + hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN + IF constdefined(hashresref) THEN + hashfound = 1 + EXIT DO + END IF + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + IF hashfound THEN + i2 = hashresref + t = consttype(i2) + IF t AND ISSTRING THEN Give_Error "Expected STRING * numeric-constant": EXIT FUNCTION + 'convert value to general formats + IF t AND ISFLOAT THEN + v## = constfloat(i2) + v&& = v## + v~&& = v&& + ELSE + IF t AND ISUNSIGNED THEN + v~&& = constuinteger(i2) + v&& = v~&& + v## = v&& + ELSE + v&& = constinteger(i2) + v## = v&& + v~&& = v&& + END IF + END IF + IF v&& < 1 OR v&& > 9999999999 THEN Give_Error "STRING * out-of-range constant": EXIT FUNCTION + bytes = v&& + dim2typepassback$ = SCase$("String * ") + constcname(i2) + GOTO constantlenstr + END IF + + IF isuinteger(c$) = 0 THEN Give_Error "Number/Constant expected after *": EXIT FUNCTION + IF LEN(c$) > 10 THEN Give_Error "Too many characters in number after *": EXIT FUNCTION + bytes = VAL(c$) + IF bytes = 0 THEN Give_Error "Cannot create a fixed string of length 0": EXIT FUNCTION + constantlenstr: + n$ = "STRING" + str2(bytes) + "_" + varname$ + + 'array of fixed length strings + IF elements$ <> "" THEN + arraydesc = 0 + IF f = 1 THEN + try = findid(varname$ + "$") + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(varname$ + "$") ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, bytes) + 'IF arraydesc THEN goto dim2exitfunc 'id already exists! + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, bytes, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = STRINGTYPE + ISFIXEDLENGTH + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + id.n = cvarname$ + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + id.tsize = bytes + IF method = 0 THEN + id.mayhave = "$" + str2(bytes) + END IF + IF method = 1 THEN + id.musthave = "$" + str2(bytes) + END IF + regid + IF Error_Happened THEN EXIT FUNCTION + vWatchVariable n$, 0 + GOTO dim2exitfunc + END IF + + 'standard fixed length string + n$ = scope2$ + n$ + IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" + IF f THEN PRINT #19, "qbs_free(" + n$ + ");" 'so descriptor can be freed + clearid + id.n = cvarname$ + id.t = STRINGTYPE + ISFIXEDLENGTH + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f THEN PRINT #13, "if(" + n$ + "==NULL){" + IF f THEN PRINT #13, "cmem_sp-=" + str2(bytes) + ";" + IF f THEN PRINT #13, "if (cmem_spchr,0," + str2(bytes) + ");" + IF f THEN PRINT #13, "}" + ELSE + IF f THEN PRINT #13, "if(" + n$ + "==NULL){" + o$ = "(uint8*)mem_static_malloc(" + str2$(bytes) + ")" + IF f THEN PRINT #13, n$ + "=qbs_new_fixed(" + o$ + "," + str2$(bytes) + ",0);" + IF f THEN PRINT #13, "memset(" + n$ + "->chr,0," + str2$(bytes) + ");" + IF f THEN PRINT #13, "}" + END IF + id.tsize = bytes + IF method = 0 THEN + id.mayhave = "$" + str2(bytes) + END IF + IF method = 1 THEN + id.musthave = "$" + str2(bytes) + END IF + id.callname = n$ + regid + vWatchVariable n$, 0 + IF Error_Happened THEN EXIT FUNCTION + GOTO dim2exitfunc + END IF + + 'variable length string processing + n$ = "STRING_" + varname$ + + 'array of variable length strings + IF elements$ <> "" THEN + arraydesc = 0 + IF f = 1 THEN + try = findid(varname$ + "$") + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(varname$ + "$") ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, -2147483647) '-2147483647=STRING + 'IF arraydesc THEN goto dim2exitfunc 'id already exists! + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, -2147483647, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.n = cvarname$ + id.arraytype = STRINGTYPE + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + IF method = 0 THEN + id.mayhave = "$" + END IF + IF method = 1 THEN + id.musthave = "$" + END IF + regid + IF Error_Happened THEN EXIT FUNCTION + vWatchVariable n$, 0 + GOTO dim2exitfunc + END IF + + 'standard variable length string + n$ = scope2$ + n$ + clearid + id.n = cvarname$ + id.t = STRINGTYPE + IF cmemlist(idn + 1) THEN + IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" + IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new_cmem(0,0);" + id.t = id.t + ISINCONVENTIONALMEMORY + ELSE + IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" + IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new(0,0);" + END IF + IF f THEN PRINT #19, "qbs_free(" + n$ + ");" + IF method = 0 THEN + id.mayhave = "$" + END IF + IF method = 1 THEN + id.musthave = "$" + END IF + id.callname = n$ + regid + vWatchVariable n$, 0 + IF Error_Happened THEN EXIT FUNCTION + GOTO dim2exitfunc + END IF + + IF LEFT$(typ$, 4) = "_BIT" OR (LEFT$(typ$, 3) = "BIT" AND qb64prefix_set = 1) THEN + IF (LEFT$(typ$, 4) = "_BIT" AND LEN(typ$) > 4) OR (LEFT$(typ$, 3) = "BIT" AND LEN(typ$) > 3) THEN + IF LEFT$(typ$, 7) <> "_BIT * " AND LEFT$(typ$, 6) <> "BIT * " THEN Give_Error "Expected " + qb64prefix$ + "BIT * number": EXIT FUNCTION + c$ = MID$(typ$, INSTR(typ$, " * ") + 3) + IF isuinteger(c$) = 0 THEN Give_Error "Number expected after *": EXIT FUNCTION + IF LEN(c$) > 2 THEN Give_Error "Cannot create a bit variable of size > 64 bits": EXIT FUNCTION + bits = VAL(c$) + IF bits = 0 THEN Give_Error "Cannot create a bit variable of size 0 bits": EXIT FUNCTION + IF bits > 64 THEN Give_Error "Cannot create a bit variable of size > 64 bits": EXIT FUNCTION + ELSE + bits = 1 + END IF + IF bits <= 32 THEN ct$ = "int32" ELSE ct$ = "int64" + IF unsgn THEN n$ = "U": ct$ = "u" + ct$ + n$ = n$ + "BIT" + str2(bits) + "_" + varname$ + + 'array of bit-length variables + IF elements$ <> "" THEN + IF bits > 63 THEN Give_Error "Cannot create a bit array of size > 63 bits": EXIT FUNCTION + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "`" + str2(bits) + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, -bits) 'passing a negative element size signifies bits not bytes + 'IF arraydesc THEN goto dim2exitfunc 'id already exists! + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, -bits, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.n = cvarname$ + id.arraytype = BITTYPE - 1 + bits + IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + IF method = 0 THEN + IF unsgn THEN id.mayhave = "~`" + str2(bits) ELSE id.mayhave = "`" + str2(bits) + END IF + IF method = 1 THEN + IF unsgn THEN id.musthave = "~`" + str2(bits) ELSE id.musthave = "`" + str2(bits) + END IF + regid + IF Error_Happened THEN EXIT FUNCTION + vWatchVariable n$, 0 + GOTO dim2exitfunc + END IF + 'standard bit-length variable + n$ = scope2$ + n$ + PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + PRINT #13, "if(" + n$ + "==NULL){" + PRINT #13, "cmem_sp-=4;" + PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "%%" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 1) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 1, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = BYTETYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = BYTETYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=1;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "%" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 2, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + + id.arraytype = INTEGERTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = INTEGERTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=2;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "%&" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, OS_BITS \ 8, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = OFFSETTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = OFFSETTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=" + str2(OS_BITS \ 8) + ";" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "&" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 4) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 4, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = LONGTYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = LONGTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=4;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$: IF unsgn THEN cmps$ = cmps$ + "~" + cmps$ = cmps$ + "&&" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 8) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 8, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = INTEGER64TYPE: IF unsgn THEN id.arraytype = id.arraytype + ISUNSIGNED + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = INTEGER64TYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=8;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$ + "!" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 4) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 4, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = SINGLETYPE + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = SINGLETYPE + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=4;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$ + "#" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 8) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 8, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = DOUBLETYPE + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = DOUBLETYPE + IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f = 1 THEN PRINT #13, "cmem_sp-=8;" + IF f = 1 THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f = 1 THEN PRINT #13, "if (cmem_sp "" THEN + arraydesc = 0 + cmps$ = varname$ + "##" + IF f = 1 THEN + try = findid(cmps$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (id.arraytype) THEN + l$ = RTRIM$(id.cn) + arraydesc = currentid: scope2$ = scope$ + EXIT DO + END IF + IF try = 2 THEN findanotherid = 1: try = findid(cmps$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + n$ = scope2$ + "ARRAY_" + n$ + + 'nume = allocarray(n$, elements$, 32) + 'IF arraydesc THEN goto dim2exitfunc + 'clearid + + IF f = 1 THEN + + IF LEN(elements$) = 1 AND ASC(elements$) = 63 THEN '"?" + E = arrayelementslist(idn + 1): IF E THEN elements$ = elements$ + str2$(E) 'eg. "?3" for a 3 dimensional array + END IF + nume = allocarray(n$, elements$, 32, 0) + IF Error_Happened THEN EXIT FUNCTION + l$ = l$ + sp + tlayout$ + IF arraydesc THEN GOTO dim2exitfunc + clearid + + ELSE + clearid + IF elements$ = "?" THEN + nume = -1 + id.linkid = glinkid + id.linkarg = glinkarg + ELSE + nume = VAL(elements$) + END IF + END IF + + id.arraytype = FLOATTYPE + IF cmemlist(idn + 1) THEN id.arraytype = id.arraytype + ISINCONVENTIONALMEMORY + IF nume > 65536 THEN nume = nume - 65536: id.staticarray = 1 + + id.arrayelements = nume + id.callname = n$ + ELSE + n$ = scope2$ + n$ + clearid + id.t = FLOATTYPE + IF f THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" + IF f THEN PRINT #13, "if(" + n$ + "==NULL){" + IF cmemlist(idn + 1) THEN + id.t = id.t + ISINCONVENTIONALMEMORY + IF f THEN PRINT #13, "cmem_sp-=32;" + IF f THEN PRINT #13, n$ + "=(" + ct$ + "*)(dblock+cmem_sp);" + IF f THEN PRINT #13, "if (cmem_sp 0 AND dimshared = 0 THEN + defdatahandle = 13 + CLOSE #13: OPEN tmpdir$ + "data" + str2$(subfuncn) + ".txt" FOR APPEND AS #13 + CLOSE #19: OPEN tmpdir$ + "free" + str2$(subfuncn) + ".txt" FOR APPEND AS #19 + END IF + + tlayout$ = l$ + +END FUNCTION + + +FUNCTION udtreference$ (o$, a$, typ AS LONG) + 'UDT REFERENCE FORMAT + 'idno|udtno|udtelementno|byteoffset + ' ^udt of the element, not of the id + + obak$ = o$ + + 'PRINT "called udtreference!" + + + r$ = str2$(currentid) + sp3 + + + o = 0 'the fixed/known part of the offset + + incmem = 0 + IF id.t THEN + u = id.t AND 511 + IF id.t AND ISINCONVENTIONALMEMORY THEN incmem = 1 + ELSE + u = id.arraytype AND 511 + IF id.arraytype AND ISINCONVENTIONALMEMORY THEN incmem = 1 + END IF + E = 0 + + n = numelements(a$) + IF n = 0 THEN GOTO fulludt + + i = 1 + udtfindelenext: + IF getelement$(a$, i) <> "." THEN Give_Error "Expected .": EXIT FUNCTION + i = i + 1 + n$ = getelement$(a$, i) + nsym$ = removesymbol(n$): IF LEN(nsym$) THEN ntyp = typname2typ(nsym$): ntypsize = typname2typsize + IF Error_Happened THEN EXIT FUNCTION + + IF n$ = "" THEN Give_Error "Expected .elementname": EXIT FUNCTION + udtfindele: + IF E = 0 THEN E = udtxnext(u) ELSE E = udtenext(E) + IF E = 0 THEN Give_Error "Element not defined": EXIT FUNCTION + n2$ = RTRIM$(udtename(E)) + IF udtebytealign(E) THEN + IF o MOD 8 THEN o = o + (8 - (o MOD 8)) + END IF + + IF n$ <> n2$ THEN + 'increment fixed offset + o = o + udtesize(E) + GOTO udtfindele + END IF + + 'check symbol after element's name (if given) is correct + IF LEN(nsym$) THEN + + IF udtetype(E) AND ISUDT THEN Give_Error "Invalid symbol after user defined type": EXIT FUNCTION + IF ntyp <> udtetype(E) OR ntypsize <> udtetypesize(E) THEN + IF nsym$ = "$" AND ((udtetype(E) AND ISFIXEDLENGTH) <> 0) THEN GOTO correctsymbol + Give_Error "Incorrect symbol after element name": EXIT FUNCTION + END IF + END IF + correctsymbol: + + 'Move into another UDT structure? + IF i <> n THEN + IF (udtetype(E) AND ISUDT) = 0 THEN Give_Error "Expected user defined type": EXIT FUNCTION + u = udtetype(E) AND 511 + E = 0 + i = i + 1 + GOTO udtfindelenext + END IF + + 'Change e reference to u | 0 reference? + IF udtetype(E) AND ISUDT THEN + u = udtetype(E) AND 511 + E = 0 + END IF + + fulludt: + + r$ = r$ + str2$(u) + sp3 + str2$(E) + sp3 + + IF o MOD 8 THEN Give_Error "QB64 cannot handle bit offsets within user defined types": EXIT FUNCTION + o = o \ 8 + + IF o$ <> "" THEN + IF o <> 0 THEN 'dont add an unnecessary 0 + o$ = o$ + "+" + str2$(o) + END IF + ELSE + o$ = str2$(o) + END IF + + r$ = r$ + o$ + + udtreference$ = r$ + typ = udtetype(E) + ISUDT + ISREFERENCE + + 'full udt override: + IF E = 0 THEN + typ = u + ISUDT + ISREFERENCE + END IF + + IF obak$ <> "" THEN typ = typ + ISARRAY + IF incmem THEN typ = typ + ISINCONVENTIONALMEMORY + + 'print "UDTREF:"+r$+","+str2$(typ) + +END FUNCTION + +FUNCTION evaluate$ (a2$, typ AS LONG) + DIM block(1000) AS STRING + DIM evaledblock(1000) AS INTEGER + DIM blocktype(1000) AS LONG + 'typ IS A RETURN VALUE + '''DIM cli(15) AS INTEGER + a$ = a2$ + typ = -1 + + IF Debug THEN PRINT #9, "evaluating:[" + a2$ + "]" + IF a2$ = "" THEN Give_Error "Syntax error": EXIT FUNCTION + + + + + + + '''cl$ = classify(a$) + + blockn = 0 + n = numelements(a$) + b = 0 'bracketting level + FOR i = 1 TO n + + reevaluate: + + + + + l$ = getelement(a$, i) + + + IF Debug THEN PRINT #9, "#*#*#* reevaluating:" + l$, i + + + IF i <> n THEN nextl$ = getelement(a$, i + 1) ELSE nextl$ = "" + + '''getclass cl$, i, cli() + + IF b = 0 THEN 'don't evaluate anything within brackets + + IF Debug THEN PRINT #9, l$ + + l2$ = l$ 'pure version of l$ + FOR try_method = 1 TO 4 + l$ = l2$ + IF try_method = 2 OR try_method = 4 THEN + IF Error_Happened THEN EXIT FUNCTION + dtyp$ = removesymbol(l$): IF Error_Happened THEN dtyp$ = "": Error_Happened = 0 + IF LEN(dtyp$) = 0 THEN + IF isoperator(l$) = 0 THEN + IF isvalidvariable(l$) THEN + IF LEFT$(l$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(l$)) - 64 + l$ = l$ + defineextaz(v) + END IF + END IF + ELSE + l$ = l2$ + END IF + END IF + try = findid(l$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + + IF Debug THEN PRINT #9, try + + 'is l$ an array? + IF nextl$ = "(" THEN + IF id.arraytype THEN + IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN + arrayid = currentid + constequation = 0 + i2 = i + 2 + b2 = 0 + evalnextele3: + l2$ = getelement(a$, i2) + IF l2$ = "(" THEN b2 = b2 + 1 + IF l2$ = ")" THEN + b2 = b2 - 1 + IF b2 = -1 THEN + c$ = arrayreference(getelements$(a$, i + 2, i2 - 1), typ2) + IF Error_Happened THEN EXIT FUNCTION + i = i2 + + 'UDT + IF typ2 AND ISUDT THEN + 'print "arrayref returned:"+c$ + getid arrayid + IF Error_Happened THEN EXIT FUNCTION + o$ = RIGHT$(c$, LEN(c$) - INSTR(c$, sp3)) + 'change o$ to a byte offset if necessary + u = typ2 AND 511 + s = udtxsize(u) + IF udtxbytealign(u) THEN + IF s MOD 8 THEN s = s + (8 - (s MOD 8)) 'round up to nearest byte + s = s \ 8 + END IF + o$ = "(" + o$ + ")*" + str2$(s) + 'print "calling evaludt with o$:"+o$ + GOTO evaludt + END IF + + GOTO evalednextele3 + END IF + END IF + i2 = i2 + 1 + GOTO evalnextele3 + evalednextele3: + blockn = blockn + 1 + block(blockn) = c$ + evaledblock(blockn) = 2 + blocktype(blockn) = typ2 + IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 + GOTO evaled + END IF + END IF + + ELSE + 'not followed by "(" + + 'is l$ a simple variable? + IF id.t <> 0 AND (id.t AND ISUDT) = 0 THEN + IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN + constequation = 0 + blockn = blockn + 1 + makeidrefer block(blockn), blocktype(blockn) + IF (blocktype(blockn) AND ISSTRING) THEN stringprocessinghappened = 1 + evaledblock(blockn) = 2 + GOTO evaled + END IF + END IF + + 'is l$ a UDT? + IF id.t AND ISUDT THEN + IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN + constequation = 0 + o$ = "" + evaludt: + b2 = 0 + i3 = i + 1 + FOR i2 = i3 TO n + e2$ = getelement(a$, i2) + IF e2$ = "(" THEN b2 = b2 + 1 + IF b2 = 0 THEN + IF e2$ = ")" OR isoperator(e2$) THEN + i4 = i2 - 1 + GOTO gotudt + END IF + END IF + IF e2$ = ")" THEN b2 = b2 - 1 + NEXT + i4 = n + gotudt: + IF i4 < i3 THEN e$ = "" ELSE e$ = getelements$(a$, i3, i4) + 'PRINT "UDTREFERENCE:";l$; e$ + e$ = udtreference(o$, e$, typ2) + IF Error_Happened THEN EXIT FUNCTION + i = i4 + blockn = blockn + 1 + block(blockn) = e$ + evaledblock(blockn) = 2 + blocktype(blockn) = typ2 + 'is the following next necessary? + 'IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 + GOTO evaled + END IF + END IF + + END IF '"(" or no "(" + + 'is l$ a function? + IF id.subfunc = 1 THEN + constequation = 0 + IF getelement(a$, i + 1) = "(" THEN + i2 = i + 2 + b2 = 0 + args = 1 + evalnextele: + l2$ = getelement(a$, i2) + IF l2$ = "(" THEN b2 = b2 + 1 + IF l2$ = ")" THEN + b2 = b2 - 1 + IF b2 = -1 THEN + IF i2 = i + 2 THEN Give_Error "Expected (...)": EXIT FUNCTION + c$ = evaluatefunc(getelements$(a$, i + 2, i2 - 1), args, typ2) + IF Error_Happened THEN EXIT FUNCTION + i = i2 + GOTO evalednextele + END IF + END IF + IF l2$ = "," AND b2 = 0 THEN args = args + 1 + i2 = i2 + 1 + GOTO evalnextele + ELSE + 'no brackets + c$ = evaluatefunc("", 0, typ2) + IF Error_Happened THEN EXIT FUNCTION + END IF + evalednextele: + blockn = blockn + 1 + block(blockn) = c$ + evaledblock(blockn) = 2 + blocktype(blockn) = typ2 + IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 + GOTO evaled + END IF + + IF try = 2 THEN findanotherid = 1: try = findid(l$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + NEXT 'try method (1-4) + + 'assume l$ an undefined array? + + IF i <> n THEN + IF getelement$(a$, i + 1) = "(" THEN + IF isoperator(l$) = 0 THEN + IF isvalidvariable(l$) THEN + IF Debug THEN + PRINT #9, "**************" + PRINT #9, "about to auto-create array:" + l$, i + PRINT #9, "**************" + END IF + dtyp$ = removesymbol(l$) + IF Error_Happened THEN EXIT FUNCTION + 'count the number of elements + nume = 1 + b2 = 0 + FOR i2 = i + 2 TO n + e$ = getelement(a$, i2) + IF e$ = "(" THEN b2 = b2 + 1 + IF b2 = 0 AND e$ = "," THEN nume = nume + 1 + IF e$ = ")" THEN b2 = b2 - 1 + IF b2 = -1 THEN EXIT FOR + NEXT + fakee$ = "10": FOR i2 = 2 TO nume: fakee$ = fakee$ + sp + "," + sp + "10": NEXT + IF Debug THEN PRINT #9, "evaluate:creating undefined array using dim2(" + l$ + "," + dtyp$ + ",1," + fakee$ + ")" + IF optionexplicit OR optionexplicitarray THEN Give_Error "Array '" + l$ + "' (" + symbol2fulltypename$(dtyp$) + ") not defined": EXIT FUNCTION + IF Error_Happened THEN EXIT FUNCTION + olddimstatic = dimstatic + method = 1 + IF subfuncn THEN + autoarray = 1 'move dimensioning of auto array to data???.txt from inline + 'static array declared by STATIC name()? + 'check if varname is on the static list + xi = 1 + FOR x = 1 TO staticarraylistn + varname2$ = getelement$(staticarraylist, xi): xi = xi + 1 + typ2$ = getelement$(staticarraylist, xi): xi = xi + 1 + dimmethod2 = VAL(getelement$(staticarraylist, xi)): xi = xi + 1 + 'check if they are similar + IF UCASE$(l$) = UCASE$(varname2$) THEN + l3$ = l2$: s$ = removesymbol(l3$) + IF symbol2fulltypename$(dtyp$) = typ2$ OR (dimmethod2 = 0 AND s$ = "") THEN + IF Error_Happened THEN EXIT FUNCTION + 'adopt properties + l$ = varname2$ + dtyp$ = typ2$ + method = dimmethod2 + dimstatic = 3 + END IF 'typ + IF Error_Happened THEN EXIT FUNCTION + END IF 'varname + NEXT + END IF 'subfuncn + bypassNextVariable = -1 + ignore = dim2(l$, dtyp$, method, fakee$) + IF Error_Happened THEN EXIT FUNCTION + dimstatic = olddimstatic + IF Debug THEN PRINT #9, "#*#*#* dim2 has returned!!!" + GOTO reevaluate + END IF + END IF + END IF + END IF + + l$ = l2$ 'restore l$ + + END IF 'b=0 + + IF l$ = "(" THEN + IF b = 0 THEN i1 = i + 1 + b = b + 1 + END IF + + IF b = 0 THEN + blockn = blockn + 1 + block(blockn) = l$ + evaledblock(blockn) = 0 + END IF + + IF l$ = ")" THEN + b = b - 1 + IF b = 0 THEN + c$ = evaluate(getelements$(a$, i1, i - 1), typ2) + IF Error_Happened THEN EXIT FUNCTION + IF (typ2 AND ISSTRING) THEN stringprocessinghappened = 1 + blockn = blockn + 1 + IF (typ2 AND ISPOINTER) THEN + block(blockn) = c$ + ELSE + block(blockn) = "(" + c$ + ")" + END IF + evaledblock(blockn) = 1 + blocktype(blockn) = typ2 + END IF + END IF + evaled: + NEXT + + r$ = "" 'return value + + IF Debug THEN PRINT #9, "evaluated blocks:"; + FOR i = 1 TO blockn + IF i <> blockn THEN + IF Debug THEN PRINT #9, block(i) + CHR$(219); + ELSE + IF Debug THEN PRINT #9, block(i) + END IF + NEXT + + + + 'identify any referencable values + FOR i = 1 TO blockn + IF isoperator(block(i)) = 0 THEN + IF evaledblock(i) = 0 THEN + + 'a number? + c = ASC(LEFT$(block(i), 1)) + IF c = 45 OR (c >= 48 AND c <= 57) THEN + num$ = block(i) + 'a float? + f = 0 + x = INSTR(num$, "E") + IF x THEN + f = 1: blocktype(i) = SINGLETYPE - ISPOINTER + ELSE + x = INSTR(num$, "D") + IF x THEN + f = 2: blocktype(i) = DOUBLETYPE - ISPOINTER + ELSE + x = INSTR(num$, "F") + IF x THEN + f = 3: blocktype(i) = FLOATTYPE - ISPOINTER + END IF + END IF + END IF + IF f THEN + 'float + IF f = 2 OR f = 3 THEN MID$(num$, x, 1) = "E" 'D,F invalid in C++ + IF f = 3 THEN num$ = num$ + "L" 'otherwise number is rounded to a double + ELSE + 'integer + blocktype(i) = typname2typ(removesymbol$(num$)) + IF Error_Happened THEN EXIT FUNCTION + IF blocktype(i) AND ISPOINTER THEN blocktype(i) = blocktype(i) - ISPOINTER + IF (blocktype(i) AND 511) > 32 THEN + IF blocktype(i) AND ISUNSIGNED THEN num$ = num$ + "ull" ELSE num$ = num$ + "ll" + END IF + END IF + block(i) = " " + num$ + " " 'pad with spaces to avoid C++ computation errors + evaledblock(i) = 1 + GOTO evaledblock + END IF + + 'number? + 'fc = ASC(LEFT$(block(i), 1)) + 'IF fc = 45 OR (fc >= 48 AND fc <= 57) THEN '- or 0-9 + ''it's a number + ''check for an extension, if none, assume integer + 'blocktype(i) = INTEGER64TYPE - ISPOINTER + 'tblock$ = " " + block(i) + 'IF RIGHT$(tblock$, 2) = "##" THEN blocktype(i) = FLOATTYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 2): GOTO evfltnum + 'IF RIGHT$(tblock$, 1) = "#" THEN blocktype(i) = DOUBLETYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 1): GOTO evfltnum + 'IF RIGHT$(tblock$, 1) = "!" THEN blocktype(i) = SINGLETYPE - ISPOINTER: block(i) = LEFT$(block(i), LEN(block$(i)) - 1): GOTO evfltnum + ' + ''C++ 32bit unsigned to signed 64bit + 'IF INSTR(block(i),".")=0 THEN + ' + 'negated=0 + 'if left$(block(i),1)="-" then block(i)=right$(block(i),len(block(i))-1):negated=1 + ' + 'if left$(block(i),2)="0x" then 'hex + 'if len(block(i))=10 then + 'if block(i)>="0x80000000" and block(i)<="0xFFFFFFFF" then block(i)="(int64)"+block(i): goto evnum + 'end if + 'if len(block(i))>10 then block(i)=block(i)+"ll": goto evnum + 'goto evnum + 'end if + ' + 'if left$(block(i),1)="0" then 'octal + 'if len(block(i))=12 then + 'if block(i)>="020000000000" and block(i)<="037777777777" then block(i)="(int64)"+block(i): goto evnum + 'if block(i)>"037777777777" then block(i)=block(i)+"ll": goto evnum + 'end if + 'if len(block(i))>12 then block(i)=block(i)+"ll": goto evnum + 'goto evnum + 'end if + ' + ''decimal + 'if len(block(i))=10 then + 'if block(i)>="2147483648" and block(i)<="4294967295" then block(i)="(int64)"+block(i): goto evnum + 'if block(i)>"4294967295" then block(i)=block(i)+"ll": goto evnum + 'end if + 'if len(block(i))>10 then block(i)=block(i)+"ll" + ' + 'evnum: + ' + 'if negated=1 then block(i)="-"+block(i) + ' + 'END IF + ' + 'evfltnum: + ' + 'block(i) = " " + block(i)+" " + 'evaledblock(i) = 1 + 'GOTO evaledblock + 'END IF + + 'a typed string in "" + IF LEFT$(block(i), 1) = CHR$(34) THEN + IF RIGHT$(block(i), 1) <> CHR$(34) THEN + block(i) = "qbs_new_txt_len(" + block(i) + ")" + ELSE + block(i) = "qbs_new_txt(" + block(i) + ")" + END IF + blocktype(i) = ISSTRING + evaledblock(i) = 1 + stringprocessinghappened = 1 + GOTO evaledblock + END IF + + 'create variable + IF isvalidvariable(block(i)) THEN + x$ = block(i) + + typ$ = removesymbol$(x$) + IF Error_Happened THEN EXIT FUNCTION + + 'add symbol extension if none given + IF LEN(typ$) = 0 THEN + IF LEFT$(x$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(x$)) - 64 + typ$ = defineextaz(v) + END IF + + 'check that it hasn't just been created within this loop (a=b+b) + try = findid(x$ + typ$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF Debug THEN PRINT #9, try + IF id.t <> 0 AND (id.t AND ISUDT) = 0 THEN 'is x$ a simple variable? + GOTO simplevarfound + END IF + IF try = 2 THEN findanotherid = 1: try = findid(x$ + typ$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + IF Debug THEN PRINT #9, "CREATING VARIABLE:" + x$ + IF optionexplicit THEN Give_Error "Variable '" + x$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": EXIT FUNCTION + bypassNextVariable = -1 + retval = dim2(x$, typ$, 1, "") + manageVariableList "", vWatchNewVariable$, 0, 3 + IF Error_Happened THEN EXIT FUNCTION + + simplevarfound: + constequation = 0 + makeidrefer block(i), blocktype(i) + IF (blocktype(i) AND ISSTRING) THEN stringprocessinghappened = 1 + IF blockn = 1 THEN + IF (blocktype(i) AND ISREFERENCE) THEN GOTO returnpointer + END IF + 'reference value + block(i) = refer(block(i), blocktype(i), 0): IF Error_Happened THEN EXIT FUNCTION + evaledblock(i) = 1 + GOTO evaledblock + END IF + Give_Error "Invalid expression": EXIT FUNCTION + + ELSE + IF (blocktype(i) AND ISREFERENCE) THEN + IF blockn = 1 THEN GOTO returnpointer + + 'if blocktype(i) and ISUDT then PRINT "UDT passed to refer by evaluate" + + block(i) = refer(block(i), blocktype(i), 0) + IF Error_Happened THEN EXIT FUNCTION + + END IF + + END IF + END IF + evaledblock: + NEXT + + + 'return a POINTER if possible + IF blockn = 1 THEN + IF evaledblock(1) THEN + IF (blocktype(1) AND ISREFERENCE) THEN + returnpointer: + IF (blocktype(1) AND ISSTRING) THEN stringprocessinghappened = 1 + IF Debug THEN PRINT #9, "evaluated reference:" + block(1) + typ = blocktype(1) + evaluate$ = block(1) + EXIT FUNCTION + END IF + END IF + END IF + 'it cannot be returned as a pointer + + + + + + + + + IF Debug THEN PRINT #9, "applying operators:"; + + + IF typ = -1 THEN + typ = blocktype(1) 'init typ with first blocktype + + + IF isoperator(block(1)) THEN 'but what if it starts with a UNARY operator? + typ = blocktype(2) 'init typ with second blocktype + END IF + END IF + + nonop = 0 + FOR i = 1 TO blockn + + IF evaledblock(i) = 0 THEN + isop = isoperator(block(i)) + IF isop THEN + nonop = 0 + + constequation = 0 + + 'operator found + o$ = block(i) + u = operatorusage(o$, typ, i$, lhstyp, rhstyp, result) + + IF u <> 5 THEN 'not unary + nonop = 1 + IF i = 1 OR evaledblock(i - 1) = 0 THEN + IF i = 1 AND blockn = 1 AND o$ = "-" THEN Give_Error "Expected variable/value after '" + UCASE$(o$) + "'": EXIT FUNCTION 'guess - is neg in this case + Give_Error "Expected variable/value before '" + UCASE$(o$) + "'": EXIT FUNCTION + END IF + END IF + IF i = blockn OR evaledblock(i + 1) = 0 THEN Give_Error "Expected variable/value after '" + UCASE$(o$) + "'": EXIT FUNCTION + + 'lhstyp & rhstyp bit-field values + '1=integeral + '2=floating point + '4=string + '8=bool *only used for result + + oldtyp = typ + newtyp = blocktype(i + 1) + + 'IF block(i - 1) = "6" THEN + 'PRINT o$ + 'PRINT oldtyp AND ISFLOAT + 'PRINT blocktype(i - 1) AND ISFLOAT + 'END + 'END IF + + + + 'numeric->string is illegal! + IF (typ AND ISSTRING) = 0 AND (newtyp AND ISSTRING) <> 0 THEN + Give_Error "Cannot convert number to string": EXIT FUNCTION + END IF + + 'Offset protection: Override conversion rules for operator as necessary + offsetmode = 0 + offsetcvi = 0 + IF (oldtyp AND ISOFFSET) <> 0 OR (newtyp AND ISOFFSET) <> 0 THEN + offsetmode = 2 + IF newtyp AND ISOFFSET THEN + IF (newtyp AND ISUNSIGNED) = 0 THEN offsetmode = 1 + END IF + IF oldtyp AND ISOFFSET THEN + IF (oldtyp AND ISUNSIGNED) = 0 THEN offsetmode = 1 + END IF + + 'depending on the operater we may do things differently + 'the default method is convert both sides to integer first + 'but these operators are different: * / ^ + IF o$ = "*" OR o$ = "/" OR o$ = "^" THEN + IF o$ = "*" OR o$ = "^" THEN + 'for mult, if either side is a float cast integers to 'long double's first + IF (newtyp AND ISFLOAT) <> 0 OR (oldtyp AND ISFLOAT) <> 0 THEN + offsetcvi = 1 + IF (oldtyp AND ISFLOAT) = 0 THEN lhstyp = 2 + IF (newtyp AND ISFLOAT) = 0 THEN rhstyp = 2 + END IF + END IF + IF o$ = "/" OR o$ = "^" THEN + 'for division or exponentials, to prevent integer division cast integers to 'long double's + offsetcvi = 1 + IF (oldtyp AND ISFLOAT) = 0 THEN lhstyp = 2 + IF (newtyp AND ISFLOAT) = 0 THEN rhstyp = 2 + END IF + ELSE + IF lhstyp AND 2 THEN lhstyp = 1 'force lhs and rhs to be integer values + IF rhstyp AND 2 THEN rhstyp = 1 + END IF + + IF result = 2 THEN result = 1 'force integer result + 'note: result=1 just sets typ&=64 if typ is a float + + END IF + + 'STEP 1: convert oldtyp and/or newtyp if required for the operator + 'convert lhs + IF (oldtyp AND ISSTRING) THEN + IF (lhstyp AND 4) = 0 THEN Give_Error "Cannot convert string to number": EXIT FUNCTION + ELSE + 'oldtyp is numeric + IF lhstyp = 4 THEN Give_Error "Cannot convert number to string": EXIT FUNCTION + IF (oldtyp AND ISFLOAT) THEN + IF (lhstyp AND 2) = 0 THEN + 'convert float to int + block(i - 1) = "qbr(" + block(i - 1) + ")" + oldtyp = 64& + END IF + ELSE + 'oldtyp is an int + IF (lhstyp AND 1) = 0 THEN + 'convert int to float + block(i - 1) = "((long double)(" + block(i - 1) + "))" + oldtyp = 256& + ISFLOAT + END IF + END IF + END IF + 'convert rhs + IF (newtyp AND ISSTRING) THEN + IF (rhstyp AND 4) = 0 THEN Give_Error "Cannot convert string to number": EXIT FUNCTION + ELSE + 'newtyp is numeric + IF rhstyp = 4 THEN Give_Error "Cannot convert number to string": EXIT FUNCTION + IF (newtyp AND ISFLOAT) THEN + IF (rhstyp AND 2) = 0 THEN + 'convert float to int + block(i + 1) = "qbr(" + block(i + 1) + ")" + newtyp = 64& + END IF + ELSE + 'newtyp is an int + IF (rhstyp AND 1) = 0 THEN + 'convert int to float + block(i + 1) = "((long double)(" + block(i + 1) + "))" + newtyp = 256& + ISFLOAT + END IF + END IF + END IF + + 'Reduce floating point values to common base for comparison? + IF isop = 7 THEN 'comparitive operator + 'Corrects problems encountered such as: + ' S = 2.1 + ' IF S = 2.1 THEN PRINT "OK" ELSE PRINT "ERROR S PRINTS AS"; S; "BUT IS SEEN BY QB64 AS..." + ' IF S < 2.1 THEN PRINT "LESS THAN 2.1" + 'concerns: + '1. Return value from TIMER will be reduced to a SINGLE in direct comparisons + 'solution: assess, and only apply to SINGLE variables/arrays + '2. Comparison of a double higher/lower than single range may fail + 'solution: out of range values convert to +/-1.#INF, making comparison still possible + IF (oldtyp AND ISFLOAT) <> 0 AND (newtyp AND ISFLOAT) <> 0 THEN 'both floating point + s1 = oldtyp AND 511: s2 = newtyp AND 511 + IF s2 < s1 THEN s1 = s2 + IF s1 = 32 THEN + block(i - 1) = "((float)(" + block(i - 1) + "))": oldtyp = 32& + ISFLOAT + block(i + 1) = "((float)(" + block(i + 1) + "))": newtyp = 32& + ISFLOAT + END IF + IF s1 = 64 THEN + block(i - 1) = "((double)(" + block(i - 1) + "))": oldtyp = 64& + ISFLOAT + block(i + 1) = "((double)(" + block(i + 1) + "))": newtyp = 64& + ISFLOAT + END IF + END IF 'both floating point + END IF 'comparitive operator + + typ = newtyp + + 'STEP 2: markup typ + ' if either side is a float, markup typ to largest float + ' if either side is integer, markup typ + 'Note: A markup is a GUESS of what the return type will be, + ' 'result' can override this markup + IF (oldtyp AND ISSTRING) = 0 AND (newtyp AND ISSTRING) = 0 THEN + IF (oldtyp AND ISFLOAT) <> 0 OR (newtyp AND ISFLOAT) <> 0 THEN + 'float + b = 0: IF (oldtyp AND ISFLOAT) THEN b = oldtyp AND 511 + IF (newtyp AND ISFLOAT) THEN + b2 = newtyp AND 511: IF b2 > b THEN b = b2 + END IF + typ = ISFLOAT + b + ELSE + 'integer + '***THIS IS THE IDEAL MARKUP FOR A 64-BIT SYSTEM*** + 'In reality 32-bit C++ only marks-up to 32-bit integers + b = oldtyp AND 511: b2 = newtyp AND 511: IF b2 > b THEN b = b2 + typ = 64& + IF b = 64 THEN + IF (oldtyp AND ISUNSIGNED) <> 0 AND (newtyp AND ISUNSIGNED) <> 0 THEN typ = 64& + ISUNSIGNED + END IF + END IF + END IF + + IF result = 1 THEN + IF (typ AND ISFLOAT) <> 0 OR (typ AND ISSTRING) <> 0 THEN typ = 64 'otherwise keep markuped integer type + END IF + IF result = 2 THEN + IF (typ AND ISFLOAT) = 0 THEN typ = ISFLOAT + 256 + END IF + IF result = 4 THEN + typ = ISSTRING + END IF + IF result = 8 THEN 'bool + typ = 32 + END IF + + 'Offset protection: Force result to be an offset type with correct signage + IF offsetmode THEN + IF result <> 8 THEN 'boolean comparison results are allowed + typ = OFFSETTYPE - ISPOINTER: IF offsetmode = 2 THEN typ = typ + ISUNSIGNED + END IF + END IF + + 'override typ=ISFLOAT+256 to typ=ISFLOAT+64 for ^ operator's result + IF u = 2 THEN + IF i$ = "pow2" THEN + + IF offsetmode THEN Give_Error "Operator '^' cannot be used with an _OFFSET": EXIT FUNCTION + + 'QB-like conversion of math functions returning floating point values + 'reassess oldtype & newtype + b = oldtyp AND 511 + IF oldtyp AND ISFLOAT THEN + 'no change to b + ELSE + IF b > 16 THEN b = 64 'larger than INTEGER? return DOUBLE + IF b > 32 THEN b = 256 'larger than LONG? return FLOAT + IF b <= 16 THEN b = 32 + END IF + b2 = newtyp AND 511 + IF newtyp AND ISFLOAT THEN + IF b2 > b THEN b = b2 + ELSE + b3 = 32 + IF b2 > 16 THEN b3 = 64 'larger than INTEGER? return DOUBLE + IF b2 > 32 THEN b3 = 256 'larger than LONG? return FLOAT + IF b3 > b THEN b = b3 + END IF + typ = ISFLOAT + b + + END IF 'pow2 + END IF 'u=2 + + 'STEP 3: apply operator appropriately + + IF u = 5 THEN + block(i + 1) = i$ + "(" + block(i + 1) + ")" + block(i) = "": i = i + 1: GOTO operatorapplied + END IF + + 'binary operators + + IF u = 1 THEN + block(i + 1) = block(i - 1) + i$ + block(i + 1) + block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied + END IF + + IF u = 2 THEN + block(i + 1) = i$ + "(" + block(i - 1) + "," + block(i + 1) + ")" + block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied + END IF + + IF u = 3 THEN + block(i + 1) = "-(" + block(i - 1) + i$ + block(i + 1) + ")" + block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied + END IF + + IF u = 4 THEN + block(i + 1) = "~" + block(i - 1) + i$ + block(i + 1) + block(i - 1) = "": block(i) = "": i = i + 1: GOTO operatorapplied + END IF + + '...more?... + + Give_Error "ERROR: Operator could not be applied correctly!": EXIT FUNCTION '<--should never happen! + operatorapplied: + + IF offsetcvi THEN block(i) = "qbr(" + block(i) + ")": offsetcvi = 0 + offsetmode = 0 + + ELSE + nonop = nonop + 1 + END IF + ELSE + nonop = nonop + 1 + END IF + IF nonop > 1 THEN Give_Error "Expected operator in equation": EXIT FUNCTION + NEXT + IF Debug THEN PRINT #9, "" + + 'join blocks + FOR i = 1 TO blockn + r$ = r$ + block(i) + NEXT + + IF Debug THEN + PRINT #9, "evaluated:" + r$ + " AS TYPE:"; + IF (typ AND ISSTRING) THEN PRINT #9, "[ISSTRING]"; + IF (typ AND ISFLOAT) THEN PRINT #9, "[ISFLOAT]"; + IF (typ AND ISUNSIGNED) THEN PRINT #9, "[ISUNSIGNED]"; + IF (typ AND ISPOINTER) THEN PRINT #9, "[ISPOINTER]"; + IF (typ AND ISFIXEDLENGTH) THEN PRINT #9, "[ISFIXEDLENGTH]"; + IF (typ AND ISINCONVENTIONALMEMORY) THEN PRINT #9, "[ISINCONVENTIONALMEMORY]"; + PRINT #9, "(size in bits=" + str2$(typ AND 511) + ")" + END IF + + + evaluate$ = r$ + + + +END FUNCTION + + + + +FUNCTION evaluatefunc$ (a2$, args AS LONG, typ AS LONG) + a$ = a2$ + + IF Debug THEN PRINT #9, "evaluatingfunction:" + RTRIM$(id.n) + ":" + a$ + + DIM id2 AS idstruct + + id2 = id + n$ = RTRIM$(id2.n) + typ = id2.ret + targetid = currentid + + IF RTRIM$(id2.callname) = "func_stub" THEN Give_Error "Command not implemented": EXIT FUNCTION + IF RTRIM$(id2.callname) = "func_input" AND args = 1 AND inputfunctioncalled = 0 THEN + inputfunctioncalled = -1 + IF vWatchOn = 1 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= -4; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + END IF + + SetDependency id2.Dependency + + passomit = 0 + omitarg_first = 0: omitarg_last = 0 + + f$ = RTRIM$(id2.specialformat) + IF LEN(f$) THEN 'special format given + + 'count omittable args + sqb = 0 + a = 0 + FOR fi = 1 TO LEN(f$) + fa = ASC(f$, fi) + IF fa = ASC_QUESTIONMARK THEN + a = a + 1 + IF sqb <> 0 AND omitarg_first = 0 THEN omitarg_first = a + END IF + IF fa = ASC_LEFTSQUAREBRACKET THEN sqb = 1 + IF fa = ASC_RIGHTSQUAREBRACKET THEN sqb = 0: omitarg_last = a + NEXT + omitargs = omitarg_last - omitarg_first + 1 + + IF args <> id2.args - omitargs AND args <> id2.args THEN + IF LEN(id2.hr_syntax) > 0 THEN + Give_Error "Incorrect number of arguments - Reference: " + id2.hr_syntax + ELSE + Give_Error "Incorrect number of arguments passed to function" + END IF + EXIT FUNCTION + END IF + + passomit = 1 'pass omit flags param to function + + IF id2.args = args THEN omitarg_first = 0: omitarg_last = 0 'all arguments were passed! + + ELSE 'no special format given + + IF n$ = "ASC" AND args = 2 THEN GOTO skipargnumchk + IF id2.overloaded = -1 AND (args >= id2.minargs AND args <= id2.args) THEN GOTO skipargnumchk + + IF id2.args <> args THEN + IF LEN(id2.hr_syntax) > 0 THEN + Give_Error "Incorrect number of arguments - Reference: " + id2.hr_syntax + ELSE + Give_Error "Incorrect number of arguments passed to function" + END IF + EXIT FUNCTION + END IF + + END IF + + skipargnumchk: + + r$ = RTRIM$(id2.callname) + "(" + + + IF id2.args <> 0 THEN + + curarg = 1 + firsti = 1 + + n = numelements(a$) + IF n = 0 THEN i = 0: GOTO noargs + + FOR i = 1 TO n + + + + IF curarg >= omitarg_first AND curarg <= omitarg_last THEN + noargs: + targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) + + 'IF (targettyp AND ISSTRING) THEN Give_Error "QB64 doesn't support optional string arguments for functions yet!": EXIT FUNCTION + + FOR fi = 1 TO omitargs - 1: r$ = r$ + "NULL,": NEXT: r$ = r$ + "NULL" + curarg = curarg + omitargs + IF i = n THEN EXIT FOR + r$ = r$ + "," + END IF + + l$ = getelement(a$, i) + IF l$ = "(" THEN b = b + 1 + IF l$ = ")" THEN b = b - 1 + IF (l$ = "," AND b = 0) OR (i = n) THEN + + targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) + nele = ASC(MID$(id2.nele, curarg, 1)) + nelereq = ASC(MID$(id2.nelereq, curarg, 1)) + + IF i = n THEN + e$ = getelements$(a$, firsti, i) + ELSE + e$ = getelements$(a$, firsti, i - 1) + END IF + + IF LEFT$(e$, 2) = "(" + sp THEN dereference = 1 ELSE dereference = 0 + + + + '*special case CVI,CVL,CVS,CVD,_CV (part #1) + IF n$ = "_CV" OR (n$ = "CV" AND qb64prefix_set = 1) THEN + IF curarg = 1 THEN + cvtype$ = type2symbol$(e$) + IF Error_Happened THEN EXIT FUNCTION + e$ = "" + GOTO dontevaluate + END IF + END IF + + '*special case MKI,MKL,MKS,MKD,_MK (part #1) + + IF n$ = "_MK" OR (n$ = "MK" AND qb64prefix_set = 1) THEN + IF RTRIM$(id2.musthave) = "$" THEN + IF curarg = 1 THEN + mktype$ = type2symbol$(e$) + IF Error_Happened THEN EXIT FUNCTION + IF Debug THEN PRINT #9, "_MK:[" + e$ + "]:[" + mktype$ + "]" + e$ = "" + GOTO dontevaluate + END IF + END IF + END IF + + IF n$ = "UBOUND" OR n$ = "LBOUND" THEN + IF curarg = 1 THEN + 'perform a "fake" evaluation of the array + e$ = e$ + sp + "(" + sp + ")" + e$ = evaluate(e$, sourcetyp) + IF Error_Happened THEN EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected array-name": EXIT FUNCTION + IF (sourcetyp AND ISARRAY) = 0 THEN Give_Error "Expected array-name": EXIT FUNCTION + 'make a note of the array's index for later + ulboundarray$ = e$ + ulboundarraytyp = sourcetyp + e$ = "" + r$ = "" + GOTO dontevaluate + END IF + END IF + + + '*special case: INPUT$ function + IF n$ = "INPUT" THEN + IF RTRIM$(id2.musthave) = "$" THEN + IF curarg = 2 THEN + IF LEFT$(e$, 2) = "#" + sp THEN e$ = RIGHT$(e$, LEN(e$) - 2) + END IF + END IF + END IF + + + '*special case* + IF n$ = "ASC" THEN + IF curarg = 2 THEN + e$ = evaluatetotyp$(e$, 32&) + IF Error_Happened THEN EXIT FUNCTION + typ& = LONGTYPE - ISPOINTER + r$ = r$ + e$ + ")" + GOTO evalfuncspecial + END IF + END IF + + + 'PRINT #12, "n$="; n$ + 'PRINT #12, "curarg="; curarg + 'PRINT #12, "e$="; e$ + 'PRINT #12, "r$="; r$ + + '*special case* + IF n$ = "_MEMGET" OR (n$ = "MEMGET" AND qb64prefix_set = 1) THEN + IF curarg = 1 THEN + memget_blk$ = e$ + END IF + IF curarg = 2 THEN + memget_offs$ = e$ + END IF + IF curarg = 3 THEN + e$ = UCASE$(e$) + IF INSTR(e$, sp + "*" + sp) THEN 'multiplier will have an appended %,& or && symbol + IF RIGHT$(e$, 2) = "&&" THEN + e$ = LEFT$(e$, LEN(e$) - 2) + ELSE + IF RIGHT$(e$, 1) = "&" OR RIGHT$(e$, 1) = "%" THEN e$ = LEFT$(e$, LEN(e$) - 1) + END IF + END IF + t = typname2typ(e$) + IF t = 0 THEN Give_Error "Invalid TYPE name": EXIT FUNCTION + IF t AND ISOFFSETINBITS THEN Give_Error qb64prefix$ + "BIT TYPE unsupported": EXIT FUNCTION + memget_size = typname2typsize + IF t AND ISSTRING THEN + IF (t AND ISFIXEDLENGTH) = 0 THEN Give_Error "Expected STRING * ...": EXIT FUNCTION + memget_ctyp$ = "qbs*" + ELSE + IF t AND ISUDT THEN + memget_size = udtxsize(t AND 511) \ 8 + memget_ctyp$ = "void*" + ELSE + memget_size = (t AND 511) \ 8 + memget_ctyp$ = typ2ctyp$(t, "") + END IF + END IF + + + + + + 'assume checking off + offs$ = evaluatetotyp(memget_offs$, OFFSETTYPE - ISPOINTER) + blkoffs$ = evaluatetotyp(memget_blk$, -6) + IF NoChecks = 0 THEN + 'change offs$ to be the return of the safe version + offs$ = "func__memget((mem_block*)" + blkoffs$ + "," + offs$ + "," + str2(memget_size) + ")" + END IF + IF t AND ISSTRING THEN + r$ = "qbs_new_txt_len((char*)" + offs$ + "," + str2(memget_size) + ")" + ELSE + IF t AND ISUDT THEN + r$ = "((void*)+" + offs$ + ")" + t = ISUDT + ISPOINTER + (t AND 511) + ELSE + r$ = "*(" + memget_ctyp$ + "*)(" + offs$ + ")" + IF t AND ISPOINTER THEN t = t - ISPOINTER + END IF + END IF + + + + + + + + typ& = t + + + GOTO evalfuncspecial + END IF + END IF + + '------------------------------------------------------------------------------------------------------------ + e2$ = e$ + e$ = evaluate(e$, sourcetyp) + IF Error_Happened THEN EXIT FUNCTION + '------------------------------------------------------------------------------------------------------------ + + '***special case*** + IF n$ = "_MEM" OR (n$ = "MEM" AND qb64prefix_set = 1) THEN + IF curarg = 1 THEN + IF args = 1 THEN + targettyp = -7 + END IF + IF args = 2 THEN + r$ = RTRIM$(id2.callname) + "_at_offset" + RIGHT$(r$, LEN(r$) - LEN(RTRIM$(id2.callname))) + IF (sourcetyp AND ISOFFSET) = 0 THEN Give_Error "Expected _MEM(_OFFSET-value,...)": EXIT FUNCTION + END IF + END IF + END IF + + '*special case* + IF n$ = "_OFFSET" OR (n$ = "OFFSET" AND qb64prefix_set = 1) THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN + Give_Error qb64prefix$ + "OFFSET expects the name of a variable/array": EXIT FUNCTION + END IF + IF (sourcetyp AND ISARRAY) THEN + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error qb64prefix$ + "OFFSET cannot reference _BIT type arrays": EXIT FUNCTION + END IF + r$ = "((uptrszint)(" + evaluatetotyp$(e2$, -6) + "))" + IF Error_Happened THEN EXIT FUNCTION + typ& = UOFFSETTYPE - ISPOINTER + GOTO evalfuncspecial + END IF '_OFFSET + + '*_OFFSET exceptions* + IF sourcetyp AND ISOFFSET THEN + IF n$ = "MKSMBF" AND RTRIM$(id2.musthave) = "$" THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + IF n$ = "MKDMBF" AND RTRIM$(id2.musthave) = "$" THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + END IF + + '*special case* + IF n$ = "ENVIRON" THEN + IF sourcetyp AND ISSTRING THEN + IF sourcetyp AND ISREFERENCE THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + GOTO dontevaluate + END IF + END IF + + '*special case* + IF n$ = "LEN" THEN + typ& = LONGTYPE - ISPOINTER + IF (sourcetyp AND ISREFERENCE) = 0 THEN + 'could be a string expression + IF sourcetyp AND ISSTRING THEN + r$ = "((int32)(" + e$ + ")->len)" + GOTO evalfuncspecial + END IF + Give_Error "String expression or variable name required in LEN statement": EXIT FUNCTION + END IF + r$ = evaluatetotyp$(e2$, -5) 'use evaluatetotyp to get 'element' size + IF Error_Happened THEN EXIT FUNCTION + GOTO evalfuncspecial + END IF + + + '*special case* + IF n$ = "_BIN" OR (n$ = "BIN" AND qb64prefix_set = 1) THEN + IF RTRIM$(id2.musthave) = "$" THEN + bits = sourcetyp AND 511 + + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + wasref = 0 + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 + IF Error_Happened THEN EXIT FUNCTION + bits = sourcetyp AND 511 + IF (sourcetyp AND ISOFFSETINBITS) THEN + e$ = "func__bin(" + e$ + "," + str2$(bits) + ")" + ELSE + IF (sourcetyp AND ISFLOAT) THEN + e$ = "func__bin_float(" + e$ + ")" + ELSE + IF bits = 64 THEN + IF wasref = 0 THEN bits = 0 + END IF + e$ = "func__bin(" + e$ + "," + str2$(bits) + ")" + END IF + END IF + typ& = STRINGTYPE - ISPOINTER + r$ = e$ + GOTO evalfuncspecial + END IF + END IF + + '*special case* + IF n$ = "OCT" THEN + IF RTRIM$(id2.musthave) = "$" THEN + bits = sourcetyp AND 511 + + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + wasref = 0 + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 + IF Error_Happened THEN EXIT FUNCTION + bits = sourcetyp AND 511 + IF (sourcetyp AND ISOFFSETINBITS) THEN + e$ = "func_oct(" + e$ + "," + str2$(bits) + ")" + ELSE + IF (sourcetyp AND ISFLOAT) THEN + e$ = "func_oct_float(" + e$ + ")" + ELSE + IF bits = 64 THEN + IF wasref = 0 THEN bits = 0 + END IF + e$ = "func_oct(" + e$ + "," + str2$(bits) + ")" + END IF + END IF + typ& = STRINGTYPE - ISPOINTER + r$ = e$ + GOTO evalfuncspecial + END IF + END IF + + '*special case* + IF n$ = "HEX" THEN + IF RTRIM$(id2.musthave) = "$" THEN + bits = sourcetyp AND 511 + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + wasref = 0 + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0): wasref = 1 + IF Error_Happened THEN EXIT FUNCTION + bits = sourcetyp AND 511 + IF (sourcetyp AND ISOFFSETINBITS) THEN + chars = (bits + 3) \ 4 + e$ = "func_hex(" + e$ + "," + str2$(chars) + ")" + ELSE + IF (sourcetyp AND ISFLOAT) THEN + e$ = "func_hex_float(" + e$ + ")" + ELSE + IF bits = 8 THEN chars = 2 + IF bits = 16 THEN chars = 4 + IF bits = 32 THEN chars = 8 + IF bits = 64 THEN + IF wasref = 1 THEN chars = 16 ELSE chars = 0 + END IF + e$ = "func_hex(" + e$ + "," + str2$(chars) + ")" + END IF + END IF + typ& = STRINGTYPE - ISPOINTER + r$ = e$ + GOTO evalfuncspecial + END IF + END IF + + + '*special case* + IF n$ = "EXP" THEN + bits = sourcetyp AND 511 + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + bits = sourcetyp AND 511 + typ& = SINGLETYPE - ISPOINTER + IF (sourcetyp AND ISFLOAT) THEN + IF bits = 32 THEN e$ = "func_exp_single(" + e$ + ")" ELSE e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER + ELSE + IF (sourcetyp AND ISOFFSETINBITS) THEN + e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER + ELSE + IF bits <= 16 THEN e$ = "func_exp_single(" + e$ + ")" ELSE e$ = "func_exp_float(" + e$ + ")": typ& = FLOATTYPE - ISPOINTER + END IF + END IF + r$ = e$ + GOTO evalfuncspecial + END IF + + '*special case* + IF n$ = "INT" THEN + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + IF (sourcetyp AND ISFLOAT) THEN e$ = "floor(" + e$ + ")" ELSE e$ = "(" + e$ + ")" + r$ = e$ + typ& = sourcetyp + GOTO evalfuncspecial + END IF + + '*special case* + IF n$ = "FIX" THEN + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits > 64 THEN e$ = "func_fix_float(" + e$ + ")" ELSE e$ = "func_fix_double(" + e$ + ")" + ELSE + e$ = "(" + e$ + ")" + END IF + r$ = e$ + typ& = sourcetyp + GOTO evalfuncspecial + END IF + + '*special case* + IF n$ = "_ROUND" OR (n$ = "ROUND" AND qb64prefix_set = 1) THEN + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + IF (sourcetyp AND ISFLOAT) THEN + bits = sourcetyp AND 511 + IF bits > 64 THEN e$ = "func_round_float(" + e$ + ")" ELSE e$ = "func_round_double(" + e$ + ")" + ELSE + e$ = "(" + e$ + ")" + END IF + r$ = e$ + typ& = 64& + IF (sourcetyp AND ISOFFSET) THEN + IF sourcetyp AND ISUNSIGNED THEN typ& = UOFFSETTYPE - ISPOINTER ELSE typ& = OFFSETTYPE - ISPOINTER + END IF + GOTO evalfuncspecial + END IF + + + '*special case* + IF n$ = "CDBL" THEN + IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits > 64 THEN e$ = "func_cdbl_float(" + e$ + ")" + ELSE + e$ = "((double)(" + e$ + "))" + END IF + r$ = e$ + typ& = DOUBLETYPE - ISPOINTER + GOTO evalfuncspecial + END IF + + '*special case* + IF n$ = "CSNG" THEN + IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits = 64 THEN e$ = "func_csng_double(" + e$ + ")" + IF bits > 64 THEN e$ = "func_csng_float(" + e$ + ")" + ELSE + e$ = "((double)(" + e$ + "))" + END IF + r$ = e$ + typ& = SINGLETYPE - ISPOINTER + GOTO evalfuncspecial + END IF + + + '*special case* + IF n$ = "CLNG" THEN + IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits > 64 THEN e$ = "func_clng_float(" + e$ + ")" ELSE e$ = "func_clng_double(" + e$ + ")" + ELSE 'integer + IF (sourcetyp AND ISUNSIGNED) THEN + IF bits = 32 THEN e$ = "func_clng_ulong(" + e$ + ")" + IF bits > 32 THEN e$ = "func_clng_uint64(" + e$ + ")" + ELSE 'signed + IF bits > 32 THEN e$ = "func_clng_int64(" + e$ + ")" + END IF + END IF + r$ = e$ + typ& = 32& + GOTO evalfuncspecial + END IF + + '*special case* + IF n$ = "CINT" THEN + IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN Give_Error "Expected numeric value": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'establish which function (if any!) should be used + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits > 64 THEN e$ = "func_cint_float(" + e$ + ")" ELSE e$ = "func_cint_double(" + e$ + ")" + ELSE 'integer + IF (sourcetyp AND ISUNSIGNED) THEN + IF bits > 15 AND bits <= 32 THEN e$ = "func_cint_ulong(" + e$ + ")" + IF bits > 32 THEN e$ = "func_cint_uint64(" + e$ + ")" + ELSE 'signed + IF bits > 16 AND bits <= 32 THEN e$ = "func_cint_long(" + e$ + ")" + IF bits > 32 THEN e$ = "func_cint_int64(" + e$ + ")" + END IF + END IF + r$ = e$ + typ& = 16& + GOTO evalfuncspecial + END IF + + '*special case MKI,MKL,MKS,MKD,_MK (part #2) + mktype = 0 + size = 0 + IF n$ = "MKI" THEN mktype = 1: mktype$ = "%" + IF n$ = "MKL" THEN mktype = 2: mktype$ = "&" + IF n$ = "MKS" THEN mktype = 3: mktype$ = "!" + IF n$ = "MKD" THEN mktype = 4: mktype$ = "#" + IF n$ = "_MK" OR (n$ = "MK" AND qb64prefix_set = 1) THEN mktype = -1 + IF mktype THEN + IF mktype <> -1 OR curarg = 2 THEN + 'IF (sourcetyp AND ISOFFSET) THEN Give_Error "Cannot convert " + qb64prefix$ + "OFFSET type to other types": EXIT FUNCTION + 'both _MK and trad. process the following + qtyp& = 0 + IF mktype$ = "%%" THEN ctype$ = "b": qtyp& = BYTETYPE - ISPOINTER + IF mktype$ = "~%%" THEN ctype$ = "ub": qtyp& = UBYTETYPE - ISPOINTER + IF mktype$ = "%" THEN ctype$ = "i": qtyp& = INTEGERTYPE - ISPOINTER + IF mktype$ = "~%" THEN ctype$ = "ui": qtyp& = UINTEGERTYPE - ISPOINTER + IF mktype$ = "&" THEN ctype$ = "l": qtyp& = LONGTYPE - ISPOINTER + IF mktype$ = "~&" THEN ctype$ = "ul": qtyp& = ULONGTYPE - ISPOINTER + IF mktype$ = "&&" THEN ctype$ = "i64": qtyp& = INTEGER64TYPE - ISPOINTER + IF mktype$ = "~&&" THEN ctype$ = "ui64": qtyp& = UINTEGER64TYPE - ISPOINTER + IF mktype$ = "!" THEN ctype$ = "s": qtyp& = SINGLETYPE - ISPOINTER + IF mktype$ = "#" THEN ctype$ = "d": qtyp& = DOUBLETYPE - ISPOINTER + IF mktype$ = "##" THEN ctype$ = "f": qtyp& = FLOATTYPE - ISPOINTER + IF mktype$ = "%&" THEN ctype$ = "o": qtyp& = OFFSETTYPE - ISPOINTER + IF mktype$ = "~%&" THEN ctype$ = "uo": qtyp& = UOFFSETTYPE - ISPOINTER + IF LEFT$(mktype$, 2) = "~`" THEN ctype$ = "ubit": qtyp& = UINTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(mktype$, LEN(mktype$) - 2)) + IF LEFT$(mktype$, 1) = "`" THEN ctype$ = "bit": qtyp& = INTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(mktype$, LEN(mktype$) - 1)) + IF qtyp& = 0 THEN Give_Error qb64prefix$ + "MK only accepts numeric types": EXIT FUNCTION + IF size THEN + r$ = ctype$ + "2string(" + str2(size) + "," + ELSE + r$ = ctype$ + "2string(" + END IF + nocomma = 1 + targettyp = qtyp& + END IF + END IF + + '*special case CVI,CVL,CVS,CVD,_CV (part #2) + cvtype = 0 + IF n$ = "CVI" THEN cvtype = 1: cvtype$ = "%" + IF n$ = "CVL" THEN cvtype = 2: cvtype$ = "&" + IF n$ = "CVS" THEN cvtype = 3: cvtype$ = "!" + IF n$ = "CVD" THEN cvtype = 4: cvtype$ = "#" + IF n$ = "_CV" OR (n$ = "CV" AND qb64prefix_set = 1) THEN cvtype = -1 + IF cvtype THEN + IF cvtype <> -1 OR curarg = 2 THEN + IF (sourcetyp AND ISSTRING) = 0 THEN Give_Error n$ + " requires a STRING argument": EXIT FUNCTION + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + typ& = 0 + IF cvtype$ = "%%" THEN ctype$ = "b": typ& = BYTETYPE - ISPOINTER + IF cvtype$ = "~%%" THEN ctype$ = "ub": typ& = UBYTETYPE - ISPOINTER + IF cvtype$ = "%" THEN ctype$ = "i": typ& = INTEGERTYPE - ISPOINTER + IF cvtype$ = "~%" THEN ctype$ = "ui": typ& = UINTEGERTYPE - ISPOINTER + IF cvtype$ = "&" THEN ctype$ = "l": typ& = LONGTYPE - ISPOINTER + IF cvtype$ = "~&" THEN ctype$ = "ul": typ& = ULONGTYPE - ISPOINTER + IF cvtype$ = "&&" THEN ctype$ = "i64": typ& = INTEGER64TYPE - ISPOINTER + IF cvtype$ = "~&&" THEN ctype$ = "ui64": typ& = UINTEGER64TYPE - ISPOINTER + IF cvtype$ = "!" THEN ctype$ = "s": typ& = SINGLETYPE - ISPOINTER + IF cvtype$ = "#" THEN ctype$ = "d": typ& = DOUBLETYPE - ISPOINTER + IF cvtype$ = "##" THEN ctype$ = "f": typ& = FLOATTYPE - ISPOINTER + IF cvtype$ = "%&" THEN ctype$ = "o": typ& = OFFSETTYPE - ISPOINTER + IF cvtype$ = "~%&" THEN ctype$ = "uo": typ& = UOFFSETTYPE - ISPOINTER + IF LEFT$(cvtype$, 2) = "~`" THEN ctype$ = "ubit": typ& = UINTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(cvtype$, LEN(cvtype$) - 2)) + IF LEFT$(cvtype$, 1) = "`" THEN ctype$ = "bit": typ& = INTEGER64TYPE - ISPOINTER: size = VAL(RIGHT$(cvtype$, LEN(cvtype$) - 1)) + IF typ& = 0 THEN Give_Error qb64prefix$ + "CV cannot return STRING type!": EXIT FUNCTION + IF ctype$ = "bit" OR ctype$ = "ubit" THEN + r$ = "string2" + ctype$ + "(" + e$ + "," + str2(size) + ")" + ELSE + r$ = "string2" + ctype$ + "(" + e$ + ")" + END IF + GOTO evalfuncspecial + END IF + END IF + + '*special case + IF RTRIM$(id2.n) = "STRING" THEN + IF curarg = 2 THEN + IF (sourcetyp AND ISSTRING) THEN + IF (sourcetyp AND ISREFERENCE) THEN e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + sourcetyp = 64& + e$ = "(" + e$ + "->chr[0])" + END IF + END IF + END IF + + '*special case + IF RTRIM$(id2.n) = "SADD" THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN + Give_Error "SADD only accepts variable-length string variables": EXIT FUNCTION + END IF + IF (sourcetyp AND ISFIXEDLENGTH) THEN + Give_Error "SADD only accepts variable-length string variables": EXIT FUNCTION + END IF + IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN + recompile = 1 + cmemlist(VAL(e$)) = 1 + r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" + typ& = 64& + GOTO evalfuncspecial + END IF + r$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + r$ = "((unsigned short)(" + r$ + "->chr-&cmem[1280]))" + typ& = 64& + GOTO evalfuncspecial + END IF + + '*special case + IF RTRIM$(id2.n) = "VARPTR" THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN + Give_Error "Expected reference to a variable/array": EXIT FUNCTION + END IF + + IF RTRIM$(id2.musthave) = "$" THEN + IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN + recompile = 1 + cmemlist(VAL(e$)) = 1 + r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" + typ& = ISSTRING + GOTO evalfuncspecial + END IF + + IF (sourcetyp AND ISARRAY) THEN + IF (sourcetyp AND ISSTRING) = 0 THEN Give_Error "VARPTR$ only accepts variable-length string arrays": EXIT FUNCTION + IF (sourcetyp AND ISFIXEDLENGTH) THEN Give_Error "VARPTR$ only accepts variable-length string arrays": EXIT FUNCTION + END IF + + 'must be a simple variable + '!assuming it is in cmem in DBLOCK + r$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN + IF (sourcetyp AND ISARRAY) THEN r$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + r$ = r$ + "->cmem_descriptor_offset" + t = 3 + ELSE + r$ = "((unsigned short)(((uint8*)" + r$ + ")-&cmem[1280]))" + '*top bit on=unsigned + '*second top bit on=bit-value (lower bits indicate the size) + 'BYTE=1 + 'INTEGER=2 + 'STRING=3 + 'SINGLE=4 + 'INT64=5 + 'FLOAT=6 + 'DOUBLE=8 + 'LONG=20 + 'BIT=64+n + t = 0 + IF (sourcetyp AND ISUNSIGNED) THEN t = t + 128 + IF (sourcetyp AND ISOFFSETINBITS) THEN + t = t + 64 + t = t + (sourcetyp AND 63) + ELSE + bits = sourcetyp AND 511 + IF (sourcetyp AND ISFLOAT) THEN + IF bits = 32 THEN t = t + 4 + IF bits = 64 THEN t = t + 8 + IF bits = 256 THEN t = t + 6 + ELSE + IF bits = 8 THEN t = t + 1 + IF bits = 16 THEN t = t + 2 + IF bits = 32 THEN t = t + 20 + IF bits = 64 THEN t = t + 5 + END IF + END IF + END IF + r$ = "func_varptr_helper(" + str2(t) + "," + r$ + ")" + typ& = ISSTRING + GOTO evalfuncspecial + END IF 'end of varptr$ + + + + + + + + + + + + 'VARPTR + IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN + recompile = 1 + cmemlist(VAL(e$)) = 1 + r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" + typ& = 64& + GOTO evalfuncspecial + END IF + + IF (sourcetyp AND ISARRAY) THEN + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "VARPTR cannot reference _BIT type arrays": EXIT FUNCTION + + 'string array? + IF (sourcetyp AND ISSTRING) THEN + IF (sourcetyp AND ISFIXEDLENGTH) THEN + getid VAL(e$) + IF Error_Happened THEN EXIT FUNCTION + m = id.tsize + index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) + typ = 64& + r$ = "((" + index$ + ")*" + str2(m) + ")" + GOTO evalfuncspecial + ELSE + 'return the offset of the string's descriptor + r$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + r$ = r$ + "->cmem_descriptor_offset" + typ = 64& + GOTO evalfuncspecial + END IF + END IF + + IF sourcetyp AND ISUDT THEN + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u + o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e + typ = 64& + r$ = "(" + o$ + ")" + GOTO evalfuncspecial + END IF + + 'non-UDT array + m = (sourcetyp AND 511) \ 8 'calculate size multiplier + index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) + typ = 64& + r$ = "((" + index$ + ")*" + str2(m) + ")" + GOTO evalfuncspecial + + END IF + + 'not an array + + IF sourcetyp AND ISUDT THEN + r$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u + o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e + typ = 64& + + 'if sub/func arg, may not be in DBLOCK + getid VAL(e$) + IF Error_Happened THEN EXIT FUNCTION + IF id.sfarg THEN 'could be in DBLOCK + 'note: segment could be the closest segment to UDT element or the base of DBLOCK + r$ = "varptr_dblock_check(((uint8*)" + r$ + ")+(" + o$ + "))" + ELSE 'definitely in DBLOCK + 'give offset relative to DBLOCK + r$ = "((unsigned short)(((uint8*)" + r$ + ") - &cmem[1280] + (" + o$ + ") ))" + END IF + + GOTO evalfuncspecial + END IF + + typ = 64& + r$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + IF (sourcetyp AND ISSTRING) THEN + IF (sourcetyp AND ISFIXEDLENGTH) THEN + + 'if sub/func arg, may not be in DBLOCK + getid VAL(e$) + IF Error_Happened THEN EXIT FUNCTION + IF id.sfarg THEN 'could be in DBLOCK + r$ = "varptr_dblock_check(" + r$ + "->chr)" + ELSE 'definitely in DBLOCK + r$ = "((unsigned short)(" + r$ + "->chr-&cmem[1280]))" + END IF + + ELSE + r$ = r$ + "->cmem_descriptor_offset" + END IF + GOTO evalfuncspecial + END IF + + 'single, simple variable + 'if sub/func arg, may not be in DBLOCK + getid VAL(e$) + IF Error_Happened THEN EXIT FUNCTION + IF id.sfarg THEN 'could be in DBLOCK + r$ = "varptr_dblock_check((uint8*)" + r$ + ")" + ELSE 'definitely in DBLOCK + r$ = "((unsigned short)(((uint8*)" + r$ + ")-&cmem[1280]))" + END IF + + GOTO evalfuncspecial + END IF + + '*special case* + IF RTRIM$(id2.n) = "VARSEG" THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN + Give_Error "Expected reference to a variable/array": EXIT FUNCTION + END IF + IF (sourcetyp AND ISINCONVENTIONALMEMORY) = 0 THEN + recompile = 1 + cmemlist(VAL(e$)) = 1 + r$ = "[CONVENTIONAL_MEMORY_REQUIRED]" + typ& = 64& + GOTO evalfuncspecial + END IF + 'array? + IF (sourcetyp AND ISARRAY) THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + IF (sourcetyp AND ISSTRING) THEN + r$ = "80" + typ = 64& + GOTO evalfuncspecial + END IF + END IF + typ = 64& + r$ = "( ( ((ptrszint)(" + refer(e$, sourcetyp, 1) + "[0])) - ((ptrszint)(&cmem[0])) ) /16)" + IF Error_Happened THEN EXIT FUNCTION + GOTO evalfuncspecial + END IF + + 'single variable/(var-len)string/udt? (usually stored in DBLOCK) + typ = 64& + 'if sub/func arg, may not be in DBLOCK + getid VAL(e$) + IF Error_Happened THEN EXIT FUNCTION + IF id.sfarg <> 0 AND (sourcetyp AND ISSTRING) = 0 THEN + IF sourcetyp AND ISUDT THEN + r$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip idnumber + e$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip u + o$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'skip e + r$ = "varseg_dblock_check(((uint8*)" + r$ + ")+(" + o$ + "))" + ELSE + r$ = "varseg_dblock_check((uint8*)" + refer(e$, sourcetyp, 1) + ")" + IF Error_Happened THEN EXIT FUNCTION + END IF + ELSE + 'can be assumed to be in DBLOCK + r$ = "80" + END IF + GOTO evalfuncspecial + END IF 'varseg + + + + + + + + + + + + + + + + 'note: this code has already been called... + '------------------------------------------------------------------------------------------------------------ + 'e2$ = e$ + 'e$ = evaluate(e$, sourcetyp) + '------------------------------------------------------------------------------------------------------------ + + 'note: this comment makes no sense... + 'any numeric variable, but it must be type-speficied + + IF targettyp = -2 THEN + e$ = evaluatetotyp(e2$, -2) + IF Error_Happened THEN EXIT FUNCTION + GOTO dontevaluate + END IF '-2 + + IF targettyp = -7 THEN + e$ = evaluatetotyp(e2$, -7) + IF Error_Happened THEN EXIT FUNCTION + GOTO dontevaluate + END IF '-7 + + IF targettyp = -8 THEN + e$ = evaluatetotyp(e2$, -8) + IF Error_Happened THEN EXIT FUNCTION + GOTO dontevaluate + END IF '-8 + + IF sourcetyp AND ISOFFSET THEN + IF (targettyp AND ISOFFSET) = 0 THEN + IF id2.internal_subfunc = 0 THEN Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + END IF + END IF + + 'note: this is used for functions like STR(...) which accept all types... + explicitreference = 0 + IF targettyp = -1 THEN + explicitreference = 1 + IF (sourcetyp AND ISSTRING) THEN Give_Error "Number required for function": EXIT FUNCTION + targettyp = sourcetyp + IF (targettyp AND ISPOINTER) THEN targettyp = targettyp - ISPOINTER + END IF + + 'pointer? + IF (targettyp AND ISPOINTER) THEN + IF dereference = 0 THEN 'check deferencing wasn't used + + + + 'note: array pointer + IF (targettyp AND ISARRAY) THEN + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected arrayname()": EXIT FUNCTION + IF (sourcetyp AND ISARRAY) = 0 THEN Give_Error "Expected arrayname()": EXIT FUNCTION + IF Debug THEN PRINT #9, "evaluatefunc:array reference:[" + e$ + "]" + + 'check arrays are of same type + targettyp2 = targettyp: sourcetyp2 = sourcetyp + targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) + sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISSTRING + ISFIXEDLENGTH + ISFLOAT) + IF sourcetyp2 <> targettyp2 THEN Give_Error "Incorrect array type passed to function": EXIT FUNCTION + + 'check arrayname was followed by '()' + IF targettyp AND ISUDT THEN + IF Debug THEN PRINT #9, "evaluatefunc:array reference:udt reference:[" + e$ + "]" + 'get UDT info + udtrefid = VAL(e$) + getid udtrefid + IF Error_Happened THEN EXIT FUNCTION + udtrefi = INSTR(e$, sp3) 'end of id + udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u + udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) + udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e + udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) + o$ = RIGHT$(e$, LEN(e$) - udtrefi3) + 'note: most of the UDT info above is not required + IF LEFT$(o$, 4) <> "(0)*" THEN Give_Error "Expected arrayname()": EXIT FUNCTION + ELSE + IF RIGHT$(e$, 2) <> sp3 + "0" THEN Give_Error "Expected arrayname()": EXIT FUNCTION + END IF + + + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) + getid idnum + IF Error_Happened THEN EXIT FUNCTION + + IF targettyp AND ISFIXEDLENGTH THEN + targettypsize = CVL(MID$(id2.argsize, curarg * 4 - 4 + 1, 4)) + IF id.tsize <> targettypsize THEN Give_Error "Incorrect array type passed to function": EXIT FUNCTION + END IF + + IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + + recompile = 1 + END IF + END IF + + + + IF id.linkid = 0 THEN + 'if id.linkid is 0, it means the number of array elements is definietly + 'known of the array being passed, this is not some "fake"/unknown array. + 'using the numer of array elements of a fake array would be dangerous! + + IF nelereq = 0 THEN + 'only continue if the number of array elements required is unknown + 'and it needs to be set + + IF id.arrayelements <> -1 THEN + nelereq = id.arrayelements + MID$(id2.nelereq, curarg, 1) = CHR$(nelereq) + END IF + + ids(targetid) = id2 + + ELSE + + 'the number of array elements required is known AND + 'the number of elements in the array to be passed is known + + + + 'REMOVE FOR TESTING PURPOSES ONLY!!! SHOULD BE UNREM'd! + 'print id.arrayelements,nelereq + ' 1 , 2 + + IF id.arrayelements <> nelereq THEN Give_Error "Passing arrays with a differing number of elements to a SUB/FUNCTION is not supported": EXIT FUNCTION + + + + END IF + END IF + + + e$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + GOTO dontevaluate + END IF + + + + + + + + + + + + + 'note: not an array... + + 'target is not an array + + IF (targettyp AND ISSTRING) = 0 THEN + IF (sourcetyp AND ISREFERENCE) THEN + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp + + targettyp2 = targettyp: sourcetyp2 = sourcetyp + + 'get info about source/target + arr = 0: IF (sourcetyp2 AND ISARRAY) THEN arr = 1 + passudtelement = 0: IF (targettyp2 AND ISUDT) = 0 AND (sourcetyp2 AND ISUDT) <> 0 THEN passudtelement = 1: sourcetyp2 = sourcetyp2 - ISUDT + + 'remove flags irrelevant for comparison... ISPOINTER,ISREFERENCE,ISINCONVENTIONALMEMORY,ISARRAY + targettyp2 = targettyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) + sourcetyp2 = sourcetyp2 AND (511 + ISOFFSETINBITS + ISUDT + ISFLOAT + ISSTRING) + + 'compare types + IF sourcetyp2 = targettyp2 THEN + + IF sourcetyp AND ISUDT THEN + 'udt/udt array + + 'get info + udtrefid = VAL(e$) + getid udtrefid + IF Error_Happened THEN EXIT FUNCTION + udtrefi = INSTR(e$, sp3) 'end of id + udtrefi2 = INSTR(udtrefi + 1, e$, sp3) 'end of u + udtrefu = VAL(MID$(e$, udtrefi + 1, udtrefi2 - udtrefi - 1)) + udtrefi3 = INSTR(udtrefi2 + 1, e$, sp3) 'skip e + udtrefe = VAL(MID$(e$, udtrefi2 + 1, udtrefi3 - udtrefi2 - 1)) + o$ = RIGHT$(e$, LEN(e$) - udtrefi3) + 'note: most of the UDT info above is not required + + IF arr THEN + n2$ = scope$ + "ARRAY_UDT_" + RTRIM$(id.n) + "[0]" + ELSE + n2$ = scope$ + "UDT_" + RTRIM$(id.n) + END IF + + e$ = "(void*)( ((char*)(" + n2$ + ")) + (" + o$ + ") )" + + 'convert void* to target type* + IF passudtelement THEN e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ + IF Error_Happened THEN EXIT FUNCTION + + ELSE + 'not a udt + IF arr THEN + IF (sourcetyp2 AND ISOFFSETINBITS) THEN Give_Error "Cannot pass BIT array offsets": EXIT FUNCTION + e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" + IF Error_Happened THEN EXIT FUNCTION + ELSE + e$ = refer(e$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + END IF + + 'note: signed/unsigned mismatch requires casting + IF (sourcetyp AND ISUNSIGNED) <> (targettyp AND ISUNSIGNED) THEN + e$ = "(" + typ2ctyp$(targettyp2 + (targettyp AND ISUNSIGNED), "") + "*)" + e$ + IF Error_Happened THEN EXIT FUNCTION + END IF + + END IF 'udt? + + 'force recompile if target needs to be in cmem and the source is not + IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + recompile = 1 + END IF + END IF + + GOTO dontevaluate + END IF 'similar + + 'IF sourcetyp2 = targettyp2 THEN + 'IF arr THEN + 'IF (sourcetyp2 AND ISOFFSETINBITS) THEN Give_Error "Cannot pass BIT array offsets yet": EXIT FUNCTION + 'e$ = "(&(" + refer(e$, sourcetyp, 0) + "))" + 'ELSE + 'e$ = refer(e$, sourcetyp, 1) + 'END IF + 'GOTO dontevaluate + 'END IF + + END IF 'source is a reference + + ELSE 'string + 'its a string + + IF (sourcetyp AND ISREFERENCE) THEN + idnum = VAL(LEFT$(e$, INSTR(e$, sp3) - 1)) 'id# of sourcetyp + IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? + IF cmemlist(idnum) = 0 THEN + cmemlist(idnum) = 1 + recompile = 1 + END IF + END IF + END IF 'reference + + END IF 'string + + END IF 'dereference was not used + END IF 'pointer + + + 'note: Target is not a pointer... + + 'IF (targettyp AND ISSTRING) = 0 THEN + 'IF (sourcetyp AND ISREFERENCE) THEN + 'targettyp2 = targettyp: sourcetyp2 = sourcetyp - ISREFERENCE + 'IF (sourcetyp2 AND ISINCONVENTIONALMEMORY) THEN sourcetyp2 = sourcetyp2 - ISINCONVENTIONALMEMORY + 'IF sourcetyp2 = targettyp2 THEN e$ = refer(e$, sourcetyp, 1): GOTO dontevaluate + 'END IF + 'END IF + 'END IF + + 'String-numeric mismatch? + IF targettyp AND ISSTRING THEN + IF (sourcetyp AND ISSTRING) = 0 THEN + nth = curarg + IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 + IF ids(targetid).args = 1 THEN Give_Error "String required for function": EXIT FUNCTION + Give_Error str_nth$(nth) + " function argument requires a string": EXIT FUNCTION + END IF + END IF + IF (targettyp AND ISSTRING) = 0 THEN + IF sourcetyp AND ISSTRING THEN + nth = curarg + IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 + IF ids(targetid).args = 1 THEN Give_Error "Number required for function": EXIT FUNCTION + Give_Error str_nth$(nth) + " function argument requires a number": EXIT FUNCTION + END IF + END IF + + 'change to "non-pointer" value + IF (sourcetyp AND ISREFERENCE) THEN + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + END IF + + IF explicitreference = 0 THEN + IF targettyp AND ISUDT THEN + nth = curarg + IF omitarg_last <> 0 AND nth > omitarg_last THEN nth = nth - 1 + IF qb64prefix_set AND udtxcname(targettyp AND 511) = "_MEM" THEN + x$ = "'" + MID$(RTRIM$(udtxcname(targettyp AND 511)), 2) + "'" + ELSE + x$ = "'" + RTRIM$(udtxcname(targettyp AND 511)) + "'" + END IF + IF ids(targetid).args = 1 THEN Give_Error "TYPE " + x$ + " required for function": EXIT FUNCTION + Give_Error str_nth$(nth) + " function argument requires TYPE " + x$: EXIT FUNCTION + END IF + ELSE + IF sourcetyp AND ISUDT THEN Give_Error "Number required for function": EXIT FUNCTION + END IF + + 'round to integer if required + IF (sourcetyp AND ISFLOAT) THEN + IF (targettyp AND ISFLOAT) = 0 THEN + '**32 rounding fix + bits = targettyp AND 511 + IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" + IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" + IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" + END IF + END IF + + IF explicitreference THEN + IF (targettyp AND ISOFFSETINBITS) THEN + 'integer value can fit inside int64 + e$ = "(int64)(" + e$ + ")" + ELSE + IF (targettyp AND ISFLOAT) THEN + IF (targettyp AND 511) = 32 THEN e$ = "(float)(" + e$ + ")" + IF (targettyp AND 511) = 64 THEN e$ = "(double)(" + e$ + ")" + IF (targettyp AND 511) = 256 THEN e$ = "(long double)(" + e$ + ")" + ELSE + IF (targettyp AND ISUNSIGNED) THEN + IF (targettyp AND 511) = 8 THEN e$ = "(uint8)(" + e$ + ")" + IF (targettyp AND 511) = 16 THEN e$ = "(uint16)(" + e$ + ")" + IF (targettyp AND 511) = 32 THEN e$ = "(uint32)(" + e$ + ")" + IF (targettyp AND 511) = 64 THEN e$ = "(uint64)(" + e$ + ")" + ELSE + IF (targettyp AND 511) = 8 THEN e$ = "(int8)(" + e$ + ")" + IF (targettyp AND 511) = 16 THEN e$ = "(int16)(" + e$ + ")" + IF (targettyp AND 511) = 32 THEN e$ = "(int32)(" + e$ + ")" + IF (targettyp AND 511) = 64 THEN e$ = "(int64)(" + e$ + ")" + END IF + END IF 'float? + END IF 'offset in bits? + END IF 'explicit? + + + IF (targettyp AND ISPOINTER) THEN 'pointer required + IF (targettyp AND ISSTRING) THEN GOTO dontevaluate 'no changes required + '20090703 + t$ = typ2ctyp$(targettyp, "") + IF Error_Happened THEN EXIT FUNCTION + v$ = "pass" + str2$(uniquenumber) + 'assume numeric type + IF MID$(sfcmemargs(targetid), curarg, 1) = CHR$(1) THEN 'cmem required? + bytesreq = ((targettyp AND 511) + 7) \ 8 + PRINT #defdatahandle, t$ + " *" + v$ + "=NULL;" + PRINT #13, "if(" + v$ + "==NULL){" + PRINT #13, "cmem_sp-=" + str2(bytesreq) + ";" + PRINT #13, v$ + "=(" + t$ + "*)(dblock+cmem_sp);" + PRINT #13, "if (cmem_spchr" + END IF + + IF LTRIM$(RTRIM$(e$)) = "0" THEN e$ = "NULL" + + END IF + + r$ = r$ + e$ + + '***special case**** + IF n$ = "_MEM" OR (n$ = "MEM" AND qb64prefix_set = 1) THEN + IF args = 1 THEN + IF curarg = 1 THEN r$ = r$ + ")": GOTO evalfuncspecial + END IF + IF args = 2 THEN + IF curarg = 2 THEN r$ = r$ + ")": GOTO evalfuncspecial + END IF + END IF + + IF i <> n AND nocomma = 0 THEN r$ = r$ + "," + nocomma = 0 + firsti = i + 1 + curarg = curarg + 1 + END IF + + IF (curarg >= omitarg_first AND curarg <= omitarg_last) AND i = n THEN + targettyp = CVL(MID$(id2.arg, curarg * 4 - 4 + 1, 4)) + 'IF (targettyp AND ISSTRING) THEN Give_Error "QB64 doesn't support optional string arguments for functions yet!": EXIT FUNCTION + FOR fi = 1 TO omitargs: r$ = r$ + ",NULL": NEXT + curarg = curarg + omitargs + END IF + + NEXT + END IF + + IF n$ = "UBOUND" OR n$ = "LBOUND" THEN + IF r$ = ",NULL" THEN r$ = ",1" + IF n$ = "UBOUND" THEN r2$ = "func_ubound(" ELSE r2$ = "func_lbound(" + e$ = refer$(ulboundarray$, sourcetyp, 1) + IF Error_Happened THEN EXIT FUNCTION + 'note: ID contins refer'ed array info + + arrayelements = id.arrayelements '2009 + IF arrayelements = -1 THEN arrayelements = 1 '2009 + + r$ = r2$ + e$ + r$ + "," + str2$(arrayelements) + ")" + typ& = INTEGER64TYPE - ISPOINTER + GOTO evalfuncspecial + END IF + + IF passomit THEN + IF omitarg_first THEN r$ = r$ + ",0" ELSE r$ = r$ + ",1" + END IF + r$ = r$ + ")" + + evalfuncspecial: + + IF n$ = "ABS" THEN typ& = sourcetyp 'ABS Note: ABS() returns argument #1's type + + 'QB-like conversion of math functions returning floating point values + IF n$ = "SIN" OR n$ = "COS" OR n$ = "TAN" OR n$ = "ATN" OR n$ = "SQR" OR n$ = "LOG" THEN + b = sourcetyp AND 511 + IF sourcetyp AND ISFLOAT THEN + 'Default is FLOATTYPE + IF b = 64 THEN typ& = DOUBLETYPE - ISPOINTER + IF b = 32 THEN typ& = SINGLETYPE - ISPOINTER + ELSE + 'Default is FLOATTYPE + IF b <= 32 THEN typ& = DOUBLETYPE - ISPOINTER + IF b <= 16 THEN typ& = SINGLETYPE - ISPOINTER + END IF + END IF + + IF id2.ret = ISUDT + (1) THEN + '***special case*** + v$ = "func" + str2$(uniquenumber) + PRINT #defdatahandle, "mem_block " + v$ + ";" + r$ = "(" + v$ + "=" + r$ + ")" + END IF + + IF id2.ccall THEN + IF LEFT$(r$, 11) = "( char* )" THEN + r$ = "qbs_new_txt(" + r$ + ")" + END IF + END IF + + IF Debug THEN PRINT #9, "evaluatefunc:out:"; r$ + evaluatefunc$ = r$ +END FUNCTION + +FUNCTION variablesize$ (i AS LONG) 'ID or -1 (if ID already 'loaded') + 'Note: assumes whole bytes, no bit offsets/sizes + IF i <> -1 THEN getid i + IF Error_Happened THEN EXIT FUNCTION + 'find base size from type + t = id.t: IF t = 0 THEN t = id.arraytype + bytes = (t AND 511) \ 8 + + IF t AND ISUDT THEN 'correct size for UDTs + u = t AND 511 + bytes = udtxsize(u) \ 8 + END IF + + IF t AND ISSTRING THEN 'correct size for strings + IF t AND ISFIXEDLENGTH THEN + bytes = id.tsize + ELSE + IF id.arraytype THEN Give_Error "Cannot determine size of variable-length string array": EXIT FUNCTION + variablesize$ = scope$ + "STRING_" + RTRIM$(id.n) + "->len" + EXIT FUNCTION + END IF + END IF + + IF id.arraytype THEN 'multiply size for arrays + n$ = RTRIM$(id.callname) + s$ = str2(bytes) + "*(" + n$ + "[2]&1)" 'note: multiplying by 0 if array not currently defined (affects dynamic arrays) + arrayelements = id.arrayelements: IF arrayelements = -1 THEN arrayelements = 1 '2009 + FOR i2 = 1 TO arrayelements + s$ = s$ + "*" + n$ + "[" + str2(i2 * 4 - 4 + 5) + "]" + NEXT + variablesize$ = "(" + s$ + ")" + EXIT FUNCTION + END IF + + variablesize$ = str2(bytes) +END FUNCTION + + + +FUNCTION evaluatetotyp$ (a2$, targettyp AS LONG) + 'note: 'evaluatetotyp' no longer performs 'fixoperationorder' on a2$ (in many cases, this has already been done) + a$ = a2$ + e$ = evaluate(a$, sourcetyp) + IF Error_Happened THEN EXIT FUNCTION + + 'Offset protection: + IF sourcetyp AND ISOFFSET THEN + IF (targettyp AND ISOFFSET) = 0 AND targettyp >= 0 THEN + Give_Error "Cannot convert _OFFSET type to other types": EXIT FUNCTION + END IF + END IF + + '-5 size + '-6 offset + IF targettyp = -4 OR targettyp = -5 OR targettyp = -6 THEN '? -> byte_element(offset,element size in bytes) + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION + + ' print "-4: evaluated as ["+e$+"]":sleep 1 + + IF (sourcetyp AND ISUDT) THEN 'User Defined Type -> byte_element(offset,bytes) + IF udtxvariable(sourcetyp AND 511) THEN Give_Error "UDT must have fixed size": EXIT FUNCTION + idnumber = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + u = VAL(e$) 'closest parent + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + E = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + o$ = e$ + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + n$ = "UDT_" + RTRIM$(id.n) + IF id.arraytype THEN + n$ = "ARRAY_" + n$ + "[0]" + 'whole array reference examplename()? + IF LEFT$(o$, 3) = "(0)" THEN + 'use -2 type method + GOTO method2usealludt + END IF + END IF + + dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + + 'determine size of element + IF E = 0 THEN 'no specific element, use size of entire type + bytes$ = str2(udtxsize(u) \ 8) + ELSE 'a specific element + IF (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -5) THEN + evaluatetotyp$ = "(*(qbs**)" + dst$ + ")->len" + EXIT FUNCTION + ELSEIF (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -4) THEN + dst$ = "(*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + "))))->chr" + bytes$ = "(*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + "))))->len" + evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" + EXIT FUNCTION + END IF + bytes$ = str2(udtesize(E) \ 8) + END IF + evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = dst$ + EXIT FUNCTION + END IF + + IF (sourcetyp AND ISARRAY) THEN 'Array reference -> byte_element(offset,bytes) + 'whole array reference examplename()? + IF RIGHT$(e$, 2) = sp3 + "0" THEN + 'use -2 type method + IF sourcetyp AND ISSTRING THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + Give_Error "Cannot pass array of variable-length strings": EXIT FUNCTION + END IF + END IF + GOTO method2useall + END IF + 'assume a specific element + IF sourcetyp AND ISSTRING THEN + IF sourcetyp AND ISFIXEDLENGTH THEN + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + ELSE + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + + evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + e$ + "->len," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = e$ + "->len" + IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + END IF + EXIT FUNCTION + END IF + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + e$ = "(&(" + e$ + "))" + bytes$ = str2((sourcetyp AND 511) \ 8) + evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = e$ + EXIT FUNCTION + END IF + + IF sourcetyp AND ISSTRING THEN 'String -> byte_element(offset,bytes) + IF sourcetyp AND ISFIXEDLENGTH THEN + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + ELSE + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + bytes$ = e$ + "->len" + END IF + evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + EXIT FUNCTION + END IF + + 'Standard variable -> byte_element(offset,bytes) + e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name + IF Error_Happened THEN EXIT FUNCTION + size = (sourcetyp AND 511) \ 8 'calculate its size in bytes + evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = str2(size) + IF targettyp = -6 THEN evaluatetotyp$ = e$ + EXIT FUNCTION + + END IF '-4, -5, -6 + + + + + IF targettyp = -8 THEN '? -> _MEM structure helper {offset, fullsize, typeval, elementsize, sf_mem_lock|???} + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION + + + IF (sourcetyp AND ISUDT) THEN 'User Defined Type -> byte_element(offset,bytes) + idnumber = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + u = VAL(e$) 'closest parent + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + E = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + o$ = e$ + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + n$ = "UDT_" + RTRIM$(id.n) + IF id.arraytype THEN + n$ = "ARRAY_" + n$ + "[0]" + 'whole array reference examplename()? + IF LEFT$(o$, 3) = "(0)" THEN + 'use -7 type method + GOTO method2usealludt__7 + END IF + END IF + 'determine size of element + IF E = 0 THEN 'no specific element, use size of entire type + bytes$ = str2(udtxsize(u) \ 8) + t1 = ISUDT + udtetype(u) + ELSE 'a specific element + bytes$ = str2(udtesize(E) \ 8) + t1 = udtetype(E) + END IF + dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + 'evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" + 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + 'IF targettyp = -6 THEN evaluatetotyp$ = dst$ + + t = Type2MemTypeValue(t1) + evaluatetotyp$ = "(ptrszint)" + dst$ + "," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" + + EXIT FUNCTION + END IF + + IF (sourcetyp AND ISARRAY) THEN 'Array reference -> byte_element(offset,bytes) + 'whole array reference examplename()? + IF RIGHT$(e$, 2) = sp3 + "0" THEN + 'use -7 type method + IF sourcetyp AND ISSTRING THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + Give_Error "Cannot pass array of variable-length strings": EXIT FUNCTION + END IF + END IF + GOTO method2useall__7 + END IF + + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + n$ = RTRIM$(id.callname) + lk$ = "(mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * id.arrayelements + 4 + 1 - 1) + "]" + + 'assume a specific element + + IF sourcetyp AND ISSTRING THEN + IF sourcetyp AND ISFIXEDLENGTH THEN + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" + 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + "," + lk$ + + ELSE + + Give_Error qb64prefix$ + "MEMELEMENT cannot reference variable-length strings": EXIT FUNCTION + + END IF + EXIT FUNCTION + END IF + + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + e$ = "(&(" + e$ + "))" + bytes$ = str2((sourcetyp AND 511) \ 8) + 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" + 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "," + bytes$ + "," + str2(t) + "," + bytes$ + "," + lk$ + + EXIT FUNCTION + END IF 'isarray + + IF sourcetyp AND ISSTRING THEN 'String -> byte_element(offset,bytes) + IF sourcetyp AND ISFIXEDLENGTH THEN + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + ELSE + Give_Error qb64prefix$ + "MEMELEMENT cannot reference variable-length strings": EXIT FUNCTION + END IF + + 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" + 'IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" + + EXIT FUNCTION + END IF + + 'Standard variable -> byte_element(offset,bytes) + e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name + IF Error_Happened THEN EXIT FUNCTION + size = (sourcetyp AND 511) \ 8 'calculate its size in bytes + 'evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" + 'IF targettyp = -5 THEN evaluatetotyp$ = str2(size) + 'IF targettyp = -6 THEN evaluatetotyp$ = e$ + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "," + str2(size) + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" + + EXIT FUNCTION + + END IF '-8 + + + + + + + + + + + IF targettyp = -7 THEN '? -> _MEM structure helper {offset, fullsize, typeval, elementsize, sf_mem_lock|???} + method2useall__7: + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION + + 'User Defined Type + IF (sourcetyp AND ISUDT) THEN + ' print "CI: -2 type from a UDT":sleep 1 + idnumber = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + u = VAL(e$) 'closest parent + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + E = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + + o$ = e$ + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + n$ = "UDT_" + RTRIM$(id.n): IF id.arraytype THEN n$ = "ARRAY_" + n$ + "[0]" + method2usealludt__7: + bytes$ = variablesize$(-1) + "-(" + o$ + ")" + IF Error_Happened THEN EXIT FUNCTION + dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + + + 'evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" + + 'note: myudt.myelement results in a size of 1 because it is a continuous run of no consistent granularity + IF E <> 0 THEN size = 1 ELSE size = udtxsize(u) \ 8 + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + dst$ + "," + bytes$ + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" + + EXIT FUNCTION + END IF + + 'Array reference + IF (sourcetyp AND ISARRAY) THEN + IF sourcetyp AND ISSTRING THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + Give_Error qb64prefix$ + "MEM cannot reference variable-length strings": EXIT FUNCTION + END IF + END IF + + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + + n$ = RTRIM$(id.callname) + lk$ = "(mem_lock*)((ptrszint*)" + n$ + ")[" + str2(4 * id.arrayelements + 4 + 1 - 1) + "]" + + tsize = id.tsize 'used later to determine element size of fixed length strings + 'note: array references consist of idnumber|unmultiplied-element-index + index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'get element index + bytes$ = variablesize$(-1) + IF Error_Happened THEN EXIT FUNCTION + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + + IF sourcetyp AND ISSTRING THEN + e$ = "((" + e$ + ")->chr)" '[2013] handle fixed string arrays differently because they are already pointers + ELSE + e$ = "(&(" + e$ + "))" + END IF + + ' print "CI: array: e$["+e$+"], bytes$["+bytes$+"]":sleep 1 + 'calculate size of elements + IF sourcetyp AND ISSTRING THEN + bytes = tsize + ELSE + bytes = (sourcetyp AND 511) \ 8 + END IF + bytes$ = bytes$ + "-(" + str2(bytes) + "*(" + index$ + "))" + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "," + bytes$ + "," + str2(t) + "," + str2(bytes) + "," + lk$ + + EXIT FUNCTION + END IF + + 'String + IF sourcetyp AND ISSTRING THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN Give_Error qb64prefix$ + "MEM cannot reference variable-length strings": EXIT FUNCTION + + idnumber = VAL(e$) + getid idnumber: IF Error_Happened THEN EXIT FUNCTION + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0): IF Error_Happened THEN EXIT FUNCTION + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "->chr," + bytes$ + "," + str2(t) + "," + bytes$ + ",sf_mem_lock" + + EXIT FUNCTION + END IF + + 'Standard variable -> byte_element(offset,bytes) + e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name + IF Error_Happened THEN EXIT FUNCTION + size = (sourcetyp AND 511) \ 8 'calculate its size in bytes + + t = Type2MemTypeValue(sourcetyp) + evaluatetotyp$ = "(ptrszint)" + e$ + "," + str2(size) + "," + str2(t) + "," + str2(size) + ",sf_mem_lock" + + EXIT FUNCTION + + END IF '-7 _MEM structure helper + + + IF targettyp = -2 THEN '? -> byte_element(offset,max possible bytes) + method2useall: + ' print "CI: eval2typ detected target type of -2 for ["+a2$+"] evaluated as ["+e$+"]":sleep 1 + + IF (sourcetyp AND ISREFERENCE) = 0 THEN Give_Error "Expected variable name/array element": EXIT FUNCTION + IF (sourcetyp AND ISOFFSETINBITS) THEN Give_Error "Variable/element cannot be BIT aligned": EXIT FUNCTION + + 'User Defined Type -> byte_element(offset,bytes) + IF (sourcetyp AND ISUDT) THEN + ' print "CI: -2 type from a UDT":sleep 1 + idnumber = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + u = VAL(e$) 'closest parent + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + E = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i) + o$ = e$ + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + n$ = "UDT_" + RTRIM$(id.n): IF id.arraytype THEN n$ = "ARRAY_" + n$ + "[0]" + method2usealludt: + bytes$ = variablesize$(-1) + "-(" + o$ + ")" + IF Error_Happened THEN EXIT FUNCTION + dst$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = dst$ + EXIT FUNCTION + END IF + + 'Array reference -> byte_element(offset,bytes) + IF (sourcetyp AND ISARRAY) THEN + 'array of variable length strings (special case, can only refer to single element) + IF sourcetyp AND ISSTRING THEN + IF (sourcetyp AND ISFIXEDLENGTH) = 0 THEN + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + e$ + "->len," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = e$ + "->len" + IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + EXIT FUNCTION + END IF + END IF + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + tsize = id.tsize 'used later to determine element size of fixed length strings + 'note: array references consist of idnumber|unmultiplied-element-index + index$ = RIGHT$(e$, LEN(e$) - INSTR(e$, sp3)) 'get element index + bytes$ = variablesize$(-1) + IF Error_Happened THEN EXIT FUNCTION + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + e$ = "(&(" + e$ + "))" + ' print "CI: array: e$["+e$+"], bytes$["+bytes$+"]":sleep 1 + 'calculate size of elements + IF sourcetyp AND ISSTRING THEN + bytes = tsize + ELSE + bytes = (sourcetyp AND 511) \ 8 + END IF + bytes$ = bytes$ + "-(" + str2(bytes) + "*(" + index$ + "))" + evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = e$ + ' print "CI: array ->["+"byte_element((uint64)" + e$ + "," + bytes$+ ","+NewByteElement$+")"+"]":sleep 1 + EXIT FUNCTION + END IF + + 'String -> byte_element(offset,bytes) + IF sourcetyp AND ISSTRING THEN + IF sourcetyp AND ISFIXEDLENGTH THEN + idnumber = VAL(e$) + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + bytes$ = str2(id.tsize) + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + ELSE + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + bytes$ = e$ + "->len" + END IF + evaluatetotyp$ = "byte_element((uint64)" + e$ + "->chr," + bytes$ + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = bytes$ + IF targettyp = -6 THEN evaluatetotyp$ = e$ + "->chr" + EXIT FUNCTION + END IF + + 'Standard variable -> byte_element(offset,bytes) + e$ = refer(e$, sourcetyp, 1) 'get the variable's formal name + IF Error_Happened THEN EXIT FUNCTION + size = (sourcetyp AND 511) \ 8 'calculate its size in bytes + evaluatetotyp$ = "byte_element((uint64)" + e$ + "," + str2(size) + "," + NewByteElement$ + ")" + IF targettyp = -5 THEN evaluatetotyp$ = str2(size) + IF targettyp = -6 THEN evaluatetotyp$ = e$ + EXIT FUNCTION + + END IF '-2 byte_element(offset,bytes) + + + + 'string? + IF (sourcetyp AND ISSTRING) <> (targettyp AND ISSTRING) THEN + Give_Error "Illegal string-number conversion": EXIT FUNCTION + END IF + + IF (sourcetyp AND ISSTRING) THEN + evaluatetotyp$ = e$ + IF (sourcetyp AND ISREFERENCE) THEN + evaluatetotyp$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + END IF + EXIT FUNCTION + END IF + + 'pointer required? + IF (targettyp AND ISPOINTER) THEN + Give_Error "evaluatetotyp received a request for a pointer (unsupported)": EXIT FUNCTION + '... + Give_Error "Invalid pointer": EXIT FUNCTION + END IF + + 'change to "non-pointer" value + IF (sourcetyp AND ISREFERENCE) THEN + e$ = refer(e$, sourcetyp, 0) + IF Error_Happened THEN EXIT FUNCTION + END IF + 'check if successful + IF (sourcetyp AND ISPOINTER) THEN + Give_Error "evaluatetotyp couldn't convert pointer type!": EXIT FUNCTION + END IF + + 'round to integer if required + IF (sourcetyp AND ISFLOAT) THEN + IF (targettyp AND ISFLOAT) = 0 THEN + bits = targettyp AND 511 + '**32 rounding fix + IF bits <= 16 THEN e$ = "qbr_float_to_long(" + e$ + ")" + IF bits > 16 AND bits < 32 THEN e$ = "qbr_double_to_long(" + e$ + ")" + IF bits >= 32 THEN e$ = "qbr(" + e$ + ")" + END IF + END IF + + evaluatetotyp$ = e$ +END FUNCTION + +FUNCTION findid& (n2$) + n$ = UCASE$(n2$) 'case insensitive + + 'return all strings as 'not found' + IF ASC(n$) = 34 THEN GOTO noid + + 'if findidsecondarg was set, it will be used for finding the name of a sub (not a func or variable) + secondarg$ = findidsecondarg: findidsecondarg = "" + + 'if findanotherid was set, findid will continue scan from last index, otherwise, it will begin a new search + findanother = findanotherid: findanotherid = 0 + IF findanother <> 0 AND findidinternal <> 2 THEN Give_Error "FINDID() ERROR: Invalid repeat search requested!": EXIT FUNCTION 'cannot continue search, no more indexes left! + IF Error_Happened THEN EXIT FUNCTION + '(the above should never happen) + findid& = 2 '2=not finished searching all indexes + + 'seperate symbol from name (if a symbol has been added), this is the only way symbols can be passed to findid + i = 0 + i = INSTR(n$, "~"): IF i THEN GOTO gotsc + i = INSTR(n$, "`"): IF i THEN GOTO gotsc + i = INSTR(n$, "%"): IF i THEN GOTO gotsc + i = INSTR(n$, "&"): IF i THEN GOTO gotsc + i = INSTR(n$, "!"): IF i THEN GOTO gotsc + i = INSTR(n$, "#"): IF i THEN GOTO gotsc + i = INSTR(n$, "$"): IF i THEN GOTO gotsc + gotsc: + IF i THEN + sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1) + IF sc$ = "`" OR sc$ = "~`" THEN sc$ = sc$ + "1" 'clarify abbreviated 1 bit reference + ELSE + ''' 'no symbol passed, so check what symbol could be assumed under the current DEF... + ''' v = ASC(n$): IF v = 95 THEN v = 27 ELSE v = v - 64 + ''' IF v >= 1 AND v <= 27 THEN 'safeguard against n$ not being a standard name + ''' couldhavesc$ = defineextaz(v) + ''' IF couldhavesc$ = "`" OR couldhavesc$ = "~`" THEN couldhavesc$ = couldhavesc$ + "1" 'clarify abbreviated 1 bit reference + ''' END IF 'safeguard + END IF + + 'optimizations for later comparisons + insf$ = subfunc + SPACE$(256 - LEN(subfunc)) + secondarg$ = secondarg$ + SPACE$(256 - LEN(secondarg$)) + IF LEN(sc$) THEN scpassed = 1: sc$ = sc$ + SPACE$(8 - LEN(sc$)) ELSE scpassed = 0 + '''IF LEN(couldhavesc$) THEN couldhavesc$ = couldhavesc$ + SPACE$(8 - LEN(couldhavesc$)): couldhavescpassed = 1 ELSE couldhavescpassed = 0 + IF LEN(n$) < 256 THEN n$ = n$ + SPACE$(256 - LEN(n$)) + + 'FUNCTION HashFind (a$, searchflags, resultflags, resultreference) + '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) + '0=doesn't exist + '1=found, no more items to scan + '2=found, more items still to scan + + 'NEW HASH SYSTEM + n$ = RTRIM$(n$) + IF findanother THEN + hashretry: + z = HashFindCont(unrequired, i) + ELSE + z = HashFind(n$, 1, unrequired, i) + END IF + findidinternal = z + IF z = 0 THEN GOTO noid + findid = z + + + 'continue from previous position? + ''IF findanother THEN start = findidinternal ELSE start = idn + + ''FOR i = start TO 1 STEP -1 + + '' findidinternal = i - 1 + '' IF findidinternal = 0 THEN findid& = 1 '1=found id, but no more to search + + '' IF ids(i).n = n$ THEN 'same name? + + 'in scope? + IF ids(i).subfunc = 0 AND ids(i).share = 0 THEN 'scope check required (not a shared variable or the name of a sub/function) + IF ids(i).insubfunc <> insf$ THEN GOTO findidnomatch + END IF + + 'some subs require a second argument (eg. PUT #, DEF SEG, etc.) + IF ids(i).subfunc = 2 THEN + IF ASC(ids(i).secondargmustbe) <> 32 THEN 'exists? + IF RTRIM$(secondarg$) = UCASE$(RTRIM$(ids(i).secondargmustbe)) THEN + ELSEIF qb64prefix_set = 1 AND LEFT$(ids(i).secondargmustbe, 1) = "_" AND LEFT$(secondarg$, 1) <> "_" AND RTRIM$(secondarg$) = UCASE$(MID$(RTRIM$(ids(i).secondargmustbe), 2)) THEN + ELSE + GOTO findidnomatch + END IF + END IF + IF ASC(ids(i).secondargcantbe) <> 32 THEN 'exists? + IF RTRIM$(secondarg$) <> UCASE$(RTRIM$(ids(i).secondargcantbe)) THEN + ELSEIF qb64prefix_set = 1 AND LEFT$(ids(i).secondargcantbe, 1) = "_" AND LEFT$(secondarg$, 1) <> "_" AND RTRIM$(secondarg$) <> UCASE$(MID$(RTRIM$(ids(i).secondargcantbe), 2)) THEN + ELSE + GOTO findidnomatch + END IF + END IF + END IF 'second sub argument possible + + 'must have symbol? + 'typically for variables defined automatically or by a symbol and not the full type name + imusthave = CVI(ids(i).musthave) 'speed up checks of first 2 characters + amusthave = imusthave AND 255 'speed up checks of first character + IF amusthave <> 32 THEN + IF scpassed THEN + IF sc$ = ids(i).musthave THEN GOTO findidok + END IF + ''' IF couldhavescpassed THEN + ''' IF couldhavesc$ = ids(i).musthave THEN GOTO findidok + ''' END IF + 'Q: why is the above triple-commented? + 'A: because if something must have a symbol to refer to it, then a could-have is + ' not sufficient, and it could mask shared variables in global scope + + 'note: symbol defined fixed length strings cannot be referred to by $ without an extension + 'note: sc$ and couldhavesc$ are already changed from ` to `1 to match stored musthave + GOTO findidnomatch + END IF + + 'may have symbol? + 'typically for variables formally dim'd + 'note: couldhavesc$ needn't be considered for mayhave checks + IF scpassed THEN 'symbol was passed, so it must match the mayhave symbol + imayhave = CVI(ids(i).mayhave) 'speed up checks of first 2 characters + amayhave = imayhave AND 255 'speed up checks of first character + IF amayhave = 32 THEN GOTO findidnomatch 'it cannot have the symbol passed (nb. musthave symbols have already been ok'd) + 'note: variable length strings are not a problem here, as they can only have one possible extension + + IF amayhave = 36 THEN '"$" + IF imayhave <> 8228 THEN '"$ " + 'it is a fixed length string + IF CVI(sc$) = 8228 THEN GOTO findidok 'allow myvariable$ to become myvariable$10 + 'allow later comparison to verify if extension is correct + END IF + END IF + IF sc$ <> ids(i).mayhave THEN GOTO findidnomatch + END IF 'scpassed + + 'return id + findidok: + + id = ids(i) + + t = id.t + temp$ = refer$(str2$(i), t, 1) + manageVariableList "", temp$, 0, 1 + currentid = i + EXIT FUNCTION + + 'END IF 'same name + findidnomatch: + 'NEXT + IF z = 2 THEN GOTO hashretry + + 'totally unclassifiable + noid: + findid& = 0 + currentid = -1 +END FUNCTION + +FUNCTION FindArray (secure$) + FindArray = -1 + n$ = secure$ + IF Debug THEN PRINT #9, "func findarray:in:" + n$ + IF alphanumeric(ASC(n$)) = 0 THEN FindArray = 0: EXIT FUNCTION + + 'establish whether n$ includes an extension + i = INSTR(n$, "~"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "`"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "%"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "&"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "!"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "#"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + i = INSTR(n$, "$"): IF i THEN sc$ = RIGHT$(n$, LEN(n$) - i + 1): n$ = LEFT$(n$, i - 1): GOTO gotsc2 + gotsc2: + n2$ = n$ + sc$ + + IF sc$ <> "" THEN + 'has an extension + 'note! findid must unambiguify ` to `5 or $ to $10 where applicable + try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype THEN + EXIT FUNCTION + END IF + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + ELSE + 'no extension + + '1. pass as is, without any extension (local) + try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype THEN + IF subfuncn = 0 THEN EXIT FUNCTION + IF id.insubfuncn = subfuncn THEN EXIT FUNCTION + END IF + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + '2. that failed, so apply the _define'd extension and pass (local) + a = ASC(UCASE$(n$)): IF a = 95 THEN a = 91 + a = a - 64 'so A=1, Z=27 and _=28 + n2$ = n$ + defineextaz(a) + try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype THEN + IF subfuncn = 0 THEN EXIT FUNCTION + IF id.insubfuncn = subfuncn THEN EXIT FUNCTION + EXIT FUNCTION + END IF + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + '3. pass as is, without any extension (global) + n2$ = n$ + try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype THEN + EXIT FUNCTION + END IF + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + '4. that failed, so apply the _define'd extension and pass (global) + a = ASC(UCASE$(n$)): IF a = 95 THEN a = 91 + a = a - 64 'so A=1, Z=27 and _=28 + n2$ = n$ + defineextaz(a) + try = findid(n2$): IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype THEN + EXIT FUNCTION + END IF + IF try = 2 THEN findanotherid = 1: try = findid(n2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + + END IF + FindArray = 0 +END FUNCTION + + + + + +FUNCTION fixoperationorder$ (savea$) + STATIC uboundlbound AS _BYTE + + a$ = savea$ + IF Debug THEN PRINT #9, "fixoperationorder:in:" + a$ + + fooindwel = fooindwel + 1 + + n = numelements(a$) 'n is maintained throughout function + + IF fooindwel = 1 THEN 'actions to take on initial call only + uboundlbound = 0 + + 'Quick check for duplicate binary operations + uppercasea$ = UCASE$(a$) 'capitalize it once to reduce calls to ucase over and over + FOR i = 1 TO n - 1 + temp1$ = getelement(uppercasea$, i) + temp2$ = getelement(uppercasea$, i + 1) + IF temp1$ = "AND" AND temp2$ = "AND" THEN Give_Error "Error: AND AND": EXIT FUNCTION + IF temp1$ = "OR" AND temp2$ = "OR" THEN Give_Error "Error: OR OR": EXIT FUNCTION + IF temp1$ = "XOR" AND temp2$ = "XOR" THEN Give_Error "Error: XOR XOR": EXIT FUNCTION + IF temp1$ = "IMP" AND temp2$ = "IMP" THEN Give_Error "Error: IMP IMP": EXIT FUNCTION + IF temp1$ = "EQV" AND temp2$ = "EQV" THEN Give_Error "Error: EQV EQV": EXIT FUNCTION + NEXT + + '----------------A. 'Quick' mismatched brackets check---------------- + b = 0 + a2$ = sp + a$ + sp + b1$ = sp + "(" + sp + b2$ = sp + ")" + sp + i = 1 + findmmb: + i1 = INSTR(i, a2$, b1$) + i2 = INSTR(i, a2$, b2$) + i3 = i1 + IF i2 THEN + IF i1 = 0 THEN + i3 = i2 + ELSE + IF i2 < i1 THEN i3 = i2 + END IF + END IF + IF i3 THEN + IF i3 = i1 THEN b = b + 1 + IF i3 = i2 THEN b = b - 1 + i = i3 + 2 + IF b < 0 THEN Give_Error "Missing (": EXIT FUNCTION + GOTO findmmb + END IF + IF b > 0 THEN Give_Error "Missing )": EXIT FUNCTION + + '----------------B. 'Quick' correction of over-use of +,- ---------------- + 'note: the results of this change are beneficial to foolayout + a2$ = sp + a$ + sp + + 'rule 1: change ++ to + + rule1: + i = INSTR(a2$, sp + "+" + sp + "+" + sp) + IF i THEN + a2$ = LEFT$(a2$, i + 2) + RIGHT$(a2$, LEN(a2$) - i - 4) + a$ = MID$(a2$, 2, LEN(a2$) - 2) + n = n - 1 + IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ + GOTO rule1 + END IF + + 'rule 2: change -+ to - + rule2: + i = INSTR(a2$, sp + "-" + sp + "+" + sp) + IF i THEN + a2$ = LEFT$(a2$, i + 2) + RIGHT$(a2$, LEN(a2$) - i - 4) + a$ = MID$(a2$, 2, LEN(a2$) - 2) + n = n - 1 + IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ + GOTO rule2 + END IF + + 'rule 3: change anyoperator-- to anyoperator + rule3: + IF INSTR(a2$, sp + "-" + sp + "-" + sp) THEN + FOR i = 1 TO n - 2 + IF isoperator(getelement(a$, i)) THEN + IF getelement(a$, i + 1) = "-" THEN + IF getelement(a$, i + 2) = "-" THEN + removeelements a$, i + 1, i + 2, 0 + a2$ = sp + a$ + sp + n = n - 2 + IF Debug THEN PRINT #9, "fixoperationorder:+/-:" + a$ + GOTO rule3 + END IF + END IF + END IF + NEXT + END IF 'rule 3 + + + + '----------------C. 'Quick' location of negation---------------- + 'note: the results of this change are beneficial to foolayout + + 'for numbers... + 'before: anyoperator,-,number + 'after: anyoperator,-number + + 'for variables... + 'before: anyoperator,-,variable + 'after: anyoperator,CHR$(241),variable + + 'exception for numbers followed by ^... (they will be bracketed up along with the ^ later) + 'before: anyoperator,-,number,^ + 'after: anyoperator,CHR$(241),number,^ + + FOR i = 1 TO n - 1 + IF i > n - 1 THEN EXIT FOR 'n changes, so manually exit if required + + IF ASC(getelement(a$, i)) = 45 THEN '- + + neg = 0 + IF i = 1 THEN + neg = 1 + ELSE + a2$ = getelement(a$, i - 1) + c = ASC(a2$) + IF c = 40 OR c = 44 THEN '(, + neg = 1 + ELSE + IF isoperator(a2$) THEN neg = 1 + END IF '() + END IF 'i=1 + IF neg = 1 THEN + + a2$ = getelement(a$, i + 1) + c = ASC(a2$) + IF c >= 48 AND c <= 57 THEN + c2 = 0: IF i < n - 1 THEN c2 = ASC(getelement(a$, i + 2)) + IF c2 <> 94 THEN 'not ^ + 'number... + i2 = INSTR(a2$, ",") + IF i2 AND ASC(a2$, i2 + 1) <> 38 THEN '&H/&O/&B values don't need the assumed negation + a2$ = "-" + LEFT$(a2$, i2) + "-" + RIGHT$(a2$, LEN(a2$) - i2) + ELSE + a2$ = "-" + a2$ + END IF + removeelements a$, i, i + 1, 0 + insertelements a$, i - 1, a2$ + n = n - 1 + IF Debug THEN PRINT #9, "fixoperationorder:negation:" + a$ + + GOTO negdone + + END IF + END IF + + + 'not a number (or for exceptions)... + removeelements a$, i, i, 0 + insertelements a$, i - 1, CHR$(241) + IF Debug THEN PRINT #9, "fixoperationorder:negation:" + a$ + + END IF 'isoperator + END IF '- + negdone: + NEXT + + + + END IF 'fooindwel=1 + + + + '----------------D. 'Quick' Add 'power of' with negation {}bracketing to bottom bracket level---------------- + pownegused = 0 + powneg: + IF INSTR(a$, "^" + sp + CHR$(241)) THEN 'quick check + b = 0 + b1 = 0 + FOR i = 1 TO n + a2$ = getelement(a$, i) + c = ASC(a2$) + IF c = 40 THEN b = b + 1 + IF c = 41 THEN b = b - 1 + IF b = 0 THEN + IF b1 THEN + IF isoperator(a2$) THEN + IF a2$ <> "^" AND a2$ <> CHR$(241) THEN + insertelements a$, i - 1, "}" + insertelements a$, b1, "{" + n = n + 2 + IF Debug THEN PRINT #9, "fixoperationorder:^-:" + a$ + GOTO powneg + pownegused = 1 + END IF + END IF + END IF + IF c = 94 THEN '^ + IF getelement$(a$, i + 1) = CHR$(241) THEN b1 = i: i = i + 1 + END IF + END IF 'b=0 + NEXT i + IF b1 THEN + insertelements a$, b1, "{" + a$ = a$ + sp + "}" + n = n + 2 + IF Debug THEN PRINT #9, "fixoperationorder:^-:" + a$ + pownegused = 1 + GOTO powneg + END IF + + END IF 'quick check + + + '----------------E. Find lowest & highest operator level in bottom bracket level---------------- + NOT_recheck: + lco = 255 + hco = 0 + b = 0 + FOR i = 1 TO n + a2$ = getelement(a$, i) + c = ASC(a2$) + IF c = 40 OR c = 123 THEN b = b + 1 + IF c = 41 OR c = 125 THEN b = b - 1 + IF b = 0 THEN + op = isoperator(a2$) + IF op THEN + IF op < lco THEN lco = op + IF op > hco THEN hco = op + END IF + END IF + NEXT + + '----------------F. Add operator {}bracketting---------------- + 'apply bracketting only if required + IF hco <> 0 THEN 'operators were used + IF lco <> hco THEN + 'brackets needed + + IF lco = 6 THEN 'NOT exception + 'Step 1: Add brackets as follows ~~~ ( NOT ( ~~~ NOT ~~~ NOT ~~~ NOT ~~~ )) + 'Step 2: Recheck line from beginning + IF n = 1 THEN Give_Error "Expected NOT ...": EXIT FUNCTION + b = 0 + FOR i = 1 TO n + a2$ = getelement(a$, i) + c = ASC(a2$) + IF c = 40 OR c = 123 THEN b = b + 1 + IF c = 41 OR c = 125 THEN b = b - 1 + IF b = 0 THEN + IF UCASE$(a2$) = "NOT" THEN + IF i = n THEN Give_Error "Expected NOT ...": EXIT FUNCTION + IF i = 1 THEN a$ = "NOT" + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2: GOTO lco_bracketting_done + a$ = getelements$(a$, 1, i - 1) + sp + "{" + sp + "NOT" + sp + "{" + sp + getelements$(a$, i + 1, n) + sp + "}" + sp + "}" + n = n + 4 + GOTO NOT_recheck + END IF 'not + END IF 'b=0 + NEXT + END IF 'NOT exception + + n2 = n + b = 0 + a3$ = "{" + n = 1 + FOR i = 1 TO n2 + a2$ = getelement(a$, i) + c = ASC(a2$) + IF c = 40 OR c = 123 THEN b = b + 1 + IF c = 41 OR c = 125 THEN b = b - 1 + IF b = 0 THEN + op = isoperator(a2$) + IF op = lco THEN + IF i = 1 THEN + a3$ = a2$ + sp + "{" + n = 2 + ELSE + IF i = n2 THEN Give_Error "Expected variable/value after '" + UCASE$(a2$) + "'": EXIT FUNCTION + a3$ = a3$ + sp + "}" + sp + a2$ + sp + "{" + n = n + 3 + END IF + GOTO fixop0 + END IF + + END IF 'b=0 + a3$ = a3$ + sp + a2$ + n = n + 1 + fixop0: + NEXT + a3$ = a3$ + sp + "}" + n = n + 1 + a$ = a3$ + + lco_bracketting_done: + IF Debug THEN PRINT #9, "fixoperationorder:lco bracketing["; lco; ","; hco; "]:" + a$ + + '--------(F)G. Remove indwelling {}bracketting from power-negation-------- + IF pownegused THEN + b = 0 + i = 0 + DO + i = i + 1 + IF i > n THEN EXIT DO + c = ASC(getelement(a$, i)) + IF c = 41 OR c = 125 THEN b = b - 1 + IF (c = 123 OR c = 125) AND b <> 0 THEN + removeelements a$, i, i, 0 + n = n - 1 + i = i - 1 + IF Debug THEN PRINT #9, "fixoperationorder:^- {} removed:" + a$ + END IF + IF c = 40 OR c = 123 THEN b = b + 1 + LOOP + END IF 'pownegused + + END IF 'lco <> hco + END IF 'hco <> 0 + + '--------Bracketting of multiple NOT/negation unary operators-------- + IF LEFT$(a$, 4) = CHR$(241) + sp + CHR$(241) + sp THEN + a$ = CHR$(241) + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2 + END IF + IF UCASE$(LEFT$(a$, 8)) = "NOT" + sp + "NOT" + sp THEN + a$ = "NOT" + sp + "{" + sp + getelements$(a$, 2, n) + sp + "}": n = n + 2 + END IF + + '----------------H. Identification/conversion of elements within bottom bracket level---------------- + 'actions performed: + ' ->builds f$(tlayout) + ' ->adds symbols to all numbers + ' ->evaluates constants to numbers + + f$ = "" + b = 0 + c = 0 + lastt = 0: lastti = 0 + FOR i = 1 TO n + f2$ = getelement(a$, i) + lastc = c + c = ASC(f2$) + + IF c = 40 OR c = 123 THEN + IF c <> 40 OR b <> 0 THEN f2$ = "" 'skip temporary & indwelling brackets + b = b + 1 + GOTO classdone + END IF + IF c = 41 OR c = 125 THEN + + b = b - 1 + + 'check for "("+sp+")" after literal-string, operator, number or nothing + IF b = 0 THEN 'must be within the lowest level + IF c = 41 THEN + IF lastc = 40 THEN + IF lastti = i - 2 OR lastti = 0 THEN + IF lastt >= 0 AND lastt <= 3 THEN + Give_Error "Unexpected (": EXIT FUNCTION + END IF + END IF + END IF + END IF + END IF + + IF c <> 41 OR b <> 0 THEN f2$ = "" 'skip temporary & indwelling brackets + GOTO classdone + END IF + + IF b = 0 THEN + + 'classifications/conversions: + '1. quoted string ("....) + '2. number + '3. operator + '4. constant + '5. variable/array/udt/function (note: nothing can share the same name as a function except a label) + + + 'quoted string? + IF c = 34 THEN '" + lastt = 1: lastti = i + + 'convert \\ to \ + 'convert \??? to CHR$(&O???) + x2 = 1 + x = INSTR(x2, f2$, "\") + DO WHILE x + c2 = ASC(f2$, x + 1) + IF c2 = 92 THEN '\\ + f2$ = LEFT$(f2$, x) + RIGHT$(f2$, LEN(f2$) - x - 1) 'remove second \ + x2 = x + 1 + ELSE + 'octal triplet value + c3 = (ASC(f2$, x + 3) - 48) + (ASC(f2$, x + 2) - 48) * 8 + (ASC(f2$, x + 1) - 48) * 64 + f2$ = LEFT$(f2$, x - 1) + CHR$(c3) + RIGHT$(f2$, LEN(f2$) - x - 3) + x2 = x + 1 + END IF + x = INSTR(x2, f2$, "\") + LOOP + 'remove ',len' (if it exists) + x = INSTR(2, f2$, CHR$(34) + ","): IF x THEN f2$ = LEFT$(f2$, x) + GOTO classdone + END IF + + 'number? + IF (c >= 48 AND c <= 57) OR c = 45 THEN + lastt = 2: lastti = i + + x = INSTR(f2$, ",") + IF x THEN + removeelements a$, i, i, 0: insertelements a$, i - 1, LEFT$(f2$, x - 1) + f2$ = RIGHT$(f2$, LEN(f2$) - x) + END IF + + IF x = 0 THEN + c2 = ASC(f2$, LEN(f2$)) + IF c2 < 48 OR c2 > 57 THEN + x = 1 'extension given + ELSE + x = INSTR(f2$, "`") + END IF + END IF + + 'add appropriate integer symbol if none present + IF x = 0 THEN + f3$ = f2$ + s$ = "" + IF c = 45 THEN + s$ = "&&" + IF (f3$ < "-2147483648" AND LEN(f3$) = 11) OR LEN(f3$) < 11 THEN s$ = "&" + IF (f3$ <= "-32768" AND LEN(f3$) = 6) OR LEN(f3$) < 6 THEN s$ = "%" + ELSE + s$ = "~&&" + IF (f3$ <= "9223372036854775807" AND LEN(f3$) = 19) OR LEN(f3$) < 19 THEN s$ = "&&" + IF (f3$ <= "2147483647" AND LEN(f3$) = 10) OR LEN(f3$) < 10 THEN s$ = "&" + IF (f3$ <= "32767" AND LEN(f3$) = 5) OR LEN(f3$) < 5 THEN s$ = "%" + END IF + f3$ = f3$ + s$ + removeelements a$, i, i, 0: insertelements a$, i - 1, f3$ + END IF 'x=0 + + GOTO classdone + END IF + + 'operator? + IF isoperator(f2$) THEN + lastt = 3: lastti = i + IF LEN(f2$) > 1 THEN + IF f2$ <> SCase2$(f2$) THEN + f2$ = SCase2$(f2$) + removeelements a$, i, i, 0 + insertelements a$, i - 1, f2$ + END IF + END IF + 'append negation + IF f2$ = CHR$(241) THEN f$ = f$ + sp + "-": GOTO classdone_special + GOTO classdone + END IF + + IF alphanumeric(c) THEN + lastt = 4: lastti = i + + IF i < n THEN nextc = ASC(getelement(a$, i + 1)) ELSE nextc = 0 + + ' a constant? + IF nextc <> 40 THEN '<>"(" (not an array) + IF lastc <> 46 THEN '<>"." (not an element of a UDT) + + e$ = UCASE$(f2$) + es$ = removesymbol$(e$) + IF Error_Happened THEN EXIT FUNCTION + + hashfound = 0 + hashname$ = e$ + hashchkflags = HASHFLAG_CONSTANT + hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN + IF constdefined(hashresref) THEN + hashfound = 1 + EXIT DO + END IF + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + + IF hashfound THEN + i2 = hashresref + 'FOR i2 = constlast TO 0 STEP -1 + 'IF e$ = constname(i2) THEN + + + + + + 'is a STATIC variable overriding this constant? + staticvariable = 0 + try = findid(e$ + es$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype = 0 THEN staticvariable = 1: EXIT DO 'if it's not an array, it's probably a static variable + IF try = 2 THEN findanotherid = 1: try = findid(e$ + es$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + 'add symbol and try again + IF staticvariable = 0 THEN + IF LEN(es$) = 0 THEN + a = ASC(UCASE$(e$)): IF a = 95 THEN a = 91 + a = a - 64 'so A=1, Z=27 and _=28 + es2$ = defineextaz(a) + try = findid(e$ + es2$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF id.arraytype = 0 THEN staticvariable = 1: EXIT DO 'if it's not an array, it's probably a static variable + IF try = 2 THEN findanotherid = 1: try = findid(e$ + es2$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + END IF + END IF + + IF staticvariable = 0 THEN + + t = consttype(i2) + IF t AND ISSTRING THEN + IF LEN(es$) > 0 AND es$ <> "$" THEN Give_Error "Type mismatch": EXIT FUNCTION + e$ = conststring(i2) + ELSE 'not a string + IF LEN(es$) THEN et = typname2typ(es$) ELSE et = 0 + IF Error_Happened THEN EXIT FUNCTION + IF et AND ISSTRING THEN Give_Error "Type mismatch": EXIT FUNCTION + 'convert value to general formats + IF t AND ISFLOAT THEN + v## = constfloat(i2) + v&& = v## + v~&& = v&& + ELSE + IF t AND ISUNSIGNED THEN + v~&& = constuinteger(i2) + v&& = v~&& + v## = v&& + ELSE + v&& = constinteger(i2) + v## = v&& + v~&& = v&& + END IF + END IF + 'apply type conversion if necessary + IF et THEN t = et + '(todo: range checking) + 'convert value into string for returning + IF t AND ISFLOAT THEN + e$ = LTRIM$(RTRIM$(STR$(v##))) + ELSE + IF t AND ISUNSIGNED THEN + e$ = LTRIM$(RTRIM$(STR$(v~&&))) + ELSE + e$ = LTRIM$(RTRIM$(STR$(v&&))) + END IF + END IF + + 'floats returned by str$ must be converted to qb64 standard format + IF t AND ISFLOAT THEN + t2 = t AND 511 + 'find E,D or F + s$ = "" + IF INSTR(e$, "E") THEN s$ = "E" + IF INSTR(e$, "D") THEN s$ = "D" + IF INSTR(e$, "F") THEN s$ = "F" + IF LEN(s$) THEN + 'E,D,F found + x = INSTR(e$, s$) + 'as incorrect type letter may have been returned by STR$, override it + IF t2 = 32 THEN s$ = "E" + IF t2 = 64 THEN s$ = "D" + IF t2 = 256 THEN s$ = "F" + MID$(e$, x, 1) = s$ + IF INSTR(e$, ".") = 0 THEN e$ = LEFT$(e$, x - 1) + ".0" + RIGHT$(e$, LEN(e$) - x + 1): x = x + 2 + IF LEFT$(e$, 1) = "." THEN e$ = "0" + e$ + IF LEFT$(e$, 2) = "-." THEN e$ = "-0" + RIGHT$(e$, LEN(e$) - 1) + IF INSTR(e$, "+") = 0 AND INSTR(e$, "-") = 0 THEN + e$ = LEFT$(e$, x) + "+" + RIGHT$(e$, LEN(e$) - x) + END IF + ELSE + 'E,D,F not found + IF INSTR(e$, ".") = 0 THEN e$ = e$ + ".0" + IF LEFT$(e$, 1) = "." THEN e$ = "0" + e$ + IF LEFT$(e$, 2) = "-." THEN e$ = "-0" + RIGHT$(e$, LEN(e$) - 1) + IF t2 = 32 THEN e$ = e$ + "E+0" + IF t2 = 64 THEN e$ = e$ + "D+0" + IF t2 = 256 THEN e$ = e$ + "F+0" + END IF + ELSE + s$ = typevalue2symbol$(t) + IF Error_Happened THEN EXIT FUNCTION + e$ = e$ + s$ 'simply append symbol to integer + END IF + + END IF 'not a string + + removeelements a$, i, i, 0 + insertelements a$, i - 1, e$ + 'alter f2$ here to original casing + f2$ = constcname(i2) + es$ + GOTO classdone + + END IF 'not static + 'END IF 'same name + 'NEXT + END IF 'hashfound + END IF 'not udt element + END IF 'not array + + 'variable/array/udt? + u$ = f2$ + + try_string$ = f2$ + try_string2$ = try_string$ 'pure version of try_string$ + + FOR try_method = 1 TO 4 + try_string$ = try_string2$ + IF try_method = 2 OR try_method = 4 THEN + dtyp$ = removesymbol(try_string$) + IF LEN(dtyp$) = 0 THEN + IF isoperator(try_string$) = 0 THEN + IF isvalidvariable(try_string$) THEN + IF LEFT$(try_string$, 1) = "_" THEN v = 27 ELSE v = ASC(UCASE$(try_string$)) - 64 + try_string$ = try_string$ + defineextaz(v) + END IF + END IF + ELSE + try_string$ = try_string2$ + END IF + END IF + try = findid(try_string$) + IF Error_Happened THEN EXIT FUNCTION + DO WHILE try + IF (subfuncn = id.insubfuncn AND try_method <= 2) OR try_method >= 3 THEN + + IF Debug THEN PRINT #9, "found id matching " + f2$ + + IF nextc = 40 OR uboundlbound <> 0 THEN '( + + uboundlbound = 0 + + 'function or array? + IF id.arraytype <> 0 OR id.subfunc = 1 THEN + 'note: even if it's an array of UDTs, the bracketted index will follow immediately + + 'correct name + f3$ = f2$ + s$ = removesymbol$(f3$) + IF Error_Happened THEN EXIT FUNCTION + IF id.internal_subfunc THEN + f2$ = SCase$(RTRIM$(id.cn)) + s$ + IF (UCASE$(f2$) = "UBOUND" OR UCASE$(f2$) = "LBOUND") THEN + uboundlbound = 2 + END IF + ELSE + f2$ = RTRIM$(id.cn) + s$ + END IF + removeelements a$, i, i, 0 + insertelements a$, i - 1, UCASE$(f2$) + f$ = f$ + f2$ + sp + "(" + sp + + 'skip (but record with nothing inside them) brackets + b2 = 1 'already in first bracket + FOR i2 = i + 2 TO n + c2 = ASC(getelement(a$, i2)) + IF c2 = 40 THEN b2 = b2 + 1 + IF c2 = 41 THEN b2 = b2 - 1 + IF b2 = 0 THEN EXIT FOR 'note: mismatched brackets check ensures this always succeeds + f$ = f$ + sp + NEXT + + 'adjust i accordingly + i = i2 + + f$ = f$ + ")" + + 'jump to UDT section if array is of UDT type (and elements are referenced) + IF id.arraytype AND ISUDT THEN + IF i < n THEN nextc = ASC(getelement(a$, i + 1)) ELSE nextc = 0 + IF nextc = 46 THEN t = id.arraytype: GOTO fooudt + END IF + + f$ = f$ + sp + GOTO classdone_special + END IF 'id.arraytype + END IF 'nextc "(" + + IF nextc <> 40 THEN 'not "(" (this avoids confusing simple variables with arrays) + IF id.t <> 0 OR id.subfunc = 1 THEN 'simple variable or function (without parameters) + + IF id.t AND ISUDT THEN + 'note: it may or may not be followed by a period (eg. if whole udt is being referred to) + 'check if next item is a period + + 'correct name + IF id.internal_subfunc THEN + f2$ = SCase$(RTRIM$(id.cn)) + removesymbol$(f2$) + ELSE + f2$ = RTRIM$(id.cn) + removesymbol$(f2$) + END IF + IF Error_Happened THEN EXIT FUNCTION + removeelements a$, i, i, 0 + insertelements a$, i - 1, UCASE$(f2$) + f$ = f$ + f2$ + + + + IF nextc <> 46 THEN f$ = f$ + sp: GOTO classdone_special 'no sub-elements referenced + t = id.t + + fooudt: + + f$ = f$ + sp + "." + sp + E = udtxnext(t AND 511) 'next element to check + i = i + 2 + + 'loop + + '"." encountered, i must be an element + IF i > n THEN Give_Error "Expected .element": EXIT FUNCTION + f2$ = getelement(a$, i) + s$ = removesymbol$(f2$) + IF Error_Happened THEN EXIT FUNCTION + u$ = UCASE$(f2$) + SPACE$(256 - LEN(f2$)) 'fast scanning + + 'is f$ the same as element e? + fooudtnexte: + IF udtename(E) = u$ THEN + 'match found + 'todo: check symbol(s$) matches element's type + + 'correct name + f2$ = RTRIM$(udtecname(E)) + s$ + removeelements a$, i, i, 0 + insertelements a$, i - 1, UCASE$(f2$) + f$ = f$ + f2$ + + IF i = n THEN f$ = f$ + sp: GOTO classdone_special + nextc = ASC(getelement(a$, i + 1)) + IF nextc <> 46 THEN f$ = f$ + sp: GOTO classdone_special 'no sub-elements referenced + 'sub-element exists + t = udtetype(E) + IF (t AND ISUDT) = 0 THEN Give_Error "Invalid . after element": EXIT FUNCTION + GOTO fooudt + + END IF 'match found + + 'no, so check next element + E = udtenext(E) + IF E = 0 THEN Give_Error "Element not defined": EXIT FUNCTION + GOTO fooudtnexte + + END IF 'udt + + 'non array/udt based variable + f3$ = f2$ + s$ = removesymbol$(f3$) + IF Error_Happened THEN EXIT FUNCTION + IF id.internal_subfunc THEN + f2$ = SCase$(RTRIM$(id.cn)) + s$ + ELSE + f2$ = RTRIM$(id.cn) + s$ + END IF + 'change was is returned to uppercase + removeelements a$, i, i, 0 + insertelements a$, i - 1, UCASE$(f2$) + GOTO CouldNotClassify + END IF 'id.t + + END IF 'nextc not "(" + + END IF + IF try = 2 THEN findanotherid = 1: try = findid(try_string$) ELSE try = 0 + IF Error_Happened THEN EXIT FUNCTION + LOOP + NEXT 'try method (1-4) + CouldNotClassify: + + 'alphanumeric, but item name is unknown... is it an internal type? if so, use capitals + f3$ = UCASE$(f2$) + internaltype = 0 + IF f3$ = "STRING" THEN internaltype = 1 + IF f3$ = "_UNSIGNED" OR (f3$ = "UNSIGNED" AND qb64prefix_set = 1) THEN internaltype = 1 + IF f3$ = "_BIT" OR (f3$ = "BIT" AND qb64prefix_set = 1) THEN internaltype = 1 + IF f3$ = "_BYTE" OR (f3$ = "BYTE" AND qb64prefix_set = 1) THEN internaltype = 1 + IF f3$ = "INTEGER" THEN internaltype = 1 + IF f3$ = "LONG" THEN internaltype = 1 + IF f3$ = "_INTEGER64" OR (f3$ = "INTEGER64" AND qb64prefix_set = 1) THEN internaltype = 1 + IF f3$ = "SINGLE" THEN internaltype = 1 + IF f3$ = "DOUBLE" THEN internaltype = 1 + IF f3$ = "_FLOAT" OR (f3$ = "FLOAT" AND qb64prefix_set = 1) THEN internaltype = 1 + IF f3$ = "_OFFSET" OR (f3$ = "OFFSET" AND qb64prefix_set = 1) THEN internaltype = 1 + IF internaltype = 1 THEN + f2$ = SCase2$(f3$) + removeelements a$, i, i, 0 + insertelements a$, i - 1, f3$ + GOTO classdone + END IF + + GOTO classdone + END IF 'alphanumeric + + classdone: + f$ = f$ + f2$ + END IF 'b=0 + f$ = f$ + sp + classdone_special: + NEXT + + IF LEN(f$) THEN f$ = LEFT$(f$, LEN(f$) - 1) 'remove trailing 'sp' + + IF Debug THEN PRINT #9, "fixoperationorder:identification:" + a$, n + IF Debug THEN PRINT #9, "fixoperationorder:identification(layout):" + f$, n + + + '----------------I. Pass (){}bracketed items (if any) to fixoperationorder & build return---------------- + 'note: items seperated by commas are done seperately + + ff$ = "" + b = 0 + b2 = 0 + p1 = 0 'where level 1 began + aa$ = "" + n = numelements(a$) + FOR i = 1 TO n + + openbracket = 0 + + a2$ = getelement(a$, i) + + c = ASC(a2$) + + + + IF c = 40 OR c = 123 THEN '({ + b = b + 1 + + IF b = 1 THEN + + + + + p1 = i + 1 + aa$ = aa$ + "(" + sp + + END IF + + openbracket = 1 + + GOTO foopass + + END IF '({ + + IF c = 44 THEN ', + IF b = 1 THEN + GOTO foopassit + END IF + END IF + + IF c = 41 OR c = 125 THEN ')} + IF uboundlbound THEN uboundlbound = uboundlbound - 1 + b = b - 1 + + IF b = 0 THEN + foopassit: + IF p1 <> i THEN + foo$ = fixoperationorder(getelements(a$, p1, i - 1)) + IF Error_Happened THEN EXIT FUNCTION + IF LEN(foo$) THEN + aa$ = aa$ + foo$ + sp + IF c = 125 THEN ff$ = ff$ + tlayout$ + sp ELSE ff$ = ff$ + tlayout$ + sp2 'spacing between ) } , varies + END IF + END IF + IF c = 44 THEN aa$ = aa$ + "," + sp: ff$ = ff$ + "," + sp ELSE aa$ = aa$ + ")" + sp + p1 = i + 1 + END IF + + GOTO foopass + END IF ')} + + + + + IF b = 0 THEN aa$ = aa$ + a2$ + sp + + + foopass: + + f2$ = getelementspecial(f$, i) + IF Error_Happened THEN EXIT FUNCTION + IF LEN(f2$) THEN + + 'use sp2 to join items connected by a period + IF c = 46 THEN '"." + IF i > 1 AND i < n THEN 'stupidity check + IF LEN(ff$) THEN MID$(ff$, LEN(ff$), 1) = sp2 'convert last spacer to a sp2 + ff$ = ff$ + "." + sp2 + GOTO fooloopnxt + END IF + END IF + + 'spacing just before ( + IF openbracket THEN + + 'convert last spacer? + IF i <> 1 THEN + IF isoperator(getelement$(a$, i - 1)) = 0 THEN + MID$(ff$, LEN(ff$), 1) = sp2 + END IF + END IF + ff$ = ff$ + f2$ + sp2 + ELSE 'not openbracket + ff$ = ff$ + f2$ + sp + END IF + + END IF 'len(f2$) + + fooloopnxt: + + NEXT + + IF LEN(aa$) THEN aa$ = LEFT$(aa$, LEN(aa$) - 1) + IF LEN(ff$) THEN ff$ = LEFT$(ff$, LEN(ff$) - 1) + + IF Debug THEN PRINT #9, "fixoperationorder:return:" + aa$ + IF Debug THEN PRINT #9, "fixoperationorder:layout:" + ff$ + tlayout$ = ff$ + fixoperationorder$ = aa$ + + fooindwel = fooindwel - 1 +END FUNCTION + + + + +FUNCTION getelementspecial$ (savea$, elenum) + a$ = savea$ + IF a$ = "" THEN EXIT FUNCTION 'no elements! + + n = 1 + p = 1 + getelementspecialnext: + i = INSTR(p, a$, sp) + + 'avoid sp inside "..." + i2 = INSTR(p, a$, CHR$(34)) + IF i2 < i AND i2 <> 0 THEN + i3 = INSTR(i2 + 1, a$, CHR$(34)): IF i3 = 0 THEN Give_Error "Expected " + CHR$(34): EXIT FUNCTION + i = INSTR(i3, a$, sp) + END IF + + IF elenum = n THEN + IF i THEN + getelementspecial$ = MID$(a$, p, i - p) + ELSE + getelementspecial$ = RIGHT$(a$, LEN(a$) - p + 1) + END IF + EXIT FUNCTION + END IF + + IF i = 0 THEN EXIT FUNCTION 'no more elements! + n = n + 1 + p = i + 1 + GOTO getelementspecialnext +END FUNCTION + + + +FUNCTION getelement$ (a$, elenum) + IF a$ = "" THEN EXIT FUNCTION 'no elements! + + n = 1 + p = 1 + getelementnext: + i = INSTR(p, a$, sp) + + IF elenum = n THEN + IF i THEN + getelement$ = MID$(a$, p, i - p) + ELSE + getelement$ = RIGHT$(a$, LEN(a$) - p + 1) + END IF + EXIT FUNCTION + END IF + + IF i = 0 THEN EXIT FUNCTION 'no more elements! + n = n + 1 + p = i + 1 + GOTO getelementnext +END FUNCTION + +FUNCTION getelements$ (a$, i1, i2) + IF i2 < i1 THEN getelements$ = "": EXIT FUNCTION + n = 1 + p = 1 + getelementsnext: + i = INSTR(p, a$, sp) + IF n = i1 THEN + i1pos = p + END IF + IF n = i2 THEN + IF i THEN + getelements$ = MID$(a$, i1pos, i - i1pos) + ELSE + getelements$ = RIGHT$(a$, LEN(a$) - i1pos + 1) + END IF + EXIT FUNCTION + END IF + n = n + 1 + p = i + 1 + GOTO getelementsnext +END FUNCTION + +SUB getid (i AS LONG) + IF i = -1 THEN Give_Error "-1 passed to getid!": EXIT SUB + + id = ids(i) + + currentid = i +END SUB + +SUB insertelements (a$, i, elements$) + IF i = 0 THEN + IF a$ = "" THEN + a$ = elements$ + EXIT SUB + END IF + a$ = elements$ + sp + a$ + EXIT SUB + END IF + + a2$ = "" + n = numelements(a$) + + + + + FOR i2 = 1 TO n + IF i2 > 1 THEN a2$ = a2$ + sp + a2$ = a2$ + getelement$(a$, i2) + IF i = i2 THEN a2$ = a2$ + sp + elements$ + NEXT + + a$ = a2$ + +END SUB + +FUNCTION isoperator (a2$) + a$ = UCASE$(a2$) + l = 0 + l = l + 1: IF a$ = "IMP" THEN GOTO opfound + l = l + 1: IF a$ = "EQV" THEN GOTO opfound + l = l + 1: IF a$ = "XOR" THEN GOTO opfound + l = l + 1: IF a$ = "OR" THEN GOTO opfound + l = l + 1: IF a$ = "AND" THEN GOTO opfound + l = l + 1: IF a$ = "NOT" THEN GOTO opfound + l = l + 1 + IF a$ = "=" THEN GOTO opfound + IF a$ = ">" THEN GOTO opfound + IF a$ = "<" THEN GOTO opfound + IF a$ = "<>" THEN GOTO opfound + IF a$ = "<=" THEN GOTO opfound + IF a$ = ">=" THEN GOTO opfound + l = l + 1 + IF a$ = "+" THEN GOTO opfound + IF a$ = "-" THEN GOTO opfound '!CAREFUL! could be negation + l = l + 1: IF a$ = "MOD" THEN GOTO opfound + l = l + 1: IF a$ = "\" THEN GOTO opfound + l = l + 1 + IF a$ = "*" THEN GOTO opfound + IF a$ = "/" THEN GOTO opfound + 'NEGATION LEVEL (MUST BE SET AFTER CALLING ISOPERATOR BY CONTEXT) + l = l + 1: IF a$ = CHR$(241) THEN GOTO opfound + l = l + 1: IF a$ = "^" THEN GOTO opfound + EXIT FUNCTION + opfound: + isoperator = l +END FUNCTION + +FUNCTION isuinteger (i$) + IF LEN(i$) = 0 THEN EXIT FUNCTION + IF ASC(i$, 1) = 48 AND LEN(i$) > 1 THEN EXIT FUNCTION + FOR c = 1 TO LEN(i$) + v = ASC(i$, c) + IF v < 48 OR v > 57 THEN EXIT FUNCTION + NEXT + isuinteger = -1 +END FUNCTION + +FUNCTION isvalidvariable (a$) + FOR i = 1 TO LEN(a$) + c = ASC(a$, i) + t = 0 + IF c >= 48 AND c <= 57 THEN t = 1 'numeric + IF c >= 65 AND c <= 90 THEN t = 2 'uppercase + IF c >= 97 AND c <= 122 THEN t = 2 'lowercase + IF c = 95 THEN t = 2 '_ underscore + IF t = 2 OR (t = 1 AND i > 1) THEN + 'valid (continue) + ELSE + IF i = 1 THEN isvalidvariable = 0: EXIT FUNCTION + EXIT FOR + END IF + NEXT + + isvalidvariable = 1 + IF i > n THEN EXIT FUNCTION 'i is always greater than n because n is undefined here. Why didn't I remove this line and the ones below it, which will never run? Cause I'm a coward. F.h. + e$ = RIGHT$(a$, LEN(a$) - i - 1) + IF e$ = "%%" OR e$ = "~%%" THEN EXIT FUNCTION + IF e$ = "%" OR e$ = "~%" THEN EXIT FUNCTION + IF e$ = "&" OR e$ = "~&" THEN EXIT FUNCTION + IF e$ = "&&" OR e$ = "~&&" THEN EXIT FUNCTION + IF e$ = "!" OR e$ = "#" OR e$ = "##" THEN EXIT FUNCTION + IF e$ = "$" THEN EXIT FUNCTION + IF e$ = "`" THEN EXIT FUNCTION + IF LEFT$(e$, 1) <> "$" AND LEFT$(e$, 1) <> "`" THEN isvalidvariable = 0: EXIT FUNCTION + e$ = RIGHT$(e$, LEN(e$) - 1) + IF isuinteger(e$) THEN isvalidvariable = 1: EXIT FUNCTION + isvalidvariable = 0 +END FUNCTION + + + + +FUNCTION lineformat$ (a$) + a2$ = "" + linecontinuation = 0 + + continueline: + + a$ = a$ + " " 'add 2 extra spaces to make reading next char easier + + ca$ = a$ + a$ = UCASE$(a$) + + n = LEN(a$) + i = 1 + lineformatnext: + IF i >= n THEN GOTO lineformatdone + + c = ASC(a$, i) + c$ = CHR$(c) '***remove later*** + + '----------------quoted string---------------- + IF c = 34 THEN '" + a2$ = a2$ + sp + CHR$(34) + p1 = i + 1 + FOR i2 = i + 1 TO n - 2 + c2 = ASC(a$, i2) + + IF c2 = 34 THEN + a2$ = a2$ + MID$(ca$, p1, i2 - p1 + 1) + "," + str2$(i2 - (i + 1)) + i = i2 + 1 + EXIT FOR + END IF + + IF c2 = 92 THEN '\ + a2$ = a2$ + MID$(ca$, p1, i2 - p1) + "\\" + p1 = i2 + 1 + END IF + + IF c2 < 32 OR c2 > 126 THEN + o$ = OCT$(c2) + IF LEN(o$) < 3 THEN + o$ = "0" + o$ + IF LEN(o$) < 3 THEN o$ = "0" + o$ + END IF + a2$ = a2$ + MID$(ca$, p1, i2 - p1) + "\" + o$ + p1 = i2 + 1 + END IF + + NEXT + + IF i2 = n - 1 THEN 'no closing " + a2$ = a2$ + MID$(ca$, p1, (n - 2) - p1 + 1) + CHR$(34) + "," + str2$((n - 2) - (i + 1) + 1) + i = n - 1 + END IF + + GOTO lineformatnext + + END IF + + '----------------number---------------- + firsti = i + IF c = 46 THEN + c2$ = MID$(a$, i + 1, 1): c2 = ASC(c2$) + IF (c2 >= 48 AND c2 <= 57) THEN GOTO lfnumber + END IF + IF (c >= 48 AND c <= 57) THEN '0-9 + lfnumber: + + 'handle 'IF a=1 THEN a=2 ELSE 100' by assuming numeric after ELSE to be a + IF RIGHT$(a2$, 5) = sp + "ELSE" THEN + a2$ = a2$ + sp + "GOTO" + END IF + + 'Number will be converted to the following format: + ' 999999 . 99999 E + 999 + '[whole$][dp(0/1)][frac$][ed(1/2)][pm(1/-1)][ex$] + ' 0 1 2 3 <-mode + + mode = 0 + whole$ = "" + dp = 0 + frac$ = "" + ed = 0 'E=1, D=2, F=3 + pm = 1 + ex$ = "" + + + + + lfreadnumber: + valid = 0 + + IF c = 46 THEN + IF mode = 0 THEN valid = 1: dp = 1: mode = 1 + END IF + + IF c >= 48 AND c <= 57 THEN '0-9 + valid = 1 + IF mode = 0 THEN whole$ = whole$ + c$ + IF mode = 1 THEN frac$ = frac$ + c$ + IF mode = 2 THEN mode = 3 + IF mode = 3 THEN ex$ = ex$ + c$ + END IF + + IF c = 69 OR c = 68 OR c = 70 THEN 'E,D,F + IF mode < 2 THEN + valid = 1 + IF c = 69 THEN ed = 1 + IF c = 68 THEN ed = 2 + IF c = 70 THEN ed = 3 + mode = 2 + END IF + END IF + + IF c = 43 OR c = 45 THEN '+,- + IF mode = 2 THEN + valid = 1 + IF c = 45 THEN pm = -1 + mode = 3 + END IF + END IF + + IF valid THEN + IF i <= n THEN i = i + 1: c$ = MID$(a$, i, 1): c = ASC(c$): GOTO lfreadnumber + END IF + + + + 'cull leading 0s off whole$ + DO WHILE LEFT$(whole$, 1) = "0": whole$ = RIGHT$(whole$, LEN(whole$) - 1): LOOP + 'cull trailing 0s off frac$ + DO WHILE RIGHT$(frac$, 1) = "0": frac$ = LEFT$(frac$, LEN(frac$) - 1): LOOP + 'cull leading 0s off ex$ + DO WHILE LEFT$(ex$, 1) = "0": ex$ = RIGHT$(ex$, LEN(ex$) - 1): LOOP + + IF dp <> 0 OR ed <> 0 THEN float = 1 ELSE float = 0 + + extused = 1 + + IF ed THEN e$ = "": GOTO lffoundext 'no extensions valid after E/D/F specified + + '3-character extensions + IF i <= n - 2 THEN + e$ = MID$(a$, i, 3) + IF e$ = "~%%" AND float = 0 THEN i = i + 3: GOTO lffoundext + IF e$ = "~&&" AND float = 0 THEN i = i + 3: GOTO lffoundext + IF e$ = "~%&" AND float = 0 THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + END IF + '2-character extensions + IF i <= n - 1 THEN + e$ = MID$(a$, i, 2) + IF e$ = "%%" AND float = 0 THEN i = i + 2: GOTO lffoundext + IF e$ = "~%" AND float = 0 THEN i = i + 2: GOTO lffoundext + IF e$ = "&&" AND float = 0 THEN i = i + 2: GOTO lffoundext + IF e$ = "~&" AND float = 0 THEN i = i + 2: GOTO lffoundext + IF e$ = "%&" AND float = 0 THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + IF e$ = "##" THEN + i = i + 2 + ed = 3 + e$ = "" + GOTO lffoundext + END IF + IF e$ = "~`" THEN + i = i + 2 + GOTO lffoundbitext + END IF + END IF + '1-character extensions + IF i <= n THEN + e$ = MID$(a$, i, 1) + IF e$ = "%" AND float = 0 THEN i = i + 1: GOTO lffoundext + IF e$ = "&" AND float = 0 THEN i = i + 1: GOTO lffoundext + IF e$ = "!" THEN + i = i + 1 + ed = 1 + e$ = "" + GOTO lffoundext + END IF + IF e$ = "#" THEN + i = i + 1 + ed = 2 + e$ = "" + GOTO lffoundext + END IF + IF e$ = "`" THEN + i = i + 1 + lffoundbitext: + bitn$ = "" + DO WHILE i <= n + c2 = ASC(MID$(a$, i, 1)) + IF c2 >= 48 AND c2 <= 57 THEN + bitn$ = bitn$ + CHR$(c2) + i = i + 1 + ELSE + EXIT DO + END IF + LOOP + IF bitn$ = "" THEN bitn$ = "1" + 'cull leading 0s off bitn$ + DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP + e$ = e$ + bitn$ + GOTO lffoundext + END IF + END IF + + IF float THEN 'floating point types CAN be assumed + 'calculate first significant digit offset & number of significant digits + IF whole$ <> "" THEN + offset = LEN(whole$) - 1 + sigdigits = LEN(whole$) + LEN(frac$) + ELSE + IF frac$ <> "" THEN + offset = -1 + sigdigits = LEN(frac$) + FOR i2 = 1 TO LEN(frac$) + IF MID$(frac$, i2, 1) <> "0" THEN EXIT FOR + offset = offset - 1 + sigdigits = sigdigits - 1 + NEXT + ELSE + 'number is 0 + offset = 0 + sigdigits = 0 + END IF + END IF + sigdig$ = RIGHT$(whole$ + frac$, sigdigits) + 'SINGLE? + IF sigdigits <= 7 THEN 'QBASIC interprets anything with more than 7 sig. digits as a DOUBLE + IF offset <= 38 AND offset >= -38 THEN 'anything outside this range cannot be represented as a SINGLE + IF offset = 38 THEN + IF sigdig$ > "3402823" THEN GOTO lfxsingle + END IF + IF offset = -38 THEN + IF sigdig$ < "1175494" THEN GOTO lfxsingle + END IF + ed = 1 + e$ = "" + GOTO lffoundext + END IF + END IF + lfxsingle: + 'DOUBLE? + IF sigdigits <= 16 THEN 'QB64 handles DOUBLES with 16-digit precision + IF offset <= 308 AND offset >= -308 THEN 'anything outside this range cannot be represented as a DOUBLE + IF offset = 308 THEN + IF sigdig$ > "1797693134862315" THEN GOTO lfxdouble + END IF + IF offset = -308 THEN + IF sigdig$ < "2225073858507201" THEN GOTO lfxdouble + END IF + ed = 2 + e$ = "" + GOTO lffoundext + END IF + END IF + lfxdouble: + 'assume _FLOAT + ed = 3 + e$ = "": GOTO lffoundext + END IF + + extused = 0 + e$ = "" + lffoundext: + + 'make sure a leading numberic character exists + IF whole$ = "" THEN whole$ = "0" + 'if a float, ensure frac$<>"" and dp=1 + IF float THEN + dp = 1 + IF frac$ = "" THEN frac$ = "0" + END IF + 'if ed is specified, make sure ex$ exists + IF ed <> 0 AND ex$ = "" THEN ex$ = "0" + + a2$ = a2$ + sp + a2$ = a2$ + whole$ + IF dp THEN a2$ = a2$ + "." + frac$ + IF ed THEN + IF ed = 1 THEN a2$ = a2$ + "E" + IF ed = 2 THEN a2$ = a2$ + "D" + IF ed = 3 THEN a2$ = a2$ + "F" + IF pm = -1 AND ex$ <> "0" THEN a2$ = a2$ + "-" ELSE a2$ = a2$ + "+" + a2$ = a2$ + ex$ + END IF + a2$ = a2$ + e$ + + IF extused THEN a2$ = a2$ + "," + MID$(a$, firsti, i - firsti) + + GOTO lineformatnext + END IF + + '----------------(number)&H...---------------- + 'note: the final value, not the number of hex characters, sets the default type + IF c = 38 THEN '& + IF MID$(a$, i + 1, 1) = "H" THEN + i = i + 2 + hx$ = "" + lfreadhex: + IF i <= n THEN + c$ = MID$(a$, i, 1): c = ASC(c$) + IF (c >= 48 AND c <= 57) OR (c >= 65 AND c <= 70) THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadhex + END IF + fullhx$ = "&H" + hx$ + + 'cull leading 0s off hx$ + DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP + IF hx$ = "" THEN hx$ = "0" + + bitn$ = "" + '3-character extensions + IF i <= n - 2 THEN + e$ = MID$(a$, i, 3) + IF e$ = "~%%" THEN i = i + 3: GOTO lfhxext + IF e$ = "~&&" THEN i = i + 3: GOTO lfhxext + IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + END IF + '2-character extensions + IF i <= n - 1 THEN + e$ = MID$(a$, i, 2) + IF e$ = "%%" THEN i = i + 2: GOTO lfhxext + IF e$ = "~%" THEN i = i + 2: GOTO lfhxext + IF e$ = "&&" THEN i = i + 2: GOTO lfhxext + IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + IF e$ = "~&" THEN i = i + 2: GOTO lfhxext + IF e$ = "~`" THEN + i = i + 2 + GOTO lfhxbitext + END IF + END IF + '1-character extensions + IF i <= n THEN + e$ = MID$(a$, i, 1) + IF e$ = "%" THEN i = i + 1: GOTO lfhxext + IF e$ = "&" THEN i = i + 1: GOTO lfhxext + IF e$ = "`" THEN + i = i + 1 + lfhxbitext: + DO WHILE i <= n + c2 = ASC(MID$(a$, i, 1)) + IF c2 >= 48 AND c2 <= 57 THEN + bitn$ = bitn$ + CHR$(c2) + i = i + 1 + ELSE + EXIT DO + END IF + LOOP + IF bitn$ = "" THEN bitn$ = "1" + 'cull leading 0s off bitn$ + DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP + GOTO lfhxext + END IF + END IF + 'if no valid extension context was given, assume one + 'note: leading 0s have been culled, so LEN(hx$) reflects its values size + e$ = "&&" + IF LEN(hx$) <= 8 THEN e$ = "&" 'as in QBASIC, signed values must be used + IF LEN(hx$) <= 4 THEN e$ = "%" 'as in QBASIC, signed values must be used + GOTO lfhxext2 + lfhxext: + fullhx$ = fullhx$ + e$ + bitn$ + lfhxext2: + + 'build 8-byte unsigned integer rep. of hx$ + IF LEN(hx$) > 16 THEN Give_Error "Overflow": EXIT FUNCTION + v~&& = 0 + FOR i2 = 1 TO LEN(hx$) + v2 = ASC(MID$(hx$, i2, 1)) + IF v2 <= 57 THEN v2 = v2 - 48 ELSE v2 = v2 - 65 + 10 + v~&& = v~&& * 16 + v2 + NEXT + + finishhexoctbin: + num$ = str2u64$(v~&&) 'correct for unsigned values (overflow of unsigned can be checked later) + IF LEFT$(e$, 1) <> "~" THEN 'note: range checking will be performed later in fixop.order + 'signed + + IF e$ = "%%" THEN + IF v~&& > 127 THEN + IF v~&& > 255 THEN Give_Error "Overflow": EXIT FUNCTION + v~&& = ((NOT v~&&) AND 255) + 1 + num$ = "-" + sp + str2u64$(v~&&) + END IF + END IF + + IF e$ = "%" THEN + IF v~&& > 32767 THEN + IF v~&& > 65535 THEN Give_Error "Overflow": EXIT FUNCTION + v~&& = ((NOT v~&&) AND 65535) + 1 + num$ = "-" + sp + str2u64$(v~&&) + END IF + END IF + + IF e$ = "&" THEN + IF v~&& > 2147483647 THEN + IF v~&& > 4294967295 THEN Give_Error "Overflow": EXIT FUNCTION + v~&& = ((NOT v~&&) AND 4294967295) + 1 + num$ = "-" + sp + str2u64$(v~&&) + END IF + END IF + + IF e$ = "&&" THEN + IF v~&& > 9223372036854775807 THEN + 'note: no error checking necessary + v~&& = (NOT v~&&) + 1 + num$ = "-" + sp + str2u64$(v~&&) + END IF + END IF + + IF e$ = "`" THEN + vbitn = VAL(bitn$) + h~&& = 1: FOR i2 = 1 TO vbitn - 1: h~&& = h~&& * 2: NEXT: h~&& = h~&& - 1 'build h~&& + IF v~&& > h~&& THEN + h~&& = 1: FOR i2 = 1 TO vbitn: h~&& = h~&& * 2: NEXT: h~&& = h~&& - 1 'build h~&& + IF v~&& > h~&& THEN Give_Error "Overflow": EXIT FUNCTION + v~&& = ((NOT v~&&) AND h~&&) + 1 + num$ = "-" + sp + str2u64$(v~&&) + END IF + END IF + + END IF '<>"~" + + a2$ = a2$ + sp + num$ + e$ + bitn$ + "," + fullhx$ + + GOTO lineformatnext + END IF + END IF + + '----------------(number)&O...---------------- + 'note: the final value, not the number of oct characters, sets the default type + IF c = 38 THEN '& + IF MID$(a$, i + 1, 1) = "O" THEN + i = i + 2 + 'note: to avoid mistakes, hx$ is used instead of 'ot$' + hx$ = "" + lfreadoct: + IF i <= n THEN + c$ = MID$(a$, i, 1): c = ASC(c$) + IF c >= 48 AND c <= 55 THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadoct + END IF + fullhx$ = "&O" + hx$ + + 'cull leading 0s off hx$ + DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP + IF hx$ = "" THEN hx$ = "0" + + bitn$ = "" + '3-character extensions + IF i <= n - 2 THEN + e$ = MID$(a$, i, 3) + IF e$ = "~%%" THEN i = i + 3: GOTO lfotext + IF e$ = "~&&" THEN i = i + 3: GOTO lfotext + IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + END IF + '2-character extensions + IF i <= n - 1 THEN + e$ = MID$(a$, i, 2) + IF e$ = "%%" THEN i = i + 2: GOTO lfotext + IF e$ = "~%" THEN i = i + 2: GOTO lfotext + IF e$ = "&&" THEN i = i + 2: GOTO lfotext + IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + IF e$ = "~&" THEN i = i + 2: GOTO lfotext + IF e$ = "~`" THEN + i = i + 2 + GOTO lfotbitext + END IF + END IF + '1-character extensions + IF i <= n THEN + e$ = MID$(a$, i, 1) + IF e$ = "%" THEN i = i + 1: GOTO lfotext + IF e$ = "&" THEN i = i + 1: GOTO lfotext + IF e$ = "`" THEN + i = i + 1 + lfotbitext: + bitn$ = "" + DO WHILE i <= n + c2 = ASC(MID$(a$, i, 1)) + IF c2 >= 48 AND c2 <= 57 THEN + bitn$ = bitn$ + CHR$(c2) + i = i + 1 + ELSE + EXIT DO + END IF + LOOP + IF bitn$ = "" THEN bitn$ = "1" + 'cull leading 0s off bitn$ + DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP + GOTO lfotext + END IF + END IF + 'if no valid extension context was given, assume one + 'note: leading 0s have been culled, so LEN(hx$) reflects its values size + e$ = "&&" + '37777777777 + IF LEN(hx$) <= 11 THEN + IF LEN(hx$) < 11 OR ASC(LEFT$(hx$, 1)) <= 51 THEN e$ = "&" + END IF + '177777 + IF LEN(hx$) <= 6 THEN + IF LEN(hx$) < 6 OR LEFT$(hx$, 1) = "1" THEN e$ = "%" + END IF + + GOTO lfotext2 + lfotext: + fullhx$ = fullhx$ + e$ + bitn$ + lfotext2: + + 'build 8-byte unsigned integer rep. of hx$ + '1777777777777777777777 (22 digits) + IF LEN(hx$) > 22 THEN Give_Error "Overflow": EXIT FUNCTION + IF LEN(hx$) = 22 THEN + IF LEFT$(hx$, 1) <> "1" THEN Give_Error "Overflow": EXIT FUNCTION + END IF + '********change v& to v~&&******** + v~&& = 0 + FOR i2 = 1 TO LEN(hx$) + v2 = ASC(MID$(hx$, i2, 1)) + v2 = v2 - 48 + v~&& = v~&& * 8 + v2 + NEXT + + GOTO finishhexoctbin + END IF + END IF + + '----------------(number)&B...---------------- + 'note: the final value, not the number of bin characters, sets the default type + IF c = 38 THEN '& + IF MID$(a$, i + 1, 1) = "B" THEN + i = i + 2 + 'note: to avoid mistakes, hx$ is used instead of 'bi$' + hx$ = "" + lfreadbin: + IF i <= n THEN + c$ = MID$(a$, i, 1): c = ASC(c$) + IF c >= 48 AND c <= 49 THEN hx$ = hx$ + c$: i = i + 1: GOTO lfreadbin + END IF + fullhx$ = "&B" + hx$ + + 'cull leading 0s off hx$ + DO WHILE LEFT$(hx$, 1) = "0": hx$ = RIGHT$(hx$, LEN(hx$) - 1): LOOP + IF hx$ = "" THEN hx$ = "0" + + bitn$ = "" + '3-character extensions + IF i <= n - 2 THEN + e$ = MID$(a$, i, 3) + IF e$ = "~%%" THEN i = i + 3: GOTO lfbiext + IF e$ = "~&&" THEN i = i + 3: GOTO lfbiext + IF e$ = "~%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + END IF + '2-character extensions + IF i <= n - 1 THEN + e$ = MID$(a$, i, 2) + IF e$ = "%%" THEN i = i + 2: GOTO lfbiext + IF e$ = "~%" THEN i = i + 2: GOTO lfbiext + IF e$ = "&&" THEN i = i + 2: GOTO lfbiext + IF e$ = "%&" THEN Give_Error "Cannot use _OFFSET symbols after numbers": EXIT FUNCTION + IF e$ = "~&" THEN i = i + 2: GOTO lfbiext + IF e$ = "~`" THEN + i = i + 2 + GOTO lfbibitext + END IF + END IF + + + '1-character extensions + IF i <= n THEN + e$ = MID$(a$, i, 1) + IF e$ = "%" THEN i = i + 1: GOTO lfbiext + IF e$ = "&" THEN i = i + 1: GOTO lfbiext + IF e$ = "`" THEN + i = i + 1 + lfbibitext: + bitn$ = "" + DO WHILE i <= n + c2 = ASC(MID$(a$, i, 1)) + IF c2 >= 48 AND c2 <= 57 THEN + bitn$ = bitn$ + CHR$(c2) + i = i + 1 + ELSE + EXIT DO + END IF + LOOP + IF bitn$ = "" THEN bitn$ = "1" + 'cull leading 0s off bitn$ + DO WHILE LEFT$(bitn$, 1) = "0": bitn$ = RIGHT$(bitn$, LEN(bitn$) - 1): LOOP + GOTO lfbiext + END IF + END IF + 'if no valid extension context was given, assume one + 'note: leading 0s have been culled, so LEN(hx$) reflects its values size + e$ = "&&" + IF LEN(hx$) <= 32 THEN e$ = "&" + IF LEN(hx$) <= 16 THEN e$ = "%" + + GOTO lfbiext2 + lfbiext: + fullhx$ = fullhx$ + e$ + bitn$ + lfbiext2: + + 'build 8-byte unsigned integer rep. of hx$ + IF LEN(hx$) > 64 THEN Give_Error "Overflow": EXIT FUNCTION + + v~&& = 0 + FOR i2 = 1 TO LEN(hx$) + v2 = ASC(MID$(hx$, i2, 1)) + v2 = v2 - 48 + v~&& = v~&& * 2 + v2 + NEXT + + GOTO finishhexoctbin + END IF + END IF + + + '----------------(number)&H??? error---------------- + IF c = 38 THEN Give_Error "Expected &H... or &O...": EXIT FUNCTION + + '----------------variable/name---------------- + '*trailing _ is treated as a seperate line extension* + IF (c >= 65 AND c <= 90) OR c = 95 THEN 'A-Z(a-z) or _ + IF c = 95 THEN p2 = 0 ELSE p2 = i + FOR i2 = i + 1 TO n + c2 = ASC(a$, i2) + IF NOT alphanumeric(c2) THEN EXIT FOR + IF c2 <> 95 THEN p2 = i2 + NEXT + IF p2 THEN 'not just underscores! + 'char is from i to p2 + n2 = p2 - i + 1 + a3$ = MID$(a$, i, n2) + + '----(variable/name)rem---- + IF n2 = 3 THEN + IF a3$ = "REM" THEN + i = i + n2 + IF i < n THEN + c = ASC(a$, i) + IF c = 46 THEN a2$ = a2$ + sp + MID$(ca$, i - n2, n2): GOTO extcheck 'rem.Variable is a valid variable name in QB45 + END IF + + 'note: In QBASIC 'IF cond THEN REM comment' counts as a single line IF statement, however use of ' instead of REM does not + IF UCASE$(RIGHT$(a2$, 5)) = sp + "THEN" THEN a2$ = a2$ + sp + "'" 'add nop + layoutcomment = SCase$("Rem") + GOTO comment + END IF + END IF + + '----(variable/name)data---- + IF n2 = 4 THEN + IF a3$ = "DATA" THEN + x$ = "" + i = i + n2 + IF i < n THEN + c = ASC(a$, i) + IF c = 46 THEN a2$ = a2$ + sp + MID$(ca$, i - n2, n2): GOTO extcheck 'data.Variable is a valid variable name in QB45 + END IF + + scan = 0 + speechmarks = 0 + commanext = 0 + finaldata = 0 + e$ = "" + p1 = 0 + p2 = 0 + nextdatachr: + IF i < n THEN + c = ASC(a$, i) + IF c = 9 OR c = 32 THEN + IF scan = 0 THEN GOTO skipwhitespace + END IF + + IF c = 58 THEN '":" + IF speechmarks = 0 THEN finaldata = 1: GOTO adddata + END IF + + IF c = 44 THEN '"," + IF speechmarks = 0 THEN + adddata: + IF prepass = 0 THEN + IF p1 THEN + 'FOR i2 = p1 TO p2 + ' DATA_add ASC(ca$, i2) + 'NEXT + x$ = x$ + MID$(ca$, p1, p2 - p1 + 1) + END IF + 'assume closing " + IF speechmarks THEN + 'DATA_add 34 + x$ = x$ + CHR$(34) + END IF + 'append comma + 'DATA_add 44 + x$ = x$ + CHR$(44) + END IF + IF finaldata = 1 THEN GOTO finisheddata + e$ = "" + p1 = 0 + p2 = 0 + speechmarks = 0 + scan = 0 + commanext = 0 + i = i + 1 + GOTO nextdatachr + END IF + END IF '"," + + IF commanext = 1 THEN + IF c <> 32 AND c <> 9 THEN Give_Error "Expected , after quoted string in DATA statement": EXIT FUNCTION + END IF + + IF c = 34 THEN + IF speechmarks = 1 THEN + commanext = 1 + speechmarks = 0 + END IF + IF scan = 0 THEN speechmarks = 1 + END IF + + scan = 1 + + IF p1 = 0 THEN p1 = i: p2 = i + IF c <> 9 AND c <> 32 THEN p2 = i + + skipwhitespace: + i = i + 1: GOTO nextdatachr + END IF 'i 40 THEN Give_Error "Identifier longer than 40 character limit": EXIT FUNCTION + c3 = ASC(a$, i) + m = 0 + IF c3 = 126 THEN '"~" + e2$ = MID$(a$, i + 1, 2) + IF e2$ = "&&" THEN e2$ = "~&&": GOTO lfgetve + IF e2$ = "%%" THEN e2$ = "~%%": GOTO lfgetve + IF e2$ = "%&" THEN e2$ = "~%&": GOTO lfgetve + e2$ = CHR$(ASC(e2$)) + IF e2$ = "&" THEN e2$ = "~&": GOTO lfgetve + IF e2$ = "%" THEN e2$ = "~%": GOTO lfgetve + IF e2$ = "`" THEN m = 1: e2$ = "~`": GOTO lfgetve + END IF + IF c3 = 37 THEN + c4 = ASC(a$, i + 1) + IF c4 = 37 THEN e2$ = "%%": GOTO lfgetve + IF c4 = 38 THEN e2$ = "%&": GOTO lfgetve + e2$ = "%": GOTO lfgetve + END IF + IF c3 = 38 THEN + c4 = ASC(a$, i + 1) + IF c4 = 38 THEN e2$ = "&&": GOTO lfgetve + e2$ = "&": GOTO lfgetve + END IF + IF c3 = 33 THEN e2$ = "!": GOTO lfgetve + IF c3 = 35 THEN + c4 = ASC(a$, i + 1) + IF c4 = 35 THEN e2$ = "##": GOTO lfgetve + e2$ = "#": GOTO lfgetve + END IF + IF c3 = 36 THEN m = 1: e2$ = "$": GOTO lfgetve + IF c3 = 96 THEN m = 1: e2$ = "`": GOTO lfgetve + '(no symbol) + + 'cater for unusual names/labels (eg a.0b%) + IF ASC(a$, i) = 46 THEN '"." + c2 = ASC(a$, i + 1) + IF c2 >= 48 AND c2 <= 57 THEN + 'scan until no further alphanumerics + p2 = i + 1 + FOR i2 = i + 2 TO n + c = ASC(a$, i2) + + IF NOT alphanumeric(c) THEN EXIT FOR + IF c <> 95 THEN p2 = i2 'don't including trailing _ + NEXT + a2$ = a2$ + sp + "." + sp + MID$(ca$, i + 1, p2 - (i + 1) + 1) 'case sensitive + n2 = n2 + 1 + (p2 - (i + 1) + 1) + i = p2 + 1 + GOTO extcheck 'it may have an extension or be continued with another "." + END IF + END IF + + GOTO lineformatnext + + lfgetve: + i = i + LEN(e2$) + a2$ = a2$ + e2$ + IF m THEN 'allow digits after symbol + lfgetvd: + IF i < n THEN + c = ASC(a$, i) + IF c >= 48 AND c <= 57 THEN a2$ = a2$ + CHR$(c): i = i + 1: GOTO lfgetvd + END IF + END IF 'm + + GOTO lineformatnext + + END IF 'p2 + END IF 'variable/name + '----------------variable/name end---------------- + + '----------------spacing---------------- + IF c = 32 OR c = 9 THEN i = i + 1: GOTO lineformatnext + + '----------------symbols---------------- + '--------single characters-------- + IF lfsinglechar(c) THEN + IF (c = 60) OR (c = 61) OR (c = 62) THEN + count = 0 + DO + count = count + 1 + IF i + count >= LEN(a$) - 2 THEN EXIT DO + LOOP UNTIL ASC(a$, i + count) <> 32 + c2 = ASC(a$, i + count) + IF c = 60 THEN '< + IF c2 = 61 THEN a2$ = a2$ + sp + "<=": i = i + count + 1: GOTO lineformatnext + IF c2 = 62 THEN a2$ = a2$ + sp + "<>": i = i + count + 1: GOTO lineformatnext + ELSEIF c = 62 THEN '> + IF c2 = 61 THEN a2$ = a2$ + sp + ">=": i = i + count + 1: GOTO lineformatnext + IF c2 = 60 THEN a2$ = a2$ + sp + "<>": i = i + count + 1: GOTO lineformatnext '>< to <> + ELSEIF c = 61 THEN '= + IF c2 = 62 THEN a2$ = a2$ + sp + ">=": i = i + count + 1: GOTO lineformatnext '=> to >= + IF c2 = 60 THEN a2$ = a2$ + sp + "<=": i = i + count + 1: GOTO lineformatnext '=< to <= + END IF + END IF + + IF c = 36 AND LEN(a2$) THEN GOTO badusage '$ + + + a2$ = a2$ + sp + CHR$(c) + i = i + 1 + GOTO lineformatnext + END IF + badusage: + + IF c <> 39 THEN Give_Error "Unexpected character on line": EXIT FUNCTION 'invalid symbol encountered + + '----------------comment(')---------------- + layoutcomment = "'" + i = i + 1 + comment: + IF i >= n THEN GOTO lineformatdone2 + c$ = RIGHT$(a$, LEN(a$) - i + 1) + cc$ = RIGHT$(ca$, LEN(ca$) - i + 1) + IF LEN(c$) = 0 THEN GOTO lineformatdone2 + layoutcomment$ = RTRIM$(layoutcomment$ + cc$) + + c$ = LTRIM$(c$) + IF LEN(c$) = 0 THEN GOTO lineformatdone2 + ac = ASC(c$) + 'note: any non-whitespace character between the comment leader and the + ' first '$' renders this a plain comment + ' : the leading '$' does NOT have to be part of a valid metacommand. + ' E.g., REM $FOO $DYNAMIC is a valid metacommand line + IF ac <> 36 THEN GOTO lineformatdone2 + nocasec$ = LTRIM$(RIGHT$(ca$, LEN(ca$) - i + 1)) + memmode = 0 + x = 1 + DO + 'note: metacommands may appear on a line any number of times but only + ' the last appearance of $INCLUDE, and either $STATIC or $DYNAMIC, + ' is processed + ' : metacommands do not need to be terminated by word boundaries. + ' E.g., $STATICanychars$DYNAMIC is valid + + IF MID$(c$, x, 7) = "$STATIC" THEN + memmode = 1 + ELSEIF MID$(c$, x, 8) = "$DYNAMIC" THEN + memmode = 2 + ELSEIF MID$(c$, x, 8) = "$INCLUDE" THEN + 'note: INCLUDE adds the file AFTER the line it is on has been processed + 'skip spaces until : + FOR xx = x + 8 TO LEN(c$) + ac = ASC(MID$(c$, xx, 1)) + IF ac = 58 THEN EXIT FOR ': + IF ac <> 32 AND ac <> 9 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION + NEXT + x = xx + 'skip spaces until ' + FOR xx = x + 1 TO LEN(c$) + ac = ASC(MID$(c$, xx, 1)) + IF ac = 39 THEN EXIT FOR 'character:' + IF ac <> 32 AND ac <> 9 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION + NEXT + x = xx + xx = INSTR(x + 1, c$, "'") + IF xx = 0 THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION + addmetainclude$ = MID$(nocasec$, x + 1, xx - x - 1) + IF addmetainclude$ = "" THEN Give_Error "Expected $INCLUDE:'filename'": EXIT FUNCTION + END IF + + x = INSTR(x + 1, c$, "$") + LOOP WHILE x <> 0 + + IF memmode = 1 THEN addmetastatic = 1 + IF memmode = 2 THEN addmetadynamic = 1 + + GOTO lineformatdone2 + + + + lineformatdone: + + 'line continuation? + 'note: line continuation in idemode is illegal + IF LEN(a2$) THEN + IF RIGHT$(a2$, 1) = "_" THEN + + linecontinuation = 1 'avoids auto-format glitches + layout$ = "" + + 'remove _ from the end of the building string + IF LEN(a2$) >= 2 THEN + IF RIGHT$(a2$, 2) = sp + "_" THEN a2$ = LEFT$(a2$, LEN(a2$) - 1) + END IF + a2$ = LEFT$(a2$, LEN(a2$) - 1) + + IF inclevel THEN + fh = 99 + inclevel + IF EOF(fh) THEN GOTO lineformatdone2 + LINE INPUT #fh, a$ + inclinenumber(inclevel) = inclinenumber(inclevel) + 1 + GOTO includecont 'note: should not increase linenumber + END IF + + IF idemode THEN + idecommand$ = CHR$(100) + ignore = ide(0) + ideerror = 0 + a$ = idereturn$ + IF a$ = "" THEN GOTO lineformatdone2 + ELSE + a$ = lineinput3$ + IF a$ = CHR$(13) THEN GOTO lineformatdone2 + END IF + + linenumber = linenumber + 1 + + includecont: + + contline = 1 + GOTO continueline + END IF + END IF + + lineformatdone2: + IF LEFT$(a2$, 1) = sp THEN a2$ = RIGHT$(a2$, LEN(a2$) - 1) + + 'fix for trailing : error + IF RIGHT$(a2$, 1) = ":" THEN a2$ = a2$ + sp + "'" 'add nop + + IF Debug THEN PRINT #9, "lineformat():return:" + a2$ + IF Error_Happened THEN EXIT FUNCTION + lineformat$ = a2$ + +END FUNCTION + + +SUB makeidrefer (ref$, typ AS LONG) + ref$ = str2$(currentid) + typ = id.t + ISREFERENCE +END SUB + +FUNCTION numelements (a$) + IF a$ = "" THEN EXIT FUNCTION + n = 1 + p = 1 + numelementsnext: + i = INSTR(p, a$, sp) + IF i = 0 THEN numelements = n: EXIT FUNCTION + n = n + 1 + p = i + 1 + GOTO numelementsnext +END FUNCTION + +FUNCTION operatorusage (operator$, typ AS LONG, info$, lhs AS LONG, rhs AS LONG, result AS LONG) + lhs = 7: rhs = 7: result = 0 + 'return values + '1 = use info$ as the operator without any other changes + '2 = use the function returned in info$ to apply this operator + ' upon left and right side of equation + '3= bracket left and right side with negation and change operator to info$ + '4= BINARY NOT l.h.s, then apply operator in info$ + '5= UNARY, bracket up rhs, apply operator info$ to left, rebracket again + + 'lhs & rhs bit-field values + '1=integeral + '2=floating point + '4=string + '8=bool + + 'string operator + IF (typ AND ISSTRING) THEN + lhs = 4: rhs = 4 + result = 4 + IF operator$ = "+" THEN info$ = "qbs_add": operatorusage = 2: EXIT FUNCTION + result = 8 + IF operator$ = "=" THEN info$ = "qbs_equal": operatorusage = 2: EXIT FUNCTION + IF operator$ = "<>" THEN info$ = "qbs_notequal": operatorusage = 2: EXIT FUNCTION + IF operator$ = ">" THEN info$ = "qbs_greaterthan": operatorusage = 2: EXIT FUNCTION + IF operator$ = "<" THEN info$ = "qbs_lessthan": operatorusage = 2: EXIT FUNCTION + IF operator$ = ">=" THEN info$ = "qbs_greaterorequal": operatorusage = 2: EXIT FUNCTION + IF operator$ = "<=" THEN info$ = "qbs_lessorequal": operatorusage = 2: EXIT FUNCTION + IF Debug THEN PRINT #9, "INVALID STRING OPERATOR!": END + END IF + + 'assume numeric operator + lhs = 1 + 2: rhs = 1 + 2 + IF operator$ = "^" THEN result = 2: info$ = "pow2": operatorusage = 2: EXIT FUNCTION + IF operator$ = CHR$(241) THEN info$ = "-": operatorusage = 5: EXIT FUNCTION + IF operator$ = "/" THEN + info$ = "/ ": operatorusage = 1 + 'for / division, either the lhs or the rhs must be a float to make + 'c++ return a result in floating point form + IF (typ AND ISFLOAT) THEN + 'lhs is a float + lhs = 2 + rhs = 1 + 2 + ELSE + 'lhs isn't a float! + lhs = 1 + 2 + rhs = 2 + END IF + result = 2 + EXIT FUNCTION + END IF + IF operator$ = "*" THEN info$ = "*": operatorusage = 1: EXIT FUNCTION + IF operator$ = "+" THEN info$ = "+": operatorusage = 1: EXIT FUNCTION + IF operator$ = "-" THEN info$ = "-": operatorusage = 1: EXIT FUNCTION + + result = 8 + IF operator$ = "=" THEN info$ = "==": operatorusage = 3: EXIT FUNCTION + IF operator$ = ">" THEN info$ = ">": operatorusage = 3: EXIT FUNCTION + IF operator$ = "<" THEN info$ = "<": operatorusage = 3: EXIT FUNCTION + IF operator$ = "<>" THEN info$ = "!=": operatorusage = 3: EXIT FUNCTION + IF operator$ = "<=" THEN info$ = "<=": operatorusage = 3: EXIT FUNCTION + IF operator$ = ">=" THEN info$ = ">=": operatorusage = 3: EXIT FUNCTION + + lhs = 1: rhs = 1: result = 1 + operator$ = UCASE$(operator$) + IF operator$ = "MOD" THEN info$ = "%": operatorusage = 1: EXIT FUNCTION + IF operator$ = "\" THEN info$ = "/ ": operatorusage = 1: EXIT FUNCTION + IF operator$ = "IMP" THEN info$ = "|": operatorusage = 4: EXIT FUNCTION + IF operator$ = "EQV" THEN info$ = "^": operatorusage = 4: EXIT FUNCTION + IF operator$ = "XOR" THEN info$ = "^": operatorusage = 1: EXIT FUNCTION + IF operator$ = "OR" THEN info$ = "|": operatorusage = 1: EXIT FUNCTION + IF operator$ = "AND" THEN info$ = "&": operatorusage = 1: EXIT FUNCTION + + lhs = 7 + IF operator$ = "NOT" THEN info$ = "~": operatorusage = 5: EXIT FUNCTION + + IF Debug THEN PRINT #9, "INVALID NUMBERIC OPERATOR!": END + +END FUNCTION + +FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) + typbak = typ + 'method: 0 return an equation which calculates the value of the "variable" + ' 1 return the C name of the variable, typ will be left unchanged + + a$ = a2$ + + 'retrieve ID + i = INSTR(a$, sp3) + IF i THEN + idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) + ELSE + idnumber = VAL(a$) + END IF + getid idnumber + IF Error_Happened THEN EXIT FUNCTION + + 'UDT? + IF typ AND ISUDT THEN + IF method = 1 THEN + n$ = "UDT_" + RTRIM$(id.n) + IF id.t = 0 THEN n$ = "ARRAY_" + n$ + n$ = scope$ + n$ + refer$ = n$ + EXIT FUNCTION + END IF + + 'print "UDTSUBSTRING[idX|u|e|o]:"+a$ + + u = VAL(a$) + i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) + i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) + n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" + IF E = 0 THEN Give_Error "User defined types in expressions are invalid": EXIT FUNCTION + IF typ AND ISOFFSETINBITS THEN Give_Error "Cannot resolve bit-length variables inside user defined types": EXIT FUNCTION + + IF typ AND ISSTRING THEN + IF typ AND ISFIXEDLENGTH THEN + o2$ = "(((uint8*)" + scope$ + n$ + ")+(" + o$ + "))" + r$ = "qbs_new_fixed(" + o2$ + "," + str2(udtetypesize(E)) + ",1)" + typ = STRINGTYPE + ISFIXEDLENGTH 'ISPOINTER retained, it is still a pointer! + ELSE + r$ = "*((qbs**)((char*)" + scope$ + n$ + "+(" + o$ + ")))" + typ = STRINGTYPE + END IF + ELSE + typ = typ - ISUDT - ISREFERENCE - ISPOINTER + IF typ AND ISARRAY THEN typ = typ - ISARRAY + t$ = typ2ctyp$(typ, "") + IF Error_Happened THEN EXIT FUNCTION + o2$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + r$ = "*" + "(" + t$ + "*)" + o2$ + END IF + + 'print "REFER:"+r$+","+str2$(typ) + refer$ = r$ + EXIT FUNCTION + END IF + + + 'array? + IF id.arraytype THEN + + n$ = RTRIM$(id.callname) + IF method = 1 THEN + refer$ = n$ + typ = typbak + EXIT FUNCTION + END IF + typ = typ - ISPOINTER - ISREFERENCE 'typ now looks like a regular value + + IF (typ AND ISSTRING) THEN + IF (typ AND ISFIXEDLENGTH) THEN + offset$ = "&((uint8*)(" + n$ + "[0]))[(" + a$ + ")*" + str2(id.tsize) + "]" + r$ = "qbs_new_fixed(" + offset$ + "," + str2(id.tsize) + ",1)" + ELSE + r$ = "((qbs*)(((uint64*)(" + n$ + "[0]))[" + a$ + "]))" + END IF + stringprocessinghappened = 1 + refer$ = r$ + EXIT FUNCTION + END IF + + IF (typ AND ISOFFSETINBITS) THEN + 'IF (typ AND ISUNSIGNED) THEN r$ = "getubits_" ELSE r$ = "getbits_" + 'r$ = r$ + str2(typ AND 511) + "(" + IF (typ AND ISUNSIGNED) THEN r$ = "getubits" ELSE r$ = "getbits" + r$ = r$ + "(" + str2(typ AND 511) + "," + r$ = r$ + "(uint8*)(" + n$ + "[0])" + "," + r$ = r$ + a$ + ")" + refer$ = r$ + EXIT FUNCTION + ELSE + t$ = "" + IF (typ AND ISFLOAT) THEN + IF (typ AND 511) = 32 THEN t$ = "float" + IF (typ AND 511) = 64 THEN t$ = "double" + IF (typ AND 511) = 256 THEN t$ = "long double" + ELSE + IF (typ AND ISUNSIGNED) THEN + IF (typ AND 511) = 8 THEN t$ = "uint8" + IF (typ AND 511) = 16 THEN t$ = "uint16" + IF (typ AND 511) = 32 THEN t$ = "uint32" + IF (typ AND 511) = 64 THEN t$ = "uint64" + IF typ AND ISOFFSET THEN t$ = "uptrszint" + ELSE + IF (typ AND 511) = 8 THEN t$ = "int8" + IF (typ AND 511) = 16 THEN t$ = "int16" + IF (typ AND 511) = 32 THEN t$ = "int32" + IF (typ AND 511) = 64 THEN t$ = "int64" + IF typ AND ISOFFSET THEN t$ = "ptrszint" + END IF + END IF + END IF + IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT FUNCTION + r$ = "((" + t$ + "*)(" + n$ + "[0]))[" + a$ + "]" + refer$ = r$ + EXIT FUNCTION + END IF 'array + + 'variable? + IF id.t THEN + r$ = RTRIM$(id.n) + t = id.t + 'remove irrelavant flags + IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY + 'string? + IF (t AND ISSTRING) THEN + IF (t AND ISFIXEDLENGTH) THEN + r$ = scope$ + "STRING" + str2(id.tsize) + "_" + r$: GOTO ref + END IF + r$ = scope$ + "STRING_" + r$: GOTO ref + END IF + 'bit-length single variable? + IF (t AND ISOFFSETINBITS) THEN + IF (t AND ISUNSIGNED) THEN + r$ = "*" + scope$ + "UBIT" + str2(t AND 511) + "_" + r$ + ELSE + r$ = "*" + scope$ + "BIT" + str2(t AND 511) + "_" + r$ + END IF + GOTO ref + END IF + IF t = BYTETYPE THEN r$ = "*" + scope$ + "BYTE_" + r$: GOTO ref + IF t = UBYTETYPE THEN r$ = "*" + scope$ + "UBYTE_" + r$: GOTO ref + IF t = INTEGERTYPE THEN r$ = "*" + scope$ + "INTEGER_" + r$: GOTO ref + IF t = UINTEGERTYPE THEN r$ = "*" + scope$ + "UINTEGER_" + r$: GOTO ref + IF t = LONGTYPE THEN r$ = "*" + scope$ + "LONG_" + r$: GOTO ref + IF t = ULONGTYPE THEN r$ = "*" + scope$ + "ULONG_" + r$: GOTO ref + IF t = INTEGER64TYPE THEN r$ = "*" + scope$ + "INTEGER64_" + r$: GOTO ref + IF t = UINTEGER64TYPE THEN r$ = "*" + scope$ + "UINTEGER64_" + r$: GOTO ref + IF t = SINGLETYPE THEN r$ = "*" + scope$ + "SINGLE_" + r$: GOTO ref + IF t = DOUBLETYPE THEN r$ = "*" + scope$ + "DOUBLE_" + r$: GOTO ref + IF t = FLOATTYPE THEN r$ = "*" + scope$ + "FLOAT_" + r$: GOTO ref + IF t = OFFSETTYPE THEN r$ = "*" + scope$ + "OFFSET_" + r$: GOTO ref + IF t = UOFFSETTYPE THEN r$ = "*" + scope$ + "UOFFSET_" + r$: GOTO ref + ref: + IF (t AND ISSTRING) THEN stringprocessinghappened = 1 + IF (t AND ISPOINTER) THEN t = t - ISPOINTER + typ = t + IF method = 1 THEN + IF LEFT$(r$, 1) = "*" THEN r$ = RIGHT$(r$, LEN(r$) - 1) + typ = typbak + END IF + refer$ = r$ + EXIT FUNCTION + END IF 'variable + + + +END FUNCTION + +SUB regid + idn = idn + 1 + + IF idn > ids_max THEN + ids_max = ids_max * 2 + REDIM _PRESERVE ids(1 TO ids_max) AS idstruct + REDIM _PRESERVE cmemlist(1 TO ids_max + 1) AS INTEGER + REDIM _PRESERVE sfcmemargs(1 TO ids_max + 1) AS STRING * 100 + REDIM _PRESERVE arrayelementslist(1 TO ids_max + 1) AS INTEGER + END IF + + n$ = RTRIM$(id.n) + + IF reginternalsubfunc = 0 THEN + IF validname(n$) = 0 THEN Give_Error "Invalid name": EXIT SUB + END IF + + 'register case sensitive name if none given + IF ASC(id.cn) = 32 THEN + n$ = RTRIM$(id.n) + id.n = UCASE$(n$) + id.cn = n$ + END IF + + id.insubfunc = subfunc + id.insubfuncn = subfuncn + + 'note: cannot be STATIC and SHARED at the same time + IF dimshared THEN + id.share = dimshared + ELSE + IF dimstatic THEN id.staticscope = 1 + END IF + + ids(idn) = id + + currentid = idn + + 'prepare hash flags and check for conflicts + hashflags = 1 + + 'sub/function? + 'Note: QBASIC does not allow: Internal type names (INTEGER,LONG,...) + IF id.subfunc THEN + ids(currentid).internal_subfunc = reginternalsubfunc + IF id.subfunc = 1 THEN hashflags = hashflags + HASHFLAG_FUNCTION ELSE hashflags = hashflags + HASHFLAG_SUB + IF reginternalsubfunc = 0 THEN 'allow internal definition of subs/functions without checks + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_CONSTANT + IF id.subfunc = 1 THEN hashchkflags = hashchkflags + HASHFLAG_FUNCTION ELSE hashchkflags = hashchkflags + HASHFLAG_SUB + hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF hashres THEN + 'Note: Numeric sub/function names like 'mid' do not clash with Internal string sub/function names + ' like 'MID$' because MID$ always requires a '$'. For user defined string sub/function names + ' the '$' would be optional so the rule should not be applied there. + allow = 0 + IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN + IF RTRIM$(ids(hashresref).musthave) = "$" THEN + IF INSTR(ids(currentid).mayhave, "$") = 0 THEN allow = 1 + END IF + END IF + IF allow = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF 'hashres + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + IF idemode THEN + IF INSTR(listOfCustomKeywords$, "@" + UCASE$(n$) + "@") = 0 THEN + listOfCustomKeywords$ = listOfCustomKeywords$ + "@" + UCASE$(n$) + "@" + END IF + END IF + END IF 'reginternalsubfunc = 0 + END IF + + 'variable? + IF id.t THEN + hashflags = hashflags + HASHFLAG_VARIABLE + IF reginternalvariable = 0 THEN + allow = 0 + var_recheck: + IF ASC(id.musthave) = 32 THEN astype2 = 1 '"AS type" declaration? + scope2 = subfuncn + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_CONSTANT + HASHFLAG_VARIABLE + hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + + 'conflict with reserved word? + IF hashresflags AND HASHFLAG_RESERVED THEN + musthave$ = RTRIM$(id.musthave) + IF INSTR(musthave$, "$") THEN + 'All reserved words can be used as variables in QBASIC if "$" is appended to the variable name! + '(allow) + ELSE + Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Conflicts with reserved word + END IF + END IF 'HASHFLAG_RESERVED + + 'conflict with sub/function? + IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN + IF ids(hashresref).internal_subfunc = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'QBASIC doesn't allow a variable of the same name as a user-defined sub/func + IF RTRIM$(id.n) = "WIDTH" AND ids(hashresref).subfunc = 2 THEN GOTO varname_exception + musthave$ = RTRIM$(id.musthave) + IF LEN(musthave$) = 0 THEN + IF RTRIM$(ids(hashresref).musthave) = "$" THEN + 'a sub/func requiring "$" can co-exist with implicit numeric variables + IF INSTR(id.mayhave, "$") THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + ELSE + Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Implicitly defined variables cannot conflict with sub/func names + END IF + END IF 'len(musthave$)=0 + IF INSTR(musthave$, "$") THEN + IF RTRIM$(ids(hashresref).musthave) = "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A sub/function name already exists as a string + '(allow) + ELSE + IF RTRIM$(ids(hashresref).musthave) <> "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A non-"$" sub/func name already exists with this name + END IF + END IF 'HASHFLAG_FUNCTION + HASHFLAG_SUB + + 'conflict with constant? + IF hashresflags AND HASHFLAG_CONSTANT THEN + scope1 = constsubfunc(hashresref) + IF (scope1 = 0 AND AllowLocalName = 0) OR scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + + 'conflict with variable? + IF hashresflags AND HASHFLAG_VARIABLE THEN + astype1 = 0: IF ASC(ids(hashresref).musthave) = 32 THEN astype1 = 1 + scope1 = ids(hashresref).insubfuncn + IF astype1 = 1 AND astype2 = 1 THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + 'same type? + IF id.t = ids(hashresref).t THEN + IF id.tsize = ids(hashresref).tsize THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + END IF + 'will astype'd fixed STRING-variable mask a non-fixed string? + IF id.t AND ISFIXEDLENGTH THEN + IF astype2 = 1 THEN + IF ids(hashresref).t AND ISSTRING THEN + IF (ids(hashresref).t AND ISFIXEDLENGTH) = 0 THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + END IF + END IF + END IF + END IF + + varname_exception: + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + END IF 'reginternalvariable + END IF 'variable + + 'array? + IF id.arraytype THEN + hashflags = hashflags + HASHFLAG_ARRAY + allow = 0 + ary_recheck: + scope2 = subfuncn + IF ASC(id.musthave) = 32 THEN astype2 = 1 '"AS type" declaration? + hashchkflags = HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION + HASHFLAG_ARRAY + hashres = HashFind(n$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + + 'conflict with reserved word? + IF hashresflags AND HASHFLAG_RESERVED THEN + musthave$ = RTRIM$(id.musthave) + IF INSTR(musthave$, "$") THEN + 'All reserved words can be used as variables in QBASIC if "$" is appended to the variable name! + '(allow) + ELSE + Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Conflicts with reserved word + END IF + END IF 'HASHFLAG_RESERVED + + 'conflict with sub/function? + IF hashresflags AND (HASHFLAG_FUNCTION + HASHFLAG_SUB) THEN + IF ids(hashresref).internal_subfunc = 0 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'QBASIC doesn't allow a variable of the same name as a user-defined sub/func + IF RTRIM$(id.n) = "WIDTH" AND ids(hashresref).subfunc = 2 THEN GOTO arrayname_exception + musthave$ = RTRIM$(id.musthave) + + IF LEN(musthave$) = 0 THEN + IF RTRIM$(ids(hashresref).musthave) = "$" THEN + 'a sub/func requiring "$" can co-exist with implicit numeric variables + IF INSTR(id.mayhave, "$") THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + ELSE + Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'Implicitly defined variables cannot conflict with sub/func names + END IF + END IF 'len(musthave$)=0 + IF INSTR(musthave$, "$") THEN + IF RTRIM$(ids(hashresref).musthave) = "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A sub/function name already exists as a string + '(allow) + ELSE + IF RTRIM$(ids(hashresref).musthave) <> "$" THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB 'A non-"$" sub/func name already exists with this name + END IF + END IF 'HASHFLAG_FUNCTION + HASHFLAG_SUB + + 'conflict with array? + IF hashresflags AND HASHFLAG_ARRAY THEN + astype1 = 0: IF ASC(ids(hashresref).musthave) = 32 THEN astype1 = 1 + scope1 = ids(hashresref).insubfuncn + IF astype1 = 1 AND astype2 = 1 THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + 'same type? + IF id.arraytype = ids(hashresref).arraytype THEN + IF id.tsize = ids(hashresref).tsize THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + END IF + 'will astype'd fixed STRING-variable mask a non-fixed string? + IF id.arraytype AND ISFIXEDLENGTH THEN + IF astype2 = 1 THEN + IF ids(hashresref).arraytype AND ISSTRING THEN + IF (ids(hashresref).arraytype AND ISFIXEDLENGTH) = 0 THEN + IF scope1 = scope2 THEN Give_Error "Name already in use (" + n$ + ")": EXIT SUB + END IF + END IF + END IF + END IF + END IF + + arrayname_exception: + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + END IF 'array + + 'add it to the hash table + HashAdd n$, hashflags, currentid + +END SUB + +SUB reginternal + reginternalsubfunc = 1 + '$INCLUDE:'subs_functions\subs_functions.bas' + reginternalsubfunc = 0 +END SUB + +'this sub is faulty atm! +'sub replacelement (a$, i, newe$) +''note: performs no action for out of range values of i +'e=1 +'s=1 +'do +'x=instr(s,a$,sp) +'if x then +'if e=i then +'a1$=left$(a$,s-1): a2$=right$(a$,len(a$)-x+1) +'a$=a1$+sp+newe$+a2$ 'note: a2 includes spacer +'exit sub +'end if +'s=x+1 +'e=e+1 +'end if +'loop until x=0 +'if e=i then +'a$=left$(a$,s-1)+sp+newe$ +'end if +'end sub + + +SUB removeelements (a$, first, last, keepindexing) + a2$ = "" + 'note: first and last MUST be valid + ' keepindexing means the number of elements will stay the same + ' but some elements will be equal to "" + + n = numelements(a$) + FOR i = 1 TO n + IF i < first OR i > last THEN + a2$ = a2$ + sp + getelement(a$, i) + ELSE + IF keepindexing THEN a2$ = a2$ + sp + END IF + NEXT + IF LEFT$(a2$, 1) = sp THEN a2$ = RIGHT$(a2$, LEN(a2$) - 1) + + a$ = a2$ + +END SUB + + + +FUNCTION symboltype (s$) 'returns type or 0(not a valid symbol) + 'note: sets symboltype_size for fixed length strings + 'created: 2011 (fast & comprehensive) + IF LEN(s$) = 0 THEN EXIT FUNCTION + 'treat common cases first + a = ASC(s$) + l = LEN(s$) + IF a = 37 THEN '% + IF l = 1 THEN symboltype = 16: EXIT FUNCTION + IF l > 2 THEN EXIT FUNCTION + IF ASC(s$, 2) = 37 THEN symboltype = 8: EXIT FUNCTION + IF ASC(s$, 2) = 38 THEN symboltype = OFFSETTYPE - ISPOINTER: EXIT FUNCTION '%& + EXIT FUNCTION + END IF + IF a = 38 THEN '& + IF l = 1 THEN symboltype = 32: EXIT FUNCTION + IF l > 2 THEN EXIT FUNCTION + IF ASC(s$, 2) = 38 THEN symboltype = 64: EXIT FUNCTION + EXIT FUNCTION + END IF + IF a = 33 THEN '! + IF l = 1 THEN symboltype = 32 + ISFLOAT: EXIT FUNCTION + EXIT FUNCTION + END IF + IF a = 35 THEN '# + IF l = 1 THEN symboltype = 64 + ISFLOAT: EXIT FUNCTION + IF l > 2 THEN EXIT FUNCTION + IF ASC(s$, 2) = 35 THEN symboltype = 64 + ISFLOAT: EXIT FUNCTION + EXIT FUNCTION + END IF + IF a = 36 THEN '$ + IF l = 1 THEN symboltype = ISSTRING: EXIT FUNCTION + IF isuinteger(RIGHT$(s$, l - 1)) THEN + IF l >= (1 + 10) THEN + IF l > (1 + 10) THEN EXIT FUNCTION + IF s$ > "$2147483647" THEN EXIT FUNCTION + END IF + symboltype_size = VAL(RIGHT$(s$, l - 1)) + symboltype = ISSTRING + ISFIXEDLENGTH + EXIT FUNCTION + END IF + EXIT FUNCTION + END IF + IF a = 96 THEN '` + IF l = 1 THEN symboltype = 1 + ISOFFSETINBITS: EXIT FUNCTION + IF isuinteger(RIGHT$(s$, l - 1)) THEN + IF l > 3 THEN EXIT FUNCTION + n = VAL(RIGHT$(s$, l - 1)) + IF n > 64 THEN EXIT FUNCTION + symboltype = n + ISOFFSETINBITS: EXIT FUNCTION + END IF + EXIT FUNCTION + END IF + IF a = 126 THEN '~ + IF l = 1 THEN EXIT FUNCTION + a = ASC(s$, 2) + IF a = 37 THEN '% + IF l = 2 THEN symboltype = 16 + ISUNSIGNED: EXIT FUNCTION + IF l > 3 THEN EXIT FUNCTION + IF ASC(s$, 3) = 37 THEN symboltype = 8 + ISUNSIGNED: EXIT FUNCTION + IF ASC(s$, 3) = 38 THEN symboltype = UOFFSETTYPE - ISPOINTER: EXIT FUNCTION '~%& + EXIT FUNCTION + END IF + IF a = 38 THEN '& + IF l = 2 THEN symboltype = 32 + ISUNSIGNED: EXIT FUNCTION + IF l > 3 THEN EXIT FUNCTION + IF ASC(s$, 3) = 38 THEN symboltype = 64 + ISUNSIGNED: EXIT FUNCTION + EXIT FUNCTION + END IF + IF a = 96 THEN '` + IF l = 2 THEN symboltype = 1 + ISOFFSETINBITS + ISUNSIGNED: EXIT FUNCTION + IF isuinteger(RIGHT$(s$, l - 2)) THEN + IF l > 4 THEN EXIT FUNCTION + n = VAL(RIGHT$(s$, l - 2)) + IF n > 64 THEN EXIT FUNCTION + symboltype = n + ISOFFSETINBITS + ISUNSIGNED: EXIT FUNCTION + END IF + EXIT FUNCTION + END IF + END IF '~ +END FUNCTION + +FUNCTION removesymbol$ (varname$) + i = INSTR(varname$, "~"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "`"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "%"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "&"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "!"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "#"): IF i THEN GOTO foundsymbol + i = INSTR(varname$, "$"): IF i THEN GOTO foundsymbol + EXIT FUNCTION + foundsymbol: + IF i = 1 THEN Give_Error "Expected variable name before symbol": EXIT FUNCTION + symbol$ = RIGHT$(varname$, LEN(varname$) - i + 1) + IF symboltype(symbol$) = 0 THEN Give_Error "Invalid symbol": EXIT FUNCTION + removesymbol$ = symbol$ + varname$ = LEFT$(varname$, i - 1) +END FUNCTION + +FUNCTION scope$ + IF id.share THEN scope$ = module$ + "__": EXIT FUNCTION + scope$ = module$ + "_" + subfunc$ + "_" +END FUNCTION + +FUNCTION seperateargs (a$, ca$, pass&) + pass& = 0 + + FOR i = 1 TO OptMax: separgs(i) = "": NEXT + FOR i = 1 TO OptMax + 1: separgslayout(i) = "": NEXT + FOR i = 1 TO OptMax + Lev(i) = 0 + EntryLev(i) = 0 + DitchLev(i) = 0 + DontPass(i) = 0 + TempList(i) = 0 + PassRule(i) = 0 + LevelEntered(i) = 0 + NEXT + + DIM id2 AS idstruct + + id2 = id + + IF id2.args = 0 THEN EXIT FUNCTION 'no arguments! + + + s$ = id2.specialformat + s$ = RTRIM$(s$) + + 'build a special format if none exists + IF s$ = "" THEN + FOR i = 1 TO id2.args + IF i <> 1 THEN s$ = s$ + ",?" ELSE s$ = "?" + NEXT + END IF + + 'note: dim'd arrays moved to global to prevent high recreation cost + + PassFlag = 1 + nextentrylevel = 0 + nextentrylevelset = 1 + level = 0 + lastt = 0 + ditchlevel = 0 + FOR i = 1 TO LEN(s$) + s2$ = MID$(s$, i, 1) + + IF s2$ = "[" THEN + level = level + 1 + LevelEntered(level) = 0 + GOTO nextsymbol + END IF + + IF s2$ = "]" THEN + level = level - 1 + IF level < ditchlevel THEN ditchlevel = level + GOTO nextsymbol + END IF + + IF s2$ = "{" THEN + lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 + DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level + i = i + 1 + i2 = INSTR(i, s$, "}") + numopts = 0 + nextopt: + numopts = numopts + 1 + i3 = INSTR(i + 1, s$, "|") + IF i3 <> 0 AND i3 < i2 THEN + Opt(lastt, numopts) = MID$(s$, i, i3 - i) + i = i3 + 1: GOTO nextopt + END IF + Opt(lastt, numopts) = MID$(s$, i, i2 - i) + T(lastt) = numopts + 'calculate words in each option + FOR x = 1 TO T(lastt) + w = 1 + x2 = 1 + newword: + IF INSTR(x2, RTRIM$(Opt(lastt, x)), " ") THEN w = w + 1: x2 = INSTR(x2, RTRIM$(Opt(lastt, x)), " ") + 1: GOTO newword + OptWords(lastt, x) = w + NEXT + i = i2 + + 'set entry level routine + EntryLev(lastt) = level 'default level when continuing a previously entered level + IF LevelEntered(level) = 0 THEN + EntryLev(lastt) = 0 + FOR i2 = 1 TO level - 1 + IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 + NEXT + END IF + LevelEntered(level) = 1 + + GOTO nextsymbol + END IF + + IF s2$ = "?" THEN + lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 + DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level + T(lastt) = 0 + 'set entry level routine + EntryLev(lastt) = level 'default level when continuing a previously entered level + IF LevelEntered(level) = 0 THEN + EntryLev(lastt) = 0 + FOR i2 = 1 TO level - 1 + IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 + NEXT + END IF + LevelEntered(level) = 1 + + GOTO nextsymbol + END IF + + 'assume "special" character (like ( ) , . - etc.) + lastt = lastt + 1: Lev(lastt) = level: PassRule(lastt) = 0 + DitchLev(lastt) = ditchlevel: ditchlevel = level 'store & reset ditch level + T(lastt) = 1: Opt(lastt, 1) = s2$: OptWords(lastt, 1) = 1: DontPass(lastt) = 1 + + 'set entry level routine + EntryLev(lastt) = level 'default level when continuing a previously entered level + IF LevelEntered(level) = 0 THEN + EntryLev(lastt) = 0 + FOR i2 = 1 TO level - 1 + IF LevelEntered(i2) = 1 THEN EntryLev(lastt) = i2 + NEXT + END IF + LevelEntered(level) = 1 + + GOTO nextsymbol + + nextsymbol: + NEXT + + + IF Debug THEN + PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:1--------" + FOR i = 1 TO lastt + PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) + PRINT #9, i, "OPTWORDS="; OptWords(i, 1) + PRINT #9, i, "T="; T(i) + PRINT #9, i, "DONTPASS="; DontPass(i) + PRINT #9, i, "PASSRULE="; PassRule(i) + PRINT #9, i, "LEV="; Lev(i) + PRINT #9, i, "ENTRYLEV="; EntryLev(i) + NEXT + END IF + + + 'Any symbols already have dontpass() set to 1 + 'This sets any {}blocks with only one option/word (eg. {PRINT}) at the lowest level to dontpass()=1 + 'because their content is manadatory and there is no choice as to which word to use + FOR x = 1 TO lastt + IF Lev(x) = 0 THEN + IF T(x) = 1 THEN DontPass(x) = 1 + END IF + NEXT + + IF Debug THEN + PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:2--------" + FOR i = 1 TO lastt + PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) + PRINT #9, i, "OPTWORDS="; OptWords(i, 1) + PRINT #9, i, "T="; T(i) + PRINT #9, i, "DONTPASS="; DontPass(i) + PRINT #9, i, "PASSRULE="; PassRule(i) + PRINT #9, i, "LEV="; Lev(i) + PRINT #9, i, "ENTRYLEV="; EntryLev(i) + NEXT + END IF + + + + + x1 = 0 'the 'x' position of the beginning element of the current levelled block + MustPassOpt = 0 'the 'x' position of the FIRST opt () in the block which must be passed + MustPassOptNeedsFlag = 0 '{}blocks don't need a flag, ? blocks do + + 'Note: For something like [{HELLO}x] a choice between passing 'hello' or passing a flag to signify x was specified + ' has to be made, in such cases, a flag is preferable to wasting a full new int32 on 'hello' + + templistn = 0 + FOR l = 1 TO 32767 + scannextlevel = 0 + FOR x = 1 TO lastt + IF Lev(x) > l THEN scannextlevel = 1 + + IF x1 THEN + IF EntryLev(x) < l THEN 'end of block reached + IF MustPassOpt THEN + 'If there's an opt () which must be passed that will be identified, + 'all the 1 option {}blocks can be assumed... + IF MustPassOptNeedsFlag THEN + 'The MustPassOpt requires a flag, so use the same flag for everything + FOR x2 = 1 TO templistn + PassRule(TempList(x2)) = PassFlag + NEXT + PassFlag = PassFlag * 2 + ELSE + 'The MustPassOpt is a {}block which doesn't need a flag, so everything else needs to + 'reference it + FOR x2 = 1 TO templistn + IF TempList(x2) <> MustPassOpt THEN PassRule(TempList(x2)) = -MustPassOpt + NEXT + END IF + ELSE + 'if not, use a unique flag for everything in this block + FOR x2 = 1 TO templistn: PassRule(TempList(x2)) = PassFlag: NEXT + IF templistn <> 0 THEN PassFlag = PassFlag * 2 + END IF + x1 = 0 + END IF + END IF + + + IF Lev(x) = l THEN 'on same level + IF EntryLev(x) < l THEN 'just (re)entered this level (not continuing along it) + x1 = x 'set x1 to the starting element of this level + MustPassOpt = 0 + templistn = 0 + END IF + END IF + + IF x1 THEN + IF Lev(x) = l THEN 'same level + + IF T(x) <> 1 THEN + 'It isn't a symbol or a {}block with only one option therefore this opt () must be passed + IF MustPassOpt = 0 THEN + MustPassOpt = x 'Only record the first instance (it MAY require a flag) + IF T(x) = 0 THEN MustPassOptNeedsFlag = 1 ELSE MustPassOptNeedsFlag = 0 + ELSE + 'Update current MustPassOpt to non-flag-based {}block if possible (to save flag usage) + '(Consider [{A|B}?], where a flag is not required) + IF MustPassOptNeedsFlag = 1 THEN + IF T(x) > 1 THEN + MustPassOpt = x: MustPassOptNeedsFlag = 0 + END IF + END IF + END IF + 'add to list + templistn = templistn + 1: TempList(templistn) = x + END IF + + IF T(x) = 1 THEN + 'It is a symbol or a {}block with only one option + 'a {}block with only one option MAY not need to be passed + 'depending on if anything else is in this block could make the existance of this opt () assumed + 'Note: Symbols which are not encapsulated inside a {}block never need to be passed + ' Symbols already have dontpass() set to 1 + IF DontPass(x) = 0 THEN templistn = templistn + 1: TempList(templistn) = x: DontPass(x) = 1 + END IF + + END IF + END IF + + NEXT + + 'scan last run (mostly just a copy of code from above) + IF x1 THEN + IF MustPassOpt THEN + 'If there's an opt () which must be passed that will be identified, + 'all the 1 option {}blocks can be assumed... + IF MustPassOptNeedsFlag THEN + 'The MustPassOpt requires a flag, so use the same flag for everything + FOR x2 = 1 TO templistn + PassRule(TempList(x2)) = PassFlag + NEXT + PassFlag = PassFlag * 2 + ELSE + 'The MustPassOpt is a {}block which doesn't need a flag, so everything else needs to + 'reference it + FOR x2 = 1 TO templistn + IF TempList(x2) <> MustPassOpt THEN PassRule(TempList(x2)) = -MustPassOpt + NEXT + END IF + ELSE + 'if not, use a unique flag for everything in this block + FOR x2 = 1 TO templistn: PassRule(TempList(x2)) = PassFlag: NEXT + IF templistn <> 0 THEN PassFlag = PassFlag * 2 + END IF + x1 = 0 + END IF + + IF scannextlevel = 0 THEN EXIT FOR + NEXT + + IF Debug THEN + PRINT #9, "--------SEPERATE ARGUMENTS REPORT #1:3--------" + FOR i = 1 TO lastt + PRINT #9, i, "OPT=" + CHR$(34) + RTRIM$(Opt(i, 1)) + CHR$(34) + PRINT #9, i, "OPTWORDS="; OptWords(i, 1) + PRINT #9, i, "T="; T(i) + PRINT #9, i, "DONTPASS="; DontPass(i) + PRINT #9, i, "PASSRULE="; PassRule(i) + PRINT #9, i, "LEV="; Lev(i) + PRINT #9, i, "ENTRYLEV="; EntryLev(i) + NEXT + END IF + + + + FOR i = 1 TO lastt: separgs(i) = "n-ll": NEXT + + + + + 'Consider: "?,[?]" + 'Notes: The comma is mandatory but the second ? is entirely optional + 'Consider: "[?[{B}?]{A}]?" + 'Notes: As unlikely as the above is, it is still valid, but pivots on the outcome of {A} being present + 'Consider: "[?]{A}" + 'Consider: "[?{A}][?{B}][?{C}]?" + 'Notes: The trick here is to realize {A} has greater priority than {B}, so all lines of enquiry must + ' be exhausted before considering {B} + + 'Use inquiry approach to solve format + 'Each line of inquiry must be exhausted + 'An expression ("?") simply means a branch where you can scan ahead + + Branches = 0 + DIM BranchFormatPos(1 TO 100) AS LONG + DIM BranchTaken(1 TO 100) AS LONG + '1=taken (this usually involves moving up a level) + '0=not taken + DIM BranchInputPos(1 TO 100) AS LONG + DIM BranchWithExpression(1 TO 100) AS LONG + 'non-zero=expression expected before next item for format item value represents + '0=no expression allowed before next item + DIM BranchLevel(1 TO 100) AS LONG 'Level before this branch was/wasn't taken + + n = numelements(ca$) + i = 1 'Position within ca$ + + level = 0 + Expression = 0 + FOR x = 1 TO lastt + + ContinueScan: + + IF DitchLev(x) < level THEN 'dropping down to a lower level + 'we can only go as low as the 'ditch' will allow us, which will limit our options + level = DitchLev(x) + END IF + + IF EntryLev(x) <= level THEN 'possible to enter level + + 'But was this optional or were we forced to be on this level? + IF EntryLev(x) < Lev(x) THEN + optional = 1 + IF level > EntryLev(x) THEN optional = 0 + ELSE + 'entrylev=lev + optional = 0 + END IF + + t = T(x) + + IF t = 0 THEN 'A "?" expression + IF Expression THEN + '*********backtrack************ + 'We are tracking an expression which we assumed would be present but was not + GOTO Backtrack + '****************************** + END IF + IF optional THEN + Branches = Branches + 1 + BranchFormatPos(Branches) = x + BranchTaken(Branches) = 1 + BranchInputPos(Branches) = i + BranchWithExpression(Branches) = 0 + BranchLevel(Branches) = level + level = Lev(x) + END IF + Expression = x + END IF 'A "?" expression + + IF t THEN + + currentlev = level + + 'Add new branch if new level will be entered + IF optional THEN + Branches = Branches + 1 + BranchFormatPos(Branches) = x + BranchTaken(Branches) = 1 + BranchInputPos(Branches) = i + BranchWithExpression(Branches) = Expression + BranchLevel(Branches) = level + END IF + + 'Scan for Opt () options + i1 = i: i2 = i + IF Expression THEN i2 = n + 'Scan a$ for opt () x + 'Note: Finding the closest opt option is necessary + 'Note: This needs to be bracket sensitive + OutOfRange = 2147483647 + position = OutOfRange + which = 0 + removePrefix = 0 + IF i <= n THEN 'Past end of contect check + FOR o = 1 TO t + words = OptWords(x, o) + b = 0 + FOR i3 = i1 TO i2 + IF i3 + words - 1 <= n THEN 'enough elements exist + c$ = getelement$(a$, i3) + IF b = 0 THEN + 'Build comparison string (spacing elements) + FOR w = 2 TO words + c$ = c$ + " " + getelement$(a$, i3 + w - 1) + NEXT w + 'Compare + noPrefixMatch = LEFT$(Opt(x, o), 1) = "_" AND qb64prefix_set = 1 AND c$ = UCASE$(MID$(RTRIM$(Opt(x, o)), 2)) + IF c$ = UCASE$(RTRIM$(Opt(x, o))) OR noPrefixMatch THEN + 'Record Match + IF i3 < position THEN + position = i3 + which = o + IF noPrefixMatch THEN removePrefix = 1 + bvalue = b + EXIT FOR 'Exit the i3 loop + END IF 'position check + END IF 'match + END IF + + IF ASC(c$) = 44 AND b = 0 THEN + EXIT FOR 'Expressions cannot contain a "," in their base level + 'Because this wasn't interceppted by the above code it isn't the Opt either + END IF + IF ASC(c$) = 40 THEN + b = b + 1 + END IF + IF ASC(c$) = 41 THEN + b = b - 1 + IF b = -1 THEN EXIT FOR 'Exited current bracketting level, making any following match invalid + END IF + + END IF 'enough elements exist + NEXT i3 + NEXT o + END IF 'Past end of contect check + + IF position <> OutOfRange THEN 'Found? + 'Found... + level = Lev(x) 'Adjust level + IF Expression THEN + 'Found...Expression... + 'Has an expression been provided? + IF position > i AND bvalue = 0 THEN + 'Found...Expression...Provided... + separgs(Expression) = getelements$(ca$, i, position - 1) + Expression = 0 + i = position + ELSE + 'Found...Expression...Omitted... + '*********backtrack************ + GOTO OptCheckBacktrack + '****************************** + END IF + END IF 'Expression + i = i + OptWords(x, which) + separgslayout(x) = CHR$(LEN(RTRIM$(Opt(x, which))) - removePrefix) + SCase$(MID$(RTRIM$(Opt(x, which)), removePrefix + 1)) + separgs(x) = CHR$(0) + str2(which) + ELSE + 'Not Found... + '*********backtrack************ + OptCheckBacktrack: + 'Was this optional? + IF Lev(x) > EntryLev(x) THEN 'Optional Opt ()? + 'Not Found...Optional... + 'Simply don't enter the optional higher level and continue as normal + BranchTaken(Branches) = 0 + level = currentlev 'We aren't entering the level after all, so our level should remain at the opt's entrylevel + ELSE + Backtrack: + 'Not Found...Mandatory... + '1)Erase previous branches where both options have been tried + FOR branch = Branches TO 1 STEP -1 'Remove branches until last taken branch is found + IF BranchTaken(branch) THEN EXIT FOR + Branches = Branches - 1 'Remove branch (it has already been tried with both possible combinations) + NEXT + IF Branches = 0 THEN 'All options have been exhausted + seperateargs_error = 1 + seperateargs_error_message = "Syntax error" + IF LEN(id2.hr_syntax) > 0 THEN seperateargs_error_message = seperateargs_error_message + " - Reference: " + id2.hr_syntax + EXIT FUNCTION + END IF + '2)Toggle taken branch to untaken and revert + BranchTaken(Branches) = 0 'toggle branch to untaken + Expression = BranchWithExpression(Branches) + i = BranchInputPos(Branches) + x = BranchFormatPos(Branches) + level = BranchLevel(Branches) + '3)Erase any content created after revert position + IF Expression THEN separgs(Expression) = "n-ll" + FOR x2 = x TO lastt + separgs(x2) = "n-ll" + separgslayout(x2) = "" + NEXT + END IF 'Optional Opt ()? + '****************************** + + END IF 'Found? + + END IF 't + + END IF 'possible to enter level + + NEXT x + + 'Final expression? + IF Expression THEN + IF i <= n THEN + separgs(Expression) = getelements$(ca$, i, n) + + 'can this be an expression? + 'check it passes bracketting and comma rules + b = 0 + FOR i2 = i TO n + c$ = getelement$(a$, i2) + IF ASC(c$) = 44 AND b = 0 THEN + GOTO Backtrack + END IF + IF ASC(c$) = 40 THEN + b = b + 1 + END IF + IF ASC(c$) = 41 THEN + b = b - 1 + IF b = -1 THEN GOTO Backtrack + END IF + NEXT + IF b <> 0 THEN GOTO Backtrack + + i = n + 1 'So it passes the test below + ELSE + GOTO Backtrack + END IF + END IF 'Expression + + IF i <> n + 1 THEN GOTO Backtrack 'Trailing content? + + IF Debug THEN + PRINT #9, "--------SEPERATE ARGUMENTS REPORT #2--------" + FOR i = 1 TO lastt + PRINT #9, i, separgs(i) + NEXT + END IF + + ' DIM PassRule(1 TO 100) AS LONG + ' '0 means no pass rule + ' 'negative values refer to an opt () element + ' 'positive values refer to a flag value + ' PassFlag = 1 + + + IF PassFlag <> 1 THEN seperateargs = 1 'Return whether a 'passed' flags variable is required + pass& = 0 'The 'passed' value (shared by argument reference) + + 'Note: The separgs() elements will be compacted to the C++ function arguments + x = 1 'The new index to move compacted content to within separgs() + + FOR i = 1 TO lastt + + IF DontPass(i) = 0 THEN + + IF PassRule(i) > 0 THEN + IF separgs(i) <> "n-ll" THEN pass& = pass& OR PassRule(i) 'build 'passed' flags + END IF + + separgs(x) = separgs(i) + separgslayout(x) = separgslayout(i) + + IF LEN(separgs(x)) THEN + IF ASC(separgs(x)) = 0 THEN + 'switch omit layout tag from item to layout info + separgs(x) = RIGHT$(separgs(x), LEN(separgs(x)) - 1) + separgslayout(x) = separgslayout(x) + CHR$(0) + END IF + END IF + + IF separgs(x) = "n-ll" THEN separgs(x) = "N-LL" + x = x + 1 + + ELSE + 'its gonna be skipped! + 'add layout to the next one to be safe + + 'for syntax such as [{HELLO}] which uses a flag instead of being passed + IF PassRule(i) > 0 THEN + IF separgs(i) <> "n-ll" THEN pass& = pass& OR PassRule(i) 'build 'passed' flags + END IF + + separgslayout(i + 1) = separgslayout(i) + separgslayout(i + 1) + + END IF + NEXT + separgslayout(x) = separgslayout(i) 'set final layout + + 'x = x - 1 + 'PRINT "total arguments:"; x + 'PRINT "pass omit (0/1):"; omit + 'PRINT "pass&="; pass& + +END FUNCTION + +SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) + a$ = a2$: typ = typ2: e$ = e2$ + IF method <> 1 THEN e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + tl$ = tlayout$ + + 'method: 0 evaulatetotyp e$ + ' 1 skip evaluation of e$ and use as is + '*due to the complexity of setting a reference with a value/string + ' this function handles the problem + + 'retrieve ID + i = INSTR(a$, sp3) + IF i THEN + idnumber = VAL(LEFT$(a$, i - 1)): a$ = RIGHT$(a$, LEN(a$) - i) + ELSE + idnumber = VAL(a$) + END IF + getid idnumber + IF Error_Happened THEN EXIT SUB + + 'UDT? + IF typ AND ISUDT THEN + + 'print "setrefer-ing a UDT!" + u = VAL(a$) + i = INSTR(a$, sp3): a$ = RIGHT$(a$, LEN(a$) - i): E = VAL(a$) + i = INSTR(a$, sp3): o$ = RIGHT$(a$, LEN(a$) - i) + n$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n$ = "ARRAY_" + n$ + "[0]" + + IF E <> 0 AND u = 1 THEN 'Setting _MEM type elements is not allowed! + Give_Error "Cannot set read-only element of _MEM TYPE": EXIT SUB + END IF + + IF E = 0 THEN + 'use u and u's size + + IF method <> 0 THEN Give_Error "Unexpected internal code reference to UDT": EXIT SUB + lhsscope$ = scope$ + e$ = evaluate(e$, t2) + IF Error_Happened THEN EXIT SUB + IF (t2 AND ISUDT) = 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB + + IF (t2 AND ISREFERENCE) = 0 THEN + IF t2 AND ISPOINTER THEN + src$ = "((char*)" + e$ + ")" + e2 = 0: u2 = t2 AND 511 + ELSE + src$ = "((char*)&" + e$ + ")" + e2 = 0: u2 = t2 AND 511 + END IF + GOTO directudt + END IF + + '****problem**** + idnumber2 = VAL(e$) + getid idnumber2 + + + IF Error_Happened THEN EXIT SUB + n2$ = "UDT_" + RTRIM$(id.n): IF id.t = 0 THEN n2$ = "ARRAY_" + n2$ + "[0]" + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): u2 = VAL(e$) + i = INSTR(e$, sp3): e$ = RIGHT$(e$, LEN(e$) - i): e2 = VAL(e$) + i = INSTR(e$, sp3): o2$ = RIGHT$(e$, LEN(e$) - i) + 'WARNING: u2 may need minor modifications based on e to see if they are the same + + 'we have now established we have 2 pointers to similar data types! + 'ASSUME BYTE TYPE!!! + src$ = "((char*)" + scope$ + n2$ + ")+(" + o2$ + ")" + directudt: + IF u <> u2 OR e2 <> 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB + dst$ = "((char*)" + lhsscope$ + n$ + ")+(" + o$ + ")" + copy_full_udt dst$, src$, 12, 0, u + + 'print "setFULLUDTrefer!" + + tlayout$ = tl$ + EXIT SUB + + END IF 'e=0 + + IF typ AND ISOFFSETINBITS THEN Give_Error "Cannot resolve bit-length variables inside user defined types": EXIT SUB + IF typ AND ISSTRING THEN + IF typ AND ISFIXEDLENGTH THEN + o2$ = "(((uint8*)" + scope$ + n$ + ")+(" + o$ + "))" + r$ = "qbs_new_fixed(" + o2$ + "," + str2(udtetypesize(E)) + ",1)" + ELSE + r$ = "*((qbs**)((char*)(" + scope$ + n$ + ")+(" + o$ + ")))" + END IF + IF method = 0 THEN e$ = evaluatetotyp(e$, STRINGTYPE - ISPOINTER) + IF Error_Happened THEN EXIT SUB + PRINT #12, "qbs_set(" + r$ + "," + e$ + ");" + PRINT #12, cleanupstringprocessingcall$ + "0);" + ELSE + typ = typ - ISUDT - ISREFERENCE - ISPOINTER + IF typ AND ISARRAY THEN typ = typ - ISARRAY + t$ = typ2ctyp$(typ, "") + IF Error_Happened THEN EXIT SUB + o2$ = "(((char*)" + scope$ + n$ + ")+(" + o$ + "))" + r$ = "*" + "(" + t$ + "*)" + o2$ + IF method = 0 THEN e$ = evaluatetotyp(e$, typ) + IF Error_Happened THEN EXIT SUB + PRINT #12, r$ + "=" + e$ + ";" + END IF + + 'print "setUDTrefer:"+r$,e$ + tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + EXIT SUB + END IF + + + 'array? + IF id.arraytype THEN + n$ = RTRIM$(id.callname) + typ = typ - ISPOINTER - ISREFERENCE 'typ now looks like a regular value + + IF (typ AND ISSTRING) THEN + IF (typ AND ISFIXEDLENGTH) THEN + offset$ = "&((uint8*)(" + n$ + "[0]))[tmp_long*" + str2(id.tsize) + "]" + r$ = "qbs_new_fixed(" + offset$ + "," + str2(id.tsize) + ",1)" + PRINT #12, "tmp_long=" + a$ + ";" + IF method = 0 THEN + l$ = "if (!new_error) qbs_set(" + r$ + "," + evaluatetotyp(e$, typ) + ");" + IF Error_Happened THEN EXIT SUB + ELSE + l$ = "if (!new_error) qbs_set(" + r$ + "," + e$ + ");" + END IF + PRINT #12, l$ + ELSE + PRINT #12, "tmp_long=" + a$ + ";" + IF method = 0 THEN + l$ = "if (!new_error) qbs_set( ((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))," + evaluatetotyp(e$, typ) + ");" + IF Error_Happened THEN EXIT SUB + ELSE + l$ = "if (!new_error) qbs_set( ((qbs*)(((uint64*)(" + n$ + "[0]))[tmp_long]))," + e$ + ");" + END IF + PRINT #12, l$ + END IF + PRINT #12, cleanupstringprocessingcall$ + "0);" + tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + EXIT SUB + END IF + + IF (typ AND ISOFFSETINBITS) THEN + 'r$ = "setbits_" + str2(typ AND 511) + "(" + r$ = "setbits(" + str2(typ AND 511) + "," + r$ = r$ + "(uint8*)(" + n$ + "[0])" + ",tmp_long," + PRINT #12, "tmp_long=" + a$ + ";" + IF method = 0 THEN + l$ = "if (!new_error) " + r$ + evaluatetotyp(e$, typ) + ");" + IF Error_Happened THEN EXIT SUB + ELSE + l$ = "if (!new_error) " + r$ + e$ + ");" + END IF + PRINT #12, l$ + tlayout$ = tl$ + EXIT SUB + ELSE + t$ = "" + IF (typ AND ISFLOAT) THEN + IF (typ AND 511) = 32 THEN t$ = "float" + IF (typ AND 511) = 64 THEN t$ = "double" + IF (typ AND 511) = 256 THEN t$ = "long double" + ELSE + IF (typ AND ISUNSIGNED) THEN + IF (typ AND 511) = 8 THEN t$ = "uint8" + IF (typ AND 511) = 16 THEN t$ = "uint16" + IF (typ AND 511) = 32 THEN t$ = "uint32" + IF (typ AND 511) = 64 THEN t$ = "uint64" + IF typ AND ISOFFSET THEN t$ = "uptrszint" + ELSE + IF (typ AND 511) = 8 THEN t$ = "int8" + IF (typ AND 511) = 16 THEN t$ = "int16" + IF (typ AND 511) = 32 THEN t$ = "int32" + IF (typ AND 511) = 64 THEN t$ = "int64" + IF typ AND ISOFFSET THEN t$ = "ptrszint" + END IF + END IF + END IF + IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT SUB + PRINT #12, "tmp_long=" + a$ + ";" + IF method = 0 THEN + l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + evaluatetotyp(e$, typ) + ";" + IF Error_Happened THEN EXIT SUB + ELSE + l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + e$ + ";" + END IF + + PRINT #12, l$ + tlayout$ = tl$ + EXIT SUB + END IF 'array + + 'variable? + IF id.t THEN + r$ = RTRIM$(id.n) + t = id.t + 'remove irrelavant flags + IF (t AND ISINCONVENTIONALMEMORY) THEN t = t - ISINCONVENTIONALMEMORY + typ = t + + 'string variable? + IF (t AND ISSTRING) THEN + IF (t AND ISFIXEDLENGTH) THEN + r$ = scope$ + "STRING" + str2(id.tsize) + "_" + r$ + ELSE + r$ = scope$ + "STRING_" + r$ + END IF + IF method = 0 THEN e$ = evaluatetotyp(e$, ISSTRING) + IF Error_Happened THEN EXIT SUB + PRINT #12, "qbs_set(" + r$ + "," + e$ + ");" + PRINT #12, cleanupstringprocessingcall$ + "0);" + IF arrayprocessinghappened THEN arrayprocessinghappened = 0 + tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + EXIT SUB + END IF + + 'bit-length variable? + IF (t AND ISOFFSETINBITS) THEN + b = t AND 511 + IF (t AND ISUNSIGNED) THEN + r$ = "*" + scope$ + "UBIT" + str2(t AND 511) + "_" + r$ + IF method = 0 THEN e$ = evaluatetotyp(e$, 64& + ISUNSIGNED) + IF Error_Happened THEN EXIT SUB + l$ = r$ + "=(" + e$ + ")&" + str2(bitmask(b)) + ";" + PRINT #12, l$ + ELSE + r$ = "*" + scope$ + "BIT" + str2(t AND 511) + "_" + r$ + IF method = 0 THEN e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN EXIT SUB + l$ = "if ((" + r$ + "=" + e$ + ")&" + str2(2 ^ (b - 1)) + "){" + PRINT #12, l$ + 'signed bit is set + l$ = r$ + "|=" + str2(bitmaskinv(b)) + ";" + PRINT #12, l$ + PRINT #12, "}else{" + 'signed bit is not set + l$ = r$ + "&=" + str2(bitmask(b)) + ";" + PRINT #12, l$ + PRINT #12, "}" + END IF + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 + IF arrayprocessinghappened THEN arrayprocessinghappened = 0 + tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + EXIT SUB + END IF + + 'standard variable? + IF t = BYTETYPE THEN r$ = "*" + scope$ + "BYTE_" + r$: GOTO sref + IF t = UBYTETYPE THEN r$ = "*" + scope$ + "UBYTE_" + r$: GOTO sref + IF t = INTEGERTYPE THEN r$ = "*" + scope$ + "INTEGER_" + r$: GOTO sref + IF t = UINTEGERTYPE THEN r$ = "*" + scope$ + "UINTEGER_" + r$: GOTO sref + IF t = LONGTYPE THEN r$ = "*" + scope$ + "LONG_" + r$: GOTO sref + IF t = ULONGTYPE THEN r$ = "*" + scope$ + "ULONG_" + r$: GOTO sref + IF t = INTEGER64TYPE THEN r$ = "*" + scope$ + "INTEGER64_" + r$: GOTO sref + IF t = UINTEGER64TYPE THEN r$ = "*" + scope$ + "UINTEGER64_" + r$: GOTO sref + IF t = SINGLETYPE THEN r$ = "*" + scope$ + "SINGLE_" + r$: GOTO sref + IF t = DOUBLETYPE THEN r$ = "*" + scope$ + "DOUBLE_" + r$: GOTO sref + IF t = FLOATTYPE THEN r$ = "*" + scope$ + "FLOAT_" + r$: GOTO sref + IF t = OFFSETTYPE THEN r$ = "*" + scope$ + "OFFSET_" + r$: GOTO sref + IF t = UOFFSETTYPE THEN r$ = "*" + scope$ + "UOFFSET_" + r$: GOTO sref + sref: + t2 = t - ISPOINTER + IF method = 0 THEN e$ = evaluatetotyp(e$, t2) + IF Error_Happened THEN EXIT SUB + l$ = r$ + "=" + e$ + ";" + PRINT #12, l$ + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 + IF arrayprocessinghappened THEN arrayprocessinghappened = 0 + tlayout$ = tl$ + + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + EXIT SUB + END IF 'variable + + tlayout$ = tl$ +END SUB + +FUNCTION str2$ (v AS LONG) + str2$ = _TRIM$(STR$(v)) +END FUNCTION + +FUNCTION str2u64$ (v~&&) + str2u64$ = LTRIM$(RTRIM$(STR$(v~&&))) +END FUNCTION + +FUNCTION str2i64$ (v&&) + str2i64$ = LTRIM$(RTRIM$(STR$(v&&))) +END FUNCTION + +FUNCTION typ2ctyp$ (t AS LONG, tstr AS STRING) + ctyp$ = "" + 'typ can be passed as either: (the unused value is ignored) + 'i. as a typ value in t + 'ii. as a typ symbol (eg. "~%") in tstr + 'iii. as a typ name (eg. _UNSIGNED INTEGER) in tstr + IF tstr$ = "" THEN + IF (t AND ISARRAY) THEN EXIT FUNCTION 'cannot return array types + IF (t AND ISSTRING) THEN typ2ctyp$ = "qbs": EXIT FUNCTION + b = t AND 511 + IF (t AND ISUDT) THEN typ2ctyp$ = "void": EXIT FUNCTION + IF (t AND ISOFFSETINBITS) THEN + IF b <= 32 THEN ctyp$ = "int32" ELSE ctyp$ = "int64" + IF (t AND ISUNSIGNED) THEN ctyp$ = "u" + ctyp$ + typ2ctyp$ = ctyp$: EXIT FUNCTION + END IF + IF (t AND ISFLOAT) THEN + IF b = 32 THEN ctyp$ = "float" + IF b = 64 THEN ctyp$ = "double" + IF b = 256 THEN ctyp$ = "long double" + ELSE + IF b = 8 THEN ctyp$ = "int8" + IF b = 16 THEN ctyp$ = "int16" + IF b = 32 THEN ctyp$ = "int32" + IF b = 64 THEN ctyp$ = "int64" + IF t AND ISOFFSET THEN ctyp$ = "ptrszint" + IF (t AND ISUNSIGNED) THEN ctyp$ = "u" + ctyp$ + END IF + IF t AND ISOFFSET THEN + ctyp$ = "ptrszint": IF (t AND ISUNSIGNED) THEN ctyp$ = "uptrszint" + END IF + typ2ctyp$ = ctyp$: EXIT FUNCTION + END IF + + ts$ = tstr$ + 'is ts$ a symbol? + IF ts$ = "$" THEN ctyp$ = "qbs" + IF ts$ = "!" THEN ctyp$ = "float" + IF ts$ = "#" THEN ctyp$ = "double" + IF ts$ = "##" THEN ctyp$ = "long double" + IF LEFT$(ts$, 1) = "~" THEN unsgn = 1: ts$ = RIGHT$(ts$, LEN(ts$) - 1) + IF LEFT$(ts$, 1) = "`" THEN + n$ = RIGHT$(ts$, LEN(ts$) - 1) + b = 1 + IF n$ <> "" THEN + IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION + b = VAL(n$) + IF b > 64 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION + END IF + IF b <= 32 THEN ctyp$ = "int32" ELSE ctyp$ = "int64" + IF unsgn THEN ctyp$ = "u" + ctyp$ + typ2ctyp$ = ctyp$: EXIT FUNCTION + END IF + IF ts$ = "%&" THEN + typ2ctyp$ = "ptrszint": IF (t AND ISUNSIGNED) THEN typ2ctyp$ = "uptrszint" + EXIT FUNCTION + END IF + IF ts$ = "%%" THEN ctyp$ = "int8" + IF ts$ = "%" THEN ctyp$ = "int16" + IF ts$ = "&" THEN ctyp$ = "int32" + IF ts$ = "&&" THEN ctyp$ = "int64" + IF ctyp$ <> "" THEN + IF unsgn THEN ctyp$ = "u" + ctyp$ + typ2ctyp$ = ctyp$: EXIT FUNCTION + END IF + 'is tstr$ a named type? (eg. 'LONG') + s$ = type2symbol$(tstr$) + IF Error_Happened THEN EXIT FUNCTION + IF LEN(s$) THEN + typ2ctyp$ = typ2ctyp$(0, s$) + IF Error_Happened THEN EXIT FUNCTION + EXIT FUNCTION + END IF + + Give_Error "Invalid type": EXIT FUNCTION + +END FUNCTION + +FUNCTION type2symbol$ (typ$) + t$ = typ$ + FOR i = 1 TO LEN(t$) + IF MID$(t$, i, 1) = sp THEN MID$(t$, i, 1) = " " + NEXT + e$ = "Cannot convert type (" + typ$ + ") to symbol" + t2$ = "_UNSIGNED _BIT": s$ = "~`1": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED _BYTE": s$ = "~%%": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED LONG": s$ = "~&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED _INTEGER64": s$ = "~&&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED INTEGER": s$ = "~%": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED _OFFSET": s$ = "~%&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_BIT": s$ = "`1": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_BYTE": s$ = "%%": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "LONG": s$ = "&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_INTEGER64": s$ = "&&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_OFFSET": s$ = "%&": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "SINGLE": s$ = "!": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "DOUBLE": s$ = "#": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "_FLOAT": s$ = "##": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "STRING": s$ = "$": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED LONG": s$ = "~&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED INTEGER": s$ = "~%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED _BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED _BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED _INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "UNSIGNED _OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED BIT": s$ = "~`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED BYTE": s$ = "~%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED INTEGER64": s$ = "~&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "_UNSIGNED OFFSET": s$ = "~%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "BIT": s$ = "`1": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "BYTE": s$ = "%%": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "INTEGER64": s$ = "&&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "INTEGER": s$ = "%": IF t$ = t2$ THEN GOTO t2sfound + t2$ = "OFFSET": s$ = "%&": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + t2$ = "FLOAT": s$ = "##": IF qb64prefix_set = 1 AND t$ = t2$ THEN GOTO t2sfound + Give_Error e$: EXIT FUNCTION + t2sfound: + type2symbol$ = s$ + IF LEN(t2$) <> LEN(t$) THEN + IF s$ <> "$" AND s$ <> "~`1" AND s$ <> "`1" THEN Give_Error e$: EXIT FUNCTION + t$ = RIGHT$(t$, LEN(t$) - LEN(t2$)) + IF LEFT$(t$, 3) <> " * " THEN Give_Error e$: EXIT FUNCTION + t$ = RIGHT$(t$, LEN(t$) - 3) + IF isuinteger(t$) = 0 THEN Give_Error e$: EXIT FUNCTION + v = VAL(t$) + IF v = 0 THEN Give_Error e$: EXIT FUNCTION + IF s$ <> "$" AND v > 64 THEN Give_Error e$: EXIT FUNCTION + IF s$ = "$" THEN + s$ = s$ + str2$(v) + ELSE + s$ = LEFT$(s$, LEN(s$) - 1) + str2$(v) + END IF + type2symbol$ = s$ + END IF +END FUNCTION + +'Strips away bits/indentifiers which make locating a variables source difficult +FUNCTION typecomp (typ) + typ2 = typ + IF (typ2 AND ISINCONVENTIONALMEMORY) THEN typ2 = typ2 - ISINCONVENTIONALMEMORY + typecomp = typ2 +END FUNCTION + +FUNCTION typname2typ& (t2$) + typname2typsize = 0 'the default + + t$ = t2$ + + 'symbol? + ts$ = t$ + IF ts$ = "$" THEN typname2typ& = STRINGTYPE: EXIT FUNCTION + IF ts$ = "!" THEN typname2typ& = SINGLETYPE: EXIT FUNCTION + IF ts$ = "#" THEN typname2typ& = DOUBLETYPE: EXIT FUNCTION + IF ts$ = "##" THEN typname2typ& = FLOATTYPE: EXIT FUNCTION + + 'fixed length string? + IF LEFT$(ts$, 1) = "$" THEN + n$ = RIGHT$(ts$, LEN(ts$) - 1) + IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after STRING * type": EXIT FUNCTION + b = VAL(n$) + IF b = 0 THEN Give_Error "Invalid index after STRING * type": EXIT FUNCTION + typname2typsize = b + typname2typ& = STRINGTYPE + ISFIXEDLENGTH + EXIT FUNCTION + END IF + + 'unsigned? + IF LEFT$(ts$, 1) = "~" THEN unsgn = 1: ts$ = RIGHT$(ts$, LEN(ts$) - 1) + + 'bit-type? + IF LEFT$(ts$, 1) = "`" THEN + n$ = RIGHT$(ts$, LEN(ts$) - 1) + b = 1 + IF n$ <> "" THEN + IF isuinteger(n$) = 0 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION + b = VAL(n$) + IF b > 64 THEN Give_Error "Invalid index after _BIT type": EXIT FUNCTION + END IF + IF unsgn THEN typname2typ& = UBITTYPE + (b - 1) ELSE typname2typ& = BITTYPE + (b - 1) + EXIT FUNCTION + END IF + + t = 0 + IF ts$ = "%%" THEN t = BYTETYPE + IF ts$ = "%" THEN t = INTEGERTYPE + IF ts$ = "&" THEN t = LONGTYPE + IF ts$ = "&&" THEN t = INTEGER64TYPE + IF ts$ = "%&" THEN t = OFFSETTYPE + + IF t THEN + IF unsgn THEN t = t + ISUNSIGNED + typname2typ& = t: EXIT FUNCTION + END IF + 'not a valid symbol + + 'type name? + FOR i = 1 TO LEN(t$) + IF MID$(t$, i, 1) = sp THEN MID$(t$, i, 1) = " " + NEXT + IF t$ = "STRING" THEN typname2typ& = STRINGTYPE: EXIT FUNCTION + + IF LEFT$(t$, 9) = "STRING * " THEN + + n$ = RIGHT$(t$, LEN(t$) - 9) + + 'constant check 2011 + hashfound = 0 + hashname$ = n$ + hashchkflags = HASHFLAG_CONSTANT + hashres = HashFindRev(hashname$, hashchkflags, hashresflags, hashresref) + DO WHILE hashres + IF constsubfunc(hashresref) = subfuncn OR constsubfunc(hashresref) = 0 THEN + IF constdefined(hashresref) THEN + hashfound = 1 + EXIT DO + END IF + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + IF hashfound THEN + i2 = hashresref + t = consttype(i2) + IF t AND ISSTRING THEN Give_Error "Expected STRING * numeric-constant": EXIT FUNCTION + 'convert value to general formats + IF t AND ISFLOAT THEN + v## = constfloat(i2) + v&& = v## + v~&& = v&& + ELSE + IF t AND ISUNSIGNED THEN + v~&& = constuinteger(i2) + v&& = v~&& + v## = v&& + ELSE + v&& = constinteger(i2) + v## = v&& + v~&& = v&& + END IF + END IF + IF v&& < 1 OR v&& > 9999999999 THEN Give_Error "STRING * out-of-range constant": EXIT FUNCTION + b = v&& + GOTO constantlenstr + END IF + + IF isuinteger(n$) = 0 OR LEN(n$) > 10 THEN Give_Error "Invalid number/constant after STRING * type": EXIT FUNCTION + b = VAL(n$) + IF b = 0 OR LEN(n$) > 10 THEN Give_Error "Invalid number after STRING * type": EXIT FUNCTION + constantlenstr: + typname2typsize = b + typname2typ& = STRINGTYPE + ISFIXEDLENGTH + EXIT FUNCTION + END IF + + IF t$ = "SINGLE" THEN typname2typ& = SINGLETYPE: EXIT FUNCTION + IF t$ = "DOUBLE" THEN typname2typ& = DOUBLETYPE: EXIT FUNCTION + IF t$ = "_FLOAT" OR (t$ = "FLOAT" AND qb64prefix_set = 1) THEN typname2typ& = FLOATTYPE: EXIT FUNCTION + IF LEFT$(t$, 10) = "_UNSIGNED " OR (LEFT$(t$, 9) = "UNSIGNED " AND qb64prefix_set = 1) THEN + u = 1 + t$ = MID$(t$, INSTR(t$, CHR$(32)) + 1) + END IF + IF LEFT$(t$, 4) = "_BIT" OR (LEFT$(t$, 3) = "BIT" AND qb64prefix_set = 1) THEN + IF t$ = "_BIT" OR (t$ = "BIT" AND qb64prefix_set = 1) THEN + IF u THEN typname2typ& = UBITTYPE ELSE typname2typ& = BITTYPE + EXIT FUNCTION + END IF + IF LEFT$(t$, 7) <> "_BIT * " OR (LEFT$(t$, 6) = "BIT * " AND qb64prefix_set = 1) THEN Give_Error "Expected _BIT * number": EXIT FUNCTION + + n$ = RIGHT$(t$, LEN(t$) - 7) + IF isuinteger(n$) = 0 THEN Give_Error "Invalid size after " + qb64prefix$ + "BIT *": EXIT FUNCTION + b = VAL(n$) + IF b = 0 OR b > 64 THEN Give_Error "Invalid size after " + qb64prefix$ + "BIT *": EXIT FUNCTION + t = BITTYPE - 1 + b: IF u THEN t = t + ISUNSIGNED + typname2typ& = t + EXIT FUNCTION + END IF + + t = 0 + IF t$ = "_BYTE" OR (t$ = "BYTE" AND qb64prefix_set = 1) THEN t = BYTETYPE + IF t$ = "INTEGER" THEN t = INTEGERTYPE + IF t$ = "LONG" THEN t = LONGTYPE + IF t$ = "_INTEGER64" OR (t$ = "INTEGER64" AND qb64prefix_set = 1) THEN t = INTEGER64TYPE + IF t$ = "_OFFSET" OR (t$ = "OFFSET" AND qb64prefix_set = 1) THEN t = OFFSETTYPE + IF t THEN + IF u THEN t = t + ISUNSIGNED + typname2typ& = t + EXIT FUNCTION + END IF + IF u THEN EXIT FUNCTION '_UNSIGNED (nothing) + + 'UDT? + FOR i = 1 TO lasttype + IF t$ = RTRIM$(udtxname(i)) THEN + typname2typ& = ISUDT + ISPOINTER + i + EXIT FUNCTION + ELSEIF RTRIM$(udtxname(i)) = "_MEM" AND t$ = "MEM" AND qb64prefix_set = 1 THEN + typname2typ& = ISUDT + ISPOINTER + i + EXIT FUNCTION + END IF + NEXT + + 'return 0 (failed) +END FUNCTION + +FUNCTION uniquenumber& + uniquenumbern = uniquenumbern + 1 + uniquenumber& = uniquenumbern +END FUNCTION + +FUNCTION validlabel (LABEL2$) + create = CreatingLabel: CreatingLabel = 0 + validlabel = 0 + IF LEN(LABEL2$) = 0 THEN EXIT FUNCTION + clabel$ = LABEL2$ + label$ = UCASE$(LABEL2$) + + n = numelements(label$) + + IF n = 1 THEN + + 'Note: Reserved words and internal sub/function names are invalid + hashres = HashFind(label$, HASHFLAG_RESERVED + HASHFLAG_SUB + HASHFLAG_FUNCTION, hashresflags, hashresref) + DO WHILE hashres + IF hashresflags AND (HASHFLAG_SUB + HASHFLAG_FUNCTION) THEN + IF ids(hashresref).internal_subfunc THEN EXIT FUNCTION + + IF hashresflags AND HASHFLAG_SUB THEN 'could be a label or a sub call! + + 'analyze format + IF ASC(ids(hashresref).specialformat) = 32 THEN + IF ids(hashresref).args = 0 THEN onecommandsub = 1 ELSE onecommandsub = 0 + ELSE + IF ASC(ids(hashresref).specialformat) <> 91 THEN '"[" + onecommandsub = 0 + ELSE + onecommandsub = 1 + a$ = RTRIM$(ids(hashresref).specialformat) + b = 1 + FOR x = 2 TO LEN(a$) + a = ASC(a$, x) + IF a = 91 THEN b = b + 1 + IF a = 93 THEN b = b - 1 + IF b = 0 AND x <> LEN(a$) THEN onecommandsub = 0: EXIT FOR + NEXT + END IF + END IF + IF create <> 0 AND onecommandsub = 1 THEN + IF INSTR(SubNameLabels$, sp + UCASE$(label$) + sp) = 0 THEN PossibleSubNameLabels$ = PossibleSubNameLabels$ + UCASE$(label$) + sp: EXIT FUNCTION 'treat as sub call + END IF + + END IF 'sub name + + ELSE + 'reserved + EXIT FUNCTION + END IF + IF hashres <> 1 THEN hashres = HashFindCont(hashresflags, hashresref) ELSE hashres = 0 + LOOP + + 'Numeric label? + 'quasi numbers are possible, but: + 'a) They may only have one decimal place + 'b) They must be typed with the exact same characters to match + t$ = label$ + 'numeric? + a = ASC(t$) + IF (a >= 48 AND a <= 57) OR a = 46 THEN + + 'refer to original formatting if possible (eg. 1.10 not 1.1) + x = INSTR(t$, CHR$(44)) + IF x THEN + t$ = RIGHT$(t$, LEN(t$) - x) + END IF + + 'note: The symbols ! and # are valid trailing symbols in QBASIC, regardless of the number's size, + ' so they are allowed in QB64 for compatibility reasons + addsymbol$ = removesymbol$(t$) + IF Error_Happened THEN EXIT FUNCTION + IF LEN(addsymbol$) THEN + IF INSTR(addsymbol$, "$") THEN EXIT FUNCTION + IF addsymbol$ <> "#" AND addsymbol$ <> "!" THEN addsymbol$ = "" + END IF + + IF a = 46 THEN dp = 1 + FOR x = 2 TO LEN(t$) + a = ASC(MID$(t$, x, 1)) + IF a = 46 THEN dp = dp + 1 + IF (a < 48 OR a > 57) AND a <> 46 THEN EXIT FUNCTION 'not numeric + NEXT x + IF dp > 1 THEN EXIT FUNCTION 'too many decimal points + IF dp = 1 AND LEN(t$) = 1 THEN EXIT FUNCTION 'cant have '.' as a label + + tlayout$ = t$ + addsymbol$ + + i = INSTR(t$, "."): IF i THEN MID$(t$, i, 1) = "p" + IF addsymbol$ = "#" THEN t$ = t$ + "d" + IF addsymbol$ = "!" THEN t$ = t$ + "s" + + IF LEN(t$) > 40 THEN EXIT FUNCTION + + LABEL2$ = t$ + validlabel = 1 + EXIT FUNCTION + END IF 'numeric + + END IF 'n=1 + + 'Alpha-numeric label? + 'Build label + + 'structure check (???.???.???.???) + IF (n AND 1) = 0 THEN EXIT FUNCTION 'must be an odd number of elements + FOR nx = 2 TO n - 1 STEP 2 + a$ = getelement$(LABEL2$, nx) + IF a$ <> "." THEN EXIT FUNCTION 'every 2nd element must be a period + NEXT + + 'cannot begin with numeric + c = ASC(clabel$): IF c >= 48 AND c <= 57 THEN EXIT FUNCTION + + 'elements check + label3$ = "" + FOR nx = 1 TO n STEP 2 + label$ = getelement$(clabel$, nx) + + 'alpha-numeric? + FOR x = 1 TO LEN(label$) + IF alphanumeric(ASC(label$, x)) = 0 THEN EXIT FUNCTION + NEXT + + 'build label + IF label3$ = "" THEN label3$ = UCASE$(label$): tlayout$ = label$ ELSE label3$ = label3$ + fix046$ + UCASE$(label$): tlayout$ = tlayout$ + "." + label$ + NEXT nx + + validlabel = 1 + LABEL2$ = label3$ + +END FUNCTION + +SUB xend + IF vWatchOn = 1 THEN + 'check if closedmain = 0 in case a main module ends in an include. + IF (inclinenumber(inclevel) = 0 OR closedmain = 0) THEN vWatchAddLabel 0, -1 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_global_vars,(ptrszint*)vwatch_local_vars);" + END IF + PRINT #12, "sub_end();" +END SUB + +SUB xfileprint (a$, ca$, n) + u$ = str2$(uniquenumber) + PRINT #12, "tab_spc_cr_size=2;" + IF n = 2 THEN Give_Error "Expected # ... , ...": EXIT SUB + a3$ = "" + b = 0 + FOR i = 3 TO n + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF a2$ = "," AND b = 0 THEN + IF a3$ = "" THEN Give_Error "Expected # ... , ...": EXIT SUB + GOTO printgotfn + END IF + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + NEXT + Give_Error "Expected # ... ,": EXIT SUB + printgotfn: + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN EXIT SUB + l$ = SCase$("Print") + sp + "#" + sp2 + tlayout$ + sp2 + "," + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN EXIT SUB + PRINT #12, "tab_fileno=tmp_fileno=" + e$ + ";" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + i = i + 1 + + 'PRINT USING? (file) + IF n >= i THEN + IF getelement(a$, i) = "USING" THEN + 'get format string + fpujump: + l$ = l$ + sp + SCase$("Using") + e$ = "": b = 0: puformat$ = "" + FOR i = i + 1 TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = "," THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB + IF a2$ = ";" THEN + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + l$ = l$ + sp + tlayout$ + sp2 + ";" + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISSTRING) = 0 THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB + puformat$ = e$ + EXIT FOR + END IF '; + END IF 'b + IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + NEXT + IF puformat$ = "" THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB + IF i = n THEN Give_Error "Expected PRINT USING #filenumber, formatstring ; ...": EXIT SUB + 'create build string + PRINT #12, "tqbs=qbs_new(0,0);" + 'set format start/index variable + PRINT #12, "tmp_long=0;" 'scan format from beginning + 'create string to hold format in for multiple references + puf$ = "print_using_format" + u$ + IF subfunc = "" THEN + PRINT #13, "static qbs *" + puf$ + ";" + ELSE + PRINT #13, "qbs *" + puf$ + ";" + END IF + PRINT #12, puf$ + "=qbs_new(0,0); qbs_set(" + puf$ + "," + puformat$ + ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + 'print expressions + b = 0 + e$ = "" + last = 0 + FOR i = i + 1 TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = ";" OR a2$ = "," THEN + fprintulast: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + IF typ AND ISSTRING THEN + + IF LEFT$(e$, 9) = "func_tab(" OR LEFT$(e$, 9) = "func_spc(" THEN + + 'TAB/SPC exception + 'note: position in format-string must be maintained + '-print any string up until now + PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0,0);" + '-print e$ + PRINT #12, "qbs_set(tqbs," + e$ + ");" + PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" + PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0,0);" + '-set length of tqbs to 0 + PRINT #12, "tqbs->len=0;" + + ELSE + + 'regular string + PRINT #12, "tmp_long=print_using(" + puf$ + ",tmp_long,tqbs," + e$ + ");" + + END IF + + ELSE 'not a string + IF typ AND ISFLOAT THEN + IF (typ AND 511) = 32 THEN PRINT #12, "tmp_long=print_using_single(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + IF (typ AND 511) = 64 THEN PRINT #12, "tmp_long=print_using_double(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + IF (typ AND 511) > 64 THEN PRINT #12, "tmp_long=print_using_float(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + ELSE + IF ((typ AND 511) = 64) AND (typ AND ISUNSIGNED) <> 0 THEN + PRINT #12, "tmp_long=print_using_uinteger64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + ELSE + PRINT #12, "tmp_long=print_using_integer64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + END IF + END IF + END IF 'string/not string + PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" + e$ = "" + IF last THEN EXIT FOR + GOTO fprintunext + END IF + END IF + IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + fprintunext: + NEXT + IF e$ <> "" THEN a2$ = "": last = 1: GOTO fprintulast + PRINT #12, "skip_pu" + u$ + ":" + 'check for errors + PRINT #12, "if (new_error){" + PRINT #12, "g_tmp_long=new_error; new_error=0; sub_file_print(tmp_fileno,tqbs,0,0,0); new_error=g_tmp_long;" + PRINT #12, "}else{" + IF a2$ = "," OR a2$ = ";" THEN nl = 0 ELSE nl = 1 'note: a2$ is set to the last element of a$ + PRINT #12, "sub_file_print(tmp_fileno,tqbs,0,0," + str2$(nl) + ");" + PRINT #12, "}" + PRINT #12, "qbs_free(tqbs);" + PRINT #12, "qbs_free(" + puf$ + ");" + PRINT #12, "skip" + u$ + ":" + PRINT #12, cleanupstringprocessingcall$ + "0);" + PRINT #12, "tab_spc_cr_size=1;" + tlayout$ = l$ + EXIT SUB + END IF + END IF + 'end of print using code + + IF i > n THEN + PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,0,1);" + GOTO printblankline + END IF + b = 0 + e$ = "" + last = 0 + FOR i = i TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = ";" OR a2$ = "," OR UCASE$(a2$) = "USING" THEN + printfilelast: + + IF UCASE$(a2$) = "USING" THEN + IF e$ <> "" THEN gotofpu = 1 ELSE GOTO fpujump + END IF + + IF a2$ = "," THEN usetab = 1 ELSE usetab = 0 + IF last = 1 THEN newline = 1 ELSE newline = 0 + extraspace = 0 + + IF LEN(e$) THEN + ebak$ = e$ + pnrtnum = 0 + printfilenumber: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF pnrtnum = 0 THEN + IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ + END IF + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISSTRING) = 0 THEN + e$ = "STR$" + sp + "(" + sp + ebak$ + sp + ")" + extraspace = 1 + pnrtnum = 1 + GOTO printfilenumber 'force re-evaluation + END IF + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line + PRINT #12, "sub_file_print(tmp_fileno," + e$ + ","; extraspace; ","; usetab; ","; newline; ");" + ELSE 'len(e$)=0 + IF a2$ = "," THEN l$ = l$ + sp + a2$ + IF a2$ = ";" THEN + IF RIGHT$(l$, 1) <> ";" THEN l$ = l$ + sp + a2$ 'concat ;; to ; + END IF + IF usetab THEN PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,1,0);" + END IF 'len(e$) + PRINT #12, "if (new_error) goto skip" + u$ + ";" + + e$ = "" + IF gotofpu THEN GOTO fpujump + IF last THEN EXIT FOR + GOTO printfilenext + END IF ', or ; + END IF 'b=0 + IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + printfilenext: + NEXT + IF e$ <> "" THEN a2$ = "": last = 1: GOTO printfilelast + printblankline: + PRINT #12, "skip" + u$ + ":" + PRINT #12, cleanupstringprocessingcall$ + "0);" + PRINT #12, "tab_spc_cr_size=1;" + tlayout$ = l$ +END SUB + +SUB xfilewrite (ca$, n) + l$ = SCase$("Write") + sp + "#" + u$ = str2$(uniquenumber) + PRINT #12, "tab_spc_cr_size=2;" + IF n = 2 THEN Give_Error "Expected # ...": EXIT SUB + a3$ = "" + b = 0 + FOR i = 3 TO n + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF a2$ = "," AND b = 0 THEN + IF a3$ = "" THEN Give_Error "Expected # ... , ...": EXIT SUB + GOTO writegotfn + END IF + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + NEXT + Give_Error "Expected # ... ,": EXIT SUB + writegotfn: + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN EXIT SUB + l$ = l$ + sp2 + tlayout$ + sp2 + "," + e$ = evaluatetotyp(e$, 64&) + IF Error_Happened THEN EXIT SUB + PRINT #12, "tab_fileno=tmp_fileno=" + e$ + ";" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + i = i + 1 + IF i > n THEN + PRINT #12, "sub_file_print(tmp_fileno,nothingstring,0,0,1);" + GOTO writeblankline + END IF + b = 0 + e$ = "" + last = 0 + FOR i = i TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = "," THEN + writefilelast: + IF last = 1 THEN newline = 1 ELSE newline = 0 + ebak$ = e$ + reevaled = 0 + writefilenumber: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF reevaled = 0 THEN + l$ = l$ + sp + tlayout$ + IF last = 0 THEN l$ = l$ + sp2 + "," + END IF + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF reevaled = 0 THEN + IF (typ AND ISSTRING) = 0 THEN + e$ = "LTRIM$" + sp + "(" + sp + "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + ")" + IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" + reevaled = 1 + GOTO writefilenumber 'force re-evaluation + ELSE + e$ = CHR$(34) + "\042" + CHR$(34) + ",1" + sp + "+" + sp + ebak$ + sp + "+" + sp + CHR$(34) + "\042" + CHR$(34) + ",1" + IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" + reevaled = 1 + GOTO writefilenumber 'force re-evaluation + END IF + END IF + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line + PRINT #12, "sub_file_print(tmp_fileno," + e$ + ",0,0,"; newline; ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + e$ = "" + IF last THEN EXIT FOR + GOTO writefilenext + END IF ', + END IF 'b=0 + IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + writefilenext: + NEXT + IF e$ <> "" THEN a2$ = ",": last = 1: GOTO writefilelast + writeblankline: + 'print #12, "}"'new_error + PRINT #12, "skip" + u$ + ":" + PRINT #12, cleanupstringprocessingcall$ + "0);" + PRINT #12, "tab_spc_cr_size=1;" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ +END SUB + +SUB xgosub (ca$) + a2$ = getelement(ca$, 2) + IF validlabel(a2$) = 0 THEN Give_Error "Invalid label": EXIT SUB + + v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk200: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk200 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd a2$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + Labels(r).Error_Line = linenumber + END IF 'x + + l$ = SCase$("GoSub") + sp + tlayout$ + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + 'note: This code fragment also used by ON ... GOTO/GOSUB + 'assume label is reachable (revise) + PRINT #12, "return_point[next_return_point++]=" + str2(gosubid) + ";" + PRINT #12, "if (next_return_point>=return_points) more_return_points();" + PRINT #12, "goto LABEL_" + a2$ + ";" + 'add return point jump + PRINT #15, "case " + str2(gosubid) + ":" + PRINT #15, "goto RETURN_" + str2(gosubid) + ";" + PRINT #15, "break;" + PRINT #12, "RETURN_" + str2(gosubid) + ":;" + gosubid = gosubid + 1 +END SUB + +SUB xongotogosub (a$, ca$, n) + IF n < 4 THEN Give_Error "Expected ON expression GOTO/GOSUB label,label,...": EXIT SUB + l$ = SCase$("On") + b = 0 + FOR i = 2 TO n + e2$ = getelement$(a$, i) + IF e2$ = "(" THEN b = b + 1 + IF e2$ = ")" THEN b = b - 1 + IF e2$ = "GOTO" OR e2$ = "GOSUB" THEN EXIT FOR + NEXT + IF i >= n OR i = 2 THEN Give_Error "Expected ON expression GOTO/GOSUB label,label,...": EXIT SUB + e$ = getelements$(ca$, 2, i - 1) + + g = 0: IF e2$ = "GOSUB" THEN g = 1 + e$ = fixoperationorder(e$) + IF Error_Happened THEN EXIT SUB + l$ = l$ + sp + tlayout$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISSTRING) THEN Give_Error "Expected numeric expression": EXIT SUB + IF (typ AND ISFLOAT) THEN + e$ = "qbr_float_to_long(" + e$ + ")" + END IF + l$ = l$ + sp + e2$ + u$ = str2$(uniquenumber) + PRINT #13, "static int32 ongo_" + u$ + "=0;" + PRINT #12, "ongo_" + u$ + "=" + e$ + ";" + ln = 1 + labelwaslast = 0 + FOR i = i + 1 TO n + e$ = getelement$(ca$, i) + IF e$ = "," THEN + l$ = l$ + sp2 + "," + IF i = n THEN Give_Error "Trailing , invalid": EXIT SUB + ln = ln + 1 + labelwaslast = 0 + ELSE + IF labelwaslast THEN Give_Error "Expected ,": EXIT SUB + IF validlabel(e$) = 0 THEN Give_Error "Invalid label!": EXIT SUB + + v = HashFind(e$, HASHFLAG_LABEL, ignore, r) + x = 1 + labchk507: + IF v THEN + s = Labels(r).Scope + IF s = subfuncn OR s = -1 THEN 'same scope? + IF s = -1 THEN Labels(r).Scope = subfuncn 'acquire scope + x = 0 'already defined + tlayout$ = RTRIM$(Labels(r).cn) + ELSE + IF v = 2 THEN v = HashFindCont(ignore, r): GOTO labchk507 + END IF + END IF + IF x THEN + 'does not exist + nLabels = nLabels + 1: IF nLabels > Labels_Ubound THEN Labels_Ubound = Labels_Ubound * 2: REDIM _PRESERVE Labels(1 TO Labels_Ubound) AS Label_Type + Labels(nLabels) = Empty_Label + HashAdd e$, HASHFLAG_LABEL, nLabels + r = nLabels + Labels(r).State = 0 + Labels(r).cn = tlayout$ + Labels(r).Scope = subfuncn + Labels(r).Error_Line = linenumber + END IF 'x + + l$ = l$ + sp + tlayout$ + IF g THEN 'gosub + lb$ = e$ + PRINT #12, "if (ongo_" + u$ + "==" + str2$(ln) + "){" + 'note: This code fragment also used by ON ... GOTO/GOSUB + 'assume label is reachable (revise) + PRINT #12, "return_point[next_return_point++]=" + str2(gosubid) + ";" + PRINT #12, "if (next_return_point>=return_points) more_return_points();" + PRINT #12, "goto LABEL_" + lb$ + ";" + 'add return point jump + PRINT #15, "case " + str2(gosubid) + ":" + PRINT #15, "goto RETURN_" + str2(gosubid) + ";" + PRINT #15, "break;" + PRINT #12, "RETURN_" + str2(gosubid) + ":;" + gosubid = gosubid + 1 + PRINT #12, "goto ongo_" + u$ + "_skip;" + PRINT #12, "}" + ELSE 'goto + PRINT #12, "if (ongo_" + u$ + "==" + str2$(ln) + ") goto LABEL_" + e$ + ";" + END IF + labelwaslast = 1 + END IF + NEXT + PRINT #12, "if (ongo_" + u$ + "<0) error(5);" + IF g = 1 THEN PRINT #12, "ongo_" + u$ + "_skip:;" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ +END SUB + +SUB xprint (a$, ca$, n) + u$ = str2$(uniquenumber) + + l$ = SCase$("Print") + IF ASC(a$) = 76 THEN lp = 1: lp$ = "l": l$ = SCase$("LPrint"): PRINT #12, "tab_LPRINT=1;": DEPENDENCY(DEPENDENCY_PRINTER) = 1 '"L" + + 'PRINT USING? + IF n >= 2 THEN + IF getelement(a$, 2) = "USING" THEN + 'get format string + i = 3 + pujump: + l$ = l$ + sp + SCase$("Using") + e$ = "": b = 0: puformat$ = "" + FOR i = i TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = "," THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB + IF a2$ = ";" THEN + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + l$ = l$ + sp + tlayout$ + sp2 + ";" + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISSTRING) = 0 THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB + puformat$ = e$ + EXIT FOR + END IF '; + END IF 'b + IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + NEXT + IF puformat$ = "" THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB + IF i = n THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB + 'create build string + IF TQBSset = 0 THEN + PRINT #12, "tqbs=qbs_new(0,0);" + ELSE + PRINT #12, "qbs_set(tqbs,qbs_new_txt_len(" + CHR$(34) + CHR$(34) + ",0));" + END IF + 'set format start/index variable + PRINT #12, "tmp_long=0;" 'scan format from beginning + + + 'create string to hold format in for multiple references + puf$ = "print_using_format" + u$ + IF subfunc = "" THEN + PRINT #13, "static qbs *" + puf$ + ";" + ELSE + PRINT #13, "qbs *" + puf$ + ";" + END IF + PRINT #12, puf$ + "=qbs_new(0,0); qbs_set(" + puf$ + "," + puformat$ + ");" + PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" + + 'print expressions + b = 0 + e$ = "" + last = 0 + FOR i = i + 1 TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = ";" OR a2$ = "," THEN + printulast: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + IF typ AND ISSTRING THEN + + IF LEFT$(e$, 9) = "func_tab(" OR LEFT$(e$, 9) = "func_spc(" THEN + + 'TAB/SPC exception + 'note: position in format-string must be maintained + '-print any string up until now + PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" + '-print e$ + PRINT #12, "qbs_set(tqbs," + e$ + ");" + PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" + IF lp THEN PRINT #12, "lprint_makefit(tqbs);" ELSE PRINT #12, "makefit(tqbs);" + PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" + '-set length of tqbs to 0 + PRINT #12, "tqbs->len=0;" + + ELSE + + 'regular string + PRINT #12, "tmp_long=print_using(" + puf$ + ",tmp_long,tqbs," + e$ + ");" + + END IF + + + + ELSE 'not a string + IF typ AND ISFLOAT THEN + IF (typ AND 511) = 32 THEN PRINT #12, "tmp_long=print_using_single(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + IF (typ AND 511) = 64 THEN PRINT #12, "tmp_long=print_using_double(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + IF (typ AND 511) > 64 THEN PRINT #12, "tmp_long=print_using_float(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + ELSE + IF ((typ AND 511) = 64) AND (typ AND ISUNSIGNED) <> 0 THEN + PRINT #12, "tmp_long=print_using_uinteger64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + ELSE + PRINT #12, "tmp_long=print_using_integer64(" + puf$ + "," + e$ + ",tmp_long,tqbs);" + END IF + END IF + END IF 'string/not string + PRINT #12, "if (new_error) goto skip_pu" + u$ + ";" + e$ = "" + IF last THEN EXIT FOR + GOTO printunext + END IF + END IF + IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + printunext: + NEXT + IF e$ <> "" THEN a2$ = "": last = 1: GOTO printulast + PRINT #12, "skip_pu" + u$ + ":" + 'check for errors + PRINT #12, "if (new_error){" + PRINT #12, "g_tmp_long=new_error; new_error=0; qbs_" + lp$ + "print(tqbs,0); new_error=g_tmp_long;" + PRINT #12, "}else{" + IF a2$ = "," OR a2$ = ";" THEN nl = 0 ELSE nl = 1 'note: a2$ is set to the last element of a$ + PRINT #12, "qbs_" + lp$ + "print(tqbs," + str2$(nl) + ");" + PRINT #12, "}" + PRINT #12, "qbs_free(tqbs);" + PRINT #12, "qbs_free(" + puf$ + ");" + PRINT #12, "skip" + u$ + ":" + PRINT #12, cleanupstringprocessingcall$ + "0);" + IF lp THEN PRINT #12, "tab_LPRINT=0;" + tlayout$ = l$ + EXIT SUB + END IF + END IF + 'end of print using code + + b = 0 + e$ = "" + last = 0 + PRINT #12, "tqbs=qbs_new(0,0);" 'initialize the temp string + TQBSset = -1 'set the temporary flag so we don't create a temp string twice, in case USING comes after something + FOR i = 2 TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = ";" OR a2$ = "," OR UCASE$(a2$) = "USING" THEN + printlast: + + IF UCASE$(a2$) = "USING" THEN + IF e$ <> "" THEN gotopu = 1 ELSE i = i + 1: GOTO pujump + END IF + + IF LEN(e$) THEN + ebak$ = e$ + pnrtnum = 0 + printnumber: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF pnrtnum = 0 THEN + IF last THEN l$ = l$ + sp + tlayout$ ELSE l$ = l$ + sp + tlayout$ + sp2 + a2$ + END IF + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF (typ AND ISSTRING) = 0 THEN + 'not a string expresion! + e$ = "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + "+" + sp + CHR$(34) + " " + CHR$(34) + pnrtnum = 1 + GOTO printnumber + END IF + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + PRINT #12, "qbs_set(tqbs," + e$ + ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + IF lp THEN PRINT #12, "lprint_makefit(tqbs);" ELSE PRINT #12, "makefit(tqbs);" + PRINT #12, "qbs_" + lp$ + "print(tqbs,0);" + ELSE + IF a2$ = "," THEN l$ = l$ + sp + a2$ + IF a2$ = ";" THEN + IF RIGHT$(l$, 1) <> ";" THEN l$ = l$ + sp + a2$ 'concat ;; to ; + END IF + END IF 'len(e$) + IF a2$ = "," THEN PRINT #12, "tab();" + e$ = "" + + IF gotopu THEN i = i + 1: GOTO pujump + + IF last THEN + PRINT #12, "qbs_" + lp$ + "print(nothingstring,1);" 'go to new line + EXIT FOR + END IF + + GOTO printnext + END IF 'a2$ + END IF 'b=0 + + IF LEN(e$) THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + printnext: + NEXT + IF LEN(e$) THEN a2$ = "": last = 1: GOTO printlast + IF n = 1 THEN PRINT #12, "qbs_" + lp$ + "print(nothingstring,1);" + PRINT #12, "skip" + u$ + ":" + PRINT #12, "qbs_free(tqbs);" + PRINT #12, cleanupstringprocessingcall$ + "0);" + IF lp THEN PRINT #12, "tab_LPRINT=0;" + tlayout$ = l$ +END SUB + + + + +SUB xread (ca$, n) + l$ = SCase$("Read") + IF n = 1 THEN Give_Error "Expected variable": EXIT SUB + i = 2 + IF i > n THEN Give_Error "Expected , ...": EXIT SUB + a3$ = "" + b = 0 + FOR i = i TO n + a2$ = getelement$(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF (a2$ = "," AND b = 0) OR i = n THEN + IF i = n THEN + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + END IF + IF a3$ = "" THEN Give_Error "Expected , ...": EXIT SUB + e$ = fixoperationorder$(a3$) + IF Error_Happened THEN EXIT SUB + l$ = l$ + sp + tlayout$: IF i <> n THEN l$ = l$ + sp2 + "," + e$ = evaluate(e$, t) + IF Error_Happened THEN EXIT SUB + IF (t AND ISREFERENCE) = 0 THEN Give_Error "Expected variable": EXIT SUB + + IF (t AND ISSTRING) THEN + e$ = refer(e$, t, 0) + IF Error_Happened THEN EXIT SUB + PRINT #12, "sub_read_string(data,&data_offset,data_size," + e$ + ");" + stringprocessinghappened = 1 + ELSE + 'numeric variable + IF (t AND ISFLOAT) <> 0 OR (t AND 511) <> 64 THEN + IF (t AND ISOFFSETINBITS) THEN + setrefer e$, t, "((int64)func_read_float(data,&data_offset,data_size," + str2(t) + "))", 1 + IF Error_Happened THEN EXIT SUB + ELSE + setrefer e$, t, "func_read_float(data,&data_offset,data_size," + str2(t) + ")", 1 + IF Error_Happened THEN EXIT SUB + END IF + ELSE + IF t AND ISUNSIGNED THEN + setrefer e$, t, "func_read_uint64(data,&data_offset,data_size)", 1 + IF Error_Happened THEN EXIT SUB + ELSE + setrefer e$, t, "func_read_int64(data,&data_offset,data_size)", 1 + IF Error_Happened THEN EXIT SUB + END IF + END IF + END IF 'string/numeric + IF i = n THEN EXIT FOR + a3$ = "": a2$ = "" + END IF + IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ + NEXT + IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ +END SUB + +SUB xwrite (ca$, n) + l$ = SCase$("Write") + u$ = str2$(uniquenumber) + IF n = 1 THEN + PRINT #12, "qbs_print(nothingstring,1);" + GOTO writeblankline2 + END IF + b = 0 + e$ = "" + last = 0 + FOR i = 2 TO n + a2$ = getelement(ca$, i) + IF a2$ = "(" THEN b = b + 1 + IF a2$ = ")" THEN b = b - 1 + IF b = 0 THEN + IF a2$ = "," THEN + writelast: + IF last = 1 THEN newline = 1 ELSE newline = 0 + ebak$ = e$ + reevaled = 0 + writechecked: + e$ = fixoperationorder$(e$) + IF Error_Happened THEN EXIT SUB + IF reevaled = 0 THEN + l$ = l$ + sp + tlayout$ + IF last = 0 THEN l$ = l$ + sp2 + "," + END IF + e$ = evaluate(e$, typ) + IF Error_Happened THEN EXIT SUB + IF reevaled = 0 THEN + IF (typ AND ISSTRING) = 0 THEN + e$ = "LTRIM$" + sp + "(" + sp + "STR$" + sp + "(" + sp + ebak$ + sp + ")" + sp + ")" + IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" + reevaled = 1 + GOTO writechecked 'force re-evaluation + ELSE + e$ = CHR$(34) + "\042" + CHR$(34) + ",1" + sp + "+" + sp + ebak$ + sp + "+" + sp + CHR$(34) + "\042" + CHR$(34) + ",1" + IF last = 0 THEN e$ = e$ + sp + "+" + sp + CHR$(34) + "," + CHR$(34) + ",1" + reevaled = 1 + GOTO writechecked 'force re-evaluation + END IF + END IF + IF (typ AND ISREFERENCE) THEN e$ = refer(e$, typ, 0) + IF Error_Happened THEN EXIT SUB + 'format: string, (1/0) extraspace, (1/0) tab, (1/0)begin a new line + PRINT #12, "qbs_print(" + e$ + ","; newline; ");" + PRINT #12, "if (new_error) goto skip" + u$ + ";" + e$ = "" + IF last THEN EXIT FOR + GOTO writenext + END IF ', + END IF 'b=0 + IF e$ <> "" THEN e$ = e$ + sp + a2$ ELSE e$ = a2$ + writenext: + NEXT + IF e$ <> "" THEN a2$ = ",": last = 1: GOTO writelast + writeblankline2: + PRINT #12, "skip" + u$ + ":" + PRINT #12, cleanupstringprocessingcall$ + "0);" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ +END SUB + +FUNCTION evaluateconst$ (a2$, t AS LONG) + a$ = a2$ + IF Debug THEN PRINT #9, "evaluateconst:in:" + a$ + + + DIM block(1000) AS STRING + DIM status(1000) AS INTEGER + '0=unprocessed (can be "") + '1=processed + DIM btype(1000) AS LONG 'for status=1 blocks + + 'put a$ into blocks + n = numelements(a$) + FOR i = 1 TO n + block(i) = getelement$(a$, i) + NEXT + + evalconstevalbrack: + + 'find highest bracket level + l = 0 + b = 0 + FOR i = 1 TO n + IF block(i) = "(" THEN b = b + 1 + IF block(i) = ")" THEN b = b - 1 + IF b > l THEN l = b + NEXT + + 'if brackets exist, evaluate that item first + IF l THEN + + b = 0 + e$ = "" + FOR i = 1 TO n + + IF block(i) = ")" THEN + IF b = l THEN block(i) = "": EXIT FOR + b = b - 1 + END IF + + IF b >= l THEN + IF LEN(e$) = 0 THEN e$ = block(i) ELSE e$ = e$ + sp + block(i) + block(i) = "" + END IF + + IF block(i) = "(" THEN + b = b + 1 + IF b = l THEN i2 = i: block(i) = "" + END IF + + NEXT i + + status(i) = 1 + block(i) = evaluateconst$(e$, btype(i)) + IF Error_Happened THEN EXIT FUNCTION + GOTO evalconstevalbrack + + END IF 'l + + 'linear equation remains with some pre-calculated & non-pre-calc blocks + + 'problem: type QBASIC assumes and type required to store calc. value may + ' differ dramatically. in qbasic, this would have caused an overflow, + ' but in qb64 it MUST work. eg. 32767% * 32767% + 'solution: all interger calc. will be performed using a signed _INTEGER64 + ' all float calc. will be performed using a _FLOAT + + 'convert non-calc block numbers into binary form with QBASIC-like type + FOR i = 1 TO n + IF status(i) = 0 THEN + IF LEN(block(i)) THEN + + a = ASC(block(i)) + IF (a = 45 AND LEN(block(i)) > 1) OR (a >= 48 AND a <= 57) THEN 'number? + + 'integers + e$ = RIGHT$(block(i), 3) + IF e$ = "~&&" THEN btype(i) = UINTEGER64TYPE - ISPOINTER: GOTO gotconstblkityp + IF e$ = "~%%" THEN btype(i) = UBYTETYPE - ISPOINTER: GOTO gotconstblkityp + e$ = RIGHT$(block(i), 2) + IF e$ = "&&" THEN btype(i) = INTEGER64TYPE - ISPOINTER: GOTO gotconstblkityp + IF e$ = "%%" THEN btype(i) = BYTETYPE - ISPOINTER: GOTO gotconstblkityp + IF e$ = "~%" THEN btype(i) = UINTEGERTYPE - ISPOINTER: GOTO gotconstblkityp + IF e$ = "~&" THEN btype(i) = ULONGTYPE - ISPOINTER: GOTO gotconstblkityp + e$ = RIGHT$(block(i), 1) + IF e$ = "%" THEN btype(i) = INTEGERTYPE - ISPOINTER: GOTO gotconstblkityp + IF e$ = "&" THEN btype(i) = LONGTYPE - ISPOINTER: GOTO gotconstblkityp + + 'ubit-type? + IF INSTR(block(i), "~`") THEN + x = INSTR(block(i), "~`") + IF x = LEN(block(i)) - 1 THEN block(i) = block(i) + "1" + btype(i) = UBITTYPE - ISPOINTER - 1 + VAL(RIGHT$(block(i), LEN(block(i)) - x - 1)) + block(i) = _MK$(_INTEGER64, VAL(LEFT$(block(i), x - 1))) + status(i) = 1 + GOTO gotconstblktyp + END IF + + 'bit-type? + IF INSTR(block(i), "`") THEN + x = INSTR(block(i), "`") + IF x = LEN(block(i)) THEN block(i) = block(i) + "1" + btype(i) = BITTYPE - ISPOINTER - 1 + VAL(RIGHT$(block(i), LEN(block(i)) - x)) + block(i) = _MK$(_INTEGER64, VAL(LEFT$(block(i), x - 1))) + status(i) = 1 + GOTO gotconstblktyp + END IF + + 'floats + IF INSTR(block(i), "E") THEN + block(i) = _MK$(_FLOAT, VAL(block(i))) + btype(i) = SINGLETYPE - ISPOINTER + status(i) = 1 + GOTO gotconstblktyp + END IF + IF INSTR(block(i), "D") THEN + block(i) = _MK$(_FLOAT, VAL(block(i))) + btype(i) = DOUBLETYPE - ISPOINTER + status(i) = 1 + GOTO gotconstblktyp + END IF + IF INSTR(block(i), "F") THEN + block(i) = _MK$(_FLOAT, VAL(block(i))) + btype(i) = FLOATTYPE - ISPOINTER + status(i) = 1 + GOTO gotconstblktyp + END IF + + Give_Error "Invalid CONST expression.1": EXIT FUNCTION + + gotconstblkityp: + block(i) = LEFT$(block(i), LEN(block(i)) - LEN(e$)) + block(i) = _MK$(_INTEGER64, VAL(block(i))) + status(i) = 1 + gotconstblktyp: + + END IF 'a + + IF a = 34 THEN 'string? + 'no changes need to be made to block(i) which is of format "CHARACTERS",size + btype(i) = STRINGTYPE - ISPOINTER + status(i) = 1 + END IF + + END IF 'len<>0 + END IF 'status + NEXT + + 'remove NULL blocks + n2 = 0 + FOR i = 1 TO n + IF block(i) <> "" THEN + n2 = n2 + 1 + block(n2) = block(i) + status(n2) = status(i) + btype(n2) = btype(i) + END IF + NEXT + n = n2 + + 'only one block? + IF n = 1 THEN + IF status(1) = 0 THEN Give_Error "Invalid CONST expression.2": EXIT FUNCTION + t = btype(1) + evaluateconst$ = block(1) + EXIT FUNCTION + END IF 'n=1 + + 'evaluate equation (equation cannot contain any STRINGs) + + '[negation/not][variable] + e$ = block(1) + IF status(1) = 0 THEN + IF n <> 2 THEN Give_Error "Invalid CONST expression.4": EXIT FUNCTION + IF status(2) = 0 THEN Give_Error "Invalid CONST expression.5": EXIT FUNCTION + IF btype(2) AND ISSTRING THEN Give_Error "Invalid CONST expression.6": EXIT FUNCTION + o$ = block(1) + + IF o$ = CHR$(241) THEN + IF btype(2) AND ISFLOAT THEN + r## = -_CV(_FLOAT, block(2)) + evaluateconst$ = _MK$(_FLOAT, r##) + ELSE + r&& = -_CV(_INTEGER64, block(2)) + evaluateconst$ = _MK$(_INTEGER64, r&&) + END IF + t = btype(2) + EXIT FUNCTION + END IF + + IF UCASE$(o$) = "NOT" THEN + IF btype(2) AND ISFLOAT THEN + r&& = _CV(_FLOAT, block(2)) + ELSE + r&& = _CV(_INTEGER64, block(2)) + END IF + r&& = NOT r&& + t = btype(2) + IF t AND ISFLOAT THEN t = LONGTYPE - ISPOINTER 'markdown to LONG + evaluateconst$ = _MK$(_INTEGER64, r&&) + EXIT FUNCTION + END IF + + Give_Error "Invalid CONST expression.7": EXIT FUNCTION + END IF + + '[variable][bool-operator][variable]... + + 'get first variable + et = btype(1) + ev$ = block(1) + + i = 2 + + evalconstequ: + + 'get operator + IF i >= n THEN Give_Error "Invalid CONST expression.8": EXIT FUNCTION + o$ = UCASE$(block(i)) + i = i + 1 + IF isoperator(o$) = 0 THEN Give_Error "Invalid CONST expression.9": EXIT FUNCTION + IF i > n THEN Give_Error "Invalid CONST expression.10": EXIT FUNCTION + + 'string/numeric mismatch? + IF (btype(i) AND ISSTRING) <> (et AND ISSTRING) THEN Give_Error "Invalid CONST expression.11": EXIT FUNCTION + + IF et AND ISSTRING THEN + IF o$ <> "+" THEN Give_Error "Invalid CONST expression.12": EXIT FUNCTION + 'concat strings + s1$ = RIGHT$(ev$, LEN(ev$) - 1) + s1$ = LEFT$(s1$, INSTR(s1$, CHR$(34)) - 1) + s1size = VAL(RIGHT$(ev$, LEN(ev$) - LEN(s1$) - 3)) + s2$ = RIGHT$(block(i), LEN(block(i)) - 1) + s2$ = LEFT$(s2$, INSTR(s2$, CHR$(34)) - 1) + s2size = VAL(RIGHT$(block(i), LEN(block(i)) - LEN(s2$) - 3)) + ev$ = CHR$(34) + s1$ + s2$ + CHR$(34) + "," + str2$(s1size + s2size) + GOTO econstmarkedup + END IF + + 'prepare left and right values + IF et AND ISFLOAT THEN + linteger = 0 + l## = _CV(_FLOAT, ev$) + l&& = l## + ELSE + linteger = 1 + l&& = _CV(_INTEGER64, ev$) + l## = l&& + END IF + IF btype(i) AND ISFLOAT THEN + rinteger = 0 + r## = _CV(_FLOAT, block(i)) + r&& = r## + ELSE + rinteger = 1 + r&& = _CV(_INTEGER64, block(i)) + r## = r&& + END IF + + IF linteger = 1 AND rinteger = 1 THEN + IF o$ = "+" THEN r&& = l&& + r&&: GOTO econstmarkupi + IF o$ = "-" THEN r&& = l&& - r&&: GOTO econstmarkupi + IF o$ = "*" THEN r&& = l&& * r&&: GOTO econstmarkupi + IF o$ = "^" THEN r## = l&& ^ r&&: GOTO econstmarkupf + IF o$ = "/" THEN r## = l&& / r&&: GOTO econstmarkupf + IF o$ = "\" THEN r&& = l&& \ r&&: GOTO econstmarkupi + IF o$ = "MOD" THEN r&& = l&& MOD r&&: GOTO econstmarkupi + IF o$ = "=" THEN r&& = l&& = r&&: GOTO econstmarkupi16 + IF o$ = ">" THEN r&& = l&& > r&&: GOTO econstmarkupi16 + IF o$ = "<" THEN r&& = l&& < r&&: GOTO econstmarkupi16 + IF o$ = ">=" THEN r&& = l&& >= r&&: GOTO econstmarkupi16 + IF o$ = "<=" THEN r&& = l&& <= r&&: GOTO econstmarkupi16 + IF o$ = "<>" THEN r&& = l&& <> r&&: GOTO econstmarkupi16 + IF o$ = "IMP" THEN r&& = l&& IMP r&&: GOTO econstmarkupi + IF o$ = "EQV" THEN r&& = l&& EQV r&&: GOTO econstmarkupi + IF o$ = "XOR" THEN r&& = l&& XOR r&&: GOTO econstmarkupi + IF o$ = "OR" THEN r&& = l&& OR r&&: GOTO econstmarkupi + IF o$ = "AND" THEN r&& = l&& AND r&&: GOTO econstmarkupi + END IF + + IF o$ = "+" THEN r## = l## + r##: GOTO econstmarkupf + IF o$ = "-" THEN r## = l## - r##: GOTO econstmarkupf + IF o$ = "*" THEN r## = l## * r##: GOTO econstmarkupf + IF o$ = "^" THEN r## = l## ^ r##: GOTO econstmarkupf + IF o$ = "/" THEN r## = l## / r##: GOTO econstmarkupf + IF o$ = "\" THEN r&& = l## \ r##: GOTO econstmarkupi32 + IF o$ = "MOD" THEN r&& = l## MOD r##: GOTO econstmarkupi32 + IF o$ = "=" THEN r&& = l## = r##: GOTO econstmarkupi16 + IF o$ = ">" THEN r&& = l## > r##: GOTO econstmarkupi16 + IF o$ = "<" THEN r&& = l## < r##: GOTO econstmarkupi16 + IF o$ = ">=" THEN r&& = l## >= r##: GOTO econstmarkupi16 + IF o$ = "<=" THEN r&& = l## <= r##: GOTO econstmarkupi16 + IF o$ = "<>" THEN r&& = l## <> r##: GOTO econstmarkupi16 + IF o$ = "IMP" THEN r&& = l## IMP r##: GOTO econstmarkupi32 + IF o$ = "EQV" THEN r&& = l## EQV r##: GOTO econstmarkupi32 + IF o$ = "XOR" THEN r&& = l## XOR r##: GOTO econstmarkupi32 + IF o$ = "OR" THEN r&& = l## OR r##: GOTO econstmarkupi32 + IF o$ = "AND" THEN r&& = l## AND r##: GOTO econstmarkupi32 + + Give_Error "Invalid CONST expression.13": EXIT FUNCTION + + econstmarkupi16: + et = INTEGERTYPE - ISPOINTER + ev$ = _MK$(_INTEGER64, r&&) + GOTO econstmarkedup + + econstmarkupi32: + et = LONGTYPE - ISPOINTER + ev$ = _MK$(_INTEGER64, r&&) + GOTO econstmarkedup + + econstmarkupi: + IF et <> btype(i) THEN + 'keep unsigned? + u = 0: IF (et AND ISUNSIGNED) <> 0 AND (btype(i) AND ISUNSIGNED) <> 0 THEN u = 1 + lb = et AND 511: rb = btype(i) AND 511 + ob = 0 + IF lb = rb THEN + IF (et AND ISOFFSETINBITS) <> 0 AND (btype(i) AND ISOFFSETINBITS) <> 0 THEN ob = 1 + b = lb + END IF + IF lb > rb THEN + IF (et AND ISOFFSETINBITS) <> 0 THEN ob = 1 + b = lb + END IF + IF lb < rb THEN + IF (btype(i) AND ISOFFSETINBITS) <> 0 THEN ob = 1 + b = rb + END IF + et = b + IF ob THEN et = et + ISOFFSETINBITS + IF u THEN et = et + ISUNSIGNED + END IF + ev$ = _MK$(_INTEGER64, r&&) + GOTO econstmarkedup + + econstmarkupf: + lfb = 0: rfb = 0 + lib = 0: rib = 0 + IF et AND ISFLOAT THEN lfb = et AND 511 ELSE lib = et AND 511 + IF btype(i) AND ISFLOAT THEN rfb = btype(i) AND 511 ELSE rib = btype(i) AND 511 + f = 32 + IF lib > 16 OR rib > 16 THEN f = 64 + IF lfb > 32 OR rfb > 32 THEN f = 64 + IF lib > 32 OR rib > 32 THEN f = 256 + IF lfb > 64 OR rfb > 64 THEN f = 256 + et = ISFLOAT + f + ev$ = _MK$(_FLOAT, r##) + + econstmarkedup: + + i = i + 1 + + IF i <= n THEN GOTO evalconstequ + + t = et + evaluateconst$ = ev$ + +END FUNCTION + +FUNCTION typevalue2symbol$ (t) + + IF t AND ISSTRING THEN + IF t AND ISFIXEDLENGTH THEN Give_Error "Cannot convert expression type to symbol": EXIT FUNCTION + typevalue2symbol$ = "$" + EXIT FUNCTION + END IF + + s$ = "" + + IF t AND ISUNSIGNED THEN s$ = "~" + + b = t AND 511 + + IF t AND ISOFFSETINBITS THEN + IF b > 1 THEN s$ = s$ + "`" + str2$(b) ELSE s$ = s$ + "`" + typevalue2symbol$ = s$ + EXIT FUNCTION + END IF + + IF t AND ISFLOAT THEN + IF b = 32 THEN s$ = "!" + IF b = 64 THEN s$ = "#" + IF b = 256 THEN s$ = "##" + typevalue2symbol$ = s$ + EXIT FUNCTION + END IF + + IF b = 8 THEN s$ = s$ + "%%" + IF b = 16 THEN s$ = s$ + "%" + IF b = 32 THEN s$ = s$ + "&" + IF b = 64 THEN s$ = s$ + "&&" + typevalue2symbol$ = s$ + +END FUNCTION + + +FUNCTION id2fulltypename$ + t = id.t + IF t = 0 THEN t = id.arraytype + size = id.tsize + bits = t AND 511 + IF t AND ISUDT THEN + a$ = RTRIM$(udtxcname(t AND 511)) + id2fulltypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISSTRING THEN + IF t AND ISFIXEDLENGTH THEN a$ = "STRING * " + str2(size) ELSE a$ = "STRING" + id2fulltypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISOFFSETINBITS THEN + IF bits > 1 THEN a$ = qb64prefix$ + "BIT * " + str2(bits) ELSE a$ = qb64prefix$ + "BIT" + IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ + id2fulltypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISFLOAT THEN + IF bits = 32 THEN a$ = "SINGLE" + IF bits = 64 THEN a$ = "DOUBLE" + IF bits = 256 THEN a$ = qb64prefix$ + "FLOAT" + ELSE 'integer-based + IF bits = 8 THEN a$ = qb64prefix$ + "BYTE" + IF bits = 16 THEN a$ = "INTEGER" + IF bits = 32 THEN a$ = "LONG" + IF bits = 64 THEN a$ = qb64prefix$ + "INTEGER64" + IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ + END IF + IF t AND ISOFFSET THEN + a$ = qb64prefix$ + "OFFSET" + IF t AND ISUNSIGNED THEN a$ = qb64prefix$ + "UNSIGNED " + a$ + END IF + id2fulltypename$ = a$ +END FUNCTION + +FUNCTION id2shorttypename$ + t = id.t + IF t = 0 THEN t = id.arraytype + size = id.tsize + bits = t AND 511 + IF t AND ISUDT THEN + a$ = RTRIM$(udtxcname(t AND 511)) + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISSTRING THEN + IF t AND ISFIXEDLENGTH THEN a$ = "STRING" + str2(size) ELSE a$ = "STRING" + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISOFFSETINBITS THEN + IF t AND ISUNSIGNED THEN a$ = "_U" ELSE a$ = "_" + IF bits > 1 THEN a$ = a$ + "BIT" + str2(bits) ELSE a$ = a$ + "BIT1" + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISFLOAT THEN + IF bits = 32 THEN a$ = "SINGLE" + IF bits = 64 THEN a$ = "DOUBLE" + IF bits = 256 THEN a$ = "_FLOAT" + ELSE 'integer-based + IF bits = 8 THEN + IF (t AND ISUNSIGNED) THEN a$ = "_UBYTE" ELSE a$ = "_BYTE" + END IF + IF bits = 16 THEN + IF (t AND ISUNSIGNED) THEN a$ = "UINTEGER" ELSE a$ = "INTEGER" + END IF + IF bits = 32 THEN + IF (t AND ISUNSIGNED) THEN a$ = "ULONG" ELSE a$ = "LONG" + END IF + IF bits = 64 THEN + IF (t AND ISUNSIGNED) THEN a$ = "_UINTEGER64" ELSE a$ = "_INTEGER64" + END IF + END IF + id2shorttypename$ = a$ +END FUNCTION + +FUNCTION symbol2fulltypename$ (s2$) + 'note: accepts both symbols and type names + s$ = s2$ + + IF LEFT$(s$, 1) = "~" THEN + u = 1 + IF LEN(typ$) = 1 THEN Give_Error "Expected ~...": EXIT FUNCTION + s$ = RIGHT$(s$, LEN(s$) - 1) + u$ = qb64prefix$ + "UNSIGNED " + END IF + + IF s$ = "%%" THEN t$ = u$ + qb64prefix$ + "BYTE": GOTO gotsym2typ + IF s$ = "%" THEN t$ = u$ + "INTEGER": GOTO gotsym2typ + IF s$ = "&" THEN t$ = u$ + "LONG": GOTO gotsym2typ + IF s$ = "&&" THEN t$ = u$ + qb64prefix$ + "INTEGER64": GOTO gotsym2typ + IF s$ = "%&" THEN t$ = u$ + qb64prefix$ + "OFFSET": GOTO gotsym2typ + + IF LEFT$(s$, 1) = "`" THEN + IF LEN(s$) = 1 THEN + t$ = u$ + qb64prefix$ + "BIT * 1" + GOTO gotsym2typ + END IF + n$ = RIGHT$(s$, LEN(s$) - 1) + IF isuinteger(n$) = 0 THEN Give_Error "Expected number after symbol `": EXIT FUNCTION + t$ = u$ + qb64prefix$ + "BIT * " + n$ + GOTO gotsym2typ + END IF + + IF u = 1 THEN Give_Error "Expected type symbol after ~": EXIT FUNCTION + + IF s$ = "!" THEN t$ = "SINGLE": GOTO gotsym2typ + IF s$ = "#" THEN t$ = "DOUBLE": GOTO gotsym2typ + IF s$ = "##" THEN t$ = qb64prefix$ + "FLOAT": GOTO gotsym2typ + IF s$ = "$" THEN t$ = "STRING": GOTO gotsym2typ + + IF LEFT$(s$, 1) = "$" THEN + n$ = RIGHT$(s$, LEN(s$) - 1) + IF isuinteger(n$) = 0 THEN Give_Error "Expected number after symbol $": EXIT FUNCTION + t$ = "STRING * " + n$ + GOTO gotsym2typ + END IF + + t$ = s$ + + gotsym2typ: + + IF RIGHT$(" " + t$, 5) = " _BIT" THEN t$ = t$ + " * 1" 'clarify (_UNSIGNED) _BIT as (_UNSIGNED) _BIT * 1 + + FOR i = 1 TO LEN(t$) + IF ASC(t$, i) = ASC(sp) THEN ASC(t$, i) = 32 + NEXT + + symbol2fulltypename$ = t$ + +END FUNCTION + +SUB lineinput3load (f$) + OPEN f$ FOR BINARY AS #1 + l = LOF(1) + lineinput3buffer$ = SPACE$(l) + GET #1, , lineinput3buffer$ + IF LEN(lineinput3buffer$) THEN IF RIGHT$(lineinput3buffer$, 1) = CHR$(26) THEN lineinput3buffer$ = LEFT$(lineinput3buffer$, LEN(lineinput3buffer$) - 1) + CLOSE #1 + lineinput3index = 1 +END SUB + +FUNCTION lineinput3$ + 'returns CHR$(13) if no more lines are available + l = LEN(lineinput3buffer$) + IF lineinput3index > l THEN lineinput3$ = CHR$(13): EXIT FUNCTION + c13 = INSTR(lineinput3index, lineinput3buffer$, CHR$(13)) + c10 = INSTR(lineinput3index, lineinput3buffer$, CHR$(10)) + IF c10 = 0 AND c13 = 0 THEN + lineinput3$ = MID$(lineinput3buffer$, lineinput3index, l - lineinput3index + 1) + lineinput3index = l + 1 + EXIT FUNCTION + END IF + IF c10 = 0 THEN c10 = 2147483647 + IF c13 = 0 THEN c13 = 2147483647 + IF c10 < c13 THEN + '10 before 13 + lineinput3$ = MID$(lineinput3buffer$, lineinput3index, c10 - lineinput3index) + lineinput3index = c10 + 1 + IF lineinput3index <= l THEN + IF ASC(MID$(lineinput3buffer$, lineinput3index, 1)) = 13 THEN lineinput3index = lineinput3index + 1 + END IF + ELSE + '13 before 10 + lineinput3$ = MID$(lineinput3buffer$, lineinput3index, c13 - lineinput3index) + lineinput3index = c13 + 1 + IF lineinput3index <= l THEN + IF ASC(MID$(lineinput3buffer$, lineinput3index, 1)) = 10 THEN lineinput3index = lineinput3index + 1 + END IF + END IF +END FUNCTION + +FUNCTION eleucase$ (a$) + 'this function upper-cases all elements except for quoted strings + 'check first element + IF LEN(a$) = 0 THEN EXIT FUNCTION + i = 1 + IF ASC(a$) = 34 THEN + i2 = INSTR(a$, sp) + IF i2 = 0 THEN eleucase$ = a$: EXIT FUNCTION + a2$ = LEFT$(a$, i2 - 1) + i = i2 + END IF + 'check other elements + sp34$ = sp + CHR$(34) + IF i < LEN(a$) THEN + DO WHILE INSTR(i, a$, sp34$) + i2 = INSTR(i, a$, sp34$) + a2$ = a2$ + UCASE$(MID$(a$, i, i2 - i + 1)) 'everything prior including spacer + i3 = INSTR(i2 + 1, a$, sp): IF i3 = 0 THEN i3 = LEN(a$) ELSE i3 = i3 - 1 + a2$ = a2$ + MID$(a$, i2 + 1, i3 - (i2 + 1) + 1) 'everything from " to before next spacer or end + i = i3 + 1 + IF i > LEN(a$) THEN EXIT DO + LOOP + END IF + a2$ = a2$ + UCASE$(MID$(a$, i, LEN(a$) - i + 1)) + eleucase$ = a2$ +END FUNCTION + + +SUB SetDependency (requirement) + IF requirement THEN + DEPENDENCY(requirement) = 1 + END IF +END SUB + +'Steve Subs/Functins for _MATH support with CONST +FUNCTION Evaluate_Expression$ (e$) + t$ = e$ 'So we preserve our original data, we parse a temp copy of it + PreParse t$ + + + IF LEFT$(t$, 5) = "ERROR" THEN Evaluate_Expression$ = t$: EXIT FUNCTION + + 'Deal with brackets first + exp$ = "(" + t$ + ")" 'Starting and finishing brackets for our parse routine. + + DO + Eval_E = INSTR(exp$, ")") + IF Eval_E > 0 THEN + c = 0 + DO UNTIL Eval_E - c <= 0 + c = c + 1 + IF Eval_E THEN + IF MID$(exp$, Eval_E - c, 1) = "(" THEN EXIT DO + END IF + LOOP + s = Eval_E - c + 1 + IF s < 1 THEN Evaluate_Expression$ = "ERROR -- BAD () Count": EXIT FUNCTION + eval$ = " " + MID$(exp$, s, Eval_E - s) + " " 'pad with a space before and after so the parser can pick up the values properly. + + ParseExpression eval$ + eval$ = LTRIM$(RTRIM$(eval$)) + IF LEFT$(eval$, 5) = "ERROR" THEN Evaluate_Expression$ = eval$: EXIT FUNCTION + exp$ = DWD(LEFT$(exp$, s - 2) + eval$ + MID$(exp$, Eval_E + 1)) + IF MID$(exp$, 1, 1) = "N" THEN MID$(exp$, 1) = "-" + END IF + LOOP UNTIL Eval_E = 0 + c = 0 + DO + c = c + 1 + SELECT CASE MID$(exp$, c, 1) + CASE "0" TO "9", ".", "-" 'At this point, we should only have number values left. + CASE ELSE: Evaluate_Expression$ = "ERROR - Unknown Diagnosis: (" + exp$ + ") ": EXIT FUNCTION + END SELECT + LOOP UNTIL c >= LEN(exp$) + + Evaluate_Expression$ = exp$ +END FUNCTION + + + +SUB ParseExpression (exp$) + DIM num(10) AS STRING + 'PRINT exp$ + exp$ = DWD(exp$) + 'We should now have an expression with no () to deal with + + FOR J = 1 TO 250 + lowest = 0 + DO UNTIL lowest = LEN(exp$) + lowest = LEN(exp$): OpOn = 0 + FOR P = 1 TO UBOUND(OName) + 'Look for first valid operator + IF J = PL(P) THEN 'Priority levels match + IF LEFT$(exp$, 1) = "-" THEN startAt = 2 ELSE startAt = 1 + op = INSTR(startAt, exp$, OName(P)) + IF op = 0 AND LEFT$(OName(P), 1) = "_" AND qb64prefix_set = 1 THEN + 'try again without prefix + op = INSTR(startAt, exp$, MID$(OName(P), 2)) + IF op > 0 THEN + exp$ = LEFT$(exp$, op - 1) + "_" + MID$(exp$, op) + lowest = lowest + 1 + END IF + END IF + IF op > 0 AND op < lowest THEN lowest = op: OpOn = P + END IF + NEXT + IF OpOn = 0 THEN EXIT DO 'We haven't gotten to the proper PL for this OP to be processed yet. + IF LEFT$(exp$, 1) = "-" THEN startAt = 2 ELSE startAt = 1 + op = INSTR(startAt, exp$, OName(OpOn)) + + numset = 0 + + '*** SPECIAL OPERATION RULESETS + IF OName(OpOn) = "-" THEN 'check for BOOLEAN operators before the - + SELECT CASE MID$(exp$, op - 3, 3) + CASE "NOT", "XOR", "AND", "EQV", "IMP" + EXIT DO 'Not an operator, it's a negative + END SELECT + IF MID$(exp$, op - 3, 2) = "OR" THEN EXIT DO 'Not an operator, it's a negative + END IF + + IF op THEN + c = LEN(OName(OpOn)) - 1 + DO + SELECT CASE MID$(exp$, op + c + 1, 1) + CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "N": numset = -1 'Valid digit + CASE "-" 'We need to check if it's a minus or a negative + IF OName(OpOn) = "_PI" OR numset THEN EXIT DO + CASE ",": numset = 0 + CASE ELSE 'Not a valid digit, we found our separator + EXIT DO + END SELECT + c = c + 1 + LOOP UNTIL op + c >= LEN(exp$) + E = op + c + + c = 0 + DO + c = c + 1 + SELECT CASE MID$(exp$, op - c, 1) + CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "N" 'Valid digit + CASE "-" 'We need to check if it's a minus or a negative + c1 = c + bad = 0 + DO + c1 = c1 + 1 + SELECT CASE MID$(exp$, op - c1, 1) + CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." + bad = -1 + EXIT DO 'It's a minus sign + CASE ELSE + 'It's a negative sign and needs to count as part of our numbers + END SELECT + LOOP UNTIL op - c1 <= 0 + IF bad THEN EXIT DO 'We found our seperator + CASE ELSE 'Not a valid digit, we found our separator + EXIT DO + END SELECT + LOOP UNTIL op - c <= 0 + s = op - c + num(1) = MID$(exp$, s + 1, op - s - 1) 'Get our first number + num(2) = MID$(exp$, op + LEN(OName(OpOn)), E - op - LEN(OName(OpOn)) + 1) 'Get our second number + IF MID$(num(1), 1, 1) = "N" THEN MID$(num(1), 1) = "-" + IF MID$(num(2), 1, 1) = "N" THEN MID$(num(2), 1) = "-" + IF num(1) = "-" THEN + num(3) = "N" + EvaluateNumbers(OpOn, num()) + ELSE + num(3) = EvaluateNumbers(OpOn, num()) + END IF + IF MID$(num(3), 1, 1) = "-" THEN MID$(num(3), 1) = "N" + IF LEFT$(num(3), 5) = "ERROR" THEN exp$ = num(3): EXIT SUB + exp$ = LTRIM$(N2S(DWD(LEFT$(exp$, s) + RTRIM$(LTRIM$(num(3))) + MID$(exp$, E + 1)))) + END IF + op = 0 + LOOP + NEXT + +END SUB + + + +SUB Set_OrderOfOperations + 'PL sets our priortity level. 1 is highest to 65535 for the lowest. + 'I used a range here so I could add in new priority levels as needed. + 'OName ended up becoming the name of our commands, as I modified things.... Go figure! LOL! + REDIM OName(10000) AS STRING, PL(10000) AS INTEGER + 'Constants get evaluated first, with a Priority Level of 1 + + i = i + 1: OName(i) = "C_UOF": PL(i) = 5 'convert to unsigned offset + i = i + 1: OName(i) = "C_OF": PL(i) = 5 'convert to offset + i = i + 1: OName(i) = "C_UBY": PL(i) = 5 'convert to unsigned byte + i = i + 1: OName(i) = "C_BY": PL(i) = 5 'convert to byte + i = i + 1: OName(i) = "C_UIN": PL(i) = 5 'convert to unsigned integer + i = i + 1: OName(i) = "C_IN": PL(i) = 5 'convert to integer + i = i + 1: OName(i) = "C_UIF": PL(i) = 5 'convert to unsigned int64 + i = i + 1: OName(i) = "C_IF": PL(i) = 5 'convert to int64 + i = i + 1: OName(i) = "C_ULO": PL(i) = 5 'convert to unsigned long + i = i + 1: OName(i) = "C_LO": PL(i) = 5 'convert to long + i = i + 1: OName(i) = "C_SI": PL(i) = 5 'convert to single + i = i + 1: OName(i) = "C_FL": PL(i) = 5 'convert to float + i = i + 1: OName(i) = "C_DO": PL(i) = 5 'convert to double + i = i + 1: OName(i) = "C_UBI": PL(i) = 5 'convert to unsigned bit + i = i + 1: OName(i) = "C_BI": PL(i) = 5 'convert to bit + + 'Then Functions with PL 10 + i = i + 1:: OName(i) = "_PI": PL(i) = 10 + i = i + 1: OName(i) = "_ACOS": PL(i) = 10 + i = i + 1: OName(i) = "_ASIN": PL(i) = 10 + i = i + 1: OName(i) = "_ARCSEC": PL(i) = 10 + i = i + 1: OName(i) = "_ARCCSC": PL(i) = 10 + i = i + 1: OName(i) = "_ARCCOT": PL(i) = 10 + i = i + 1: OName(i) = "_SECH": PL(i) = 10 + i = i + 1: OName(i) = "_CSCH": PL(i) = 10 + i = i + 1: OName(i) = "_COTH": PL(i) = 10 + i = i + 1: OName(i) = "COS": PL(i) = 10 + i = i + 1: OName(i) = "SIN": PL(i) = 10 + i = i + 1: OName(i) = "TAN": PL(i) = 10 + i = i + 1: OName(i) = "LOG": PL(i) = 10 + i = i + 1: OName(i) = "EXP": PL(i) = 10 + i = i + 1: OName(i) = "ATN": PL(i) = 10 + i = i + 1: OName(i) = "_D2R": PL(i) = 10 + i = i + 1: OName(i) = "_D2G": PL(i) = 10 + i = i + 1: OName(i) = "_R2D": PL(i) = 10 + i = i + 1: OName(i) = "_R2G": PL(i) = 10 + i = i + 1: OName(i) = "_G2D": PL(i) = 10 + i = i + 1: OName(i) = "_G2R": PL(i) = 10 + i = i + 1: OName(i) = "ABS": PL(i) = 10 + i = i + 1: OName(i) = "SGN": PL(i) = 10 + i = i + 1: OName(i) = "INT": PL(i) = 10 + i = i + 1: OName(i) = "_ROUND": PL(i) = 10 + i = i + 1: OName(i) = "_CEIL": PL(i) = 10 + i = i + 1: OName(i) = "FIX": PL(i) = 10 + i = i + 1: OName(i) = "_SEC": PL(i) = 10 + i = i + 1: OName(i) = "_CSC": PL(i) = 10 + i = i + 1: OName(i) = "_COT": PL(i) = 10 + i = i + 1: OName(i) = "ASC": PL(i) = 10 + i = i + 1: OName(i) = "C_RG": PL(i) = 10 '_RGB32 converted + i = i + 1: OName(i) = "C_RA": PL(i) = 10 '_RGBA32 converted + i = i + 1: OName(i) = "_RGB": PL(i) = 10 + i = i + 1: OName(i) = "_RGBA": PL(i) = 10 + i = i + 1: OName(i) = "C_RX": PL(i) = 10 '_RED32 converted + i = i + 1: OName(i) = "C_GR": PL(i) = 10 ' _GREEN32 converted + i = i + 1: OName(i) = "C_BL": PL(i) = 10 '_BLUE32 converted + i = i + 1: OName(i) = "C_AL": PL(i) = 10 '_ALPHA32 converted + i = i + 1: OName(i) = "_RED": PL(i) = 10 + i = i + 1: OName(i) = "_GREEN": PL(i) = 10 + i = i + 1: OName(i) = "_BLUE": PL(i) = 10 + i = i + 1: OName(i) = "_ALPHA": PL(i) = 10 + + 'Exponents with PL 20 + i = i + 1: OName(i) = "^": PL(i) = 20 + i = i + 1: OName(i) = "SQR": PL(i) = 20 + i = i + 1: OName(i) = "ROOT": PL(i) = 20 + 'Multiplication and Division PL 30 + i = i + 1: OName(i) = "*": PL(i) = 30 + i = i + 1: OName(i) = "/": PL(i) = 30 + 'Integer Division PL 40 + i = i + 1: OName(i) = "\": PL(i) = 40 + 'MOD PL 50 + i = i + 1: OName(i) = "MOD": PL(i) = 50 + 'Addition and Subtraction PL 60 + i = i + 1: OName(i) = "+": PL(i) = 60 + i = i + 1: OName(i) = "-": PL(i) = 60 + + 'Relational Operators =, >, <, <>, <=, >= PL 70 + i = i + 1: OName(i) = "<>": PL(i) = 70 'These next three are just reversed symbols as an attempt to help process a common typo + i = i + 1: OName(i) = "><": PL(i) = 70 + i = i + 1: OName(i) = "<=": PL(i) = 70 + i = i + 1: OName(i) = ">=": PL(i) = 70 + i = i + 1: OName(i) = "=<": PL(i) = 70 'I personally can never keep these things straight. Is it < = or = <... + i = i + 1: OName(i) = "=>": PL(i) = 70 'Who knows, check both! + i = i + 1: OName(i) = ">": PL(i) = 70 + i = i + 1: OName(i) = "<": PL(i) = 70 + i = i + 1: OName(i) = "=": PL(i) = 70 + 'Logical Operations PL 80+ + i = i + 1: OName(i) = "NOT": PL(i) = 80 + i = i + 1: OName(i) = "AND": PL(i) = 90 + i = i + 1: OName(i) = "OR": PL(i) = 100 + i = i + 1: OName(i) = "XOR": PL(i) = 110 + i = i + 1: OName(i) = "EQV": PL(i) = 120 + i = i + 1: OName(i) = "IMP": PL(i) = 130 + i = i + 1: OName(i) = ",": PL(i) = 1000 + + REDIM _PRESERVE OName(i) AS STRING, PL(i) AS INTEGER +END SUB + +FUNCTION EvaluateNumbers$ (p, num() AS STRING) + DIM n1 AS _FLOAT, n2 AS _FLOAT, n3 AS _FLOAT + 'PRINT "EVALNUM:"; OName(p), num(1), num(2) + + IF _TRIM$(num(1)) = "" THEN num(1) = "0" + + IF PL(p) >= 20 AND (LEN(_TRIM$(num(1))) = 0 OR LEN(_TRIM$(num(2))) = 0) THEN + EvaluateNumbers$ = "ERROR - Missing operand": EXIT FUNCTION + END IF + + IF INSTR(num(1), ",") THEN + EvaluateNumbers$ = "ERROR - Invalid comma (" + num(1) + ")": EXIT FUNCTION + END IF + l2 = INSTR(num(2), ",") + IF l2 THEN + SELECT CASE OName(p) 'only certain commands should pass a comma value + CASE "C_RG", "C_RA", "_RGB", "_RGBA", "_RED", "_GREEN", "C_BL", "_ALPHA" + CASE ELSE + C$ = MID$(num(2), l2) + num(2) = LEFT$(num(2), l2 - 1) + END SELECT + END IF + + SELECT CASE PL(p) 'divide up the work so we want do as much case checking + CASE 5 'Type conversions + 'Note, these are special cases and work with the number BEFORE the command and not after + SELECT CASE OName(p) 'Depending on our operator.. + CASE "C_UOF": n1~%& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%&))) + CASE "C_ULO": n1%& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%&))) + CASE "C_UBY": n1~%% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%%))) + CASE "C_UIN": n1~% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~%))) + CASE "C_BY": n1%% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%%))) + CASE "C_IN": n1% = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1%))) + CASE "C_UIF": n1~&& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~&&))) + CASE "C_OF": n1~& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~&))) + CASE "C_IF": n1&& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1&&))) + CASE "C_LO": n1& = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1&))) + CASE "C_UBI": n1~` = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1~`))) + CASE "C_BI": n1` = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1`))) + CASE "C_FL": n1## = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1##))) + CASE "C_DO": n1# = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1#))) + CASE "C_SI": n1! = VAL(num(1)): EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1!))) + END SELECT + EXIT FUNCTION + CASE 10 'functions + SELECT CASE OName(p) 'Depending on our operator.. + CASE "_PI" + n1 = 3.14159265358979323846264338327950288## 'Future compatable in case something ever stores extra digits for PI + IF num(2) <> "" THEN n1 = n1 * VAL(num(2)) + CASE "_ACOS": n1 = _ACOS(VAL(num(2))) + CASE "_ASIN": n1 = _ASIN(VAL(num(2))) + CASE "_ARCSEC": n1 = _ARCSEC(VAL(num(2))) + CASE "_ARCCSC": n1 = _ARCCSC(VAL(num(2))) + CASE "_ARCCOT": n1 = _ARCCOT(VAL(num(2))) + CASE "_SECH": n1 = _SECH(VAL(num(2))) + CASE "_CSCH": n1 = _CSCH(VAL(num(2))) + CASE "_COTH": n1 = _COTH(VAL(num(2))) + CASE "C_RG" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGB32": EXIT FUNCTION + c1 = INSTR(n$, ",") + IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") + IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") + IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") + IF c1 = 0 THEN 'there's no comma in the command to parse. It's a grayscale value + n = VAL(num(2)) + n1 = _RGB32(n, n, n) + ELSEIF c2 = 0 THEN 'there's one comma and not 2. It's grayscale with alpha. + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n1 = _RGBA32(n, n, n, n2) + ELSEIF c3 = 0 THEN 'there's two commas. It's _RGB values + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n3 = VAL(MID$(num(2), c2 + 1)) + n1 = _RGB32(n, n2, n3) + ELSEIF c4 = 0 THEN 'there's three commas. It's _RGBA values + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n3 = VAL(MID$(num(2), c2 + 1)) + n4 = VAL(MID$(num(2), c3 + 1)) + n1 = _RGBA32(n, n2, n3, n4) + ELSE 'we have more than three commas. I have no idea WTH type of values got passed here! + EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + ")": EXIT FUNCTION + END IF + CASE "C_RA" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGBA32": EXIT FUNCTION + c1 = INSTR(n$, ",") + IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") + IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") + IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") + IF c3 = 0 OR c4 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + ")": EXIT FUNCTION + 'we have to have 3 commas; not more, not less. + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n3 = VAL(MID$(num(2), c2 + 1)) + n4 = VAL(MID$(num(2), c3 + 1)) + n1 = _RGBA32(n, n2, n3, n4) + CASE "_RGB" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGB": EXIT FUNCTION + c1 = INSTR(n$, ",") + IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") + IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") + IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") + IF c3 = 0 OR c4 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + "). _RGB requires 4 parameters for Red, Green, Blue, ScreenMode.": EXIT FUNCTION + 'we have to have 3 commas; not more, not less. + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n3 = VAL(MID$(num(2), c2 + 1)) + n4 = VAL(MID$(num(2), c3 + 1)) + SELECT CASE n4 + CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values + CASE ELSE + EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n4) + ")": EXIT FUNCTION + END SELECT + t = _NEWIMAGE(1, 1, n4) + n1 = _RGB(n, n2, n3, t) + _FREEIMAGE t + CASE "_RGBA" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null _RGBA": EXIT FUNCTION + c1 = INSTR(n$, ",") + IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") + IF c2 THEN c3 = INSTR(c2 + 1, n$, ",") + IF c3 THEN c4 = INSTR(c3 + 1, n$, ",") + IF c4 THEN c5 = INSTR(c4 + 1, n$, ",") + IF c4 = 0 OR c5 <> 0 THEN EvaluateNumbers$ = "ERROR - Invalid comma count (" + num(2) + "). _RGBA requires 5 parameters for Red, Green, Blue, Alpha, ScreenMode.": EXIT FUNCTION + 'we have to have 4 commas; not more, not less. + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + n3 = VAL(MID$(num(2), c2 + 1)) + n4 = VAL(MID$(num(2), c3 + 1)) + n5 = VAL(MID$(num(2), c4 + 1)) + SELECT CASE n5 + CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values + CASE ELSE + EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n5) + ")": EXIT FUNCTION + END SELECT + t = _NEWIMAGE(1, 1, n5) + n1 = _RGBA(n, n2, n3, n4, t) + _FREEIMAGE t + CASE "_RED", "_GREEN", "_BLUE", "_ALPHA" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null " + OName(p): EXIT FUNCTION + c1 = INSTR(n$, ",") + IF c1 = 0 THEN EvaluateNumbers$ = "ERROR - " + OName(p) + " requires 2 parameters for Color, ScreenMode.": EXIT FUNCTION + IF c1 THEN c2 = INSTR(c1 + 1, n$, ",") + IF c2 THEN EvaluateNumbers$ = "ERROR - " + OName(p) + " requires 2 parameters for Color, ScreenMode.": EXIT FUNCTION + n = VAL(LEFT$(num(2), c1)) + n2 = VAL(MID$(num(2), c1 + 1)) + SELECT CASE n2 + CASE 0 TO 2, 7 TO 13, 256, 32 'these are the good screen values + CASE ELSE + EvaluateNumbers$ = "ERROR - Invalid Screen Mode (" + STR$(n2) + ")": EXIT FUNCTION + END SELECT + t = _NEWIMAGE(1, 1, n4) + SELECT CASE OName(p) + CASE "_RED": n1 = _RED(n, t) + CASE "_BLUE": n1 = _BLUE(n, t) + CASE "_GREEN": n1 = _GREEN(n, t) + CASE "_ALPHA": n1 = _ALPHA(n, t) + END SELECT + _FREEIMAGE t + CASE "C_RX", "C_GR", "C_BL", "C_AL" + n$ = num(2) + IF n$ = "" THEN EvaluateNumbers$ = "ERROR - Invalid null " + OName(p): EXIT FUNCTION + n = VAL(num(2)) + SELECT CASE OName(p) + CASE "C_RX": n1 = _RED32(n) + CASE "C_BL": n1 = _BLUE32(n) + CASE "C_GR": n1 = _GREEN32(n) + CASE "C_AL": n1 = _ALPHA32(n) + END SELECT + CASE "COS": n1 = COS(VAL(num(2))) + CASE "SIN": n1 = SIN(VAL(num(2))) + CASE "TAN": n1 = TAN(VAL(num(2))) + CASE "LOG": n1 = LOG(VAL(num(2))) + CASE "EXP": n1 = EXP(VAL(num(2))) + CASE "ATN": n1 = ATN(VAL(num(2))) + CASE "_D2R": n1 = 0.0174532925 * (VAL(num(2))) + CASE "_D2G": n1 = 1.1111111111 * (VAL(num(2))) + CASE "_R2D": n1 = 57.2957795 * (VAL(num(2))) + CASE "_R2G": n1 = 0.015707963 * (VAL(num(2))) + CASE "_G2D": n1 = 0.9 * (VAL(num(2))) + CASE "_G2R": n1 = 63.661977237 * (VAL(num(2))) + CASE "ABS": n1 = ABS(VAL(num(2))) + CASE "SGN": n1 = SGN(VAL(num(2))) + CASE "INT": n1 = INT(VAL(num(2))) + CASE "_ROUND": n1 = _ROUND(VAL(num(2))) + CASE "_CEIL": n1 = _CEIL(VAL(num(2))) + CASE "FIX": n1 = FIX(VAL(num(2))) + CASE "_SEC": n1 = _SEC(VAL(num(2))) + CASE "_CSC": n1 = _CSC(VAL(num(2))) + CASE "_COT": n1 = _COT(VAL(num(2))) + END SELECT + CASE 20 TO 60 'Math Operators + SELECT CASE OName(p) 'Depending on our operator.. + CASE "^": n1 = VAL(num(1)) ^ VAL(num(2)) + CASE "SQR": n1 = SQR(VAL(num(2))) + CASE "ROOT" + n1 = VAL(num(1)): n2 = VAL(num(2)) + IF n2 = 1 THEN EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1))): EXIT FUNCTION + IF n1 < 0 AND n2 >= 1 THEN sign = -1: n1 = -n1 ELSE sign = 1 + n3 = 1## / n2 + IF n3 <> INT(n3) AND n2 < 1 THEN sign = SGN(n1): n1 = ABS(n1) + n1 = sign * (n1 ^ n3) + CASE "*": n1 = VAL(num(1)) * VAL(num(2)) + CASE "/" + IF VAL(num(2)) <> 0 THEN + n1 = VAL(num(1)) / VAL(num(2)) + ELSE + EvaluateNumbers$ = "ERROR - Division By Zero" + EXIT FUNCTION + END IF + CASE "\" + IF FIX(VAL(num(2))) = 0 THEN + EvaluateNumbers$ = "ERROR - Division By Zero" + EXIT FUNCTION + END IF + + n1 = VAL(num(1)) \ FIX(VAL(num(2))) + CASE "MOD" + IF FIX(VAL(num(2))) = 0 THEN + EvaluateNumbers$ = "ERROR - Division By Zero" + EXIT FUNCTION + END IF + + n1 = VAL(num(1)) MOD FIX(VAL(num(2))) + + CASE "+": n1 = VAL(num(1)) + VAL(num(2)) + CASE "-": + n1 = VAL(num(1)) - VAL(num(2)) + END SELECT + CASE 70 'Relational Operators =, >, <, <>, <=, >= + SELECT CASE OName(p) 'Depending on our operator.. + CASE "=": n1 = VAL(num(1)) = VAL(num(2)) + CASE ">": n1 = VAL(num(1)) > VAL(num(2)) + CASE "<": n1 = VAL(num(1)) < VAL(num(2)) + CASE "<>", "><": n1 = VAL(num(1)) <> VAL(num(2)) + CASE "<=", "=<": n1 = VAL(num(1)) <= VAL(num(2)) + CASE ">=", "=>": n1 = VAL(num(1)) >= VAL(num(2)) + END SELECT + CASE ELSE 'a value we haven't processed elsewhere + SELECT CASE OName(p) 'Depending on our operator.. + CASE "NOT": n1 = NOT VAL(num(2)) + CASE "AND": n1 = VAL(num(1)) AND VAL(num(2)) + CASE "OR": n1 = VAL(num(1)) OR VAL(num(2)) + CASE "XOR": n1 = VAL(num(1)) XOR VAL(num(2)) + CASE "EQV": n1 = VAL(num(1)) EQV VAL(num(2)) + CASE "IMP": n1 = VAL(num(1)) IMP VAL(num(2)) + END SELECT + END SELECT + + EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1))) + C$ +END FUNCTION + +FUNCTION DWD$ (exp$) 'Deal With Duplicates + 'To deal with duplicate operators in our code. + 'Such as -- becomes a + + '++ becomes a + + '+- becomes a - + '-+ becomes a - + t$ = exp$ + DO + bad = 0 + DO + l = INSTR(t$, "++") + IF l THEN t$ = LEFT$(t$, l - 1) + "+" + MID$(t$, l + 2): bad = -1 + LOOP UNTIL l = 0 + DO + l = INSTR(t$, "+-") + IF l THEN t$ = LEFT$(t$, l - 1) + "-" + MID$(t$, l + 2): bad = -1 + LOOP UNTIL l = 0 + DO + l = INSTR(t$, "-+") + IF l THEN t$ = LEFT$(t$, l - 1) + "-" + MID$(t$, l + 2): bad = -1 + LOOP UNTIL l = 0 + DO + l = INSTR(t$, "--") + IF l THEN t$ = LEFT$(t$, l - 1) + "+" + MID$(t$, l + 2): bad = -1 + LOOP UNTIL l = 0 + LOOP UNTIL NOT bad + DWD$ = t$ +END FUNCTION + +SUB PreParse (e$) + DIM f AS _FLOAT + STATIC TotalPrefixedPP_TypeMod AS LONG, TotalPP_TypeMod AS LONG + + IF PP_TypeMod(0) = "" THEN + REDIM PP_TypeMod(100) AS STRING, PP_ConvertedMod(100) AS STRING 'Large enough to hold all values to begin with + PP_TypeMod(0) = "Initialized" 'Set so we don't do this section over and over, as we keep the values in shared memory. + 'and the below is a conversion list so symbols don't get cross confused. + i = i + 1: PP_TypeMod(i) = "~`": PP_ConvertedMod(i) = "C_UBI" 'unsigned bit + i = i + 1: PP_TypeMod(i) = "~%%": PP_ConvertedMod(i) = "C_UBY" 'unsigned byte + i = i + 1: PP_TypeMod(i) = "~%&": PP_ConvertedMod(i) = "C_UOF" 'unsigned offset + i = i + 1: PP_TypeMod(i) = "~%": PP_ConvertedMod(i) = "C_UIN" 'unsigned integer + i = i + 1: PP_TypeMod(i) = "~&&": PP_ConvertedMod(i) = "C_UIF" 'unsigned integer64 + i = i + 1: PP_TypeMod(i) = "~&": PP_ConvertedMod(i) = "C_ULO" 'unsigned long + i = i + 1: PP_TypeMod(i) = "`": PP_ConvertedMod(i) = "C_BI" 'bit + i = i + 1: PP_TypeMod(i) = "%%": PP_ConvertedMod(i) = "C_BY" 'byte + i = i + 1: PP_TypeMod(i) = "%&": PP_ConvertedMod(i) = "C_OF" 'offset + i = i + 1: PP_TypeMod(i) = "%": PP_ConvertedMod(i) = "C_IN" 'integer + i = i + 1: PP_TypeMod(i) = "&&": PP_ConvertedMod(i) = "C_IF" 'integer64 + i = i + 1: PP_TypeMod(i) = "&": PP_ConvertedMod(i) = "C_LO" 'long + i = i + 1: PP_TypeMod(i) = "!": PP_ConvertedMod(i) = "C_SI" 'single + i = i + 1: PP_TypeMod(i) = "##": PP_ConvertedMod(i) = "C_FL" 'float + i = i + 1: PP_TypeMod(i) = "#": PP_ConvertedMod(i) = "C_DO" 'double + i = i + 1: PP_TypeMod(i) = "_RGB32": PP_ConvertedMod(i) = "C_RG" 'rgb32 + i = i + 1: PP_TypeMod(i) = "_RGBA32": PP_ConvertedMod(i) = "C_RA" 'rgba32 + i = i + 1: PP_TypeMod(i) = "_RED32": PP_ConvertedMod(i) = "C_RX" 'red32 + i = i + 1: PP_TypeMod(i) = "_GREEN32": PP_ConvertedMod(i) = "C_GR" 'green32 + i = i + 1: PP_TypeMod(i) = "_BLUE32": PP_ConvertedMod(i) = "C_BL" 'blue32 + i = i + 1: PP_TypeMod(i) = "_ALPHA32": PP_ConvertedMod(i) = "C_AL" 'alpha32 + TotalPrefixedPP_TypeMod = i + i = i + 1: PP_TypeMod(i) = "RGB32": PP_ConvertedMod(i) = "C_RG" 'rgb32 + i = i + 1: PP_TypeMod(i) = "RGBA32": PP_ConvertedMod(i) = "C_RA" 'rgba32 + i = i + 1: PP_TypeMod(i) = "RED32": PP_ConvertedMod(i) = "C_RX" 'red32 + i = i + 1: PP_TypeMod(i) = "GREEN32": PP_ConvertedMod(i) = "C_GR" 'green32 + i = i + 1: PP_TypeMod(i) = "BLUE32": PP_ConvertedMod(i) = "C_BL" 'blue32 + i = i + 1: PP_TypeMod(i) = "ALPHA32": PP_ConvertedMod(i) = "C_AL" 'alpha32 + TotalPP_TypeMod = i + REDIM _PRESERVE PP_TypeMod(i) AS STRING, PP_ConvertedMod(i) AS STRING 'And then resized to just contain the necessary space in memory + END IF + t$ = e$ + + 'First strip all spaces + t$ = "" + FOR i = 1 TO LEN(e$) + IF MID$(e$, i, 1) <> " " THEN t$ = t$ + MID$(e$, i, 1) + NEXT + + t$ = UCASE$(t$) + IF t$ = "" THEN e$ = "ERROR -- NULL string; nothing to evaluate": EXIT SUB + + 'ERROR CHECK by counting our brackets + l = 0 + DO + l = INSTR(l + 1, t$, "("): IF l THEN c = c + 1 + LOOP UNTIL l = 0 + l = 0 + DO + l = INSTR(l + 1, t$, ")"): IF l THEN c1 = c1 + 1 + LOOP UNTIL l = 0 + IF c <> c1 THEN e$ = "ERROR -- Bad Parenthesis:" + STR$(c) + "( vs" + STR$(c1) + ")": EXIT SUB + + 'replace existing CONST values + sep$ = "()+-*/\><=^" + FOR i2 = 0 TO constlast + thisConstName$ = constname(i2) + FOR replaceConstPass = 1 TO 2 + found = 0 + DO + found = INSTR(found + 1, UCASE$(t$), thisConstName$) + IF found THEN + IF found > 1 THEN + IF INSTR(sep$, MID$(t$, found - 1, 1)) = 0 THEN _CONTINUE + END IF + IF found + LEN(thisConstName$) <= LEN(t$) THEN + IF INSTR(sep$, MID$(t$, found + LEN(thisConstName$), 1)) = 0 THEN _CONTINUE + END IF + t = consttype(i2) + IF t AND ISSTRING THEN + r$ = conststring(i2) + i4 = _INSTRREV(r$, ",") + r$ = LEFT$(r$, i4 - 1) + ELSE + IF t AND ISFLOAT THEN + r$ = STR$(constfloat(i2)) + r$ = N2S(r$) + ELSE + IF t AND ISUNSIGNED THEN r$ = STR$(constuinteger(i2)) ELSE r$ = STR$(constinteger(i2)) + END IF + END IF + t$ = LEFT$(t$, found - 1) + _TRIM$(r$) + MID$(t$, found + LEN(thisConstName$)) + END IF + LOOP UNTIL found = 0 + thisConstName$ = constname(i2) + constnamesymbol(i2) + NEXT + NEXT + + 'Modify so that NOT will process properly + l = 0 + DO + l = INSTR(l + 1, t$, "NOT ") + IF l THEN + 'We need to work magic on the statement so it looks pretty. + ' 1 + NOT 2 + 1 is actually processed as 1 + (NOT 2 + 1) + 'Look for something not proper + l1 = INSTR(l + 1, t$, "AND") + IF l1 = 0 OR (INSTR(l + 1, t$, "OR") > 0 AND INSTR(l + 1, t$, "OR") < l1) THEN l1 = INSTR(l + 1, t$, "OR") + IF l1 = 0 OR (INSTR(l + 1, t$, "XOR") > 0 AND INSTR(l + 1, t$, "XOR") < l1) THEN l1 = INSTR(l + 1, t$, "XOR") + IF l1 = 0 OR (INSTR(l + 1, t$, "EQV") > 0 AND INSTR(l + 1, t$, "EQV") < l1) THEN l1 = INSTR(l + 1, t$, "EQV") + IF l1 = 0 OR (INSTR(l + 1, t$, "IMP") > 0 AND INSTR(l + 1, t$, "IMP") < l1) THEN l1 = INSTR(l + 1, t$, "IMP") + IF l1 = 0 THEN l1 = LEN(t$) + 1 + t$ = LEFT$(t$, l - 1) + "(" + MID$(t$, l, l1 - l) + ")" + MID$(t$, l + l1 - l) + l = l + 3 + 'PRINT t$ + END IF + LOOP UNTIL l = 0 + + uboundPP_TypeMod = TotalPrefixedPP_TypeMod + IF qb64prefix_set = 1 THEN uboundPP_TypeMod = TotalPP_TypeMod + FOR j = 1 TO uboundPP_TypeMod + l = 0 + DO + l = INSTR(l + 1, t$, PP_TypeMod(j)) + IF l = 0 THEN EXIT DO + i = 0: l1 = 0: l2 = 0: lo = LEN(PP_TypeMod(j)) + DO + IF PL(i) > 10 THEN + l2 = _INSTRREV(l, t$, OName$(i)) + IF l2 > 0 AND l2 > l1 THEN l1 = l2 + END IF + i = i + lo + LOOP UNTIL i > UBOUND(PL) + l$ = LEFT$(t$, l1) + m$ = MID$(t$, l1 + 1, l - l1 - 1) + r$ = PP_ConvertedMod(j) + MID$(t$, l + lo) + IF j > 15 THEN + t$ = l$ + m$ + r$ 'replacement routine for commands which might get confused with others, like _RGB and _RGB32 + ELSE + 'the first 15 commands need to properly place the parenthesis around the value we want to convert. + t$ = l$ + "(" + m$ + ")" + r$ + END IF + l = l + 2 + LEN(PP_TypeMod(j)) 'move forward from the length of the symbol we checked + the new "(" and ")" + LOOP + NEXT + + 'Check for bad operators before a ( bracket + l = 0 + DO + l = INSTR(l + 1, t$, "(") + IF l > 0 AND l > 2 THEN 'Don't check the starting bracket; there's nothing before it. + good = 0 + FOR i = 1 TO UBOUND(OName) + m$ = MID$(t$, l - LEN(OName(i)), LEN(OName(i))) + IF m$ = OName(i) THEN + good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) + ELSE + IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN + 'try without prefix + m$ = MID$(t$, l - (LEN(OName(i)) - 1), LEN(OName(i)) - 1) + IF m$ = MID$(OName(i), 2) THEN good = -1: EXIT FOR + END IF + END IF + NEXT + IF NOT good THEN e$ = "ERROR - Improper operations before (.": EXIT SUB + l = l + 1 + END IF + LOOP UNTIL l = 0 + + 'Check for bad operators after a ) bracket + l = 0 + DO + l = INSTR(l + 1, t$, ")") + IF l > 0 AND l < LEN(t$) THEN + good = 0 + FOR i = 1 TO UBOUND(OName) + m$ = MID$(t$, l + 1, LEN(OName(i))) + IF m$ = OName(i) THEN + good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI + ELSE + IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN + 'try without prefix + m$ = MID$(t$, l + 1, LEN(OName(i)) - 1) + IF m$ = MID$(OName(i), 2) THEN good = -1: EXIT FOR + END IF + END IF + NEXT + IF MID$(t$, l + 1, 1) = ")" THEN good = -1 + IF NOT good THEN e$ = "ERROR - Improper operations after ).": EXIT SUB + l = l + 1 + END IF + LOOP UNTIL l = 0 OR l = LEN(t$) 'last symbol is a bracket + + 'Turn all &H (hex) numbers into decimal values for the program to process properly + l = 0 + DO + l = INSTR(t$, "&H") + IF l THEN + E = l + 1: finished = 0 + DO + E = E + 1 + comp$ = MID$(t$, E, 1) + SELECT CASE comp$ + CASE "0" TO "9", "A" TO "F" 'All is good, our next digit is a number, continue to add to the hex$ + CASE ELSE + good = 0 + FOR i = 1 TO UBOUND(OName) + IF MID$(t$, E, LEN(OName(i))) = OName(i) AND PL(i) > 1 AND PL(i) <= 250 THEN good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) + NEXT + IF NOT good THEN e$ = "ERROR - Improper &H value. (" + comp$ + ")": EXIT SUB + E = E - 1 + finished = -1 + END SELECT + LOOP UNTIL finished OR E = LEN(t$) + t$ = LEFT$(t$, l - 1) + LTRIM$(RTRIM$(STR$(VAL(MID$(t$, l, E - l + 1))))) + MID$(t$, E + 1) + END IF + LOOP UNTIL l = 0 + + 'Turn all &B (binary) numbers into decimal values for the program to process properly + l = 0 + DO + l = INSTR(t$, "&B") + IF l THEN + E = l + 1: finished = 0 + DO + E = E + 1 + comp$ = MID$(t$, E, 1) + SELECT CASE comp$ + CASE "0", "1" 'All is good, our next digit is a number, continue to add to the hex$ + CASE ELSE + good = 0 + FOR i = 1 TO UBOUND(OName) + IF MID$(t$, E, LEN(OName(i))) = OName(i) AND PL(i) > 1 AND PL(i) <= 250 THEN good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) + NEXT + IF NOT good THEN e$ = "ERROR - Improper &B value. (" + comp$ + ")": EXIT SUB + E = E - 1 + finished = -1 + END SELECT + LOOP UNTIL finished OR E = LEN(t$) + bin$ = MID$(t$, l + 2, E - l - 1) + FOR i = 1 TO LEN(bin$) + IF MID$(bin$, i, 1) = "1" THEN f = f + 2 ^ (LEN(bin$) - i) + NEXT + t$ = LEFT$(t$, l - 1) + LTRIM$(RTRIM$(STR$(f))) + MID$(t$, E + 1) + END IF + LOOP UNTIL l = 0 + + + 't$ = N2S(t$) + VerifyString t$ + e$ = t$ +END SUB + + + +SUB VerifyString (t$) + 'ERROR CHECK for unrecognized operations + j = 1 + DO + comp$ = MID$(t$, j, 1) + SELECT CASE comp$ + CASE "0" TO "9", ".", "(", ")", ",": j = j + 1 + CASE ELSE + good = 0 + extrachar = 0 + FOR i = 1 TO UBOUND(OName) + IF MID$(t$, j, LEN(OName(i))) = OName(i) THEN + good = -1: EXIT FOR 'We found an operator after our ), and it's not a CONST (like PI) + ELSE + IF LEFT$(OName(i), 1) = "_" AND qb64prefix_set = 1 THEN + 'try without prefix + IF MID$(t$, j, LEN(OName(i)) - 1) = MID$(OName(i), 2) THEN + good = -1: extrachar = 1: EXIT FOR + END IF + END IF + END IF + NEXT + IF NOT good THEN t$ = "ERROR - Bad Operational value. (" + comp$ + ")": EXIT SUB + j = j + (LEN(OName(i)) - extrachar) + END SELECT + LOOP UNTIL j > LEN(t$) +END SUB + +FUNCTION N2S$ (exp$) 'scientific Notation to String + + t$ = LTRIM$(RTRIM$(exp$)) + IF LEFT$(t$, 1) = "-" OR LEFT$(t$, 1) = "N" THEN sign$ = "-": t$ = MID$(t$, 2) + + dp = INSTR(t$, "D+"): dm = INSTR(t$, "D-") + ep = INSTR(t$, "E+"): em = INSTR(t$, "E-") + check1 = SGN(dp) + SGN(dm) + SGN(ep) + SGN(em) + IF check1 < 1 OR check1 > 1 THEN N2S = exp$: EXIT FUNCTION 'If no scientic notation is found, or if we find more than 1 type, it's not SN! + + SELECT CASE l 'l now tells us where the SN starts at. + CASE IS < dp: l = dp + CASE IS < dm: l = dm + CASE IS < ep: l = ep + CASE IS < em: l = em + END SELECT + + l$ = LEFT$(t$, l - 1) 'The left of the SN + r$ = MID$(t$, l + 1): r&& = VAL(r$) 'The right of the SN, turned into a workable long + + + IF INSTR(l$, ".") THEN 'Location of the decimal, if any + IF r&& > 0 THEN + r&& = r&& - LEN(l$) + 2 + ELSE + r&& = r&& + 1 + END IF + l$ = LEFT$(l$, 1) + MID$(l$, 3) + END IF + + SELECT CASE r&& + CASE 0 'what the heck? We solved it already? + 'l$ = l$ + CASE IS < 0 + FOR i = 1 TO -r&& + l$ = "0" + l$ + NEXT + l$ = "0." + l$ + CASE ELSE + FOR i = 1 TO r&& + l$ = l$ + "0" + NEXT + END SELECT + + N2S$ = sign$ + l$ +END FUNCTION + + +FUNCTION QuotedFilename$ (f$) + + IF os$ = "WIN" THEN + QuotedFilename$ = CHR$(34) + f$ + CHR$(34) + EXIT FUNCTION + END IF + + IF os$ = "LNX" THEN + QuotedFilename$ = "'" + f$ + "'" + EXIT FUNCTION + END IF + +END FUNCTION + + +FUNCTION HashValue& (a$) 'returns the hash table value of a string + '[5(first)][5(second)][5(last)][5(2nd-last)][3(length AND 7)][1(first char is underscore)] + l = LEN(a$) + IF l = 0 THEN EXIT FUNCTION 'an (invalid) NULL string equates to 0 + a = ASC(a$) + IF a <> 95 THEN 'does not begin with underscore + SELECT CASE l + CASE 1 + HashValue& = hash1char(a) + 1048576 + EXIT FUNCTION + CASE 2 + HashValue& = hash2char(CVI(a$)) + 2097152 + EXIT FUNCTION + CASE 3 + HashValue& = hash2char(CVI(a$)) + hash1char(ASC(a$, 3)) * 1024 + 3145728 + EXIT FUNCTION + CASE ELSE + HashValue& = hash2char(CVI(a$)) + hash2char(ASC(a$, l) + ASC(a$, l - 1) * 256) * 1024 + (l AND 7) * 1048576 + EXIT FUNCTION + END SELECT + ELSE 'does begin with underscore + SELECT CASE l + CASE 1 + HashValue& = (1048576 + 8388608): EXIT FUNCTION 'note: underscore only is illegal in QB64 but supported by hash + CASE 2 + HashValue& = hash1char(ASC(a$, 2)) + (2097152 + 8388608) + EXIT FUNCTION + CASE 3 + HashValue& = hash2char(ASC(a$, 2) + ASC(a$, 3) * 256) + (3145728 + 8388608) + EXIT FUNCTION + CASE 4 + HashValue& = hash2char((CVL(a$) AND &HFFFF00) \ 256) + hash1char(ASC(a$, 4)) * 1024 + (4194304 + 8388608) + EXIT FUNCTION + CASE ELSE + HashValue& = hash2char((CVL(a$) AND &HFFFF00) \ 256) + hash2char(ASC(a$, l) + ASC(a$, l - 1) * 256) * 1024 + (l AND 7) * 1048576 + 8388608 + EXIT FUNCTION + END SELECT + END IF +END FUNCTION + +SUB HashAdd (a$, flags, reference) + + 'find the index to use + IF HashListFreeLast > 0 THEN + 'take from free list + i = HashListFree(HashListFreeLast) + HashListFreeLast = HashListFreeLast - 1 + ELSE + IF HashListNext > HashListSize THEN + 'double hash list size + HashListSize = HashListSize * 2 + REDIM _PRESERVE HashList(1 TO HashListSize) AS HashListItem + REDIM _PRESERVE HashListName(1 TO HashListSize) AS STRING * 256 + END IF + i = HashListNext + HashListNext = HashListNext + 1 + END IF + + 'setup links to index + x = HashValue(a$) + i2 = HashTable(x) + IF i2 THEN + i3 = HashList(i2).LastItem + HashList(i2).LastItem = i + HashList(i3).NextItem = i + HashList(i).PrevItem = i3 + ELSE + HashTable(x) = i + HashList(i).PrevItem = 0 + HashList(i).LastItem = i + END IF + HashList(i).NextItem = 0 + + 'set common hashlist values + HashList(i).Flags = flags + HashList(i).Reference = reference + HashListName(i) = UCASE$(a$) + +END SUB + +FUNCTION HashFind (a$, searchflags, resultflags, resultreference) + '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) + '0=doesn't exist + '1=found, no more items to scan + '2=found, more items still to scan + i = HashTable(HashValue(a$)) + IF i THEN + ua$ = UCASE$(a$) + SPACE$(256 - LEN(a$)) + hashfind_next: + f = HashList(i).Flags + IF searchflags AND f THEN 'flags in common + IF HashListName(i) = ua$ THEN + resultflags = f + resultreference = HashList(i).Reference + i2 = HashList(i).NextItem + IF i2 THEN + HashFind = 2 + HashFind_NextListItem = i2 + HashFind_Reverse = 0 + HashFind_SearchFlags = searchflags + HashFind_Name = ua$ + HashRemove_LastFound = i + EXIT FUNCTION + ELSE + HashFind = 1 + HashRemove_LastFound = i + EXIT FUNCTION + END IF + END IF + END IF + i = HashList(i).NextItem + IF i THEN GOTO hashfind_next + END IF +END FUNCTION + +FUNCTION HashFindRev (a$, searchflags, resultflags, resultreference) + '(0,1,2)z=hashfind[rev]("RUMI",Hashflag_label,resflag,resref) + '0=doesn't exist + '1=found, no more items to scan + '2=found, more items still to scan + i = HashTable(HashValue(a$)) + IF i THEN + i = HashList(i).LastItem + ua$ = UCASE$(a$) + SPACE$(256 - LEN(a$)) + hashfindrev_next: + f = HashList(i).Flags + IF searchflags AND f THEN 'flags in common + IF HashListName(i) = ua$ THEN + resultflags = f + resultreference = HashList(i).Reference + i2 = HashList(i).PrevItem + IF i2 THEN + HashFindRev = 2 + HashFind_NextListItem = i2 + HashFind_Reverse = 1 + HashFind_SearchFlags = searchflags + HashFind_Name = ua$ + HashRemove_LastFound = i + EXIT FUNCTION + ELSE + HashFindRev = 1 + HashRemove_LastFound = i + EXIT FUNCTION + END IF + END IF + END IF + i = HashList(i).PrevItem + IF i THEN GOTO hashfindrev_next + END IF +END FUNCTION + +FUNCTION HashFindCont (resultflags, resultreference) + '(0,1,2)z=hashfind[rev](resflag,resref) + '0=no more items exist + '1=found, no more items to scan + '2=found, more items still to scan + IF HashFind_Reverse THEN + + i = HashFind_NextListItem + hashfindrevc_next: + f = HashList(i).Flags + IF HashFind_SearchFlags AND f THEN 'flags in common + IF HashListName(i) = HashFind_Name THEN + resultflags = f + resultreference = HashList(i).Reference + i2 = HashList(i).PrevItem + IF i2 THEN + HashFindCont = 2 + HashFind_NextListItem = i2 + HashRemove_LastFound = i + EXIT FUNCTION + ELSE + HashFindCont = 1 + HashRemove_LastFound = i + EXIT FUNCTION + END IF + END IF + END IF + i = HashList(i).PrevItem + IF i THEN GOTO hashfindrevc_next + EXIT FUNCTION + + ELSE + + i = HashFind_NextListItem + hashfindc_next: + f = HashList(i).Flags + IF HashFind_SearchFlags AND f THEN 'flags in common + IF HashListName(i) = HashFind_Name THEN + resultflags = f + resultreference = HashList(i).Reference + i2 = HashList(i).NextItem + IF i2 THEN + HashFindCont = 2 + HashFind_NextListItem = i2 + HashRemove_LastFound = i + EXIT FUNCTION + ELSE + HashFindCont = 1 + HashRemove_LastFound = i + EXIT FUNCTION + END IF + END IF + END IF + i = HashList(i).NextItem + IF i THEN GOTO hashfindc_next + EXIT FUNCTION + + END IF +END FUNCTION + +SUB HashRemove + + i = HashRemove_LastFound + + 'add to free list + HashListFreeLast = HashListFreeLast + 1 + IF HashListFreeLast > HashListFreeSize THEN + HashListFreeSize = HashListFreeSize * 2 + REDIM _PRESERVE HashListFree(1 TO HashListFreeSize) AS LONG + END IF + HashListFree(HashListFreeLast) = i + + 'unlink + i1 = HashList(i).PrevItem + IF i1 THEN + 'not first item in list + i2 = HashList(i).NextItem + IF i2 THEN + '(not first and) not last item + HashList(i1).NextItem = i2 + HashList(i2).LastItem = i1 + ELSE + 'last item + x = HashTable(HashValue(HashListName$(i))) + HashList(x).LastItem = i1 + HashList(i1).NextItem = 0 + END IF + ELSE + 'first item in list + x = HashTable(HashValue(HashListName$(i))) + i2 = HashList(i).NextItem + IF i2 THEN + '(first item but) not last item + HashTable(x) = i2 + HashList(i2).PrevItem = 0 + HashList(i2).LastItem = HashList(i).LastItem + ELSE + '(first and) last item + HashTable(x) = 0 + END IF + END IF + +END SUB + +SUB HashDump 'used for debugging purposes + fh = FREEFILE + OPEN "hashdump.txt" FOR OUTPUT AS #fh + b$ = "12345678901234567890123456789012}" + FOR x = 0 TO 16777215 + IF HashTable(x) THEN + + PRINT #fh, "START HashTable("; x; "):" + i = HashTable(x) + + 'validate + lasti = HashList(i).LastItem + IF HashList(i).LastItem = 0 OR HashList(i).PrevItem <> 0 OR HashValue(HashListName(i)) <> x THEN GOTO corrupt + + PRINT #fh, " HashList("; i; ").LastItem="; HashList(i).LastItem + hashdumpnextitem: + x$ = " [" + STR$(i) + "]" + HashListName(i) + + f = HashList(i).Flags + x$ = x$ + ",.Flags=" + STR$(f) + "{" + FOR z = 1 TO 32 + ASC(b$, z) = (f AND 1) + 48 + f = f \ 2 + NEXT + x$ = x$ + b$ + + x$ = x$ + ",.Reference=" + STR$(HashList(i).Reference) + + PRINT #fh, x$ + + 'validate + i1 = HashList(i).PrevItem + i2 = HashList(i).NextItem + IF i1 THEN + IF HashList(i1).NextItem <> i THEN GOTO corrupt + END IF + IF i2 THEN + IF HashList(i2).PrevItem <> i THEN GOTO corrupt + END IF + IF i2 = 0 THEN + IF lasti <> i THEN GOTO corrupt + END IF + + i = HashList(i).NextItem + IF i THEN GOTO hashdumpnextitem + + PRINT #fh, "END HashTable("; x; ")" + END IF + NEXT + CLOSE #fh + + EXIT SUB + corrupt: + PRINT #fh, "HASH TABLE CORRUPT!" 'should never happen + CLOSE #fh + +END SUB + +SUB HashClear 'clear entire hash table + + HashListSize = 65536 + HashListNext = 1 + HashListFreeSize = 1024 + HashListFreeLast = 0 + REDIM HashList(1 TO HashListSize) AS HashListItem + REDIM HashListName(1 TO HashListSize) AS STRING * 256 + REDIM HashListFree(1 TO HashListFreeSize) AS LONG + REDIM HashTable(16777215) AS LONG '64MB lookup table with indexes to the hashlist + + HashFind_NextListItem = 0 + HashFind_Reverse = 0 + HashFind_SearchFlags = 0 + HashFind_Name = "" + HashRemove_LastFound = 0 + +END SUB + +FUNCTION removecast$ (a$) + removecast$ = a$ + IF INSTR(a$, " )") THEN + removecast$ = RIGHT$(a$, LEN(a$) - INSTR(a$, " )") - 2) + END IF +END FUNCTION + +FUNCTION converttabs$ (a2$) + IF ideautoindent THEN s = ideautoindentsize ELSE s = 4 + a$ = a2$ + DO WHILE INSTR(a$, CHR_TAB) + x = INSTR(a$, CHR_TAB) + a$ = LEFT$(a$, x - 1) + SPACE$(s - ((x - 1) MOD s)) + RIGHT$(a$, LEN(a$) - x) + LOOP + converttabs$ = a$ +END FUNCTION + + +FUNCTION NewByteElement$ + a$ = "byte_element_" + str2$(uniquenumber) + NewByteElement$ = a$ + IF use_global_byte_elements THEN + PRINT #18, "byte_element_struct *" + a$ + "=(byte_element_struct*)malloc(12);" + ELSE + PRINT #13, "byte_element_struct *" + a$ + "=NULL;" + PRINT #13, "if (!" + a$ + "){" + PRINT #13, "if ((mem_static_pointer+=12) 40 THEN + IF l = 0 THEN EXIT FUNCTION + 'Note: variable names with periods need to be obfuscated, and this affects their length + i = INSTR(a$, fix046$) + DO WHILE i + l = l - LEN(fix046$) + 1 + i = INSTR(i + 1, a$, fix046$) + LOOP + IF l > 40 THEN EXIT FUNCTION + l = LEN(a$) + END IF + + 'check for single, leading underscore + IF l >= 2 THEN + IF ASC(a$, 1) = 95 AND ASC(a$, 2) <> 95 THEN EXIT FUNCTION + END IF + + FOR i = 1 TO l + a = ASC(a$, i) + IF alphanumeric(a) = 0 THEN EXIT FUNCTION + IF isnumeric(a) THEN + trailingunderscore = 0 + IF alphabetletter = 0 THEN EXIT FUNCTION + ELSE + IF a = 95 THEN + trailingunderscore = 1 + ELSE + alphabetletter = 1 + trailingunderscore = 0 + END IF + END IF + NEXT + IF trailingunderscore THEN EXIT FUNCTION + validname = 1 +END FUNCTION + +FUNCTION str_nth$ (x) + IF x = 1 THEN str_nth$ = "1st": EXIT FUNCTION + IF x = 2 THEN str_nth$ = "2nd": EXIT FUNCTION + IF x = 3 THEN str_nth$ = "3rd": EXIT FUNCTION + str_nth$ = str2(x) + "th" +END FUNCTION + +SUB Give_Error (a$) + Error_Happened = 1 + Error_Message = a$ +END SUB + +SUB WriteConfigSetting (section$, item$, value$) + WriteSetting ConfigFile$, section$, item$, value$ +END SUB + +FUNCTION ReadConfigSetting (section$, item$, value$) + value$ = ReadSetting$(ConfigFile$, section$, item$) + ReadConfigSetting = (LEN(value$) > 0) +END FUNCTION + +FUNCTION VRGBS~& (text$, DefaultColor AS _UNSIGNED LONG) + 'Value of RGB String = VRGBS without a ton of typing + 'A function to get the RGB value back from a string such as _RGB32(255,255,255) + 'text$ is the string that we send to check for a value + 'DefaultColor is the value we send back if the string isn't in the proper format + + VRGBS~& = DefaultColor 'A return the default value if we can't parse the string properly + IF UCASE$(LEFT$(text$, 4)) = "_RGB" THEN + rpos = INSTR(text$, "(") + gpos = INSTR(rpos, text$, ",") + bpos = INSTR(gpos + 1, text$, ",") + IF rpos <> 0 AND bpos <> 0 AND gpos <> 0 THEN + red = VAL(_TRIM$(MID$(text$, rpos + 1))) + green = VAL(_TRIM$(MID$(text$, gpos + 1))) + blue = VAL(_TRIM$(MID$(text$, bpos + 1))) + VRGBS~& = _RGB32(red, green, blue) + END IF + END IF +END FUNCTION + +FUNCTION rgbs$ (c AS _UNSIGNED LONG) + rgbs$ = "_RGB32(" + _TRIM$(STR$(_RED32(c))) + ", " + _TRIM$(STR$(_GREEN32(c))) + ", " + _TRIM$(STR$(_BLUE32(c))) + ")" +END FUNCTION + +FUNCTION EvalPreIF (text$, err$) + temp$ = text$ 'so we don't corrupt the string sent to us for evaluation + err$ = "" 'null the err message to begin with + 'first order of business is to solve for <>= + DIM PC_Op(3) AS STRING + PC_Op(1) = "=" + PC_Op(2) = "<" + PC_Op(3) = ">" + DO + 'look for the existence of the first symbol if there is any + firstsymbol$ = "": first = 0 + FOR i = 1 TO UBOUND(PC_Op) + temp = INSTR(temp$, PC_Op(i)) + IF first = 0 THEN first = temp: firstsymbol$ = PC_Op(i) + IF temp <> 0 AND temp < first THEN first = temp: firstsymbol$ = PC_Op(i) + NEXT + IF firstsymbol$ <> "" THEN 'we've got = < >; let's see if we have a combination of them + secondsymbol = 0: second = 0 + FOR i = first + 1 TO LEN(temp$) + a$ = MID$(temp$, i, 1) + SELECT CASE a$ + CASE " " 'ignore spaces + CASE "=", "<", ">" + IF a$ = firstsymbol$ THEN err$ = "Duplicate operator (" + a$ + ")": EXIT FUNCTION + second = i: secondsymbol$ = a$ + CASE ELSE 'we found a symbol we don't recognize + EXIT FOR + END SELECT + NEXT + END IF + IF first THEN 'we found a symbol + l$ = RTRIM$(LEFT$(temp$, first - 1)) + IF second THEN rightstart = second + 1 ELSE rightstart = first + 1 + + r$ = LTRIM$(MID$(temp$, rightstart)) + symbol$ = MID$(temp$, first, 1) + MID$(temp$, second, 1) + 'now we check for spaces to separate this segment from any other AND/OR conditions and such + FOR i = LEN(l$) TO 1 STEP -1 + IF ASC(l$, i) = 32 THEN EXIT FOR + NEXT + leftside$ = RTRIM$(LEFT$(temp$, i)) + l$ = LTRIM$(RTRIM$(MID$(temp$, i + 1, LEN(l$) - i))) + IF validname(l$) = 0 THEN err$ = "Invalid flag name": EXIT FUNCTION + rightstop = LEN(r$) + FOR i = 1 TO LEN(r$) + IF ASC(r$, i) = 32 THEN EXIT FOR + NEXT + rightside$ = LTRIM$(MID$(r$, i + 1)) + r$ = LTRIM$(RTRIM$(LEFT$(r$, i - 1))) + IF symbol$ = "=<" THEN symbol$ = "<=" + IF symbol$ = "=>" THEN symbol$ = ">=" + IF symbol$ = "><" THEN symbol$ = "<>" + result$ = " 0 " + IF symbol$ = "<>" THEN 'check to see if we're NOT equal in any case with <> + FOR i = 0 TO UserDefineCount + IF UserDefine(0, i) = l$ AND UserDefine(1, i) <> r$ THEN result$ = " -1 ": GOTO finishedcheck + NEXT + END IF + IF INSTR(symbol$, "=") THEN 'check to see if we're equal in any case with = + UserFound = 0 + FOR i = 0 TO UserDefineCount + IF UserDefine(0, i) = l$ THEN + UserFound = -1 + IF UserDefine(1, i) = r$ THEN result$ = " -1 ": GOTO finishedcheck + END IF + NEXT + IF UserFound = 0 AND LTRIM$(RTRIM$(r$)) = "UNDEFINED" THEN result$ = " -1 ": GOTO finishedcheck + IF UserFound = -1 AND LTRIM$(RTRIM$(r$)) = "DEFINED" THEN result$ = " -1 ": GOTO finishedcheck + END IF + + IF INSTR(symbol$, ">") THEN 'check to see if we're greater than in any case with > + FOR i = 0 TO UserDefineCount + IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values + IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) > VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck + ELSE + IF UserDefine(0, i) = l$ AND UserDefine(1, i) > r$ THEN result$ = " -1 ": GOTO finishedcheck + END IF + NEXT + END IF + IF INSTR(symbol$, "<") THEN 'check to see if we're less than in any case with < + FOR i = 0 TO UserDefineCount + IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values + IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) < VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck + ELSE + IF UserDefine(0, i) = l$ AND UserDefine(1, i) < r$ THEN result$ = " -1 ": GOTO finishedcheck + END IF + NEXT + END IF + + + + finishedcheck: + temp$ = leftside$ + result$ + rightside$ + END IF + LOOP UNTIL first = 0 + + 'And at this point we should now be down to a statement with nothing but AND/OR/XORS in it + + PC_Op(1) = " AND " + PC_Op(2) = " OR " + PC_Op(3) = " XOR " + + DO + first = 0 + FOR i = 1 TO UBOUND(PC_Op) + IF PC_Op(i) <> "" THEN + t = INSTR(temp$, PC_Op(i)) + IF first <> 0 THEN + IF t < first AND t <> 0 THEN first = t: firstsymbol = i + ELSE + first = t: firstsymbol = i + END IF + END IF + NEXT + IF first = 0 THEN EXIT DO + leftside$ = RTRIM$(LEFT$(temp$, first - 1)) + symbol$ = MID$(temp$, first, LEN(PC_Op(firstsymbol))) + t$ = MID$(temp$, first + LEN(PC_Op(firstsymbol))) + t = INSTR(t$, " ") 'the first space we come to + IF t THEN + m$ = LTRIM$(RTRIM$(LEFT$(t$, t - 1))) + rightside$ = LTRIM$(MID$(t$, t)) + ELSE + m$ = LTRIM$(MID$(t$, t)) + rightside$ = "" + END IF + leftresult = 0 + IF VerifyNumber(leftside$) THEN + IF VAL(leftside$) <> 0 THEN leftresult = -1 + ELSE + FOR i = 0 TO UserDefineCount + IF UserDefine(0, i) = leftside$ THEN + t$ = LTRIM$(RTRIM$(UserDefine(1, i))) + IF t$ <> "0" AND t$ <> "" THEN leftresult = -1: EXIT FOR + END IF + NEXT + END IF + rightresult = 0 + IF VerifyNumber(m$) THEN + IF VAL(m$) <> 0 THEN rightresult = -1 + ELSE + FOR i = 0 TO UserDefineCount + IF UserDefine(0, i) = m$ THEN + t$ = LTRIM$(RTRIM$(UserDefine(1, i))) + IF t$ <> "0" AND t$ <> "" THEN rightresult = -1: EXIT FOR + END IF + NEXT + END IF + SELECT CASE LTRIM$(RTRIM$(symbol$)) + CASE "AND" + IF leftresult <> 0 AND rightresult <> 0 THEN result$ = " -1 " ELSE result$ = " 0 " + CASE "OR" + IF leftresult <> 0 OR rightresult <> 0 THEN result$ = " -1 " ELSE result$ = " 0 " + CASE "XOR" + IF leftresult <> rightresult THEN result$ = " -1 " ELSE result$ = " 0 " + END SELECT + temp$ = result$ + rightside$ + LOOP + + IF VerifyNumber(temp$) THEN + EvalPreIF = VAL(temp$) + ELSE + IF INSTR(temp$, " ") THEN err$ = "Invalid Resolution of $IF; check statements" 'If we've got more than 1 statement, it's invalid + FOR i = 0 TO UserDefineCount + IF UserDefine(0, i) = temp$ THEN + t$ = LTRIM$(RTRIM$(UserDefine(1, i))) + IF t$ <> "0" AND t$ <> "" THEN EvalPreIF = -1: EXIT FOR + END IF + NEXT + END IF + +END FUNCTION + +FUNCTION VerifyNumber (text$) + t$ = LTRIM$(RTRIM$(text$)) + v = VAL(t$) + t1$ = LTRIM$(STR$(v)) + IF t$ = t1$ THEN VerifyNumber = -1 +END FUNCTION + +SUB initialise_udt_varstrings (n$, udt, file, base_offset) + IF NOT udtxvariable(udt) THEN EXIT SUB + element = udtxnext(udt) + offset = 0 + DO WHILE element + IF udtetype(element) AND ISSTRING THEN + IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + PRINT #file, "*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ") = qbs_new(0,0);" + END IF + ELSEIF udtetype(element) AND ISUDT THEN + initialise_udt_varstrings n$, udtetype(element) AND 511, file, offset + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + +SUB free_udt_varstrings (n$, udt, file, base_offset) + IF NOT udtxvariable(udt) THEN EXIT SUB + element = udtxnext(udt) + offset = 0 + DO WHILE element + IF udtetype(element) AND ISSTRING THEN + IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + PRINT #file, "qbs_free(*((qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ")));" + END IF + ELSEIF udtetype(element) AND ISUDT THEN + initialise_udt_varstrings n$, udtetype(element) AND 511, file, offset + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + +SUB clear_udt_with_varstrings (n$, udt, file, base_offset) + IF NOT udtxvariable(udt) THEN EXIT SUB + element = udtxnext(udt) + offset = 0 + DO WHILE element + IF udtetype(element) AND ISSTRING THEN + IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + PRINT #file, "(*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + "))->len=0;" + ELSE + PRINT #file, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");" + END IF + ELSE + IF udtetype(element) AND ISUDT THEN + clear_udt_with_varstrings n$, udtetype(element) AND 511, file, base_offset + offset + ELSE + PRINT #file, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");" + END IF + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + + +SUB initialise_array_udt_varstrings (n$, udt, base_offset, bytesperelement$, acc$) + IF NOT udtxvariable(udt) THEN EXIT SUB + offset = base_offset + element = udtxnext(udt) + DO WHILE element + IF udtetype(element) AND ISSTRING THEN + IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + acc$ = acc$ + CHR$(13) + CHR$(10) + "*(qbs**)(" + n$ + "[0]+(" + bytesperelement$ + "-1)*tmp_long+" + STR$(offset) + ")=qbs_new(0,0);" + END IF + ELSEIF udtetype(element) AND ISUDT THEN + initialise_array_udt_varstrings n$, udtetype(element) AND 511, offset, bytesperelement$, acc$ + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + +SUB free_array_udt_varstrings (n$, udt, base_offset, bytesperelement$, acc$) + IF NOT udtxvariable(udt) THEN EXIT SUB + offset = base_offset + element = udtxnext(udt) + DO WHILE element + IF udtetype(element) AND ISSTRING THEN + IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + acc$ = acc$ + CHR$(13) + CHR$(10) + "qbs_free(*(qbs**)(" + n$ + "[0]+(" + bytesperelement$ + "-1)*tmp_long+" + STR$(offset) + "));" + END IF + ELSEIF udtetype(element) AND ISUDT THEN + free_array_udt_varstrings n$, udtetype(element) AND 511, offset, bytesperelement$, acc$ + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + +SUB copy_full_udt (dst$, src$, file, base_offset, udt) + IF NOT udtxvariable(udt) THEN + PRINT #file, "memcpy(" + dst$ + "+" + STR$(base_offset) + "," + src$ + "+" + STR$(base_offset) + "," + STR$(udtxsize(udt) \ 8) + ");" + EXIT SUB + END IF + offset = base_offset + element = udtxnext(udt) + DO WHILE element + IF ((udtetype(element) AND ISSTRING) > 0) AND (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN + PRINT #file, "qbs_set(*(qbs**)(" + dst$ + "+" + STR$(offset) + "), *(qbs**)(" + src$ + "+" + STR$(offset) + "));" + ELSEIF ((udtetype(element) AND ISUDT) > 0) THEN + copy_full_udt dst$, src$, 12, offset, udtetype(element) AND 511 + ELSE + PRINT #file, "memcpy((" + dst$ + "+" + STR$(offset) + "),(" + src$ + "+" + STR$(offset) + ")," + STR$(udtesize(element) \ 8) + ");" + END IF + offset = offset + udtesize(element) \ 8 + element = udtenext(element) + LOOP +END SUB + +SUB dump_udts + f = FREEFILE + OPEN "types.txt" FOR OUTPUT AS #f + PRINT #f, "Name Size Align? Next Var?" + FOR i = 1 TO lasttype + PRINT #f, RTRIM$(udtxname(i)), udtxsize(i), udtxbytealign(i), udtxnext(i), udtxvariable(i) + NEXT i + PRINT #f, "Name Size Align? Next Type Tsize Arr" + FOR i = 1 TO lasttypeelement + PRINT #f, RTRIM$(udtename(i)), udtesize(i), udtebytealign(i), udtenext(i), udtetype(i), udtetypesize(i), udtearrayelements(i) + NEXT i + CLOSE #f +END SUB + +SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) + DIM findItem AS LONG, cname$, i AS LONG, j AS LONG, name$, temp$ + name$ = RTRIM$(__name$) + cname$ = RTRIM$(__cname$) + + IF LEN(cname$) = 0 THEN EXIT SUB + + findItem = INSTR(cname$, "[") + IF findItem THEN + cname$ = LEFT$(cname$, findItem - 1) + END IF + + found = 0 + FOR i = 1 TO totalVariablesCreated + IF usedVariableList(i).cname = cname$ THEN found = -1: EXIT FOR + NEXT + + SELECT CASE action + CASE 0 'add + IF found = 0 THEN + IF i > UBOUND(usedVariableList) THEN + REDIM _PRESERVE usedVariableList(UBOUND(usedVariableList) + 999) AS usedVarList + END IF + + usedVariableList(i).id = currentid + usedVariableList(i).used = 0 + usedVariableList(i).watch = 0 + usedVariableList(i).displayFormat = 0 + usedVariableList(i).storage = "" + usedVariableList(i).linenumber = linenumber + usedVariableList(i).includeLevel = inclevel + IF inclevel > 0 THEN + usedVariableList(i).includedLine = inclinenumber(inclevel) + thisincname$ = getfilepath$(incname$(inclevel)) + thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1) + usedVariableList(i).includedFile = thisincname$ + ELSE + totalMainVariablesCreated = totalMainVariablesCreated + 1 + usedVariableList(i).includedLine = 0 + usedVariableList(i).includedFile = "" + END IF + usedVariableList(i).scope = subfuncn + usedVariableList(i).subfunc = subfunc + usedVariableList(i).varType = id2fulltypename$ + usedVariableList(i).cname = cname$ + usedVariableList(i).localIndex = localIndex + + 'remove eventual instances of fix046$ in name$ + DO WHILE INSTR(name$, fix046$) + x = INSTR(name$, fix046$): name$ = LEFT$(name$, x - 1) + "." + RIGHT$(name$, LEN(name$) - x + 1 - LEN(fix046$)) + LOOP + + IF LEN(RTRIM$(id.musthave)) > 0 THEN + usedVariableList(i).name = name$ + RTRIM$(id.musthave) + ELSEIF LEN(RTRIM$(id.mayhave)) > 0 THEN + usedVariableList(i).name = name$ + RTRIM$(id.mayhave) + ELSE + usedVariableList(i).name = name$ + END IF + + IF (id.arrayelements > 0) THEN + usedVariableList(i).isarray = -1 + usedVariableList(i).name = usedVariableList(i).name + "()" + ELSE + usedVariableList(i).isarray = 0 + END IF + usedVariableList(i).watchRange = "" + usedVariableList(i).arrayElementSize = 0 + usedVariableList(i).indexes = "" + usedVariableList(i).elements = "" + usedVariableList(i).elementTypes = "" + usedVariableList(i).elementOffset = "" + totalVariablesCreated = totalVariablesCreated + 1 + + temp$ = MKL$(-1) + MKL$(LEN(cname$)) + cname$ + found = INSTR(backupVariableWatchList$, temp$) + IF found THEN + 'this variable existed in a previous edit of this program + 'in this same session; let's preselect it. + j = CVL(MID$(backupVariableWatchList$, found + LEN(temp$), 4)) + + 'if there have been changes in TYPEs, this variable won't be preselected + IF (LEN(backupUsedVariableList(j).elements) > 0 AND backupTypeDefinitions$ = typeDefinitions$) OR _ + (LEN(backupUsedVariableList(j).elements) = 0) THEN + usedVariableList(i).watch = backupUsedVariableList(j).watch + usedVariableList(i).watchRange = backupUsedVariableList(j).watchRange + usedVariableList(i).indexes = backupUsedVariableList(j).indexes + usedVariableList(i).displayFormat = backupUsedVariableList(j).displayFormat + usedVariableList(i).elements = backupUsedVariableList(j).elements + usedVariableList(i).elementTypes = backupUsedVariableList(j).elementTypes + usedVariableList(i).elementOffset = backupUsedVariableList(j).elementOffset + END IF + END IF + END IF + CASE ELSE 'find and mark as used + IF found THEN + usedVariableList(i).used = -1 + END IF + END SELECT +END SUB + +SUB addWarning (whichLineNumber AS LONG, includeLevel AS LONG, incLineNumber AS LONG, incFileName$, header$, text$) + warningsissued = -1 + totalWarnings = totalWarnings + 1 + + IF idemode = 0 AND ShowWarnings THEN + thissource$ = getfilepath$(CMDLineFile) + thissource$ = MID$(CMDLineFile, LEN(thissource$) + 1) + thisincname$ = getfilepath$(incFileName$) + thisincname$ = MID$(incFileName$, LEN(thisincname$) + 1) + + IF NOT MonochromeLoggingMode THEN COLOR 15 + IF includeLevel > 0 AND incLineNumber > 0 THEN + PRINT thisincname$; ":"; + PRINT str2$(incLineNumber); ": "; + ELSE + PRINT thissource$; ":"; + PRINT str2$(whichLineNumber); ": "; + END IF + + IF NOT MonochromeLoggingMode THEN COLOR 13 + PRINT "warning: "; + IF NOT MonochromeLoggingMode THEN COLOR 7 + PRINT header$ + + IF LEN(text$) > 0 THEN + IF NOT MonochromeLoggingMode THEN COLOR 2 + PRINT SPACE$(4); text$ + IF NOT MonochromeLoggingMode THEN COLOR 7 + END IF + ELSEIF idemode THEN + IF NOT IgnoreWarnings THEN + IF whichLineNumber > maxLineNumber THEN maxLineNumber = whichLineNumber + IF lastWarningHeader <> header$ THEN + lastWarningHeader = header$ + GOSUB increaseWarningCount + warning$(warningListItems) = header$ + warningLines(warningListItems) = 0 + END IF + + GOSUB increaseWarningCount + warning$(warningListItems) = text$ + warningLines(warningListItems) = whichLineNumber + IF includeLevel > 0 THEN + thisincname$ = getfilepath$(incFileName$) + thisincname$ = MID$(incFileName$, LEN(thisincname$) + 1) + warningIncLines(warningListItems) = incLineNumber + warningIncFiles(warningListItems) = thisincname$ + ELSE + warningIncLines(warningListItems) = 0 + warningIncFiles(warningListItems) = "" + END IF + END IF + END IF + EXIT SUB + increaseWarningCount: + warningListItems = warningListItems + 1 + IF warningListItems > UBOUND(warning$) THEN + REDIM _PRESERVE warning$(warningListItems + 999) + REDIM _PRESERVE warningLines(warningListItems + 999) AS LONG + REDIM _PRESERVE warningIncLines(warningListItems + 999) AS LONG + REDIM _PRESERVE warningIncFiles(warningListItems + 999) AS STRING + END IF + RETURN +END SUB + +FUNCTION SCase$ (t$) + IF ideautolayoutkwcapitals THEN SCase$ = UCASE$(t$) ELSE SCase$ = t$ +END FUNCTION + +FUNCTION SCase2$ (t$) + separator$ = sp + IF ideautolayoutkwcapitals THEN + SCase2$ = UCASE$(t$) + ELSE + newWord = -1 + temp$ = "" + FOR i = 1 TO LEN(t$) + s$ = MID$(t$, i, 1) + IF newWord THEN + IF s$ = "_" OR s$ = separator$ THEN + temp$ = temp$ + s$ + ELSE + temp$ = temp$ + UCASE$(s$) + newWord = 0 + END IF + ELSE + IF s$ = separator$ THEN + temp$ = temp$ + separator$ + newWord = -1 + ELSE + temp$ = temp$ + LCASE$(s$) + END IF + END IF + NEXT + SCase2$ = temp$ + END IF +END FUNCTION + +SUB increaseUDTArrays + x = UBOUND(udtxname) + REDIM _PRESERVE udtxname(x + 1000) AS STRING * 256 + REDIM _PRESERVE udtxcname(x + 1000) AS STRING * 256 + REDIM _PRESERVE udtxsize(x + 1000) AS LONG + REDIM _PRESERVE udtxbytealign(x + 1000) AS INTEGER 'first element MUST be on a byte alignment & size is a multiple of 8 + REDIM _PRESERVE udtxnext(x + 1000) AS LONG + REDIM _PRESERVE udtxvariable(x + 1000) AS INTEGER 'true if the udt contains variable length elements + 'elements + REDIM _PRESERVE udtename(x + 1000) AS STRING * 256 + REDIM _PRESERVE udtecname(x + 1000) AS STRING * 256 + REDIM _PRESERVE udtebytealign(x + 1000) AS INTEGER + REDIM _PRESERVE udtesize(x + 1000) AS LONG + REDIM _PRESERVE udtetype(x + 1000) AS LONG + REDIM _PRESERVE udtetypesize(x + 1000) AS LONG + REDIM _PRESERVE udtearrayelements(x + 1000) AS LONG + REDIM _PRESERVE udtenext(x + 1000) AS LONG +END SUB + +'$INCLUDE:'utilities\strings.bas' +'$INCLUDE:'utilities\file.bas' +'$INCLUDE:'utilities\build.bas' +'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas' +'$INCLUDE:'utilities\ini-manager\ini.bm' + +DEFLNG A-Z + +'-------- Optional IDE Component (2/2) -------- +'$INCLUDE:'ide\ide_methods.bas' + + diff --git a/source/qb64pe.ico b/source/qb64pe.ico new file mode 100644 index 000000000..541e29c47 Binary files /dev/null and b/source/qb64pe.ico differ diff --git a/source/qb64pe.png b/source/qb64pe.png new file mode 100644 index 000000000..5ae162cfa Binary files /dev/null and b/source/qb64pe.png differ diff --git a/tests/compile_tests/icon/qb64.ico b/tests/compile_tests/icon/qb64.ico deleted file mode 100644 index ca26aacfd..000000000 Binary files a/tests/compile_tests/icon/qb64.ico and /dev/null differ diff --git a/tests/compile_tests/icon/qb64pe.ico b/tests/compile_tests/icon/qb64pe.ico new file mode 100644 index 000000000..541e29c47 Binary files /dev/null and b/tests/compile_tests/icon/qb64pe.ico differ diff --git a/tests/compile_tests/icon/test.bas b/tests/compile_tests/icon/test.bas index 31159d091..84538fadf 100644 --- a/tests/compile_tests/icon/test.bas +++ b/tests/compile_tests/icon/test.bas @@ -1,4 +1,4 @@ -$EXEICON:'tests/compile_tests/icon/qb64.ico' +$EXEICON:'tests/compile_tests/icon/qb64pe.ico' _ICON diff --git a/tests/compile_tests/icon_relative/qb64.ico b/tests/compile_tests/icon_relative/qb64.ico deleted file mode 100644 index ca26aacfd..000000000 Binary files a/tests/compile_tests/icon_relative/qb64.ico and /dev/null differ diff --git a/tests/compile_tests/icon_relative/qb64pe.ico b/tests/compile_tests/icon_relative/qb64pe.ico new file mode 100644 index 000000000..541e29c47 Binary files /dev/null and b/tests/compile_tests/icon_relative/qb64pe.ico differ diff --git a/tests/compile_tests/icon_relative/test.bas b/tests/compile_tests/icon_relative/test.bas index 622fe14d1..c8cb068e7 100644 --- a/tests/compile_tests/icon_relative/test.bas +++ b/tests/compile_tests/icon_relative/test.bas @@ -1,4 +1,4 @@ -$EXEICON:'./qb64.ico' +$EXEICON:'./qb64pe.ico' _ICON diff --git a/tests/compile_tests/winresource/qb64.ico b/tests/compile_tests/winresource/qb64.ico deleted file mode 100644 index ca26aacfd..000000000 Binary files a/tests/compile_tests/winresource/qb64.ico and /dev/null differ diff --git a/tests/compile_tests/winresource/qb64pe.ico b/tests/compile_tests/winresource/qb64pe.ico new file mode 100644 index 000000000..541e29c47 Binary files /dev/null and b/tests/compile_tests/winresource/qb64pe.ico differ diff --git a/tests/compile_tests/winresource/test.bas b/tests/compile_tests/winresource/test.bas index 438db5f7b..63904ba23 100644 --- a/tests/compile_tests/winresource/test.bas +++ b/tests/compile_tests/winresource/test.bas @@ -1,5 +1,5 @@ -$EXEICON:'tests/compile_tests/winresource/qb64.ico' +$EXEICON:'tests/compile_tests/winresource/qb64pe.ico' $VERSIONINFO:FileDescription='Test Description' $VERSIONINFO:ProductName='Test Product Name' diff --git a/tests/dist_tests.sh b/tests/dist_tests.sh index dc95a8ec9..bb1f164f4 100755 --- a/tests/dist_tests.sh +++ b/tests/dist_tests.sh @@ -25,7 +25,7 @@ case "$2" in win) # Verify that the Resource information was correctly applied # windres returns an error if the exe has no resource section - windresResult=$($ROOT/internal/c/c_compiler/bin/windres.exe -i ./qb64.exe) + windresResult=$($ROOT/internal/c/c_compiler/bin/windres.exe -i ./qb64pe.exe) assert_success_named "Windows Resource Section" printf "\n$windresResult\n" ;; @@ -53,7 +53,7 @@ do TESTCASE=$test - ./qb64 -x "$TEST_CASES/$test.bas" -o "$outputExe" 1>$RESULTS_DIR/$test-compile_result.txt + ./qb64pe -x "$TEST_CASES/$test.bas" -o "$outputExe" 1>$RESULTS_DIR/$test-compile_result.txt ERR=$? cp_if_exists ./internal/temp/compilelog.txt $RESULTS_DIR/$test-compilelog.txt diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 68f73dbf6..7f84eca51 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -2,7 +2,7 @@ result=0 -./tests/assert.sh ./tests/compile_tests.sh ./qb64 || result=1 -./tests/assert.sh ./tests/qbasic_tests.sh ./qb64 || result=1 +./tests/assert.sh ./tests/compile_tests.sh ./qb64pe || result=1 +./tests/assert.sh ./tests/qbasic_tests.sh ./qb64pe || result=1 exit $result