Scanning Property Directories

  1.   prog "@propdir/" nextprop ( Start the nextprop cycle. Note that to start it, the string must end in a "/" )
  2.   BEGIN ( Tells the compiler the start of the loop )
  3.     dup "" strcmp WHILE ( we use while so that if the property directory is empty or doesn't exist, the loop will stop immediately and jump to the pop after the REPEAT )
  4.     ( Here we'd put the code that would do whatever we want to do with each property. I recommend it be a separate word for testing )
  5.     prog swap nextprop ( Fetch the next property )
  6.   REPEAT ( Forces program back to the first instruction after the BEGIN )
  7.   pop ( Pop off empty property name that will be left over after coming out of the loop )

muf primitives are case-insensitive. This means I can get away with putting BEGIN, UNTIL, REPEAT, WHILE in all caps. I've found that this makes it much easier to "see" the loop.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6> <blockquote> <iframe>
  • Lines and paragraphs break automatically.
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • Use [# ...] to insert automatically numbered footnotes. Textile variant.
  • Web page addresses and e-mail addresses turn into links automatically. (Better URL filter.)
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <glow>, <muf>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Images can be added to this post.

More information about formatting options