IQ Command Examples
|Wiki Pages (this site)|
- IQCommandExamples <-- You Are Here!
Be sure to read section 5 on "DOCUMENT Mark Ups" on the Home page.
As the first User Interface is the Command Line, we are going to use it, in Windows its called "Command Prompt"
Download the IQ.zip file and Unpack the file with an archive program (i.e.7-zip)
Copy the "IQ" directory this creates and paste to the base directory of C: drive (i.e. C:\IQ )
In Windows "Start Menu" enter into the search box "command" (without hitting return)
Right Click on "Command Prompt" and select: Send to > Desktop (create shortcut)
This will put a shortcut on your desktop (to make this easier)
Double left click on the shortcut to start up a Command Prompt
Type in (or copy/paste) the following at the Command Prompt and hit return
The Command Prompt should be this:
Entering "bin\iq" will run IQ and output some help.
Now enter the following (or copy/paste.)
This will list the keys in the knmvic.iq file (the Example document.)
It may look like a "table of content," but shows "unique keys" only. Keys may be being used elsewhere as well.
In the following command line the two "." are space separated. The "." is a pattern matching wildcards and matches everything. So one in the "word" and one in "sub" positions.
C:\IQ> bin\iq -k knmvic.iq . .
From the above we can see what is marked up as a "word indicator or key" and "sub indicator or key" and with this enter the word "The" and sub "7" (Note Case Sensitivity.)
C:\IQ> bin\iq knmvic.iq The 7
In the above we see the contents of the matching "word key" and "sub key" were output but we also see the content of the empty "sub indicator" was also output.
As mentioned, there are some rules making the "mark ups", the "indicators" versatile.
When IQ processes a file it reads the file one line at a time, top to bottom, and if it finds a "word key" it checks to see if it matches the word given on the command line, and if it matches then its content is output but only as far as the "sub key(s)" match that the sub keys content is also output.
- An empty "word indicator" or "sub indicator" mark up will pass its content if the markup is reached.
- When a "word indicator or key" or "sub indicator or key" markup is reached. the previous indicator or key markup content ends.
- Typically "subs" are within the content of a "word", but they do not have to be.
- "sub" cannot be within a "sub" as "subs" are equal, nor are "words" within "words" as they are equal.
- "words are never within "subs" as "words" are first level, "subs" are second level inward.
- For "subs" within a "word" to be reached, the "word" has to match its command line value.
- For "subs" to output, they must match their command line values
- The third mark up "filename indicator or key" can be placed anywhere, and if reached then the processing continues into that file.
- Reaching a "filename indicator or key" markup does NOT end the contents of the previous markup reached.
So what all do we Know now?
C:\IQ> bin\iq knmvic.iq Know .
And what Knowledge and Mapping do we Know now? Applying constraints!
C:\IQ> bin\iq knmvic.iq Know Kno Map
Let's take a look at what keys are in another file that is a dictionary of user accessible functionality for an application.
Note: this document file is for an application on the Amiga Computer platform. A platform which has a standard side door port for applications and other functionality. The Amiga platform has all three Primary User Interfaces. Unfortunately, that platform was suppressed from the mass market. However, the Amiga platform proves all three Interfaces are possible in a user friendly manner. Fortunately there is the AROS Open Source Software project.
C:\IQ> bin\iq -k thor-arexx.iq . .
In the above we can see there are "sub keys" but we don't see which "word keys" have these. We can check.
C:\IQ> bin\iq -k thor-arexx.iq STARTEDITOR .
Assuming all you want of this definition is the "Example sub key" content.
C:\IQ> bin\iq thor-arexx.iq STARTEDITOR EXAMPLE
But as you see we get more than just the content we want, so we apply the "-s" command line option (see: help output above.)
C:\IQ> bin\iq -s thor-arexx.iq STARTEDITOR EXAMPLE
And there it is, just the content of what is found in this application dictionary at the "word key" STARTEDITOR and "sub key" of EXAMPLE.
Now this seems like a lot of work just to get a piece of "code" and many will argue there are other tools much easier to do the same thing, and there are. However, there is another command line option "-e" making it possible to run the example (if the example is compatible on your computer setup. i.e. application(s) needed for the example to run and available.) More important, this is only just one of the Action Constants. Worth noting is the IQ command does contain the "essence" of the others and as such, its useful for developing an initial understanding of the Action Constants. And together, there is a lot the Action Constants can do to allow the user to create their own automatons that can be simple or quite complex.
Imagine if executing the contents of a definition it ran the same command line that got to it. You'd have a loop running.
In the IQ directory there is a file with the name "lnswitch.off" but if you rename it to "lnswitch.on" and run any of the examples it will output its processing too, that you can see how it works.
To turn lnswitch on:
C:\IQ> rename lnswitch.off lnswitch.on
To turn lnswitch off:
C:\IQ> rename lnswitch.on lnswitch.off
Try the following with the lnswitch.off and lnswitch.on (don't forget the two wildcards "."):
C:\IQ> bin\iq test.iq . .