AML 文件读取

/* Get file from user and open the file.

&setvar fil := [response 'Enter file name to read']

&if [null %fil%] &then

  &return &warning No file entered.

&setvar filunit := [open %fil% openstatus -read]

 

/* Check for error in opening file.

&if %openstatus% <> 0 &then

  &return &warning Error opening file.

 

/* Read from file

&setvar line := [read %filunit% readstatus]

&if %readstatus% <> 0 &then

  &return &warning Could not read file.

&do &while %readstatus% = 0

  &type %line%

  /* Read next line.

  &setvar line := [read %filunit% readstatus]

&end

 

/* Close file.

&if [close %filunit%] <> 0 &then

  &return &warning Unable to close %fil%.

&return End of file.

原文地址:https://www.cnblogs.com/gisbase/p/1660164.html