![]() |
KGrok Database |
Home Menu Card Search Pref Crypto |
In the following list, the tilde (~) stands for your home directory on the PDA, usually /home/root. The asterisk (*) stands for any application name.
Note that on your PDA, applications (*.gf) and data (*.db and *.ts) are stored in separate directories while they are stored in the same directory on memory cards.
In general, app files (*.gf) describe the type and presentation of data, along with default queries and other general GUI info. The data files (*.db) are basically comma-separated lists (any character instead of comma can be used if the app file says so; a colon is common too). Newlines separate cards. Separators, newlines, and backslashes in data strings are escaped with a backslash.
Home |
This is a quick reference only. For details, refer to the manual. n stands for numerical expressions, and s stands for string expressions. In general, numerical expressions are enclosed in (), and string expressions are enclosed in {}. Booleans use 0 or "0" for false and 1 or "1" for true. Note that short-circuiting with ?: && || does not work.
Numerical Operations: arithmetic operators use standard C precedences.
(n) number {s} in number context, convert string to a number n ? n : n select n2 if n1 is nonzero, n3 if zero n , n evaluate both numbers, return second -n sign change !n boolean NOT ~n bitwise NOT n + n add n - n subtract n * n multiply n / n divide, n/0 is 1 n % n modulus, n%0 is 1 n & n bitwise AND n && n boolean AND n | n bitwise OR n || n boolean OR n ^ n bitwise XOR n << n bitwise left shift n >> n bitwise right shift n == n equal n != n not equal n < n less than n > n greater than n <= n less than or equal n >= n greater than or equal sqrt (n) square root exp (n) exponential log (n) logarithm to base 10 ln (n) logarithm to base e pow(n, n) n1 raised to n2 sin (n) sine cos (n) cosine tan (n) tangent asin (n) arc sine acos (n) arc cosine atan (n) arctangent atan2(n,n) quadrant-aligned arctangent len (s) string length bound(n,n,n) n1 bounded by n2 and n3
String Operations: note that string comparisons return strings, and must be enclosed in braces {} if && or || or other numerical operators are used on the result. Printf arguments generally need to be parenthesized also.
"string" literal string {s} string (n) in string context, convert number to string s ; s evaluate both strings, return second s . s concatenate strings s ? s : s select s2 if s1 evaluates nz, s3 if zero s == s strings are equal s != s strings are not equal s < s lexicographically less than s > s lexicographically greater than s <= s lexicographically less than or equal s >= s lexicographically greater than or equal s in s first string is contained in second string chop(s) s without trailing newline substr(s,n,n) substring of the s1; n1 is start index and n2 is length printf (args) formatted string, args is comma-separated expr list
Variables: variables are letters a through z that can hold strings or numbers. When a variable is assigned to, the result of the assignment is returned. All variables are reset to the empty string (or 0) when a database is loaded from disk.
var value of variable var = s assign string to variable var = n assign number to variable var .= s append string to variable var += n add number to variable var -= n subtract number from variable var *= n multiply variable by number var /= n divide variable by number var %= n assign modulo with number to variable var &= n logical AND with variable var |= n logical OR with variable var++ post-increment var-- post-decrement ++var pre-increment --var pre-decrement
Database Access:
_field database field of current card, field is number or name _field [n] database field from any card this number of current card, 0 is first last number of last card avg (_field) average of field in all cards qavg (_field) average of field in current query result dev (_field) standard deviation of field in all cards qdev (_field) standard deviation of field in current query result min (_field) minimum value of field in all cards qmin (_field) minimum value of field in current query result max (_field) maximum value of field in all cards qmax (_field) maximum value of field in current query result sum (_field) sum of field in all cards qsum (_field) sum of field in current query result dbase name of current database file form name of the current file prevform name of the previous form file expand (_field) returns the mnemonic value of choice and flag fields expand (_field[n]) same for card n search("", "") do nothing search("", "*") put all cards in summary search("", "{expr}") all cards for which {expr} is not "0" or empty search("", "(expr)") all cards for which (expr) is not 0 search("", "string") all cards that contain search string search("name", "x") switch to form "name", then do query "x"
Operating System Access:
system (s) execute shell command and return stdout $envvar environment variable host local host name user user's login name uid user's numeric user ID gid user's numeric group ID access(s,n) 1 if any/r/w/x permission for file s for n=0/1/2/4 beep ring terminal bell, return "" error (args) like printf but into a window, return ""
Time Conversion: dates and times are stored as number of seconds since January 1, 1970. Durations are stored as number of seconds. Note that this means that a time is a significantly larger number than a duration, even if both have the same hh:mm string representation.
time current time as hh:mm or hh:mm[ap] time (n) number as hh:mm or hh:mm[ap] date today's date as dd.mm.yy or mm/dd/yy date (n) number as dd.mm.yy or mm/dd/yy duration(n) number of seconds as hh:mm date seconds since January 1, 1970 year (n) n as four-digit year month (n) n as month 1..12 day (n) n as day 1..31 hour (n) n as hour 0..23 minute (n) n as minute 0..59 second (n) n as second 0..59 julian (n) n as julian date 0..365 leap (n) 1 if the time n is in a leap year, 0 otherwise
Home |