home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 1
-
-
- BASDLX.LIB
-
- Deluxe Library of routines written in assembly language for the
- BASIC Compiler
-
- BASDLX, Basic Deluxe, is a library of powerful routines for com-
- piled BASIC. To use BASDLX.LIB you will need, either the IBM
- Basic compiler or the Microsoft Quickbasic compiler. I suggest
- that you use PC-DOS/MS-DOS versions 2.0 or later to insure full
- compatibility. These routines have been tested with the IBM Basic
- compiler version 2.0 and have caused no problems. However, I am
- not responsible for any damages caused by but, not limited to,
- the use, misuse or inability to use BASDLX. These deluxe routine
- are intended to be used in compiled basic only. Do not confuse
- compiled BASIC with the BASIC interpreter, BASIC.COM or
- BASICA.COM that comes with DOS. The routines provided in this
- library have been designed to run faster than it's correspondent
- basic code, and often take up less space, leaving you with more
- room to write longer programs!
-
- This is the Third, of many public releases of the Basic Deluxe
- library. You are free to use the routines provided in the BASDLX
- library in your programs. The copyright is only here to preserve
- my work and to protect you from any unauthorized modifications of
- BASDLX; it is NOT here to protect against the free distribution
- of BASDLX. You may copy and distribute BASDLX to others as long
- as no fee or special consideration is charged and all of the re-
- lated files to BASDLX are included together in the unmodified
- form. If you use BASDLX in your programs and find it a valuable
- tool then I would appreciate it if you would send a contribution
- ($25 suggested). It would be nice if you could acknowledge use
- of BASDLX routines in your programs or documentation that use
- them. With a minimum contribution of $25 I will send you a disk
- with the source code to BASDLX. Previous contributors will need
- only send $10 for an update of BASDLX. A contribution of $55 will
- grant you a one year subscription to BASDLX. With a subscription
- you will automatically receive new updates as soon as they come
- out. All contributions are non-refundable. Updates come complete
- with source code, BASDLX library, and documentation.
-
- These routines have been incorporated into a library to make them
- easily accessible by the DOS LINK.EXE program. All you have to
- do is copy BASDLX.LIB to the directory or disk where you keep
- your library files. When you link your programs that use
- routines from BASDLX, be sure to specify: BASDLX when the linker
- prompts you for a Library [.LIB] file(s). Please refer to your
- DOS manual for more information on the LINK.EXE program.
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 2
-
- Special Notes
-
- The routines provided in this library are available to you by
- using the CALL command from compiled BASIC. All numeric variables
- passed as arguments to the routines must defined as integers.
- This means that you can either globally set all numeric variables
- to integers by issuing the DEFINT A-Z command at the beginning of
- your program or, you can declare a single variable as integer by
- adding a "%" symbol at the end of its name. (i.e. I%, this will
- declare the variable as being integer). I will always add the "%"
- symbol at the end of all my numeric variables in all of my ex-
- amples, to remind you that they MUST be integers.
-
- The variable names used in my examples don't have to be exactly
- the same. you may choose other names that would be more ap-
- propriate. keep in mind that the variable types do have to be the
- same in the argument list (i.e. strings must be strings, integers
- must be integers).
-
- As I mentioned before I have tested these routines and they, to
- the best of my knowledge, work bug free. But, if you happen to
- find any bugs I'll be happy to fix them. Be sure to check that
- you are CALLing the routines properly. That is that you are send-
- ing the correct arguments to the routine. One of the most common
- error that occurs is when the calling program sends to the
- routine an incorrect variable type. Remember that numeric vari-
- ables must be declared integer.
-
-
-
- Please refer any questions, comments, requests for new routines
- or contributions to the following address:
-
- Gustavo H. Verdun
- 6424 Hollins Drive
- Bethesda, MD 20817
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 3
-
- Routine Name : BSORTN
- Arguments : (Num_of_elements,Integer_array%(start))
- type : integer array service
- Purpose : Sorts an integer array in ascending order with
- negative numbers appearing at the end in
- ascending order.
-
- Description:
- Integer variables in BASIC can contain numbers between -32,768
- and 32,767. This routine does not distinguish between negative or
- positive numbers. It will sort the elements in ascending order
- with all the negative numbers (if existing) appearing after the
- positive numbers in ascending order. Make sure that the array is
- of type integer. Unpredictable results may occur if not!
-
- Example:
- dim a%(300):print "Array Before sort:"
- for i%=0 to 300:a%(i%)=int(rnd(1)*30000):print a%(i%),:next
- enum%=301:call bsortn(enum%,a%(0))
- rem enum%=301 because there are 301 elements in the array (0-300)
- print "Array After sort:":for i%=0 to 300:print a%(i%),:next
- rem the list should be sorted in ascending numerical order!
-
- Routine Name : BSORTS
- Arguments : (Num_of_elements%,Array$(start_position))
- Type : String array service
- Purpose : Sorts a string array in ascending alphabetical
- order.
-
- Description:
- The first argument should contain the number of elements to sort
- in the array. The second argument is the array itself. be sure to
- specify the starting position in the array [i.e.
- BSORTS(elements%,a$(0))]
- IMPORTANT: All of the elements in the array MUST have equal
- lengths, if not, unpredictable results will occur to BASIC
-
- Example:
- dim a$(10):a$(0)"First":a$(1)="Second":a$(2)="Third"
- a$(3)="Fourth":a$(4)="Fifth":a$(5)="Sixth":a$(6)="Seventh"
- a$(7)="Eighth":a$(8)="Ninth":a$(9)="Tenth"
- for i%=0 to 9:b$=space$(10):call setl(a$(i%),b$):a$(i%)=b$:next
- rem the above line will make all of the elements in the array
- rem have equal lengths.
- print "Array before sort:":for i%=0 to 9:print a$(i%):next
- enum%=10:call bsorts(enum%,a$(0))
- rem enum%=10 because there are 10 elements in the array (0-9)
- print "Array After sort:":for i%=0 to 9:print a$(i%):next
- rem the list should be sorted in ascending alphabetical order!
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 4
-
- Routine Name : DATESTR
- Arguments : (String_space$,Length%,mode%)
- Type : Date support
- Purpose : Reads the date and writes string_space$ with the
- date in the following format: week-day month day,
- year. (i.e. Thursday, March 12, 1987)
-
- Description :
- The first argument, String_space$, must be of at least 30
- characters of length. If Length% returns with a zero then there
- wasn't enough space in the string variable String_space$. The
- Mode% argument tells the routine to either write the full name of
- the week-day and month or just the first three letters of each.
- If Mode%=0, or any number other than one, then the full names of
- the week-day and month will be written. If Mode%=1 then only the
- first three characters of the week-day and month will be written.
- The Length% argument is used to tell BASIC the true and final
- length of String_space$ (This way you easily get rid of the
- trailing characters after the year since, the actual length of
- String_space$ will vary greatly depending on the date.)
- NOTE: String_space$ will never be any longer than 30 characters
- of length.
-
- Example:
- D$=space$(30):l%=0:mode%=0:call datestr(d$,l%,mode%)
- if l%=0 then print "Not enough space in D$!":stop
- d$=left(d$,l%):print "Today is ";d$
- D$=space$(30):l%=0:mode%=1:call datestr(d$,l%,mode%)
- if l%=0 then print "Not enough space in D$!":stop
- d$=left(d$,l%):print "Today is ";d$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 5
-
- Routine Name : GETSTRD
- Arguments :
-
- (String$,length%,frame%,overwrite%,insert%,color%,mode%)
-
- Type : String/Data entry enhancement
- Purpose : This routine accepts input from the keyboard and
- stores it in String$ argument allowing the use of
- standard editing commands.
-
- Description :
- To start with I will describe each of the arguments:
-
- String$, This is the space where the input data will be stored.
- The field size of the input data will be set to the length of
- this string. If there is already some data in the string it will
- not be erased. Just be sure to set the length to the proper value
- to let GETSTRD know that there is already data in the String$
- variable that is ready to be edited.
-
- Length%, I added this argument so if you have a string length
- that is shorter than the field size that you have allocated for
- the data, GETSTRD will be able to know and upon return tell you
- the actual length of the string. This makes it easy to remove the
- trailing spaces in the String$ if they are not important. a
- Length% of zero tells GETSTRD that it is a `fresh' data field
- containing no information.
-
- Overwrite% & Insert%, These two arguments contain the cursor
- shapes that indicate if overwrite or insert is active. The
- formula for the values that must be stored in these two arguments
- is as follows: =(START and 31)*256+STOP Where START & STOP are
- the values for cursor start & stop scan lines which must be in
- the range of 0-31. (See the BASIC LOCATE command for more infor-
- mation on cursor shapes.)
-
- Frame%, this argument contains the ASCII code for the frame
- character. GETSTRD draws a one line frame of the length of
- String$ to let you see the field size.
-
- Color%, here is where you may specify the color attribute that
- GETSTRD will use. The formula for the color value is as follows:
- Color%=(BACKGROUND and 7)*16+FOREGROUND
-
- Mode%, GETSTRD currently supports two modes of operation. If
- Mode%=0 GETSTRD will operate normally without exiting unless
- [ESC] or [RETURN] is pressed. If Mode%=1 GETSTRD will operate
- normally except that if it reads from the keyboard an extended
- scan code that is not one of it's editing commands it will exit
- the routine and return with the extended scan code to that key in
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 6
-
- Mode%. This feature makes it easy to write programs that allow
- the user to scroll through other data fields without changing or
- having to re-enter data. If upon exit from the GETSTRD routine
- Mode%=-1 then the [ESC] key was pressed and your program should
- do whatever the [ESC] key means. If [ESC] means nothing to your
- program then just go back to the line that CALLs GETSTRD and con-
- tinue.
-
- The following Editing keys are supported:
-
- [LEFT-ARROW] Move cursor one space left.
- [RIGHT-ARROW] Move cursor one space right.
- [HOME] Move cursor to beginning of line.
- [END] Move cursor to the end of line.
- (NOTE: The end of the line is determined by the current length
- of the input data and not the maximum length of the data field.)
- [CTRL]-[RIGHT-ARROW] Move cursor one word right.
- [CTRL]-[LEFT-ARROW] Move cursor one word left.
- [CTRL]-[HOME] Erase entire input field.
- [CTRL]-[END] Erase from cursor position to the end of
- the line.
- [INS] Set/Clear Insert mode.
- [DEL] Deletes character at cursor position.
- [BACKSPACE] Deletes character to the left of cursor.
-
- Example :
- 10 rem This example is for mode 0.
- 12 mode%=0:oc%=(0 and 31)*256+7:ic%=(5 and 31)*256+7:frame%=95
- 14 c%=31:rem oc% & ic% are the overwrite and insert cursors.
- 16 A$=""
- 18 l%=len(A$):b$=space$(50):call setl(a$,b$):a$=b$:rem add field
- 20 print "Enter data ";
- 22 call getstrd(a$,l%,frame%,oc%,ic%,c%,mode%)
- 24 a$=left$(a$,l%):if mode%=-1 then 18
- .
-
- 10 rem this example is for mode 1.
- 12 mode%=1:oc%=(0 and 31)*256+7:ic%=(5 and 31)*256+7:frame%=95
- 14 c%=31: rem oc% & ic% are the overwrite and insert cursors.
- 16 A$="":c
- 18 l%=len(A$):b$=space$(50):call setl(a$,b$):a$=b$:rem add field
- 20 locate 10,5:print "Enter data 1 ";
- 22 call getstrd(a$,l%,frame%,oc%,ic%,c%,mode%)
- 24 a$=left$(a$,l%):if mode%=-1 then 36
- 26 l%=len(C$):b$=space$(50):call setl(C$,b$):C$=b$:rem add field
- 28 locate 11,5:print "Enter data 2 ";
- 30 call getstrd(c$,l%,frame%,oc%,ic%,c%,mode%)
- 32 a$=left$(c$,l%):if mode%=-1 then 36
- 34 if mode%=72 or mode%=80 then 18
- 36 print "Data A: ";a$:print "Data B: ";c$:end
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 7
-
- Routine Name : GUN
- Arguments : (Num_of_shots%)
- Type : Speaker support
- Purpose : Simulates the sound of a gun or machine gun
-
- Description :
- This routine generates the sound by sending spurts of white noise
- to the speaker. This will create the sound of a quick explosion.
- the only parameter needed is the number of shots to fire.
-
- Example:
- input "Number of shots to fire :",shots%:if shots%=0 then end
- call gun(shots%)
-
- Routine Name : READP
- Arguments : (Port_num%)
- Type : Printer support
- Purpose : Reads the printer status of the specified port
- number (1-3) and returns with the status byte
- for that port in the Port_num% variable.
-
- Description:
- The status byte of contains the following information:
-
- bit: 7 6 5 4 3 2-1 0
- | | | | | | |_Time out
- | | | | | |_Unused
- | | | | |_1 = I/O Error
- | | | |_1 = Selected
- | | |_1 = Out of Paper
- | |_1 = Acknowledge
- |_1 = Not Busy
-
- IMPORTANT: This routine does not check for a valid port number.
- Be sure that the port number is in the range of 1-3
-
- Example:
- port%=1:call readp(port%):print port%
- if port% and 32=32 then print "Printer is out of paper"
- if port% and 128=0 then print "Printer is Off-line"
-
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 8
-
- Routine Name : RESETP
- Arguments : (Port_num%)
- Type : Printer support
- Purpose : Resets the specified printer port number (1-3)
- and returns with its status byte (see the READP
- routine description for information on the
- printer status byte)
-
- Description:
- This routine sends a reset status through the parallel interface
- of the specified port number. This routine does check the
- parameters to be sure that they are in the range of 1 to 3. If
- the Port_num% argument is equal to -1 upon return then the port
- number is not valid.
-
- Example:
- port%=1:call resetp(port%):print port%
- if port%=-1 then print"Port number must be in the range of 1-3"
- if port% and 32=32 then print "Printer is out of paper"
- if port% and 128=0 then print "Printer is Off-line"
-
- Routine Name : SETL
- Arguments : (Source_string$,Destination_string$)
- Type : String manipulation
- Purpose : This routine will place the source string inside
- of the destination left-justified. If the source
- string is longer than the destination string then
- the right portion of the string will be truncated.
-
- Description :
- This routine automatically clears the destination string to
- spaces (ASCII 32) even if the source string is of length zero. Be
- sure to save the destination string into the source string after
- the call.
-
- Example:
- a$="Enter Name":b$=space(20):call setl(a$,b$):a$=b$
- rem the last command "a$=b$" saves the destination string in the
- rem source string since the routine cant' change the length of
- rem any string.
- print ">";a$";"<":REM this will show you the new length of a$
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 9
-
- Routine Name : SETR
- Arguments : (Source_string$,Destination_string$)
- Type : String manipulation
- Purpose : This routine will place the source string inside
- the destination string right justified. If the
- destination string is shorter than the source
- string then the right portion of the string will
- be truncated.
-
- Description :
- This routine automatically sets the destination string to all
- spaces (ASCII 32) even if the source string is of length zero. Be
- sure to save the destination string into the source string after
- the call.
-
- Example:
- a$="Enter Name":b$=space(20):call setr(a$,b$):a$=b$
- rem the last command "a$=b$" saves the destination string in the
- rem source string since the routine cant' change the length of
- rem any string.
- print ">";a$;"<":REM this will show you the new length of a$
-
- Routine Name : SNDOFF
- Arguments : NONE
- Type : Speaker support
- Purpose : Turns speaker off. If this routine is used then
- the BASIC SOUND or BEEP commands will not work.
-
- Description :
- This routine can be useful for those programs that use sound
- prompts to get attention when input is required. With this
- routine you can easily add the feature to your programs that will
- let the user decide if he wants to have the sound prompts on or
- off. If he wants the off then at the beginning of your program
- just call this routine. Any sound statements following this com-
- mand will execute without producing a single sound. Be sure not
- to forget to turn them on before the program finishes (SNDON).
-
-
- Example :
- sound 200,1:sound 300,1:sound 400,1:call sndoff
- sound 200,1:sound 300,1:sound 400,1
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 10
-
- Routine Name : SNDON
- Arguments : NONE
- Type : Speaker support
- Purpose : Turns sound on so that the BASIC SOUND and BEEP
- commands work.
-
- Description:
- This routine can help solve the problem that occurs when you use
- some memory resident programs that use the speaker and when they
- are done the turn it off so that any SOUND or BEEP commands won't
- produce an audible signal. It can also turn on the sound when it
- was turned off by the routine SNDOFF!
-
- Example:
- sound 200,1:sound 300,1:sound 400,1:call sndoff
- sound 200,1:sound 300,1:sound 400,1:call sndon
- sound 200,1:sound 300,1:sound 400,1
-
- Routine Name : TIMESTR
- Arguments : (String_space$)
- Type : Time support
- Purpose : Reads clock and loads String_space$ with the time
- in decimal ASCII. The format is as follows:
- HH:MM:SS.HD
- Where, HH are hours,MM are minutes, SS are seconds
- and, HD are Hundredths of a second.
-
- Description :
- String_space$ must be of at least 11 characters of length for
- this routine to work successfully. If it is not of the proper
- minimum length then the routine will do nothing and return with
- the String_space$ unmodified.
-
- Example:
- t$=space$(11):call timestr(t$):print t$
-
-
- Routine Name : XLC
- Arguments : (String$)
- Type : String manipulation
- Purpose : Converts the string to lower case.
-
- Description:
- No further explanations are necessary, I hope!
-
- Example:
- a="THIS WILL BE IN LOWER CASE!":call xlc(a$):print a$
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 11
-
- Routine Name : XUC
- Arguments : (String$)
- Type : String manipulation
- Purpose : Converts the string to upper case.
-
- Description:
- No further explanations are necessary, I hope!
-
- Example:
- a="this will be in upper case!":call xuc(a$):print a$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 12
-
- Summary of Routines
-
- Please use this as a quick summary to BASDLX routines. This sum-
- mary should only be used once you understand the routines, but
- just need a quick refreshment.
-
- Routine Name : BSORTN
- Arguments : (Num_of_elements,Integer_array%(start))
- type : integer variable service
- Purpose : Sorts an integer array in ascending order with
- negative numbers appearing at the end in ascend-
- ing order.
-
- Routine Name : BSORTS
- Arguments : (Num_of_elements%,Array$(start_position))
- Type : String service
- Purpose : Sorts a string array in ascending alphabetical
- order.
-
- Routine Name : DATESTR
- Arguments : (String_space$,Length%,mode%)
- Type : Date support
- Purpose : Reads the date and writes string_space$ with the
- date in the following format: week-day month day,
- year. (i.e. Thursday, March 12, 1987)
-
- Routine Name : GETSTRD
- Arguments :
-
- (String$,length%,frame%,overwrite%,insert%,color%,mode%)
-
- Type : String/Data entry enhancement
- Purpose : This routine accepts input from the keyboard and
- stores it in String$ argument allowing the use of
- standard editing commands.
-
- Routine Name : GUN
- Arguments : (Num_of_shots%)
- Type : Speaker support
- Purpose : Simulates the sound of a gun or machine gun
-
- Routine Name : READP
- Arguments : (Port_num%)
- Type : Printer support
- Purpose : Reads the printer status of the specified port
- number (1-3) and returns with the status byte for
- that port in the port_num% variable.
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 13
-
- Summary of Routines (Cont.)
-
- Routine Name : RESETP
- Arguments : (Port_num%)
- Type : Printer support
- Purpose : Resets the specified printer port number (1-3)
- and returns with its status byte (see the READP
- routine description for information on the
- printer status byte)
-
- Routine Name : SETL
- Arguments : (Source_string$,Destination_string$)
- Type : String manipulation
- Purpose : This routine will place the source string inside
- of the destination left-justified. If the source
- string is longer than the destination string then
- the right portion of the string will be truncated.
-
- Routine Name : SETR
- Arguments : (Source_string$,Destination_string$)
- Type : String manipulation
- Purpose : This routine will place the source string inside
- the destination string right justified. If the
- destination string is shorter than the source
- string then the right portion of the string will
- be truncated.
-
- Routine Name : SNDOFF
- Arguments : NONE
- Type : Speaker support
- Purpose : Turns speaker off. If this routine is used then
- the BASIC SOUND or BEEP commands will not work.
-
- Routine Name : SNDON
- Arguments : NONE
- Type : Speaker support
- Purpose : Turns sound on so that the BASIC SOUND and BEEP
- commands work.
-
- Routine Name : TIMESTR
- Arguments : (String_space$)
- Type : Time support
- Purpose : Reads clock and loads String_space$ with the time
- in decimal ASCII. The format is as follows:
- HH:MM:SS.HD
- Where, HH are hours,MM are minutes, SS are seconds
- and, HD are Hundredths of a second.
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-
-
-
-
-
-
- BASDLX (C) Copyright 1986-87 By Gustavo Verdun Page 14
-
- Summary of Routines (Cont.)
-
- Routine Name : XLC
- Arguments : (String$)
- Type : String manipulation
- Purpose : Converts the string to lower case.
-
- Routine Name : XUC
- Arguments : (String$)
- Type : String manipulation
- Purpose : Converts the string to upper case.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- --- BASDLX Version 1.3 March 1987 ---
-