home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / gridset.pdrx < prev    next >
Encoding:
Text File  |  1994-09-07  |  2.4 KB  |  77 lines

  1. /*
  2. Copyright 1992 StarTeck. All rights reserved.
  3.  
  4. This Genie sets the grid SIZE !!!
  5.  
  6. *** It is up to you to turn the grid ON or OFF. ***
  7.          Key-Board Shortcut CTRL-G
  8. */
  9.  
  10. /* Trace ?results */
  11.  
  12. call pdm_AutoUpdate(0)
  13. cr = '0a'x
  14. count = 0
  15. units = pdm_getunits()
  16. datafile = 'datafile'
  17. filename = 'sys:S/GridSet.STk'
  18.  
  19. if open(datafile, filename, 'r') then do   /* open gridlist */
  20.    if datafile = '' then exit_msg(filename' is empty...')
  21.    do while ~eof(datafile)      /* do until end of file */
  22.       count = count + 1
  23.       line = readln(datafile)
  24.       numberofwords = words(line)
  25.       if numberofwords = 2 then do 
  26.          gridlistline.count.X = word(line,1)
  27.          if ~(datatype(gridlistline.count.X,n)) then exit_msg('Invalid input in 'filename' not a number.')
  28.          if ~(gridlistline.count.X > 0) then exit_msg('Invalid input in 'filename' negative number.')
  29.          gridlistline.count.Y = word(line,2)
  30.          if ~(datatype(gridlistline.count.Y,n)) then exit_msg('Invalid input in 'filename' not a number.')
  31.          if ~(gridlistline.count.Y > 0) then exit_msg('Invalid input in 'filename' negative number.')
  32.          end /* if numberofwords = 2 */
  33.          else do
  34.             if ~numberofwords = 0 then exit_msg('Invalid format in 'filename)
  35.             count = count - 1
  36.             end /* else */           
  37.       end /* do while */
  38.    end /* if then do */
  39. else exit_msg('Could not find file: 'filename)
  40.  
  41. call close(datafile)
  42.  
  43. if units > 2 then do       /* convert units if picas */
  44.    do i = 1 to count
  45.       gridlistline.i.X = pdm_ConvertUnits(1,units,gridlistline.i.X)
  46.       gridlistline.i.Y = pdm_ConvertUnits(1,units,gridlistline.i.Y)
  47.       end
  48.    end
  49.  
  50. gridlist = ''
  51.  
  52. do i = 1 to count - 1   /* build list into a varible to use in pdm_selectfromlist */
  53.    gridlist = insert(gridlist, 'X'gridlistline.i.X' ')
  54.    gridlist = insert(gridlist, 'Y'gridlistline.i.Y " "cr)
  55.    end
  56. gridlist = insert(gridlist, 'X'gridlistline.count.X' ')
  57. gridlist = insert(gridlist, 'Y'gridlistline.count.Y)
  58.  
  59.    userchoice = pdm_selectfromlist("Choose grid size...",11,count,2,gridlist)
  60.    if userchoice = '' then exit_msg()
  61.  
  62.    parse var userchoice 'X'Xsize ' Y'Ysize
  63.    Ysize = strip(Ysize)
  64.          
  65.    call pdm_setgridsize(Xsize,Ysize)
  66.  
  67.  
  68. exit_msg:
  69. do
  70.         parse arg message
  71.         if message ~= '' then
  72.             call pdm_Inform(1, message,)
  73.         call pdm_ClearStatus()
  74.         call pdm_SetUnits(units)
  75.         exit
  76. end
  77.