The BASIX Fanzine



 
 

ISSUE #16 - September 1999
Edited By David Groulx

Contents


Articles Programming Challenge

Miscellaneous & Credits
I know a lot of programers read the Fanzine, but so very few of you are contributing. Any contributions to the Basix Fanzine would greatly be appreciated.

Some may have seen the changes to the Basix Fanzine Webpage. This is to create a Website with stable links, meaning the URL's will never change.

Also there is a request page up on the Fanzine's website for people who aren't sure what to write. You can see what other people have asked for.

There is also a survey page. The difference between the survey and the questionnaire is the questionaire is long, with multiple questions, while the survey is single short answer type questions. Please take the Survey.

And some may have noticed the difference between the Online Edition, and the download edition. With the V3 URL its harder to link certain pages, and it's easier to link on the website. There is no difference between the two issues, the Content is the same.

And another plus, this issue is on time.

Im still desperately looking for articles for the next issue. The next issues should be coming out in October, but depending on articles and stuff I receive it may be push back until November.

Until then, happy programming

David Groulx
 


Articles



Moving from Qbasic to C++
Alan Copeland

Many people might wonder why in the Basic fanzine, there is any article about switching programming languages.  First of all, this article is not written for you to become one of those "people" who learns a bit a of C and then spends the next week trashing Qbasic. C++ is an indispensable tool for a programmer, despite its needlessly cryptic commands. With the right skill, you can even write a procedure in C++ and then use it in your Qbasic program. So in essence you are not 'moving' to C++, you are adding on to your Qbasic skills. Just like arrays or loops, C is a tool to make you program better.

So what makes C++ better?  Everybody says it is superior to Basic in every way, but why? First of all, it is quicker, despite any argument you might have.  But you have to take into account that Qbasic has stayed more or less the same since the 80's and there are about 4 companies competing to make a faster, better C compiler every year. Quick lesson in capitalism: Consumer buys the better good. Competition makes better product, and the better good becomes the competition.  Repeat

But in all actuality, C++ has its ups and downs. Just like Qbasic, there are things its designed to do and things its not.  And when the time comes when its needed, its good to know you have it.  C++ is great at doing graphics, machine-independant tasks, and classes and such.  Qbasic is far superior at manipulating strings.  So don't think C or Qbasic is better, just different.

Another difference from basic is that C++ is a compiled language, not an interpreted language.  An interpreted language takes the code you write, and the interpreter translates it into machine code one line at a time.  Contrary to belief, even the bc.exe does not compile the code.  Basically, it takes the instruction that start the interpreter and places them at the beginning of your code.  Hence, you need the BRUN45.EXE (The interpreter) with your 'compiled' code.  Luckily, you can also smack that in your file also.  But I digress; I am vascillitating from the point.

A compiled language transfers your program into machine-code every time you run it.  Hence, whenever you need to test your program, you need to compile it.  This is a hassle that I really don't like about C, because when your programs get really big, its a pain to have to wait the 15-20 seconds to test one little thing.  But again, I digress.

The second to last thing you need to know before you start coding some C, is that you type C code in a text file, and then give that to a compiler.  And there are a multitude of compilers.  My preference is Turbo C++ 3.1, but you can use whatever you please.  Don't, however, use any sort of 'Visual' C++ for Windows.  I don't like them, don't use them, and don't guarantee that any of these programs will work.

Let's get one last thing straight.  I am not a C guru.  I know just about enough to handle small tasks, and that's the way I like it.  I don't know C++ the way I know Basic, but I know enough to get you started.  I hope

Lesson one:  Hello, World!

Anyone will tell you the best way to learn something is to do it.  And C++ is no exception.  So the first thing we will do is lay down Hello, World and then go into an in-depth study of it.  Here is the code for Hello, World

#include <iostream.h>

void main(void)
{
   cout << "Hello, World\n";
}

Compile, and Tada, you wrote your C++ program.  But you are probably saying "What the heck did I just do?".

WARNING:  Depending on what program you use, it may just dump you back to the programming screen after it compiles.  This doesn't mean it doesn't work, it just means that it doesn't pause after you program runs.  Try looking in your menus for the 'User Screen' command.  This should let you see the last screen that was used

