home *** CD-ROM | disk | FTP | other *** search
- REM ************************************************************************
- REM Text template maker --- subroutine (tbdisp2.cdl)
-
- REM Purpose: Draws a selection box on the screen to allow the user
- REM to indicate field to write onto the part
- REM ************************************************************************
-
-
- IF (tbdisp_ent == 1)
- GOTO get_fld
- retrn = 1
- SET devin, $tplname
-
- count = 0
- :read_fld
- count = count + 1
- INPUT "%d %s %d",sqnum,$tmp,nchar
- CLEAR $fldtxt
- ARRAY $fldtxt[nchar+1]
-
- REM *** dummy read two characters
- INPUT "%c %c",$fldtxt[0],$fldtxt[1]
-
- i = 0
- :txtloop
- INPUT "%c",$fldtxt[i]
- IF ($fldtxt[i] == 34)
- GOTO read_more
- i = i + 1
- goto txtloop
-
- :read_more
- $fldtxt[i] = 0
- INPUT "%f %f %f %f %f %d %d\n",dx,dy,fldlngth,txtht,asprat,font,pen
-
- IF (sqnum != 10000)
- GOTO read_fld
- GOTO close_fl
-
- :close_fl
- CLOSE devin
- nlines = count - 1
-
- :create_boxes
- sdx = (@xmax - @xmin)/40
- sdy = (@ymax - @ymin)/30
- minx = @xmin + sdx
- maxx = @xmax - sdx
- miny = @ymin + sdy
- maxy = @ymax - sdy
- tcols = 7
- trows = 13
- xinc = (maxx - minx) / tcols
- yinc = (maxy - miny) / trows
- nrows = ceil(nlines / tcols)
-
- MODE draw
- i = 0
- :hlines
- VLINE minx, maxy - i*yinc, 0, maxx, maxy - i*yinc, 0, 0, 3
- i = i + 1
- IF (i == nrows + 1)
- GOTO st_vlines
- GOTO hlines
-
- :st_vlines
- i = 0
- :vlines
- VLINE minx + i*xinc, maxy, 0, minx + i*xinc, maxy - nrows*yinc, 0, 0, 3
- i = i + 1
- IF (i == tcols + 1)
- GOTO read_names
- GOTO vlines
-
- :read_names
- SET devin, $tplname
-
- k = 0
- :read_loop1
- j = 0
- k = k + 1
- :read_loop2
- INPUT "%d %s %d",sqnum,$tmp,nchar
- CLEAR $fldtxt
- ARRAY $fldtxt[nchar+1]
-
- REM *** dummy read two characters
- INPUT "%c %c",$fldtxt[0],$fldtxt[1]
-
- i = 0
- :txtloop1
- INPUT "%c",$fldtxt[i]
- IF ($fldtxt[i] == 34)
- GOTO read1_more
- i = i + 1
- goto txtloop1
-
- :read1_more
- $fldtxt[i] = 0
- INPUT "%f %f %f %f %f %d %d\n",dx,dy,fldlngth,txtht,asprat,font,pen
-
- IF (sqnum != 10000)
- GOTO st_write
- GOTO close1_fl
-
- :st_write
- sdx = yinc/3
- sdy = yinc/4
- stx = minx + j*xinc + sdx
- sty = maxy - k*yinc + sdy
- TEXT stx, sty, $tmp, 0, yinc/2, 0.5, 0, 3
- j = j + 1
- IF (j == tcols)
- GOTO read_loop1
- GOTO read_loop2
-
- :close1_fl
- CLOSE devin
-
- :get_fld
- opt = 1
- GETPOS "Cursor-indicate field", opt
- IF (@KEY <= -2)
- GOTO return
- IF (@KEY != 1)
- GOTO get_fld
- pdx = @xview - minx
- pdy = maxy - @yview
- col = floor (pdx / xinc) + 1
- row = floor (pdy / yinc) + 1
- pnum = tcols*(row - 1) + col
- IF (pnum > nlines)
- GOTO message1
- GOTO exit
-
- :message1
- PROMPT "Field selection error... try again"
- WAIT 2
- GOTO get_fld
-
- :return
- retrn = 0
-
- :exit
- MODE normal
- EXIT
-