home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / sprint / indepen.zip / INDEPEN.SPM
Text File  |  1993-08-31  |  5KB  |  134 lines

  1.                Make Your .spms be Machine Independent
  2.  
  3. Problem: 
  4.  
  5. Do you run Sprint on more than one machine, or get a new machine
  6. and want to move Sprint over?  Meanwhile, you are going crazy
  7. getting the hardcoded directories lined up properly.  Or you are
  8. forever going crazy trying to keep the PC at home and the PC at
  9. work more or less talking the same interface.  Well after years
  10. of suffering, I believe I have figured out a way to make a
  11. system-independent Sprint.  
  12.  
  13. General Solution: 
  14.  
  15. Following the idea of multi-platform packages, make a
  16. "config.spm" for each machine that has all the hardcoded files
  17. and/or machine-specific macros.  Now you can move your basic
  18. package, from machine to machine without problem.  
  19.  
  20. The details goes like this:
  21.  
  22. Step #1:  In your "main" .spm file (the one that you start your interface
  23.           compile with)-- Add this line (like this):
  24.  
  25. : if (ask "Toshiba? ") home "C:\\bin\\sprint\\" else home "R:\\sprint\\"
  26.  
  27.    ;;  You can generalize to have as many tests as needed to specify the
  28.    ;;  home directory for a given machine.  You could also set
  29.    ;;  variables/flags at this point (e.g., to leave out mouse.spm).
  30.  
  31. Step #2:  For each machine you will compile Sprint on, make a file
  32.           called config.spm that has the "hardcoded" files (i.e.,
  33.           special directories, ramdisks, etc.)
  34.           [Here is part of mine, where G: is a ramdisk]
  35.  
  36.    MacroDir : ->x (set qnumber x "S:\\sprint\\bas")
  37.    MacroFiles : ->x (set qnumber x "S:\\sprint\\bas\\*.spm")
  38.    RefFiles : ->x (set qnumber x "S:\\l\\*.lst")   
  39.    PipeFile : ->x (set qnumber x "G:\\xxxxzzzz.")
  40.    TempSPM : ->x (set qnumber x "G:\\123456.spm") 
  41.    ScratchFile : ->x (set qnumber x "G:\\xxxxzzzz.$$$")
  42.  
  43.  
  44. Step #3:  Put #include "config" near the beginning of your main.spm
  45.          (at least before you read in include other .spms that might need
  46.          these config files.) For example:
  47.  
  48.    #include "config"    ;; machine specific definitions - usually files/directories
  49.    #include "sethcore"  ;; basic definitions -- movement, search
  50.    #include "column"    ;; column commands --menu included.
  51.    #include "spell"     ;; 
  52.      etc.
  53.  
  54. Step #4   In those places in your macros where you have referred to
  55.           hard-coded file names, use the macros found in
  56.           config.spm  For example, instead of using 
  57.           set QD "G:\\xxxxzzzz.$$$"
  58.           you would use: 
  59.           13 ScratchFile  
  60.           (where ScratchFile is defined in config.spm).  
  61.  
  62. That's it.  It works really well for me.  I can move my entire
  63. collection of macros from machine to machine, and provided there
  64. is a config.spm defined on that machine, can recompile without
  65. problem.  And if a new machine is being set up, it is easy enough
  66. to hack an existing config.spm to taste.
  67.  
  68. -----------------------------------------------------------------------
  69.  
  70.                         Added Bonus
  71.  
  72.    Recompile your interface while remaining in your current directory.  
  73.  
  74. Normally, to recompile your interface, you have to set your
  75. directory to be where your .spms are.  Well that can be a pain in
  76. the neck if you are working in other directory, and making
  77. occasional changes to a single .spm.  So...here is a way
  78. to recompile your entire interface without having to switch
  79. directories and without having to lose your current directory.
  80.  
  81. It goes like this:
  82.  
  83. 1.  Include the following macro into your current interface
  84.     (and you probably will want to add it to your user interface menu). 
  85.     N.B.!  You must change "seth.spm" to be the name of your main .spm 
  86.     (sp.spm, fwii.spm, etc.)
  87.     (You have already learned to use MacroDir (see Step #2 above).
  88.  
  89. RecompileInterface :  
  90.             set QD cd      ; hold current directory
  91.             mark {to QD insert "■"} ; set flag for automatic macro
  92.             0 MacroDir     ; get macro directory
  93.             set cd Q0      ; change to macro directory
  94.             2 mread "seth.spm" ; compile interface
  95.  
  96. 2.  After you have recompiled the preceding macro into your
  97.     interface, then add the following automatic macro to the end
  98.     of your main .spm file (or at least after you have read in
  99.     all the "include"'ed .spm files).
  100.  
  101. ; reset current directory after a recompile--must be after all .spms
  102. ; see RecompileInterface in macro.spm
  103. : if ((0 subchar QD) = '■') { mark {to QD del } set cd QD  }
  104.  
  105.    Although all macros and variables are wiped out by the #clear,
  106.    the Q-registers remain unchanged.  So this macro
  107.    automatic macro to your main.spm.  It simply checks the QD
  108.    register to see if the first character is ASCII 254.  
  109.    If it is, then delete it, and set the directory to QD,
  110.    otherwise do nothing.
  111.  
  112. -----------------------------------------------------------------------
  113.  
  114.                      Conditions of Use
  115.  
  116. Use the code as you want, don't sell it, and give credit where
  117. due.  Let me know if you try it out, find problems, make
  118. improvements, etc.  If get some programming ideas/code
  119. from all this, then I would be grateful if you would share some
  120. of your own interesting macros or formatter hacking with me.  If
  121. you don't have any code to share, a postcard or email will be
  122. just fine.  Enjoy.
  123.  
  124. Seth Chaiklin
  125. Institute of Psychology
  126. University of Aarhus
  127. 8240 Risskov
  128. DENMARK
  129.  
  130. email:  psykseth@aau.dk
  131. fax:   +45 (86) 17 59 73
  132.  
  133. 30 August 1993
  134.