QBASIC

ImprimirCitar

QBasic is an integrated development environment and interpreter for a variant of the BASIC programming language based on the QuickBASIC compiler. Code entered into the IDE is compiled to an intermediate form, and this is immediately interpreted on demand within the IDE. It can run under almost all versions of DOS and Windows, or with DOSBox/DOSEMU, on Linux and FreeBSD. In its time, QBasic provided an advanced IDE, including a debugger with features such as expression evaluation and rapid code modification. The QBASIC development environment includes several features still rare in current development environments.

Like QuickBASIC, but unlike earlier versions of Microsoft BASIC, QBasic is a structured programming language, supporting constructs such as subroutines and while loops. Line numbers, a concept often associated with BASIC, are supported for compatibility, but are not considered a good form, being replaced by descriptive tags. QBasic has limited support for user-defined data types (structs), and various primitive types used to contain text strings or numerical data.

QBASIC was also used to teach programming to people who did not have much knowledge of programming.

History

QBasic was created in 1991 to replace BASICA and GW-BASIC as a programming language for the end user. It was based on the earlier QuickBASIC 4.5 compiler but without the QuickBASIC compiler and linker elements. Version 1.0 was shipped with MS-DOS 5.0 and later, as well as Windows 95, Windows NT 3.x, and Windows NT 4.0. IBM recompiled QBasic and included it in PC-DOS 5.x, as well as from OS/2 2.0 onwards. eComStation, a descendant of the OS/2 code, includes QBasic 1.0. QBasic 1.1 is included with MS-DOS 6.x, and, without EDIT, in Windows 95, Windows 98 and Windows Me.

Microsoft included it as an option on the Windows 95 and Windows 98 installation disks, included in the olddos.exe package, but stopped distributing QBASIC in later versions of Windows. Starting with Windows 2000, Microsoft no longer includes QBasic. (However, some localized versions of Windows 2000 and Windows XP still have it, and it can be delivered as freeware.) It is currently distributed only through the Microsoft website for users licensed to use MS-DOS.

QBasic (as well as the built-in MS-DOS Editor) is backwards compatible with DOS releases prior to 5.0 (up to at least DOS 3.20). However, if used on any 8088/8086 computer, or on some 80286 computers, the QBasic program may run very slowly, or perhaps not at all, due to its size in memory. Until MS-DOS 7, the MS-DOS Editor required QBasic. The "edit.com" it simply starts QBasic in edit mode only, and this mode can also be entered by running QBASIC.EXE with the /EDIT switch (ie, the "QBASIC /EDIT" command line).

Subsequently, products have appeared that continued the QBASIC/QuikBASIC standard, including PowerBASIC, FreeBASIC and QB64/QB32.

Examples

The examples that can be presented of programs written in this language are many, let's see some that allow us to see the format of this programming language.

Examples that come with QBasic

QBasic came complete with four prewritten sample programs. These were "Nibbles" (a variant of the Snake game), "gorillas", an artillery game, "MONEY MANAGER", personal finance manager and a "RemLine", a remover program number of lines for GW-BASIC code.

Hello world

The following is a very simple "hello world" written in QBASIC:

PRINT "Hello Gente"INPUT " Enter Your Name: "; Name$PRINT "Your Name is: " + Name$ 'This is a comment.

Quarter equation

Program to solve a quadratic equation:

Ax2+Bx+C=0{displaystyle Ax^{2}+Bx+C=0,}
CLSPRINT "Resolution of a second-degree equation"PRINT "Ax^2 + Bx + C = 0"PRINTINPUT "Coefficient A:, AINPUT "Coefficient B: ", BINPUT "Coefficient C:, CPRINTIF A = 0 THEN REM A = 0 IF B = 0 THEN REM A = 0 And B = 0 IF C = 0 THEN REM A = 0, B = 0 And C = 0 PRINT "No equation" ELSE REM A = 0, B = 0, C  0 PRINT C; "= 0, impossible" END IF ELSE REM A = 0, B  0 PRINT "First-degree equation" PRINT "X="; -C / B " END IFELSE REM A  0 D = B ^ 2 - 4  A  C IF D  0 THEN REM A  0, D  0 PRINT "Two Real Solutions" PRINT "X1="; (-B + SQR(D) / (2  A) PRINT "X2="; (-B - SQR(D) / (2  A) ELSE REM A  0, D  0 IF D = 0 THEN REM A  0, D = 0 PRINT "Unique real solution" PRINT "X1=X2="; -B / (2  A) ELSE REM A  0, D . 0 R = -B / (2  A) I = ABS(SQR(-D) / (2  A) PRINT " Complex root" PRINT "X1="; R; "+"; I; "i" PRINT "X2="; R; "-"; I; "i" END IF END IFEND IF

This program contemplates the following decision tree:

<math alttext="{displaystyle ax^{2}+bx+c=0left{{begin{array}{ll}a=0&left{{begin{array}{ll}b=0&left{{begin{array}{ll}c=0&longrightarrow Sin;ecuaci{acute {o}}n\\cneq 0&longrightarrow Imposibleend{array}}right.\\bneq 0&longrightarrow ;Ecuaci{acute {o}}n;de;1^{e};gradoend{array}}right.\\aneq 0&left{{begin{array}{ll}b^{2}-4ac0&longrightarrow Dos;soluciones;realesend{array}}right.end{array}}right.}" xmlns="http://www.w3.org/1998/Math/MathML">ax2+bx+c=0{a=0{b=0{c=0Δ Δ Sinecuacior♪ ♪ ncI was. I was. 0Δ Δ ImporsiblebI was. I was. 0Δ Δ Ecuacior♪ ♪ nde1egradoraI was. I was. 0{b2− − 4ac.0Δ Δ Raı ı ♪ ♪ zcormplejab2− − 4ac=0Δ Δ Sorlucior♪ ♪ nrealu♪ ♪ nicab2− − 4ac▪0Δ Δ Dorssorluciornesreales##### ###################################################################################################### ##################################################################################################################################################### !<img alt="{displaystyle ax^{2}+bx+c=0left{{begin{array}{ll}a=0&left{{begin{array}{ll}b=0&left{{begin{array}{ll}c=0&longrightarrow Sin;ecuaci{acute {o}}n\\cneq 0&longrightarrow Imposibleend{array}}right.\\bneq 0&longrightarrow ;Ecuaci{acute {o}}n;de;1^{e};gradoend{array}}right.\\aneq 0&left{{begin{array}{ll}b^{2}-4ac0&longrightarrow Dos;soluciones;realesend{array}}right.end{array}}right.}" aria-hidden="true" class="mwe-math-fallback-image-inline" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0304563484625f2d574e5e9fe452bd0bc9f5dd01" style="vertical-align: -17.338ex; width:72.459ex; height:35.676ex;"/>

Solving in each case the values of x that satisfy the equation, the IF instruction is used to select the specific case and perform the appropriate operations, presenting the solution of x according to the case that satisfies the equation, contemplating extreme cases such as: a=0, b=0, c=0.

Contenido relacionado

Shell sorting

The shell sort is a sorting algorithm. The method is named Shell after its inventor Donald Shell. Its original implementation requires Ocomparisons and swaps...

PhpMyAdmin

phpMyAdmin is a tool written in PHP intended to handle MySQL administration through web pages, using a web browser. Currently you can create and drop...

Open-relay

It is understood as open relay an SMTP server configured in such a way that it allows any Internet user to use it to send email through it, not just mail...
Más resultados...
Tamaño del texto:
Copiar