Docsity

Quick Basic Design - Programming Languages - Project | CSC 415, Study Guides, Projects, Research of Programming Languages

Partial preview of the text

Download Quick Basic Design - Programming Languages - Project | CSC 415 and more Study Guides, Projects, Research Programming Languages in PDF only on Docsity!

Chu-Yen Chan

CSC 415

Dr. William Lyle

November 11, 2003

Term Project

Brief Understanding in QuickBasic

Chu-Yen Chan CSC 415 This project explicates the brief characteristics of QuickBasic; also include reviews as in the angle of a user in the modern language world.

II. Data Types

  1. Numeric types. Integer uses the suffix “%” for declaration. Integer range: Integer* 32,767 to -32,768 in decimal as default i%=&h0 -- i %=&hFFFF in hexadecimal i%=&o0 -- i %=&o177777 in octal Long integer (double precision) uses suffix “&” for declaration. Long integer range: Integer* -2,147,483,648 -- 2,147,483, i&=&h0& -- i&=&hFFFFFFFF& in hexadecimal i&=&o0& -- i&=037777777777& in octal Float uses the suffix “!” for declaration. The use of A! and A are treated as the same, which means any variables declare without a suffix would treated as a single precision float. Float range: Real4 as default -3.4X10^38 -- 3.4X10^38 (~ significant figures) Long float (double precision) uses suffix “#” for declaration. Long float range: Real -1.7X10^308 -- 1.7X10^308 (~ significant figures) ( _Nam Sun Wang,
  1. Other types._ Boolean types are included in QuickBasic. QuickBasic do not have a reserve word for Boolean types. Users simply need to set the value of a Boolean. Any numerical value is allowed to use for true of false with one restriction. Values of true and false need to be reverse of each other, which mean if 0 being assign to false then 1 is not allowed for true. The reverse of 0 is - 1 so the value of true need to be -1. String uses the suffix “$” for declaration range from 0 to 32,767. It’s similar to most other language; QuickBasic required double quotation marks to assign the string value. Strings are function with fixed value or varied depend on the declaration part. Array types, another important type that a good programming language required. QuickBasic has its array types starting point from “0” like C++ and JAVA. If an array been declared as 20 and this array contains 21 spaces for variables, unlike Ada if 20 being declare then 20 is used. III. Expression and Assignment statement 1. Arithmetic expression The very first of arithmetic expression is to investigate the language rules that specify the order of evaluation of operators (Sebesta, 2003). The following is the operator precedence for QuickBasic: Parenthetic () Exponentiation ^ Negation – Multiplication and Division *,/,,mod Add and subtract +,- The associativity rules of the QuickBasic work from left to right when an expression contains two adjacent occurrences of operators with the same level of precedence. Operator overloading is not included in QuickBasic. 2. Type conventions QuickBasic allowed mix-mode arithmetic, which means QuickBasic gave the authority of mix numeric type calculation as long as it’s not overflow. QuickBasic has several functions involved with type conventions. These functions are showing beneath. ASC returns the ASCII code of a string CDBL converts to double CHR$ transfer ASCII code to character CINT rounds to the nearest integer; CSNG converts to single FIX truncates to the next lower integer; INT truncates to an integer; STR$ changes a number string VAL does the opposite of STR$ (Noggle, 1992)
  2. Relational & Boolean Expressions QuickBasic’s relational expressions are =, <>, <, >, <=, >=. Boolean expressions are not, and, or, xor, eqv, imp. According to the precedence of QuickBasic both expressions execute at last, relational expressions execute before Boolean expressions.
  3. Assignments Statements In simple assignments, QuickBasic is function the same way like many other languages just a simple “=”. Compound assignment operator and unary assignment