I believe its the basic concepts that are hard to learn in C++, and not the actual language itself.  And coming straight from an interpreter based language (runs one line at a time inside a program) to a compiler based language (has to run a compiler on a file before you can run it) is a rather large hurdle.  But let's get down to business.

In C++, there are no 'built-in' commands.  Every command in C++ is in a header file, or an 'include file', or 'function prototype'.  So before you can call a command, you need to include it at the top of your program.  For example, imagine a QuickBasic library.  Before you could write a program that used functions in that library, you would have to load up the proper files, etc.  Well, in C++ all the commands are in 'libraries', and they are divided up into different files according to purposed (mainly for memory efficiency, I guess).  So before you can use any command, you need to #include the appropriate file.  Your C++ help file should have a list.

Next, everything in C is programmed in functions.  There is no 'main module'. There is the main function, which the compiler starts with, but you just can't write some code down and expect it to run.  If you are quite proficient in QB, you know that functions are different then subroutines because functions return a value after they run.  In C++, Functions are defined by what values they return.  So a VOID function would return nothing.  In essence, a void function is a subroutine.  Here is the breakdown of the second line, and an example of the equivalent QB command.

void main(void)
 \    \    \
 |    |    the function does not accept any parameters(or arguments)
 |   name of the function
function does not return a value
 

DECLARE SUB MAIN()
 

Qbasic was nice.  For each function/sub, you got a separate screen.  However, in C++, all you functions are declared in one screen, so you use { and } to define the start and end of the function.

Now for the actual command, cout (C OUT, get it?).  COUT is the equivalent of the PRINT command.  I'm not really sure what the brackets are for, but I guess they just tell where to direct the output.  As you can see, the text is in the quotes, and the ; marks the end of the statement.  Remember this:  ALMOST ALL EXECUTABLE STATEMENTS END WITH A SEMI-COLON.  This is because C++ doesn't recognize white-space as anything.  You could stop the statement after the " and put ; down 10 lines and tabbed over 20 times, and it would work.

Here is the old code, with some comments (notice how the comments are presented):

#include <iostream.h>           // include our iostream.h header file

void main(void)                 // declare the main function
{                               // start the main function
   cout << "Hello, World\n";    // Do our print command
}                               // End the main function


USING CIRCLE ROUTINES AS TITLE SCREENS
Gloria McMillan

        I teach Computer-assisted writing at a community college and for several years I have been writing my own curricula.  Students like things that are a bit eye-catching to start them off and add a bit of pizazz to a library skills exercise, for instance.

        My skill in programming QBasic and Quickbasic comes mainly from the book lang.basic.misc when I have bogged down.  I thought that my title for exercises would be more interesting if it moved in some way.  I saw some circles that grew by the STEP procedure in and I thought that they would make an interesting title screen, if only I could get several of them to advance across the screen and to overlap in some way.

        Of course, I thought of a FOR LOOP.  I made several attempts at launching circles up the screen, moving from bottom to top, in a FOR sequence.  I had a problem getting my circles to advance, as I recall, and they simply overwrote each other.  So after several tries, I asked if anyone on our Basic newsgroup had a way to make circles go up the screen. This is what Don Schullian sent me from last April on our comp.lang.basic.misc group:

'==============Don's Subroutine that worked for circling=================
'
'From:  Don Schullian
SCREEN 9: CLS

MyColors:
  DATA 01, 320
  DATA 01, 320
  DATA 09, 310
  DATA 02, 310
  DATA 02, 310
  DATA 14, 310
  DATA  0

RESTORE MyColors
x% = 320
Y% = 300

DO
  READ Colour%
  IF Colour% = 0 THEN END
  READ x%

  FOR Radius% = 1 TO 300 STEP 3
    CIRCLE (x%, Y%), Radius%, Colour%
  NEXT Radius%

  Y% = Y% + 10

LOOP

        I finally got the idea from Don's FOR radius% statement how to make the circles dance up the screen.  I realized that I had been locked into a "Duh!" moment, but vowed that I would do something truly interesting with the routine and you can be the judge of that.

        Instead of just moving up the screen, I decided to make my circles go around the border of the screen in a counterclockwise fashion.  The direction just happened and I never consciously thought of it.  Anyone can reverse the order of the advancing circles.  Here is a sample of a title screen for one of my class exercises:

' ================== GLORIA'S TITLE SCREEN ======================
'
' Apologies to whomever who showed how to place circles into a
' SUB statement.
'
DECLARE SUB DrawCircle (x!, Y!, colr!)
SCREEN 9

