English

How To: Convert a 1039 plot file to a coverage via SML

Summary

Instructions provided present an SML code that will convert a PC ARC/INFO 1039 plot file to a PC ARC/INFO coverage.

Procedure

The following program will convert a .PLT file into a PC ARC/INFO coverage. The color of the line and shades are used as the user ids. It should be called PLT2COV.R. It needs to be compiled and linked via the SML compiler and linker.

Code:
compsml plt2cov r plt2cov
linksml
plt2cov
plt2cov
<cr>
plt2cov
<cr>

Note:
Delete the plt2cov.lml and plt2cov.lmx files if necessary. You need both the plt2cov.cml and plt2cov.cmx files to run the routine.

Code:
======================plt2cov.r==========================================
&ROUTINE PLT2COV
&REM File PLT2COV.R
&REM This program is used to convert a .PLT file into a PC ARC/INFO coverage.
&REM The color of the lines and shades are used as the user ids
&REM for the arcs. These routines must be compiled and linked first
&REM before running.
&REM THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
&REM EXPRESS OR IMPLIED. ALL WARRANTIES OF FITNESS FOR A
&REM PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
&REM
&REM by Joseph H. Zastrow
&REM Mar 05, 1993
&REM

&define name 1 &var Name of plot file (and coverage)

&REM Ask for name and check existance
&ASK [name] "Enter PLT file:"
&IF &nf [name].plt &DO
&type "[name] not found."
&return
&end

&REM Export it with N OPTION
EXPORT PLOT [name] [name] N

&REM Convert export file to a generate file.
&TYPE "Converting [name].e00 to [name].gen..."
&RUN EXP2GEN
del [name].e00

&REM Run generate
&openw t$temp.sml
&write "input [name].gen"
&write "lines"
&write "quit"
&closew
GENERATE [name] t$temp.sml
del t$temp.sml
del [name].gen

&REM Build the coverage.
build [name] LINE
&return

&ROUTINE EXP2GEN
&REM This routine will create a generate file from an .E00 created
&REM via an EXPORT of a plot file using the N option. The line or
&REM shade color is used as the user-id.

&define name 1 &var Name of export file (passed in)
&define line 10 &var Current line from export file
&define opt 11 &var Option from current line
&define color 12 &var Current pen color
&define userid 13 &var Current user id (either pen color or shade color).
&define coord 14 &var First coordinate of ARC or "X" if previous was not
move.
&define first 15 &var T if first line, else F.

&REM Open files.

&OPEN [name].e00 DONE
&OPENW [name].GEN

&REM Initialize color and First coordinate.
&SV [color] 1
&SV [coord] "X"
&SV [first] T
&REM Loop over every line in the E00 file.
&WHILE &DO

&REM Read line and get option from position 1&2.
&READ [line] [BREAK]
&VALUE [opt] [line] 1 2

&REM Figure out what kind of drawing option
&IF &eq [opt] " 2" &OR &eq [opt] "11" &OR &eq [opt] "12" &DO

&REM Middle portion of line or polygon.
&IF ≠ [coord] "X" &DO
&REM Write end of last line, current userid and first coordinate.
&REM Note: this is done here and not in the " 1" and "10" sectons
&REM to ignore a sequence of "Moves".
&IF &eq [first] F &DO
&write "END"
&ELSE
&sv [first] F
&END
&write "[userid]"
&write "[coord]"
&END

&REM Write this segment.
&value [coord] [line] 4
&write "[coord]"
&sv [coord] "X"

&ELSEIF &eq [opt] " 1" &DO

&REM Beginning of line, set userid (from color) and first coord.
&SV [userid] [color]
&VALUE [coord] [line] 4

&ELSEIF &eq [opt] "10" &DO

&REM Beginning of polygon, set userid (from shade) and first coord.
&VALUE [userid] [line] 4 12
&IF &rn [userid] 1 999999999 &DO
&CV [userid] ( [userid] + 6 ) / 7 INT
&ELSE
&CV [userid] [userid] ABS
&read [line] [BREAK]
&END
&READ [line] [BREAK]
&VALUE [coord] [line] 4

&ELSEIF &eq [opt] " 0" &DO

&REM New line color
&VALUE [color] [line] 4 12

&END
&END
&CLOSE
&write "END"
&write "END"
&CLOSEW
&LABEL DONE
&RET