GHS Port Reference Center
Information for maritime designers, engineers and builders
Maintained by Creative Systems, Inc., Creators of GHS
Click here for information about GHS and other fine marine software.
Go to Main page

Using READ (DATA) to propagate variables
    proj I-O
    clear all
    `Create a simple text file with three columns of data
    me (report) test.dat
    me 1 2 3
    me 4 5 6
    me 7 8 9
    me (report) off
    `Add a fourth line to the test.dat
    write (lines) test.dat 10 11 12
    view test.dat
    `Begin commands to read data into variables.
    variable n=0
    Macro lines  `while loop that reads three variables from each line
     if eof then exit      `while not EOF do
     set n = {n} plus 1
     variable X{n}, Y{n}, Z{n}
     read X{n} Y{n} Z{n}
     exit lines            `exit vice execute avoids recursive macro error
    `Read the first three values in each row into newly created variables
    read (data) test.dat
    read (data) off
    `Write the variables to a txt file to verify.
    write (variables) variables.txt
    view variables.txt
Add a free link to your site
Copyright © , Creative Systems, Inc.
Privacy policy