CALL DrawCircle(320, 8, 3)
CALL DrawCircle(260, 8, 2)
CALL DrawCircle(210, 8, 1)
CALL DrawCircle(160, 8, 15)
CALL DrawCircle(110, 8, 14)
CALL DrawCircle(60, 8, 13)
CALL DrawCircle(10, 8, 12)
CALL DrawCircle(10, 88, 11)
CALL DrawCircle(10, 138, 3)
CALL DrawCircle(10, 188, 2)
CALL DrawCircle(10, 238, 1)
CALL DrawCircle(10, 388, 2)
CALL DrawCircle(70, 438, 1)
CALL DrawCircle(130, 438, 15)
CALL DrawCircle(200, 438, 14)
CALL DrawCircle(270, 438, 13)
CALL DrawCircle(340, 438, 12)
CALL DrawCircle(400, 438, 11)
CALL DrawCircle(670, 338, 10)
CALL DrawCircle(670, 238, 1)
CALL DrawCircle(670, 138, 2)
CALL DrawCircle(670, 38, 3)

LINE (80, 20)-(550, 330), 0, BF

' I adapted this routine from a book of samples of
' enlarged letters, via multiples of X and Y values.

 DEFINT X-Y
 COLOR 8
 LOCATE 25, 1
 PRINT "  Hi, World!";

 FOR Y = 0 TO 11
          Y2 = 2 * Y: Y3 = 3 * Y: Y4 = 4 * Y
          FOR x = 0 TO 94
                        Z = POINT(x, 349 - Y)
                        IF Z <> 0 THEN
                        X2 = 2 * x: X3 = 3 * x
                        ' Chubby rounded font
                        CIRCLE (150 + X3, 200 - Y4), 3, 10
                        END IF
          NEXT
 NEXT

LOCATE 17, 25
COLOR 11
PRINT "shareware Gloria McMillan 1999"
SLEEP 1

LOCATE 20, 27
COLOR 2
PRINT "THIS WOULD START A PROGRAM."

 F$ = INPUT$(1)
CLS

DEFSNG X-Y
DEFINT X-Y
SUB DrawCircle (x!, Y!, colr!)
    COLOR colr
    FOR radius = 1 TO 300 STEP 3
        CIRCLE (x, Y), radius
    NEXT radius
END SUB



Polar Hilbert Curve
Al Aab

Newsgroup: comp.lang.basic.misc

'copyright 1999, al aab, toronto
'looks better in higher resolution
DECLARE SUB R ()
DECLARE SUB L ()
DECLARE SUB U ()
DECLARE SUB D ()
CLS : SCREEN 11
DIM SHARED O, w, rd, rdd, A, da
O = 5
w = 96
rd = 34
rdd = 2
da = 3.14 / 32
WINDOW (-w, -w)-(w, w)
CIRCLE STEP(0, 0), .1
x0 = rd * COS(A): y0 = SIN(A)
PSET (x0, y0)
CIRCLE STEP(0, 0), .1

R
PSET (rd * COS(A), SIN(A))
A = -.1
L
LINE -(x0, y0)
A$ = INPUT$(1)
PAINT (x0 + 1, y0 + 1)
CIRCLE (x0 + 1, y0 + 1), 1
A$ = INPUT$(1)
END

SUB D
IF O < 1 THEN EXIT SUB ELSE O = O - 1
CALL L: rd = rd - rdd: LINE -(rd * COS(A), rd * SIN(A))
CALL D: A = A - da: LINE -(rd * COS(A), rd * SIN(A)): D
rd = rd + rdd: LINE -(rd * COS(A), rd * SIN(A)): R
O = O + 1
END SUB

SUB L
IF O < 1 THEN EXIT SUB ELSE O = O - 1
CALL D: A = A - da: LINE -(rd * COS(A), rd * SIN(A))
CALL L: rd = rd - rdd: LINE -(rd * COS(A), rd * SIN(A)): L
A = A + da: LINE -(rd * COS(A), rd * SIN(A)): U
O = O + 1
END SUB

SUB R
IF O < 1 THEN EXIT SUB ELSE O = O - 1
CALL U: A = A + da: LINE -(rd * COS(A), rd * SIN(A))
CALL R: rd = rd + rdd: LINE -(rd * COS(A), rd * SIN(A)): R
A = A - da: LINE -(rd * COS(A), rd * SIN(A)): D
O = O + 1
END SUB

