Article ID: 51411
Article Last Modified on 8/16/2005
APPLIES TO
- Microsoft QuickBasic 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBasic 4.5 for MS-DOS
- Microsoft BASIC Compiler 6.0
- Microsoft BASIC Compiler 6.0b
This article was previously published under Q51411
SUMMARY
The examples shown below demonstrate how to use the SEG keyword with arrays. The SEG keyword may be used in either a DECLARE statement or a CALL statement when calling a non-Basic routine, and is used to pass both the segment and offset of a variable (which corresponds to passing a far address).
MORE INFORMATION
When using SEG in the DECLARE statement to pass the far address of an array to a non-Basic routine, the array should be specified as a simple variable without using the array notation, as follows:
DECLARE SUB TEST(SEG a AS INTEGER) DIM a(10) AS INTEGER TEST(a(0))
A compilation error will occur if the array is DECLAREd using array notation as follows:
DECLARE SUB TEST(SEG a() AS INTEGER) DIM a(10) AS INTEGER TEST(a(0))
Inside the QuickBasic QB.EXE environment, the error message "Expected: , or )" will be displayed for the above DECLARE statement. When compiled from the BC.EXE command line, the following two error messages display:
When using SEG in an explicit CALL statement there should not be a DECLARE statement. Explicitly using the CALL keyword (instead of using an implied call) takes the place of the DECLARE statement. The correct syntax is as follows:
DIM a(10) AS INTEGER CALL TEST(SEG a(0))
If a DECLARE statement is used with an explicit CALL statement that uses SEG, the error "Parameter type mismatch" displays.
Additional query words: QuickBas BasicCom
Keywords: KB51411