Logiweb(TM)

7.1.5.3 Includes

Prev Up Next Page 139 of 800 Search internet


The lgs language has an 'include' feature which allows to include the contents of arbitrary files in an lgs source. The include feature, however, is rather different from e.g. #include of C in that in lgs one can only include other files as strings.

The ""#, ""$, and ""S escape sequences allow to include files as strings. The first one denotes a binary include in which all bytes of the file are included as a string without any modification. As an example,

  ""#logiweb.png"

includes a file named 'logiweb.png' as a string without modification of any of the bytes in the file.

The ""$ escape sequence also includes a text file as a string. The contents of the included file undergoes the same transformations as the lgs file itself: host newline sequences and form feeds are replaced by line feeds and horizontal tabs are replaced by spaces. As an example,

  ""$man/man1/lgc.1"

includes the file named 'man/man1/lgc.1' but also translates host newlines to line feeds. The replacement of host newlines to line feeds is done during reading of the file. The file itself is unaffected.

The ""S escape sequence includes the source text itself as a string. The source text is included the same way a binary file is, i.e. without replacement of newline sequences. But it undergoes some other transformations which may seem strange at the present point. Here are the transformations: If the file starts with "";;, then all hex digits (if any) after "";; until the first non-hex-digit are deleted. If the file does not start with "";; then "";; and a host newline sequence is added. As an example,

  ""S

includes the lgs source as a string within the lgs source itself. As a combined example, the following is a syntactically valid lgs source:

   ""P my page
   ""D 6
   " ++ "
   ""B
   "abc" ++
   ""#logiweb.png" ++
   ""$man/man1/lgc.1" ++
   ""S

Prev Up Next Page 139 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05