SUB U
IF O < 1 THEN EXIT SUB ELSE O = O - 1
CALL R: rd = rd + rdd: LINE -(rd * COS(A), rd * SIN(A))
CALL U: A = A + da: LINE -(rd * COS(A), rd * SIN(A)): U
rd = rd - rdd: LINE -(rd * COS(A), rd * SIN(A)): L
O = O + 1
END SUB


Basilar Data Types

The first thing that you need to know is the group of the basilar data types. The computer's CPU can handle by default only four types of data (BYTE, WORD, DOUBLE WORD), but all the programing languages have created other custom data-types. The most important are : SINGLE AND DOUBLE FLOATING POINT, INTEGERS, LONG INTEGER and STRING. These types are supported by Qbasic and QuickBasic, and the PDS 7.1 supports the CURRENCY type too.

Now, let examine all of these data types.

BIT

|0|
The bit is the simplest type of data that exists. It can be either a 1 or a zero. A sequence of bit can make all the other data types known on the computer world. For example a sequence of 8 bits generates a byte. All the computers uses a BASE-2 (or binary) number system. For example, 0001 = 1 , 0010 = 2, 0011 = 3 , 1000 = 15.

BYTE - 8 BIT
|0000 0000|

The BYTE is the standard chunk of information. The BYTE is 8 BITs, and it's maximum value is FF (HEXADECIMAL) or 255. Also, the equivalent of 255 is 11111111. Any memory reference is indicated using bytes. For example, is you query how many memory has your computer, the answer is xxxx bytes. Usually the BYTE word is preceded by a "kilo" or "mega" prefix. A kilobytes is 1024 bytes and a megabyte (MB) is 1024 kilobytes (KB), or 1048576 bytes.

WORD - 2 BYTES - 16 BIT
|0000 0000 0000 0000|

A Word is just two bytes together, or 16 bits. The maximum value of a word is 65535 (FFFF HEXADECIMAL), and , with the byte, it's the most used data type. The equivalent of 65535 is 16 '1' together. The word type is the same of the "unsigned integer", but see the Integer data type for more information about signed and unsigned integers.

DOUBLE WORD -4 BYTES - 32 BIT
|0000 0000 0000 0000 0000 0000 0000 0000|

A double word is two words, or 32 bit. The maximum value of a DWord is 4294967295 of FFFFFFFF HEX. The DWord is the same of the 'Unsingned Long integer' or of the 'Signed Long Integer'.

A small consideration about Singed and Unsigned integers (WORDs): an unsigned word have a range from 0 to 65535, and all the 16 bits are used for store the value. Also, 65535 is

1111 1111 1111 1111

But, how store negative numbers? The solution can be only one: use a bit for the sign. So, a signed word have a range from -32768 to 32767. Here's an example:
 
Decimal
Hexadecimal
Binary
32765
7FFD
0111 1111 1111 1101
32766
7FFE
0111 1111 1111 1110
32767
7FFF
0111 1111 1111 1111
-32768
8000
1000 0000 0000 0000
32767
8001
1000 0000 0000 0001
-1
FFFF
1111 1111 1111 1111
0
0000
0000 0000 0000 0000

If the last bit (note that the first bit is on the right) is 0 the value is positive, if the last bit is 1 is negative. This isn't too important in Basic, but every programmer must known this topic, for general knowledge.

Now let see the QuickBasic standard data types. These types are derived from the basilar types (see above), usually used with Assembler. Note that QuickBasic doesn't supports the BYTE type and the unsigned words.

INTEGER. (%)

Is the same thing of a signed word, with a minimum value of -32768 and a maximum value of +32767. Is the most used type of QB.

LONG INTEGER (&)

Is the same thing of a signed double word, with a range from 2,147,483,647 to -2,147,483,648. This type is usually used for scientific and math programs with big numbers.

SINGLE FLOATING POINT (!)

The storage method for this type is totally different than the one of integers. The data is split in three portion: the mantissa, the exponent and the sign bit. The mantissa holds the base value of the number, the exponents holds the power that the mantissa must be raised, and the sign bit, like integers, is used to show if the number is positive or negative.