operators are allowed in QuickBasic, unfortunately it did not function with the nice feature of C’s +=, -=, -- or ++. Mix-mode assignment and mix-mode expressions are allowed in QuickBasic. IV. Statement- Level control Structure

  1. Selection Statements QuickBasic supports IF statements for two- way selection statements. IF (expr) THEN IF (expr) THEN statements ELSE statements IF (expr) THEN statements ELSEIF (expr) statement ELSE statements END IF. IF...THEN statement is just a simple one line IF statement and only requirement is code in a single line. IF…THEN…ELSE statement is like IF...THEN statements with an ELSE function. The third IF statement from above is a nested IF statement. This IF statement allows multiple IF statements combine in one nested IF statement. END IF is required in the nested IF statement only, it’s optional for IF...THEN and IF...THEN...ESLE statements. THEN is required always for every IF statements. Another selection statement included in QuickBasic is the CASE statements. QuickBasic’s CASE statement used SELECT to start the CASE statement. An example comes beneath. SELECT CASE INT% CASE 1 to 5 PRINT INT%
    • 10 CASE 5 to 10 PRINT INT%
    • 5 CASE > 10 PRINT INT% CASE ELSE PRINT “False input integer.” END SELECT CASE statement in QuickBasic is very similar to the CASE statement in ADA and SWITCH statement in C++ and JAVA. ON GOTO is another select statement available in QuickBasic. It works this way, if (expr) is true then goto designated place specify by the statement. A common way of using ON GOTO is ON ERROR GOTO. This is used for testing run time error, if any error occurs during run time it’ll catch it and then the program would execute the statement where GOTO indicate or resume the program by a resume function. See an example code of ON EROR GOTO in Appendices under the title of ON ERROR GOTO.
      1. Iterative Statements QuickBasic supports several iterative types and DO...LOOP is one of them. DO...LOOP construct has four variations, DO WHILE [condition] … LOOP DO UNTIL [condition] … LOOP DO … LOOP WHILE [condition] DO … LOOP UNTIL [condition] DO…LOOP is a loop execute under a Boolean condition. All four variations of DO… LOOP worked in very similar way just differ from the orders. See example code of DO…LOOP at Appendices. FOR…NEXT, another nice feature QuickBasic function with. FOR…NEXT construct causes the code between these statements to be executed repeatedly (Noggle, 1992). FOR… NEXT loop is very similar to Ada’s for…loop. It works just a little bit different from Ada, but the basic concepts are the same. FOR variable = (start value) TO (end value) Statements NEXT. This is a single FOR…NEXT loop for nested loop just add another FOR…NEXT loop inside another FOR…NEXT loop for example: FOR variable = (start value) TO (end value) Stateme nts FOR v ar ia bl e = (s ta rt v al u e) T O (e n d v al u e) St at e m e

special words would also bring some confusions as because for someone who is not familiar with the language it’s pretty hard to recognize and understand these statements. So, generally QuickBasic has some strength in readability and also some weakness. b. Writability Writability for QuickBasic in the modern programming language world is terrible. Most languages have developed an easier way for declarations and modern style special words. Although QuickBasic is pretty easier to learn and adapt there’s a need of lots memorizing over here. For a pure QuickBasic programmer it wouldn’t be a big issue, but for multi- language programmer it would be a good idea for them to learn languages related to what they’ve learned, for Basic kind languages familiar programmer QuickBasic is kind of easy. c. Reliability Talk about reliability, good readability and writeability definitely would make good reliability, but it’s not necessary; for example JAVA is poor in writeability, but it’s still pretty reliability. So let’s focus on exception handling for this language. QuickBasic has a poor exception handing environment. Weak exception handling would certainly bring down the language reliability. QuickBasic allowed mix-mode arithmetic and this would occur more run time errors as because mix-mode arithmetic has a greater possibility to occur overflow and outcome might not be significant enough. From these facts plus the overall confusing QuickBasic is probably not reliable enough for the modern programming language. d. Cost To success in Cost for a language there’s several important characteristics need to aware in the language. Cost of training programmers, it’s probably not going to be a big issue as because to learn QuickBasic is not too hard and not to mention there’s still a lot of QuickBasic programmers in the market. Cost of writing programs, it might takes times for non-QuickBasic programmers to write in QuickBasic because of old type language confusions in the language, but for QuickBasic programmers there’s probably no such barrier for them. Cost of executing programs in QuickBasic is not a big issue too as it doesn’t take long time in compiling like JAVA does. Next is the cost of QuickBasic compilers, since first version of QuickBasic was published in mid 1980 s and there are a lot of free compilers in the market. Cost of poor reliability, it’s a big issue for QuickBasic. As because of QuickBasic is poor in reliability and it might occur some run time error, which generally cost a lot in the high cost critical system. Last, the cost of maintainability, as QuickBasic is an old language and it’s kind of out dated, eventually there wouldn’t be any QuickBasic programmers left in the market. So the cost of maintainability is kind of high and by the way QuickBasic is kind of weak in readability, which would bring up the cost of maintainability. Overall cost for QuickBasic in the modern world is pretty high and it’ll soon be out dated. After carefully consideration and research QuickBasic might be a fun language to learn, but certainly not a language would fit today’s language world. D. Appendices – Names INPUT INT% -- 100 PRINT INT% -- 100 INPUT LONGINT& -- 12345678912345678 9 PRINT LONGINT& -- 12345678912345678 9 Mix-Mode Numeric Variable INPUT FLOAT1 --

