home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / irclient / !IRClient / Scripts / Docs / Prog / Config next >
Encoding:
Text File  |  1996-08-10  |  3.6 KB  |  104 lines

  1. Programing configuration routines
  2. =================================
  3. Because the configuration of modules is handled by a single module you should
  4. provide an interface to that module similar to the way in which other
  5. extensions are added. Basically there are three things you need to do :
  6.  
  7.   1. Make the configure module aware that you provide commands
  8.   2. Provide a standard help message when the configuration mode is entered.
  9.   3. Process the users configuration request
  10.  
  11. These are increasingly awkward as you might expect.
  12.  
  13. Making module aware that you accept configuration options is relatively easy.
  14. You simply provide a function to return the name like so :
  15.  
  16.   DEFFNOverload_ConfigModName(count)
  17.   LOCAL ret$
  18.   IF count=0 THEN
  19.    ret$="<modname>"
  20.   ELSE
  21.    ret$=FN@(count-1)
  22.   ENDIF
  23.   =ret$
  24.  
  25. The name given will be the name passed to you on subsequent calls and which
  26. you MUST recognise.
  27.  
  28. The second thing - displaying a help message - is also relatively simple.
  29. Basically you provide a function called PROCOverload_ConfigOptions which is
  30. supplied with the module name. If this is your module then you should respond
  31. by displaying a message similar to the following :
  32.  
  33.   -- <mod name> configuration --
  34.   You can configure :
  35.     <opt1>     : <what it means>
  36.     <opt2>     : <what it means>
  37.  
  38. You should leave a blank line before displaying this message. Otherwise, you
  39. should pass the call on to another module. The code will be something like :
  40.  
  41.   DEFPROCOverload_ConfigOptions(module$)
  42.   IF module$="<modname>" THEN
  43.    PROCDisplayConfig("")
  44.    PROCDisplayConfig("-- <modname> configuration --")
  45.    PROCDisplayConfig("You can configure :")
  46.    PROCDisplayConfig("  <opt1>     : <what it does>")
  47.    ... etc ...
  48.   ELSE
  49.    PROC@(module$)
  50.   ENDIF
  51.   ENDPROC
  52.  
  53. Finally, to accept the users input you should again recognise your module
  54. name. The commands passed will always be capitalised and will contain the
  55. first word entered on the line. You should recognise null variables and
  56. return a syntax string in the form 'Syntax: <command> <params>'. After
  57. setting a variable you should confirm the configuration with a message in the
  58. form 'Set <var> to <value>' or similar depending on how you parse commands.
  59.  
  60. You should ALWAYS recognise LIST to provide a list of the current
  61. configuration options and HELP to provide help on either commands or the
  62. general module. Help may simply be in the form of a call to
  63. PROCOverload_ConfigOptions, but must do something. All unrecognised commands
  64. must give a message similar to 'Command not recognised'.
  65.  
  66. The code should be something like :
  67.  
  68.   DEFPROCOverload_ConfigCommand(module$,com$,str$)
  69.   IF module$="<modname>" THEN
  70.    CASE com$ OF
  71.     WHEN "<opt1>"
  72.      ... whatever ...
  73.      PROCDisplayConfig("Set <opt1> to <value>")
  74.     WHEN "LIST"
  75.      ... list the current status, preceeded by blank line ...
  76.     WHEN "HELP"
  77.      PROCOverload_ConfigOptions(module$)
  78.      
  79.     OTHERWISE
  80.      PROCDisplayConfig("Command not recognised")
  81.    ENDCASE
  82.   ELSE
  83.    PROC@(module$,com$,str$)
  84.   ENDIF
  85.   ENDPROC
  86.  
  87. Additional notes
  88. ----------------
  89. You will never receive the command QUIT as this is dealt with externally for
  90. speed.
  91.  
  92. To display messages in the configuration window, use :
  93.   PROCDisplayConfig(message$)
  94.  
  95. To store a configuration option in the configuration file you should use :
  96.   PROCDB_WriteConfig(var$,value$)
  97. var$ should usually be the modules name followed by an underscore and the
  98. variable name, eg Web_Homepage.
  99.  
  100. When you initialise your module you should read in any configuration options
  101. you have placed in the file, unless you wish to access them directly at
  102. runtime (not recommended). You should use :
  103.   value$=FNDB_ReadConfig(var$)
  104.