Node:Application definition file syntax, Next:Key bindings, Previous:Modes of deployment, Up:Top
This tries to describe the syntax that must be used to write the
application definition file. Parser for the file is done in yacc
and greedy souls1 willing
to know everything might want to have a look at file kortparser.y
and kortelements.lex to find out what really happens.
The file is line-oriented e.g. one thingie is one line in the file,
line ends when \n is found. Reason for this is TCL as TCL really
seems to be a line-oriented programming language where one line of
code is one statement or something alike and as TCL may be included
in the same file, we must be able to pass the endlines
In file, rows beginning with # are comments and silently ignored.
Beginning from kort version 0.0.3 the application definition file needs to
be in UTF-8 encoding. If you're using english language only and expressing
your things in US7ASCII only then you don't need to care about this
but for the rest of us this is important: trying to use ISO8859-1 or
any other "codepage" won't do any more and if you have had an application
written for kort that has international characters in it then you need
to convert the file to UTF-8 unicode before you can use it. I have not
tried using UTF-8 in table or column or field names and I'm almost sure
that it will not work so please keep them in US7ASCII. For label contents
and TCL scripts UTF-8 is very ok and should work. And remember to set
UTF-8 locale before using kort :)
The file always begins with record definition (or comment). More record
definitions (or comments) may follow but at least one is required
(not a comment). Record definition begins with word RECORD
that must be typed in UPPER CASE, followed by record name, that is
Case SeNsitive when referenced. Record name is followed be word
DBTABLE or word NOTSAVED. Word DBTABLE must be
followed by database table name where this record will be saved. Database
table name may be followed by word JOINS meaning that this
record is a subrecord of some other record. Name of the master record
must follow. Examples might be like these:
RECORD not_a_saved_record NOTSAVED RECORD kew1_stuff DBTABLE kew1_table RECORD subkew1_stuff DBTABLE subkewl_table JOINS kew1_stuffRecord definition continues with function key command definitions for the defined record. List is newline separated. Entries in the list are generally of form
FUNCTION_KEY x command labelwhere x is number of function key, command is the thing to do and label is a "quoted" string to display in bottom line of the terminal for guidance to user. Possible commands are the following:
FUNCTION_KEY 5 MOVETE RECORD FooRecord "FooData"that causes F5 to be given label "FooData" and when hit, transfers focus to record FooRecord that must be defined in the same application definition file.
SCRIPT_BEGIN FUNCTION_KEY 6 "Calc" set answer [ expr $a_number + $another_number ] SCRIPT_ENDWhere between lines SCRIPT_BEGIN and SCRIPT_END is the code. SCRIPT_BEGIN is always followed by event when the code is run. In this example the event is user hitting F6. F6 is here given label "Calc". The actual code given to TCL interpreter is one line
set answer [ expr $a_number + $another_number ]that makes sense if there are fields in the current record with names answer, a_number and another_number as before program is given to interpreter, each field in the current record is defined as a variable in TCL interpreter with value being the current value from the field. After TCL commands are done the same variable names are searched from the interpreter and if found, values assigned back to current record. Possible events for TCL code to get executed when code relates to a record are the following:
RECFIELD 5 2 20 just_a_field STRING "Yes, sir: " SCRIPT_BEGIN ONENTER set a_counter [ expr $counter + 1 ] set COUNTER_DISPLAYED $a_counter SCRIPT_ENDPrevious example shows TCL code that is done before user navigates to a field named "just_a_field". Code is done after user has issued a command that changes input focus to another field and that another field happens to be "just_a_field" and before control is returned to user. Is the previous field happened to have ONLEAVE code, this ONLEAVE -code is interpreted before next fields ONENTER -code.
LABEL row column "some text here"that place some text here so that letter s is located at row row and at column column. Using labels is not necessary from syntaxes point of view. Syntax demands that at least one record field is defined for each record. A record field definition has several forms, the most basic being
RECFIELD row column length name type "label"where row and column and length are integer numbers. Name is an un-quoted string, type is one of STRING, DECIMAL, INTEGER, DATETIME. When type DATETIME is used, length must be omitted as dates have a format that dictates the length. Entities row and column dictate the place of first letter l of "label", in the screen. Field content is expected to be typed immediately after "label", e.g. right of "label". Length tells the maximum length the content may have. Field with STRING type may contain anything. Field with INTEGER type may contain a plus or minus sign and 1-n numbers. Field with DECIMAL type is like INTEGER except that it may have a decimal point between the numbers. DATETIME type always has format, default format is dd.mm.yyyy hh:mi:ss where each dmyhmis must be a number. A different format may be specified, like in this example:
RECFIELD 10 2 today DATETIME "To-Day is: " "dd.mm.yyyy"The date format is interpreted as follows:
RECFIELD 5 2 20 zuib STRING "Zuib: " REGEXP "foo|foo18"where values of zuib may be either "foo" or "foo18" and nothing else. See man regexec for regular expressions. Also note that usage of UTF-8 sequnces in regular expressions is ok with kort ; those sequences are turned into strings of wchar_t and the tre regexp mathcing library is used to match those and it seems to work ok at least with scandinavian letter that I've tried it.
RECFIELD 6 2 20 z STRING "Z: " ALLOWED_VALUES DBTABLE t TABLEFIELD cthat causes field z to need to have values from table/column t.c. This affects only new values e.g. if user inputs one day a value that is on that day found from t.c and then t.c changes and another day user comes back it does not affect z but only if user does not try to modify z. If user types to z something not found from t.c then a list of values from t.c is presented and user is forced to select one. Empty value is always allowed regardless precence of null valus in t.c.