data2inc.exm 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Please compile this file with data2inc (e.g. data2inc data2inc.exm demo.inc)
  2. #
  3. # This demo file should show all possibilities of the data2inc program.
  4. # (comment chars are %;#, empty lines are ignored)
  5. # First, the standard purpose of data2inc.
  6. # FPC (before 0.99.12) allowed only textual constants of up to 255 bytes.
  7. # The main use of data2inc is to circumvent this by defining a constant of
  8. # type ARRAY OF BYTE in an include file.
  9. #
  10. # Some of my utils have a small screen of text to show when wrong or no
  11. # commandline parameters are passed. The below example is for ../demo/crtolf.pp
  12. # I use an extremely small procedure in EFIO (EFIO.WrArrChar) to display such
  13. # constants.
  14. #
  15. # CrToLf Usage text.
  16. #
  17. # First, a '!' to indictate a new record (constant in the include file). This
  18. # also defines the type of the constant. The record ends at the next line
  19. # starting with '!' or at the end of the file.
  20. #
  21. # !name is an array of char type constant
  22. # !$name is an array of byte type constant.
  23. # This is an array of char, named UsageCrtolf
  24. !UsageCrtolf
  25. # Now the contents of the type. Empty lines are deleted, so we have to put
  26. # some constant to indicate an empty line. To ease this, \xxx octal character
  27. # codes are allowed. (The \015's below translate to CHR(13) which is CR).
  28. # In data2inc, all characters (and I mean all, even #0 #13 etc) are allowed
  29. # as long as unprintable characters are noted as with octal code.
  30. # Beware that a single \ has to be escaped as \\ !!!!!!!!
  31. Usage: CrToLf <FileName1> [FileName2] [Switches]\015
  32. Default all separators are translated to CrLf, spaces are tabbed\015
  33. with a default tablength of 8\015
  34. Switches:\015
  35. /C : Lineseparator always Cr\015
  36. /L : Lineseparator always Lf\015
  37. /B : Lineseparator always CrLf(default)\015
  38. /T : Convert spaces to hardtabs, default the otherway around\015
  39. /S:<Nr> : Use tabsize <Nr> (default:8)\015
  40. \015
  41. /W[:size] : word wrap the file to a width of 80 (default) or <size>\015
  42. characters if /W is used, tabbing is off\015
  43. \015
  44. /P : (only together with /W) Strip multiple points too (.... becomes .)\015
  45. /R : (Ignored with /W): Never write more than one linefeed.\015
  46. /D : ROT 13 file (not together with /w)\015
  47. /M : Clean up MAN pages linux\015\015
  48. # Now we define a new constant, the same principle as above, but we let it
  49. # translate to an ARRAY OF BYTE typed constant.
  50. #
  51. # indexer usage text, translate to array of byte. (The dollarsign after the
  52. # exclamation mark).
  53. #
  54. !$usageindexer
  55. Usage: Indexer <directory>\015
  56. Creates indexes and Files.bbs from descript.ion, recursing directories.\015
  57. Usage : Indexer <Starting-Directory>\015
  58. E.g. Indexer c:..\\source\015\015
  59. #
  60. # Now we are moving up to the more advanced possibilities. Everywhere in
  61. # a record you can add data by placing keyword DATA on a new line, and
  62. # put your data after it, which works pretty much like the BASIC data command
  63. #
  64. # After the DATA keyword, you should put a space, and then several fields
  65. # with either (integer)nummerical or textual constants.
  66. #
  67. # Textual constants are similar to TP textual constants except that you can also
  68. # use double quotes instead of single, and you can use single quotes inside
  69. # double quotes. Also #xxx character codes are allowed, and '+' characters
  70. # which indicate concatenation of strings under BP.
  71. #
  72. # Nummerical integer constants come in quite much flavours.
  73. # $123 , 0x123 , 123h and 123H are equivalent to hexadecimal 123 (= 291 decimal)
  74. # \666 , 666o and 666O are equivalent to octal 666 (=438 decimal)
  75. # 123 , 123d and 123D is plain decimal 123
  76. # %010 , 010b and 010B are equivalent to binary 010 (= 4 decimal)
  77. #
  78. #
  79. # The only problem with integer constants is that 123 is NOT equal to 0123 or
  80. # 000123
  81. # 123 will occupy 1 byte
  82. # 0123 will occupy 2 bytes.
  83. # 000123 will occupy 4 bytes
  84. #
  85. # Same for hexadecimal constants (and the others)
  86. #
  87. # FFh will occupy 1 byte
  88. # 0FFh will occupy 2 bytes.
  89. # 000FFh will occupy 4 bytes
  90. #
  91. # First define a new record, ARRAY OF BYTE style
  92. # If you want to verify DATA, try removing the '$' in the line below and
  93. # view the ARRAY OF CHAR data.
  94. !$weirddata
  95. This line is just text
  96. # now a data statement
  97. # textual , rest nummerical
  98. DATA 'Hello :'#12+"another 'hello'"#39,123,$123,0x456,789d,776o
  99. Again normal text.
  100. DATA \666,12d,13h,%10101010
  101. # Be carefull with statements as below. Data2inc syntax isn't entirely basic.
  102. # If you do define lines like the one below, you can't tell one,two,three apart.
  103. DATA 'one','two','three'
  104. # A solution would be:
  105. DATA 'one'#0,'two'#0,'three'#0,0
  106. #
  107. # A demonstration line for the difference between $FF, $0FF and $000FF
  108. #
  109. DATA $FF,$00FF,$000FF
  110. #
  111. # Everything between the !$weirddata line and this line will be added to
  112. # the constant weirddata. The empty and comment lines are of course not added.