Qbasic Constructing Qbasic Programs 2002 John Urrutia All
Qbasic Constructing Qbasic Programs © 2002 John Urrutia. All rights reserved. 1
Program Development l. Problem definition – statement èWho – The person, group, organization èWhat – The record, file, system, data èWhen – The timeframe èWhere– The location èWhy – The business reason © 2002 John Urrutia. All rights reserved. 2
Steps in Program Development l 1. Clearly State the Problem èData w Input – what are the data sources. w Output – what are the data sinks. èProcess (algorithm) w Detailed description of how the Input is manipulated into Output. © 2002 John Urrutia. All rights reserved. 3
Steps in Program Development l. Data decomposition – the process of: èIdentifying the required output. w Reports w Files èIdentifying the raw input data needed to find a solution. w Can be an elementary data element w Can be a grouped data element © 2002 John Urrutia. All rights reserved. 4
Steps in Program Development l. The Algorithm – is the process èSequence – linear execution of instructions èSelection – Identify a processing path w Binary w Case èIteration – repetitive execution of instructions © 2002 John Urrutia. All rights reserved. 5
Steps in Program Development l 2. Plan the Logic of the program èUse one or more of these to graphically represent the algorithm. w Flowchart w Pseudocode w Hierarchy chart © 2002 John Urrutia. All rights reserved. 6
Steps in Program Development l. Flowcharts èA graphical representation of the problem definition Manual Decision Termination Process Screen © 2002 John Urrutia. All rights reserved. 7
Steps in Program Development l. Hierarchy charts (Visual TOC) èA graphical representation of the functional decomposition Room Area Program © 2002 John Urrutia. All rights reserved. 8
Steps in Program Development l. Pseudocode èAn English-like representation of the problem definition w IF the meat is green THEN move it to the waste bucket ELSE move it to the good bucket. © 2002 John Urrutia. All rights reserved. 9
Steps in Program Development l 3. Code the program The syntactical exercise of converting the program design into a specific programming language. This should be done first on paper. © 2002 John Urrutia. All rights reserved. 10
Steps in Program Development l 4. Key the program. Transfer the coded program into the QBASIC environment and save it as a QBASIC file. èMy. Prog. bas © 2002 John Urrutia. All rights reserved. 11
Steps in Program Development l 5. Test and Debug the program. èV&V –Verification & Validation w Verification – Are we doing the right job? w Validation – Are we doing the job right? © 2002 John Urrutia. All rights reserved. 12
Steps in Program Development l. Specification errors – èProblem definition omissions, inaccuracies, lack of clarity l. Syntax errors – èCoding or Keying l. Logic errors èDo what I think not what I say… © 2002 John Urrutia. All rights reserved. 13
Steps in Program Development l 6. Complete the Documentation èDevelop a program package containing: w Program specification, hierarchy chart, flowchart, and pseudocode. èTest plan and results èFinal version of tested program © 2002 John Urrutia. All rights reserved. 14
B. A. S. I. C. l. Beginners l. All-purpose l. Symbolic l. Instruction l. Code l. QBasic – Quick. BASIC èDeveloped at Dartmouth in 1960’s © 2002 John Urrutia. All rights reserved. 15
Qbasic Character Set l. Letters: a-z and A-Z l. Digits: 0 -9 l. Blank: the space character ( ) l. Special characters: +-*/=<>. , ’”(): ; ^_$#? !%& © 2002 John Urrutia. All rights reserved. 16
Qbasic Keywords l. A keyword has a predefined meaning within Qbasic. èExamples: LET END REM PRINT © 2002 John Urrutia. All rights reserved. 17
The QBASIC Environment l. QBASIC is an interpreter èEach line of code is translated into machine language just prior to its execution… every time. èCreates an interactive environment that’s easy to work with. © 2002 John Urrutia. All rights reserved. 18
QBASIC … © 2002 John Urrutia. All rights reserved. 19
Demonstration © 2002 John Urrutia. All rights reserved. 20
The CLS statement l. CLear Screen èErases all characters from the terminal èPlaces cursor at position 1, 1 (top left corner) © 2002 John Urrutia. All rights reserved. 21
The PRINT statement l. Writes information to the terminal. PRINT output-list PRINT X$ PRINT 5 + 7 PRINT “Hello World” PRINT (prints a blank line) © 2002 John Urrutia. All rights reserved. 22
The PRINT statement l. Horizontal spacing èEach PRINT statement will occupy one line on the users screen l. Vertical spacing è; – places data adjacent to each other è, – places data at multiples of 14 columns on the line © 2002 John Urrutia. All rights reserved. 23
- Slides: 23