top of page

Infirmiere Québec

Public·4 membres

How to Run QBasic Programs on Windows, Linux and macOS with QB64


QBasic 64: A Modern Version of BASIC for the Modern Era




QBasic is one of the most popular and easy-to-learn programming languages in the world. It was developed by Microsoft in the late 1980s as a simplified version of QuickBASIC, which was itself a successor of GW-BASIC and BASICA. QBasic was widely used for teaching programming, creating games, and developing simple applications. However, with the advent of newer operating systems and technologies, QBasic became obsolete and incompatible with modern computers.




qbasic 64 download



That's where QBasic 64 comes in. QBasic 64 is a self-hosting BASIC compiler for Windows, Linux, and Mac OS X, designed to be compatible with Microsoft QBasic and QuickBASIC. It is also known as QB64, which stands for QuickBASIC Extended for Windows/Linux/Mac OS X. QBasic 64 is a free and open-source software that can be downloaded from GitHub. It allows you to run many QBasic programs on modern machines, as well as create new programs using enhanced features and capabilities.


In this article, we will explore what QBasic 64 is, what it can do, how to use it, and some examples of programs written in it. We will also learn about the history and development of QBasic 64 and its relation to other BASIC dialects.


Features of QBasic 64




QBasic 64 is not just a clone of QBasic or QuickBASIC. It is a modern version of BASIC that retains the simplicity and elegance of the original language while adding new features and improvements. Some of the main features and advantages of QBasic 64 are:


  • It is compatible with most QBasic statements and functions, as well as many QuickBASIC commands. It can run many QBasic programs without modification, including Microsoft's QBasic Gorillas and Nibbles games.



  • It extends the QBASIC programming language to include 64-bit data types, such as _INTEGER64 (&&) and _FLOAT (##), which can store larger numbers and more precision than the standard data types.



  • It supports better sound and graphics than QBasic or QuickBASIC. It can play WAV files, MIDI files, MP3 files, OGG files, MOD files, etc. It can also display images in various formats, such as BMP, PNG, JPG, GIF, etc. It can also create animations, sprites, fonts, shapes, colors, etc.



  • It has debugging abilities, such as breakpoints, watch variables, step over/into/out commands, etc. It also has a new $DEBUG meta command that allows you to enable or disable debugging features in your code.



  • It can compile your code into native binaries for Windows (XP and up), Linux (32-bit or 64-bit), or Mac OS X (Intel or PowerPC). It can also create standalone executables that do not require any external libraries or files.



It has an integrated development environment (IDE) that resembles the QBASIC IDE Tutorial of QBasic 64




Now that you have learned what QBasic 64 is and what it can do, let's see how to use it to create your own programs. In this section, we will cover the basics of using the integrated development environment (IDE) and the interpreter of QBasic 64, as well as some fundamental concepts and syntax of the QBasic 64 programming language.


Using the IDE and the interpreter




The IDE of QBasic 64 is where you write, edit, save, load, run, and debug your code. It consists of a menu bar, a toolbar, a status bar, and a text editor. The menu bar provides access to various commands and options, such as File, Edit, View, Run, Debug, Options, and Help. The toolbar contains buttons for some frequently used commands, such as New, Open, Save, Run, Stop, etc. The status bar shows information about the current line and column number, the current mode (Ready or Running), and any error messages. The text editor is where you type your code using the QBasic 64 syntax.


The interpreter of QBasic 64 is what executes your code and displays the output on the screen. It can run your code in two ways: either by compiling it to an intermediate representation (IR) and executing it on demand within the IDE (this is the default mode), or by compiling it to a native binary for your operating system and executing it as a standalone executable (this requires using the F11 key or the Make EXE File command from the Run menu). The interpreter also provides error handling and debugging features, such as displaying error messages, highlighting syntax errors, setting breakpoints, watching variables, stepping through code, etc.


Writing and running a simple program




To write a simple program in QBasic 64, you need to follow these steps:


qbasic 64 download for windows 10


qbasic 64 download for mac


qbasic 64 download for linux


qbasic 64 download free


qbasic 64 download github


qbasic 64 download softpedia


qbasic 64 download latest version


qbasic 64 download source code


qbasic 64 download and install


qbasic 64 download zip file


qbasic 64 download windows 7


qbasic 64 download windows 8


qbasic 64 download windows xp


qbasic 64 download tutorial


qbasic 64 download examples


qbasic 64 download games


qbasic 64 download programs


qbasic 64 download compiler


qbasic 64 download ide


qbasic 64 download manual


qbasic 64 download wiki


qbasic 64 download forum


qbasic 64 download discord


qbasic 64 download twitter


qbasic 64 download youtube


qbasic 64 download reddit


qbasic 64 download quora


qbasic 64 download stack overflow


qbasic 64 download review


qbasic 64 download rating


qbasic 64 download alternatives


qbasic 64 download comparison


qbasic 64 download features


qbasic 64 download benefits


qbasic 64 download drawbacks


qbasic 64 download issues


qbasic 64 download bugs


qbasic 64 download fixes


qbasic 64 download updates


qbasic 64 download changelog


qbasic 64 download license


qbasic 64 download terms of service


qbasic 64 download privacy policy


qbasic 64 download support


qbasic 64 download contact


qbasic 64 download faq


qbasic 64 download tips and tricks


qbasic 64 download best practices


qbasic 64 download resources


  • Open the QBasic 64 IDE by double-clicking on the QB64.exe file in your QBasic 64 folder.



  • Select New from the File menu or click on the New button on the toolbar. This will open a new blank file in the text editor.



  • Type your code in the text editor using the QBasic 64 syntax. For example, you can type this simple program that prints "Hello, world!" on the screen:PRINT "Hello, world!"



  • Save your code by selecting Save or Save As from the File menu or clicking on the Save button on the toolbar. You can give your file any name you want with a .bas extension. For example, you can save your file as hello.bas in your QBasic 64 folder.



  • Run your code by selecting Start from the Run menu or clicking on the Run button on the toolbar. This will compile your code to IR and execute it within the IDE. You will see a new window pop up with the output of your program. For example, you will see this output:Hello, world!



  • Close the output window by pressing any key or clicking on the X button on the top right corner. This will return you to the IDE.



Congratulations! You have just written and run your first program in QBasic 64!


Using variables, data types, operators, statements, loops, functions, and arrays




A program is more than just printing some text on the screen. A program can perform various operations on data using variables, data types, operators, statements, loops, functions, and arrays. Let's see what these concepts mean and how to use them in QBasic 64.


Variables




A variable is a name that represents a value that can change during the execution of a program. For example, you can use a variable called score to store the score of a game. You can assign a value to a variable using the = operator. For example:score = 0


You can also use a variable to store the result of an expression that involves other variables or constants. For example:score = score + 10


You can print the value of a variable using the PRINT statement. For example:PRINT score


You can use any combination of letters (A-Z or a-z), digits (0-9), or underscores (_) to name a variable. However, you cannot start a variable name with a digit or use any reserved words as variable names. Reserved words are words that have special meanings in QBasic 64, such as PRINT, IF, FOR, etc. You can also use suffixes to indicate the data type of a variable. For example, you can use % to indicate an integer variable, $ to indicate a string variable, or # to indicate a double-precision floating-point variable. For example:name$ = "John"age% = 25pi# = 3.14159


QBasic 64 also supports 64-bit data types, such as _INTEGER64 (&&) and _FLOAT (##), which can store larger numbers and more precision than the standard data types. For example:big&& = 1234567890123456789small## = 0.000000000000000001


Data types




A data type is a category of values that a variable can hold. QBasic 64 supports several data types, such as:


Data typeDescriptionRangeSuffix


INTEGERA 16-bit signed integer-32768 to 32767%


LONGA 32-bit signed integer-2147483648 to 2147483647&


_INTEGER64A 64-bit signed integer-9223372036854775808 to 9223372036854775807&&


SINGLEA 32-bit single-precision floating-point number-3.402823E+38 to -1.401298E-45 for negative values1.401298E-45 to 3.402823E+38 for positive values0 for zero!


DOUBLEA 64-bit double-precision floating-point number-1.79769313486232E+308 to -4.94065645841247E-324 for negative values4.94065645841247E-324 to 1.79769313486232E+308 for positive values0 for zero#


_FLOATA 80-bit extended-precision floating-point number-3.36210314311293E+4932 to -3.64519953188247E-4951 for negative values3.64519953188247E-4951 to 3.36210314311293E+4932 for positive values0 for zero##


STRINGA sequence of characters enclosed in quotation marks or assigned to a string variableUp to 2 billion characters (limited by available memory)$


_BIT (bit)A single bit that can be either 0 or 10 or 1N/A


_BYTE (byte)A 8-bit unsigned integer0 to 255N/A


_WORD (word)A 16-bit unsigned integer0 to 65535N/A


_DWORD (dword)A 32-bit unsigned integer0 to 4294967295N/A


_QUAD (quad)A 64-bit unsigned integer0 to 18446744073709551615N/A


You can use the _DEFINE command to create your own data types using the existing ones. For example, you can create a data type called POINT that consists of two integers, x and y, to represent the coordinates of a point on the screen. For example:_DEFINE POINT x AS INTEGER, y AS INTEGER


You can then declare a variable of type POINT and assign values to its fields using the . operator. For example:DIM p AS POINTp.x = 100p.y = 200


Operators




An operator is a symbol that performs a specific operation on one or more operands. Operands are the values or variables that are involved in the operation. QBasic 64 supports various types of operators, such as:


  • Arithmetic operators: These are used to perform mathematical calculations on numeric operands. For example, +, -, *, /, ^, etc.



  • Relational operators: These are used to compare two operands and return a logical value (TRUE or FALSE). For example, =, , , =, etc.



  • Logical operators: These are used to combine two or more logical values and return a logical value. For example, AND, OR, NOT, XOR, etc.



  • Bitwise operators: These are used to manipulate individual bits of an operand. For example, AND (&), OR (), NOT (), XOR (^), SHL (>), etc.



  • String operators: These are used to perform operations on string operands. For example, + (concatenation), = (comparison), , , = (lexicographical comparison), etc.



  • Parentheses: These are used to group expressions and change the order of evaluation. For example, (2 + 3) * 4.



You can use operators in expressions that can be assigned to variables or printed on the screen. For example:a = 2 + 3 * 4PRINT ab = "Hello" + " " + "world!"PRINT bc = (a > b) AND NOT (b = c)PRINT c


Statements




A statement is a command that tells the interpreter what to do. QBasic 64 supports many statements that can perform various tasks, such as:


  • Input and output statements: These are used to get input from the user or display output on the screen. For example, INPUT, PRINT, CLS, LOCATE, COLOR, etc.



  • Control flow statements: These are used to control the execution flow of the program based on certain conditions or repetitions. For example, IF...THEN...ELSE, SELECT CASE, FOR...NEXT, WHILE...WEND, DO...LOOP, GOTO, GOSUB...RETURN, etc.



  • Data manipulation statements: These are used to manipulate data in variables or arrays. For example, LET, DIM, REDIM, SWAP, ERASE, etc.



  • Function and subroutine statements: These are used to define and call functions and subroutines that can perform specific tasks and return values. For example, DECLARE, FUNCTION...END FUNCTION, SUB...END SUB, CALL, RETURN, etc.



  • Miscellaneous statements: These are used to perform other tasks that do not fall into the above categories. For example, REM, DATA...READ...RESTORE, RANDOMIZE...RND, SLEEP, SYSTEM, etc.



You can use statements in your program to perform various operations and tasks. Each statement must be written on a separate line or separated by a colon (:). For example:REM This is a commentRANDOMIZE TIMERx = RND * 100y = RND * 100PRINT "The sum of x and y is "; x + yS LEEP 3SYSTEM


Loops




A loop is a structure that allows you to repeat a block of code multiple times until a certain condition is met. QBasic 64 supports several types of loops, such as:


FOR...NEXT loop: This is a loop that repeats a block of code a fixed number of times, using a counter variable that changes by a specified step value. For example:FOR i = 1 TO 10 STEP 2PRINT iNEXT i


  • This loop will print the odd numbers from 1 to 10.



WHILE...WEND loop: This is a loop that repeats a block of code as long as a condition is true. For example:x = 1WHILE x x = x * 2PRINT xWEND


  • This loop will print the powers of 2 that are less than 100.



DO...LOOP loop: This is a loop that repeats a block of code either until or while a condition is true. For example:y = 1DO UNTIL y > 1000y = y + 100PRINT yLOOP


  • This loop will print the multiples of 100 that are less than or equal to 1000.



You can use loops in your program to perform repetitive tasks and operations. You can also use the EXIT FOR, EXIT WHILE, or EXIT DO statements to exit a loop prematurely. For example:FOR i = 1 TO 10IF i = 5 THEN EXIT FORPRINT iNEXT i


This loop will print the numbers from 1 to 4 and then exit the loop.


Functions and subroutines




A function is a block of code that performs a specific task and returns a value. A subroutine is a block of code that performs a specific task but does not return a value. You can use functions and subroutines in your program to modularize your code and avoid repetition. You can also pass parameters to functions and subroutines to customize their behavior. For example:


DECLARE FUNCTION Factorial% (n%)SUB PrintFactorial (n%)DIM f%f% = Factorial(n%)PRINT n%; "! = "; f%END SUBFUNCTION Factorial% (n%)DIM i%, result%result% = 1FOR i% = 1 TO n%result% = result% * i%NEXT i%Factorial% = result%END FUNCTIONx% = 5y% = 10PrintFactorial x%PrintFactorial y%


This program defines a function called Factorial that calculates the factorial of a given number, and a subroutine called PrintFactorial that prints the factorial of a given number. It then calls the subroutine with two different parameters, x and y, and prints their factorials.


Arrays




An array is a collection of values of the same data type that are stored in consecutive memory locations and accessed by an index. You can use arrays in your program to store and manipulate multiple values using a single variable name. For example:


DIM names$(5)DIM ages%(5)n ames$(1) = "Alice"ages%(1) = 20names$(2) = "Bob"ages%(2) = 25names$(3) = "Charlie"ages%(3) = 30names$(4) = "David"ages%(4) = 35names$(5) = "Eve"ages%(5) = 40FOR i% = 1 TO 5PRINT names$(i%); " is "; ages%(i%); " years old."NEXT i%


This program defines two arrays, names and ages, that store the names and ages of five people. It then prints the names and ages of each person using a loop.


Examples of QBasic 64 programs




To demonstrate the power and versatility of QBasic 64, let's look at some examples of programs written in it. These programs are not meant to be comprehensive or optimized, but rather to illustrate some of the features and capabilities of QBasic 64. You can try these programs yourself by typing them in the QBasic 64 IDE and running them.


A calculator




This program is a simple calculator that can perform basic arithmetic operations on two numbers. It uses the INPUT statement to get the numbers and the operator from the user, and the SELECT CASE statement to perform the appropriate calculation. It also uses the _TITLE command to change the title of the output window.


_TITLE "QBasic 64 Calculator"DIM num1#, num2#, result#DIM op$INPUT "Enter the first number: ", num1#INPUT "Enter the second number: ", num2#INPUT "Enter the operator (+, -, *, /): ", op$SELECT CASE op$CASE "+"result# = num1# + num2#CASE "-"result# = num1# - num2#CASE "*"result# = num1# * num2#CASE "/"IF num2# 0 THENresult# = num1# / num2#ELSEPRINT "Cannot divide by zero!"END IFCASE ELSEPRINT "Invalid operator!"END SELECTPRINT "The result is "; result#


A clock




This program is a digital clock that displays the current time in hours, minutes, and seconds. It uses the _TIME$ function to get the current time as a string, and the LOCATE and COLOR statements to position and color the output on the screen. It also uses a DO...LOOP loop to update the time every second, and the SLEEP command to pause the program for a specified amount of milliseconds.


_TITLE "QBasic 64 Clock"DIM time$CLSCOLOR 15, 0DOtime$ = _TIME$LOCATE 12, 36PRINT time$;SLEE


À propos

Bienvenue dans le groupe ! Vous pouvez communiquer avec d'au...

membres

bottom of page