macro.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. Extended macros
  2. Extended macros allows which takes parameters over several
  3. lines in this file. Like single line macros, macro_1 through
  4. macro_5 correspond to the F6 through F10 keys, but you can
  5. name these anything, so long as you start it with macro_
  6. (for instance, macro_sprite is valid). The first line is
  7. the definition which states the macro's name and label,
  8. and all proceeding lines which are indented by a single space
  9. or tab character are part of the macro body.
  10. Lines enclosed in parentheses denote parameters. The format
  11. is as follows:
  12. (type param1, param2, param3, ...)
  13. Where type describes the kind of parameter and param1, 2, 3,
  14. etc are parameters of that type. For instance, you may type
  15. (string32 first_name, last_name, address)
  16. Where the user is expected to supply three strings of up to
  17. 32 characters. These strings are referred to as first_name,
  18. last_name, and address.
  19. The following types are valid:
  20. stringN - strings of N characters
  21. Example: string100
  22. The N is not optional.
  23. numberA-B - an integer value in the range of A to B.
  24. numberA - an integer value in the range of 0 to A.
  25. Examples:
  26. number20-30
  27. number256
  28. character - a single byte character.
  29. color - an MZX style color (includes wildcard variants)
  30. After defining all of your parameters, you can write the
  31. contents of the actual macro. To insert the value of the
  32. parameter, put inside the macro its name, enclosed in
  33. exclamation points. For instance:
  34. * "~fHello, !firstname! !lastname!."
  35. Parameters may also have default values. For instance,
  36. (string10 name=Bob, address=Nowhere)
  37. Note that whitespace may not be placed before or after
  38. the equals sign, otherwise it'd be considered part of the
  39. variable name and the default value respectively.
  40. The following are valid default values:
  41. For string: Any sequence of characters.
  42. For number: An integer number such as 1234
  43. For character: An integer value or a character inside
  44. single quotes, for instance 200 or 'x'
  45. For color: An MZX style color, such as c0F or c?3
  46. If you don't supply defaults, default defaults are used:
  47. For string: The empty string
  48. For number: The lower boundary of the type
  49. For character: 0
  50. For color: c??
  51. Once you write up an extended macro you can use it in the
  52. robot editor. F6 through F10 will execute the macros named
  53. macro_1 through macro_5 if they exist (even if single line
  54. versions are defined). This will bring up a GUI window
  55. where you can visually enter all paramter values.
  56. For other macros, you can enter them via text. All lines
  57. starting with are considered macro invocations. The
  58. format is
  59. macro_name(param1, param2, param3, ...)
  60. Note that the parameters can be supplied in one of two
  61. ways, by order or by name. Supplying by order means
  62. that the nth by order parameter you enter will
  63. correspond to the nth parameter defined in the macro.
  64. By name means that you give the name of the macro along
  65. with its value in the following way:
  66. name=value
  67. Note that values here follow the same formatting that
  68. default values do.
  69. Here's an example of writing a simple macro then calling
  70. it textually from the robot editor:
  71. macro_test = A Test
  72. (number20 a, b)
  73. (string32 c)
  74. set "!c!" "(!a! + !b!)"
  75. If the user then types..
  76. #test(1, 2, counter)
  77. The following code would be produced:
  78. set "counter" "(1 + 2)"
  79. You could also type something like:
  80. #test(c=counter)
  81. Which would output...
  82. set "counter" "(0 + 0)"
  83. Notice that you don't have to supply every paramter. If you
  84. don't supply something for a value, its default will be used.
  85. By pressing alt + m, you can bring up a text box that will
  86. let you enter the name of a macro to be edited via GUI.