INPUT FLOAT2 --

PRINT INT% + FLOAT1 -- 111 PRINT INT% + FLOAT2 – 112 If Statement IF INT% > 10 THAN PRINT INT -- if..than statement IF INT% > 10 THAN PRINT INT ELSE PRINT INT% + 10 – simple if..than with else statement IF INT% > 10 THAN PRINT INT ELSE IF INT % >5 PRINT INT% + 5 ELSE PRINT INT% + 10 END IF – showing the use of end if Select Statement SELECT CASE INT% CASE 1 to 5 PRINT INT%

  • 10 CASE 5 to 10 PRINT INT%
  • 5 CASE > PRINT INT% CASE ELSE PRINT “False input for integer.”

END SELECT

Loop DO: n = n + 1 [Statements] LOOP WHILE n <= 20 DO: n = n + 1 [Statements] LOOP UNTIL n = 20 FOR I = 1 to 20 [Statements] FOR J = 1 to I [Statements] NEXT NEXT ON ERROR GOTO ON ERROR GOTO ErrorLine CLS Start: DO PRINT “Enter number : [Enter] to stop: “; INPUT ; X$ IF X$ <> “” THEN X = VAL(X$) PRINT “ “; SQR(X), 1/x END IF LOOP WHILE X$ <> “” END: ‘ statement REQUIRED! ErrorLine: PRINT “Error”;ERR RESUME Start (Noggle, 1993) Sub-Program & Function SUB Name[(Arg[, Arg].. .)] static [EXIT SUB] END SUB FUNCTION FUN(X) [Statements] END FUNCTION User-Define Function def fnd(a, b, c) = b * b

  • 4 * a * c def fnx(a, b, d) = (-b + d) / (a + a) def fnroot1(a, b, c) = fnx(a, b, sqr(fnd(a, b, c))) def fnroot2(a, b, c) = fnx(a, b, -sqr(fnd(a, b, c))) print fnroot1(a, b, c), fnroot2(a, b, c) (Leinweber, 2000) E. Bibliography and References -
  1. Noggle, Joseph H. QuickBASIC Programming for Scientists and Engineers. Boca Raton: CRC Press, 1993
  2. Sebesta, Robert W. Concepts of Programming Languages. Colorado Springs: Pearson, 2003
  3. Wikimedia Foundation Inc. “Wikipedia”. 2001 http://en2.wikiped ia.org/wiki/Main_ Page
  4. KBasic Team. “KBasic”. 2002 http://www.kbasic .org/1/home.php
  5. Zohrob, David. “the qbasic page”. 1999 http://www.qbasic .com/qbindex.sht ml
  6. Leinweb, Larry. “The Basmark QuickBASIC Programmer’s Manual”. 1991 http://www.leinwe b.com/basic/man ual/index.htm
  7. Wang, Nam Sung. “Computer Methods in Chemical Engineering”. 2002 http://www.glue.u md.edu/~nsw/enc h250/ench250.ht m
  8. Microsoft. “Version History of Microsoft QuickBasic for

MS-DOS”. 2003

http://support.mic rosoft.com/default .aspx?scid=http:// support.microsoft. com:80/support/ kb/articles/ Q39/7/30.ASP&N oWebContent= Table 1. Published Date of QuickBasic Version Number 5.25- Inch Release 3.5-Inch Release 1.00 08/18/ none First release. 1.01 January 1986 none Corrects problems known in Version 1.00. No major enhancements. Few copies of Version 1.01 were shipped due to a problem discovered with compiling medium-sized programs. 1.02 02/06/ 05/07/ Corrects problems known in Version 1.01. No major enhancements. 2.00 09/29/ 08/15/ Major release. The following new features are added: Built-in editor environment