home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / busi / smiiutil.zip / EDITPROJ.PF2 < prev    next >
Text File  |  1990-01-10  |  6KB  |  159 lines

  1. '*****************************************************************************
  2. '       FILENAME:   EDITPROJ.PF2
  3. '
  4. '     Programmer:   Pierce D. Nunley
  5. '        Updated:   A.M.  12/24/89
  6. '
  7. '          Notes:   Written in PDL (Informix, SmartWare II, Ver. 1.01)
  8. '
  9. '    Description:   This project will search the current DATAPATH for all
  10. '                   project files of the current module (*.pf?).  It will put
  11. '                   them in a menu from which they may be selected to edit in
  12. '                   the Text-Editor.  It will save the information of which
  13. '                   project was last chosen to edit so that it will first
  14. '                   highlight that file on reexecution of this project while
  15. '                   in the SAME module and the SAME session.
  16. '
  17. '                   If an error occurs during compilation, this project will
  18. '                   reload the file in the Text-Editor and move the cursor to
  19. '                   the line and space of the error.  [This is a very inter-
  20. '                   esting piece of code for a programmer.  This is a good
  21. '                   example of the power of SmartII PDL]
  22. '
  23. '                   I have set ^E (EDIT) as a macro that will run this project.
  24. '                   It is in my default macro load.
  25. '
  26. '                   I have also put this as a menu option off of my tools
  27. '                   menu using the SMART.MNU file.
  28. '
  29. '                   REMEMBER: It will search the current datapath (set by
  30. '                   Tools Preferences (Module) and Tools Directory
  31. '                   New-directory).
  32. '
  33. '****************************************************************************
  34. ' Copyright Notice
  35. ' Copyright (c) May 12, 1989    Pierce Nunley Consulting
  36. ' 3921 Bell Ave.
  37. ' Kansas City, Missouri  64111
  38. '****************************************************************************
  39.  
  40. 'VARIABLE NAME DECLARATIONS
  41. public $modl $path $modl_name $files $fname $glob_select $select $c_select
  42. public $ln_error $ch_error $q
  43.  
  44.  
  45. '****************
  46. MAIN
  47. '****************
  48. 'lock these variable for reexecution
  49. lock module $modl $path $modl_name $files $glob_select $c_select
  50.  
  51. '******************
  52. label top
  53. '******************
  54. if $glob_select < 1  'check to see if editproj has been run this session
  55.   $glob_select = 1
  56.   $c_select = 1
  57.   smartpeek $_modl $modl  'get the current smart module number into $modl
  58.   $modl_name = case $modl (0,"Main Menu")(1,"Spreadsheet")(2,"Wordprocessor")\
  59.                           (3,"Database")(4,"Communications")
  60. end if
  61.  
  62. 'the following keeps the same order of files as long as there have been no
  63. 'additions or deletions to the list or directory changes.  It insures the
  64. 'integrity of the highlighter when the project is re-run
  65. if len(getfnames("*.pf"|str($modl),1)) <> len($files) or $path <> path(datapath)
  66.   '** add the following line if you have Norton Utilities, Disk Sort.
  67.   'tools os "ds d-t-"
  68.   $path = path(datapath)
  69.   $files = getfnames("*.pf"|str($modl) ,1)
  70. end if
  71. screen clear box 4 9 21 71 12 1  'print a blue box with red border
  72. screen print 21 11 14 1 " Path = "|$path|" "  'print the path on the box
  73.  
  74. if len($files) < 3 ' check for no project files in directory
  75.   beep
  76.   screen print 11 10 12 1 format "M60" "There are no"&$modl_name&"project files in this directory"
  77.   inchar
  78.   exit
  79. end if
  80.  
  81. screen print 4 11 14 1 " "|$modl_name&"Project Files - Choose & Press Enter "
  82. screen menu 5 10 20 70  15 1  1 15 $glob_select $files $select
  83.  
  84. if $select = 0   'checks for ESC out of menu
  85.   exit 'quit project
  86. end if
  87.  
  88.    'init $glob_select after checking for ESC maintains highlighter integrity
  89.    $glob_select=$select
  90.  
  91. $fname = group($files,$glob_select) 'convert the menu number to the file name
  92.  
  93. if not(file($fname)) 'check to see if file is in directory, if not then reread
  94.   $glob_select=0
  95.   screen clear box 9 15 15 65 9 14
  96.   screen print 11 16 12 14 format "M48" "Project File """|$fname|""" not Found"
  97.   screen print 13 16 9 14 format "M48" "Press Any Key to Re-Read the Directory"
  98.   inchar
  99.   clear $files
  100.   jump top
  101. end if
  102.  
  103. clearerror
  104. error off
  105. tools text-editor path(datapath)|$fname
  106. error on
  107. if lerror = 58 'insufficient memory error
  108.   beep
  109.   screen clear box 1 1 scrheight 80 0 0 no-border
  110.   screen clear box 5 15 11 65 14 1
  111.   screen print 7 16 12 1 format "M48" "Project File could not fit into memory!"
  112.   screen print 9 16 15 1 format "M48" "Press Any Key to Exit"
  113.   inchar
  114.   exit
  115. end if
  116.  
  117. '-----------------------
  118. label done_edit
  119. '-----------------------
  120. screen clear box 1 1 scrheight 80 0 0 no-border 'clear total screen to black
  121. screen clear box 5 25 11 55 14 1
  122. screen print 7 26 15 1 format "M28" "Compile Project? (Y/n)"
  123. $q=inchar
  124. if $q <> keyvalue("Esc") and lower(chr($q)) <> "n"
  125.   screen menu 9 32 9 48  15 1  0 15 $c_select "No-Debug Debug" $c_select
  126.  
  127.   clearerror
  128.   case $c_select
  129.   when  0   'checks for ESC out of menu
  130.      exit  'quit project
  131.   when 1
  132.      remember tools compile no-debug $fname
  133.   when 2
  134.      remember tools compile debug $fname
  135.   end case
  136.   if lerror > 1   'if there is an error during compilation, the following will:
  137.                   '  1) find out where the error occured,
  138.                   '  2) load the file into the text-editor, and
  139.                   '  3) place the cursor on the line & space of the error
  140.  
  141.      smartpeek $_pfel $ln_error  'line number of project compile error
  142.      smartpeek $_pfec $ch_error  'character offset of project compile error
  143.  
  144.      fopen "editproj.mac" as 1  'define our own macro file
  145.      fwrite 1 from "#1000 = ""tt"", """|$fname|""", Enter, Alt-G, \
  146.           """|str($ln_error)|""", Enter, repeat, #"|str($ch_error)|", Right"
  147.      fclose 1
  148.      tools macros load "editproj"  'load our macro file
  149.  
  150.      suspendone command   'suspend to run macro and text-editor
  151.      keys lookon, #1000   'run the new macro
  152.  
  153.      jump done_edit   'ask again if the project should be compiled
  154.   end if
  155.  
  156. end if
  157.  
  158. END MAIN
  159.