WD: Sharing a Globally Dimensioned Array Between (WordBasic)Last reviewed: November 17, 1997Article ID: Q77273 |
The information in this article applies to:
SUMMARYIn the Microsoft WordBasic macro language, you can create a dimensioned array, such as A(6,6), that is available throughout any macro.
MORE INFORMATIONTo create a dimensioned array that is available globally to any WordBasic macro or subroutine, load the values into the array, open a text file, and write the contents of the array to the text file. If a macro needs to access these values, it opens the text file, reads the values into the array, and manipulates the values as necessary. The macro writes the values back to the text file. The manipulated values are available again to the originating macro or any other WordBasic macro that requires them. The following sample WordBasic macro illustrates this process:
Sub MAIN
Dim a(6, 6)
For x = 1 To 6
For y = 1 To 6
a(x, y) = y : Rem loading the array
Next y
Next x
Open "test.dat" For Output As #2
For x = 1 To 6
For y = 1 To 6
Print #2, a(x, y):REM Writing the array to a text file
Next y
Next x
Close 2
REM After opening a second macro, open the text file and read
REM it into the array again. Manipulate the array at this
REM point and write it back out to the text file.
Open "TEST.DAT" For Input As #2
For x = 1 To 6
For y = 1 To 6
Input #2, a(x, y) : Print "read " ; a(x, y)
Next y
Next x
Close 2
End Sub
Kbcategory: kbusage kbmacro
KBSubcategory: kbwordvba
|
Additional query words: passing parameters winword2 6.0 6.0a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |