Skip to content

A BASIC interpreter for the terminal (or console), written in C

License

Notifications You must be signed in to change notification settings

PQCraft/CLIBASIC

Repository files navigation


image

Command Line Interface Beginners All-purpose Symbolic Instruction Code

CLIBASIC is a version of BASIC designed to run in the command line or terminal



Links

Examples: https://github.com/PQCraft/clibasic-examples
Documentation: https://github.com/PQCraft/clibasic-docs
Extensions: https://github.com/PQCraft/clibasic-extensions
Windows Readline: https://github.com/PQCraft/clibasic-winrllib


Required Packages/Programs

Linux

Arch (pacman): base-devel, readline
Debian (apt): build-essential, libreadline-dev
Alpine (apk): build-base, readline-dev

Windows

NT - 10 (download): MinGW, Make for Windows
7 - 10 (choco): mingw, make

MacOS

Mojave - Big Sur (brew): gcc, make, readline


Recommended Packages/Programs

Linux

Arch (pacman): git
Debian (apt): git
Alpine (apk): git

Windows

NT - 10 (download): git
7 - 10 (choco): git

MacOS

Mojave - Big Sur (brew): git


Building and Running

Linux/MacOS

To build, use make build.
To run, use make run or ./clibasic.
To build then run, use make (same as make all).

Windows

Make sure you have downloaded the readline lib folder from here.

  1. Download the ZIP
  2. Go into the .zip file you downloaded
  3. Copy the lib folder in clibasic-winrllib-master
  4. Paste the folder into the directory with your CLIBASIC source code

Make sure the bin folders of MinGW and Make are in the %PATH%.
Type gcc --version into CMD and if you received a "Can't recognize" message, MinGW is not in your %PATH%.
Type make --version into CMD and if you received a "Can't recognize" message, Make is not in your %PATH%.
How to add MinGW and/or Make to the %PATH%:

  1. Navigate to where MinGW or Make is installed
  2. For MinGW, open the mingw64 folder
  3. Open the bin folder
  4. Copy the location
  5. Add the location you copied to the %PATH% environment variable
    • For Windows 7 and older
      1. Open the Start Menu
      2. Right-click on Computer and click Properties
      3. Click Advanced system settings
      4. Click the Advanced tab
      5. Click Environment Variables
      6. Under System variables, find Path and click Edit
      7. Add the copied location
    • For Windows 8 and newer
      1. Open the Start Menu
      2. Search for and run 'Edit the system environment variables'
      3. Click Environment Variables
      4. Under System variables, find Path and click Edit
      5. Add the copied location

To build, use make build.
To run, use make run or .\clibasic.exe.
To build then run, use make (same as make all).
To build CLIBASIC with support for VT escape codes, add vt before the rest of the rules.


Demo

asciicast



Notes

  • On Arch Linux, you can install CLIBASIC by installing either the clibasic or clibasic-bin AUR package.
  • On Windows, pressing CTRL+C will not display a new prompt line due to the Windows version of readline catching and ignoring the CTRL+C.
  • Most terminals cannot handle input while processing a cursor position request and INKEY$() will not reflect keys that were pressed during that time. The effect is more noticeable on terminals that are slow to respond such as Alacritty, Gnome Terminal, and Termux. A terminal that is fast to respond such as Konsole is recommended.
  • If the file .clibasic_history is present in the user's home directory CLIBASIC will automatically save history there. Run _AUTOCMDHIST, _SAVECMDHIST (without any arguments), or create the file .clibasic_history in your home/user folder to enable this feature. Remove the file to disable this feature.
  • CLIBASIC will look for ~/.clibasicrc, ~/autorun.bas, then ~/.autorun.bas in this order in the user's home directory and run the first file found.
  • The development scripts are build.sh which is for testing if CLIBASIC compiles correctly for Linux and Windows, package.sh which creates the zip files for making a CLIBASIC release, commit.sh which automates the build and push process, and release-text.sh which generates the text for making a CLIBASIC release.
  • Include the clibasic.h file when making a clibasic extension.
  • There will most likely not be any more updates as CLIBASIC is a major architectural disaster.