#indent-#unindent

One perhaps troublesome requirement for #include'ing program and other files is that you must indent them.  You may use the #indent ... #unindent preprocessor directives to fake indentation.  More precisely, enclosing entire files, or portions of files, with #indent-#unindent inserts an automatic single-tab indent at the beginning of every enclosed line.

For example, piktc interprets this

#indent
#!/usr/local/bin/expect

set timeout [lindex $argv 0]
eval spawn -noecho [lrange $argv 1 end]
expect
#unindent
in the same way that it sees this
        #!/usr/local/bin/expect

        set timeout [lindex $argv 0]
        eval spawn -noecho [lrange $argv 1 end]
        expect
You can do this
maxtime.exp
#indent
#include <maxtime.exp_programs.cfg>
#unindent
to achieve indentation without actually having to indent the maxtime.exp program file.

#indent-#unindent is also very useful when applied to any of the .obj files.  For example

passwd
#indent
#include "/etc/passwd"
#unindent
would allow you to use the system passwd file as a PIKT object set without your having to worry about actual indentation.

For greater clarity, you may indent your preprocessor lines--that is, put spaces (or tabs) between the '#' and the preprocessor keyword.  Note that this has nothing to do with the indenting just discussed.

For example, you could render complex preprocessor code like

#ifdef paranoid
#if solaris
#ifdef doexec
        [code...]
#elsedef
        [code...]
#endifdef
#else
        [code...]
#endif
#elsedef
        [code...]
#endifdef
instead as
#ifdef paranoid
#  if solaris
#    ifdef doexec
        [code...]
#    elsedef
        [code...]
#    endifdef
#  else
        [code...]
#  endif
#elsedef
        [code...]
#endifdef

Refer to the Samples section for many more examples.

prev page 1st page next page
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
HTML head
macros