WD: Sharing a Globally Dimensioned Array Between (WordBasic)

ID: Q77273


The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a


SUMMARY

In the Microsoft WordBasic macro language, you can create a dimensioned array, such as A(6,6), that is available throughout any macro.


MORE INFORMATION

To 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 

Additional query words: passing parameters winword2 6.0 6.0a 6.0c winword 6.0a 6.0c 7.0 word95 word6 1.0 1.10 1.10a 2.0 2.0a macword 6.0.1 word7 2.0a-CD 2.0b 2.0c

Keywords : winword word6 winword2 word95
Version : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type :


Last Reviewed: December 21, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.