There's two methods to indicate Floating Point numbers, the MBF (Microsoft Binary Format) or the IEEE format. The IEEE format is the slower but is more accurate. QuickBasic 4.x supports the IEEE format and the PDS too. The Single floating point is a floating point number, with a range from &plusmn;3.402823 E+38 (10 ^ 38) to &plusmn;1.401298 E-45, and requires 32 bits (4 bytes) like a Long Integer

DOUBLE FLOATING POINT (#)

The Double floating point is a single floating point but more accurate. It requires 64 bits (8 bytes) , and can store number from &plusmn;1.7976931 D+308 to &plusmn;4.940656 D-324.

A problem for the floating point number is the rounding error. Try this program

For X% = 1 to 10000     'repeats 10000 times
Number! = Number! + 1.1 'add to Number 1.1 every time
Next ;repeat
Print Number!           'show the Number!

Expected result: 11000.00

Returned result: 10999.52

STRINGS.

A string is an alpha numerical sequence of one or more Ascii characters( space included). An example of string can be

AVXSFD0113245&"!&middot;Ì&brvbar; !!!

In Basic strings are delimited from two ". For example, to assign to a variable a text, use this command:

X$ = "ABCDE"

There's are two types of strings in Basic; fixed and variable length strings. A fixed length string is a string that have a constant length, declared with the DIM statement. For example, this program demostrates how a fixed length string is handled by Basic.

CLS
DIM A AS STRING * 3                          'Fixed length string of 3 chars
A ="ABC"                                     'Assign a text of three characters
PRINT A                                      'Prints the string
A = "ABCDEF"                                 'Assign a text with a length major of 3 chars
PRINT A                                      'Prints the string, note the output!
A = "ABC!&pound;$%&/()=?^^?=)(/&%$&pound;!|" 'Another time
PRINT A

Output :

ABC
ABC
ABC

When a fixed length string is used with an assignment instruction (=) only the declared characters are considered. On this example only the first three characters are used.

VARIABLE LENGTH STRINGS.

The size of variable length string can change every time that an assignment instruction is done. Try this example:

CLS
DIM A AS STRING
A = "ABC"
PRINT A
A = "ABCDEF"
PRINT A
A = "ABC!£$%&/()=?^^?=)(/&%$£!|"
PRINT A

The maximum length of a string (fixed or variable length) is 32767, and each character need a byte of memory (in variable length strings four byte are needed for the string descriptor). Also, you can use empty strings too. A string can be easily converted to a numerical variable and from a numerical variable. See the STR$ and the VAL command for future reference.

The Currency type

With the exit of Microsoft PDS, a new type was introduced, the Currency type (scaled integer). The range of this type is -922337203685477.5808 to 922337203685477.5807 , with 15 digits on the left of the sign and four on the right. This number can be used for big integer operations or for very precise floating point operation, simply by scaling per 10000. Also, the currency is called "fixed point" too.

Summary

After reading this text, you should know the common used data types. If you want to check your knowledge, read and answer this text:

  1. What's a BIT?
  2. How many BIT have a word?
  3. What the maximum range of an unsigned Double Word?
  4. How are called the three parts of a floating point number?
  5. What the difference between WORDs and INTEGERs?
Answers:
  1. The BIT is the simplest data type. It can be either 1 or 0
  2. 16
  3. 4.294.967.295
  4. Sign, Mantissa and Exponent
  5. A word is usually unsigned, a Basic Integer is always signed. Also, except this detail, they are the same thing.


Also, you learned these things:
BIT, WORD AND DOUBLE WORD: Basilar datas handled directly by the computer. None of these types is used in basic.
INTERGER, LONG INTEGER: The Basic's types equivalent of word and Dword. They are always signed. SINGLE AND DOUBLE FLOATING POINT: Basic floating point types. These types are handled by Basic, with the IEEE format. STRINGS: Data type that can store strings of characters and numbers. Unknown for the CPU they are totally handled by Basic. A string can be 'fixed length' or 'variable length'
 
 


Fast read from a file
Thomas Laguzzi

FIRST OF ALL: Before you read this tutorial save the file CREATE.BAS and be ready to run it every time is asked. (You can also compile it for speed ). That program creates an Empty dummy file used for the programs of this tutorial. The file created is in C:\TEST.DAT . If you already have that file, modify the source of the program... Now, let's go!

Have you ever tried to open a big file as binary and store it into memory?

All the programmers I know (Ok, I don't know a lot of programmers:-) for get a certain data from a file reads it byte per byte. This method is really slow, specially with big files. For example, create a file big 200 kb (using CREATE.EXE with the value of 204800), the run this program:

OPEN "C:\test.dat" FOR BINARY AS #1 'Open the file
T = TIMER                           'Take the initial time
FOR i = 1 TO 204800                 'Read 204800 bytes with the one-byte method
GET #1, , a%                        'Get the byte
NEXT i                              'Repeat
PRINT TIMER - T                     'Print the elapsed time
CLOSE #1 'Close the file
END

This programs reads every byte of the file in the var a (integer). If you take a look on the LED of your HD, you don't see anything...

On my 133 the program takes 9 seconds, that depends on the speed of your CPU, but it's still slow. You can say: why must I read 200 kb of data into a Basic program? For an Image, for example. If you're using SVGA each screen in 640x480x256 needs 300 KB of memory. If you want to load a BMP you can't wait 9+ seconds!!!
The first solution is use long integers instead of simple integers. Try to use
GET #1, , a& instead of GET #1, , a&

8,5 seconds... hum... only half second of difference . Ok, after this stupid try, I'll write the right solution of the problem. Q(uick)Basic let you get strings too. For example, if you have a file with ABCDEF and you use this:

A$=" "
GET #1, , A$
 

A$ will contain the first character, A. Now, Try this:

A$=" "
GET #1, , A$

A$ will contain ABCD. I think you can see the solution. If you use a string long 1024 characters you'll get 1 kb every time you access the file. Try this code:

OPEN "C:\TEST.DAT" FOR BINARY AS #1
Buffer$= STRING$(1024," ") ' Creates a buffer long 1 KB
T= TIMER
FOR I% = 1 TO 200          ' The file can contain 200 buffers (200Kb)
Get #1 , , Buffer$         ' Get the buffer
NEXT I%
PRINT TIMER - T
CLOSE #1
END

The result: 0 . Yes, I on my 133 get a big 0. Don't worry, the code works good. If you insert a PRINT Buffer$ instruction after the Get, you'll get a number greater than 0. You get 0 because the code is executed in less that 1/18 of second that's the minimum sensibility of the DOS Timer. Try to generate a file big 10 MB (10485760), then use:

FOR I% = 1 to 10240

instead of the old code. 4.5 seconds: the half of the time for read 200 kb byte per byte... Also, use

FOR I% = 1 TO 2560

and

Buffer$= STRING$ (4096," ")

Now we use a 4 KB buffer, let's see the result... the same!
Now, we'll create a program that reads a file of unknown size with a variable buffer. We'll use some variables:

We use the Remaining var because if we have a file big 1026 bytes with a buffer of only 1024 bytes, two bytes are remaining. For Calculate the two vars, use the formula:

HowMany& = FileSize& \ BuffSize&
Remaining& = FileSize& MOD BuffSize&

Note that you should use the '\' operator and not the '/' one.
Here's a commented program, that's better than a teoric explanation:
Try to generate a file with different sizes, and try to use different buffer sizes...

CLS
BuffSize& = 16384                    'Here's the buffer size: modify as you want...
OPEN "C:\TEST.DAT" FOR BINARY AS #1  'Open the file
FileSize& = LOF(1)                   'The LOF function returns the size of the file in bytes...
HowMany& = FileSize& \ BuffSize&     'Calculate how many buffers are in the files
Remaining& = FileSize& MOD BuffSize& ' The Remaining bytes
Buffer$=String$(BuffSize&," ")       'Generates a buffer
T = TIMER
For I&=1 to HowMany&                 'Read the data from the file
Get #1, , Buffer$     '... Here You can process the data that you have read from the file
Next I&
Buffer$ = String$(Remaining&," ")    'Creates a buffer for the remaining bytes
Get #1, , Buffer$                    'And read from the file
PRINT TIMER - T                      'Elapsed time
CLOSE #1
END

If you have a file with many numeric values, you can extract them using Peek-Poke, ecc... I can't write how to make it on this tutorial, but if you want to know it, write me, I'll tell you! (or I'll write another tutorial!)
You can say that you have understand this topic if you can make a COPYING program, that copies a file from another using a buffer.


Sleep via Interrupt
Thomas Laguzzi

The Sleep routine without parameters waits for a keypress, then release the control to your program. Some computer, after some SLEEPs, generates a beep every time the instruction is used, that's because the buffer is full… If you simply need to wait until a key is pressed, you can use the keyboard interrupt. Try this code: (load QB with the /L parameter)

'$include:'qb.bi'
DIM Regs as RegType       'Registers for the Interrupt function
Regs.AX = 00              'Interrupt service 00: return a character
Interruput &H16,Regs,Regs 'Call the Interrupt 16h, handled by the Keyboard bios

The function 00 returns in AX the Ascii value and the keyboard code of the key pressed. Here's a small file ASM for the ASM Sleep routine that you can use (Related file: SMSleep.obj,ASMSleep.ASM,ASMSleep.QLB)

.MODEL MEDIUM,BASIC ;QuickBasic uses the Medium model
.STACK 200h         ;Define our small stack
.CODE
ASMSleep proc FAR   ;The SUB ASMSleep
Public ASMSleep     ;Make it pubblic to QB
MOV AX,00           ;Interrupt 16h service 0
INT 16h             ;Call the INTerrupt
RET                 ;Return to Basic
ENDP ASMSleep       ;End of the sub
END                 ;End of the file

The File included (OBJ) can be linked with the command:

LINK /QU ASMSleep.OBJ,,,BQLB45.LIB

QB /LASMSleep.QLB

If you want to run the file without link:

QB /LASMSleep.QLB

See the QuickLibraires section for more information

For use the ASM code in QB use this code:

Declare sub ASMSleep ()
Print "Please Press a Key"
ASMSleep
Print "You've Pressed a key!"
END


Programming Challenge


Its simple, create a program for the Challenge decribed bellow

The rules are simple. It must be able to run in Qbasic.
The winners' will be featured program will be featured in the next issue.
All enterants' programs will be on the featured.

All submissions become the joint property of the author and the Basix Fanzine. Either the author and the Basix Fanzine may modify, edit, copy, and/or redistribute programs.

When entered the programs will not be edited in any way what so ever. All programs that fail to run properly it will be put aside and the author will be notified by e-mail of the problem, at which time the author may resubmit the program. The Author can only resubmit their programto a maximum of three times.

If there is any problem, concern, contact me.

And now onto the challenge:

This issue's challenge: Make a Forest Fire Program

It should follow this pattern:

Build the forest, can be either a pre-made forest or a random forest
draw the forest
A lightining strike should set off one or more fires
redraw the forrest

DO
    the fire should spread and grow
     - each tree within 1 away from the fire, will catch fire
     - after one generation, the fire burn out, and turn to soil
     - in the next genereation it turns to a tree
     - if already a tree it stays a tree
    redraw the forest
LOOP Until the Fire Burns it self out

Optional: Put out the fire in a certain area

Entries will be marked on the following:

When sending in you porgrams Please include: Send Entries to Basix_Fanzine@yahoo.com


Miscellaneous & Credits


Website Award

nominate a site: 

Or you can vote or nominated for your favorite webpage on the Basix Fanzine homepage.


Credits


Many thanks goes out to the people who contribute to this issue of the Basix Fanzine
 
Gloria McMillan
Al Aab
Alan Copeland
Thomas Laguzzi http://tlp.virtualave.net


Contact Info


 
ARTICLES Basix_Fanzine@yahoo.com
OTHER INQUIRIES ETC. Basix_Fanzine@yahoo.com
WWW ADDRESS www.come.to/basixfanzine


Mailing List


Currently there are around 150 people on the list. Please note that I assume no responsibility for any message that you receive or don't receive from being on the list. Your email address and/or any other information will not be given to anyone.

To join send an email to "Basix Fanzine" <ListProcessor@mindspring.com> with "SUBSCRIBE" in the subject line of the message.

To unsubcribe send an email to "Basix Fanzine" <ListProcessor@mindspring.com> with "UNSUBCRIBE" in the subject line of the message.


Next Issue

As always I am always looking for articles, tutorials, comments, newsgroup articles, etc. to put in the anzine. Please send them in. If you're not sure of what to write, check out what other people have requested. And stay turned for the winner of the Basix Fanzine Programming Challenge.
 
 



Edited By David Groulx
Copyright © September 1999 The Basix Fanzine