Sign up to the jQuery Grid Subscription list.

Sunday, June 29, 2008

Analyzing the remline.bas sample

I told you the last time that to remember a language syntax or to learn a language syntax that is like another one that you know, you'll need a sample code. The sample code will give you a fast and quick startup to begin programming with that language.

Now we have to analyze the remline.bas sample in order to understand how it works and how to make cool application with Qbasic, to make powerful application in the future and who know.

Reading the comment: The first thing to start with is to read the header comments, that is the principal thing. Why fetching a code that has no advantages for us? So reading the comment will give us a general summary about this code.

Remline.bas headers' comment

'
' Microsoft RemLine - Line Number Removal Utility
' Copyright (C) Microsoft Corporation 1985-1990
'
' REMLINE.BAS is a program to remove line numbers from Microsoft Basic
' Programs. It removes only those line numbers that are not the object
' of one of the following statements: GOSUB, RETURN, GOTO, THEN, ELSE,
' RESUME, RESTORE, or RUN.
'
' When REMLINE is run, it will ask for the name of the file to be
' processed and the name of the file or device to receive the
' reformatted output. If no extension is given, .BAS is assumed (except
' for output devices). If filenames are not given, REMLINE prompts for
' file names. If both filenames are the same, REMLINE saves the original
' file with the extension .BAK.
'
' REMLINE makes several assumptions about the program:
'
' 1. It must be correct syntactically, and must run in BASICA or
' GW-BASIC interpreter.
' 2. There is a 400 line limit. To process larger files, change
' MaxLines constant.
' 3. The first number encountered on a line is considered a line
' number; thus some continuation lines (in a compiler-specific
' construction) may not be handled correctly.
' 4. REMLINE can handle simple statements that test the ERL function
' using relational operators such as =, <, and >. For example,
' the following statement is handled correctly:
'
' IF ERL = 100 THEN END
'
' Line 100 is not removed from the source code. However, more
' complex expressions that contain the +, -, AND, OR, XOR, EQV,
' MOD, or IMP operators may not be handled correctly. For example,
' in the following statement REMLINE does not recognize line 105
' as a referenced line number and removes it from the source code:
'
' IF ERL + 5 = 105 THEN END
'
' If you do not like the way REMLINE formats its output, you can modify
' the output lines in SUB GenOutFile. An example is shown in comments
What Remline.bas sample?
If you read the comment as you should, they you must understand that remline aim is fetch and find numbered lines and to delete those lines. However, it shouldn't delete necessary numbers, like the ones that a goto use!
The matter seems complicated but we need to think it a little bit, I'll start with you from 0!

No comments: