[This HELP section is not complete yet: read the respective section in STARLING for DOS Help: you can use the file starhelp.dbf in Star4Win just like any other database. Note: most of StarLing functions can be used both in StarLing and Star4Win, but interface functions (involving screen output) are usually different.]
There are some new functions available in Star4Win, both compared with standard xBase and DOS StarLing.
You can use all of them in your expressions. If you make some mistake (forget about parentheses, brackets or misspell some string or variable), the system will display an error message - it is up to you to correct your expression.
All of these functions are supposed to function also within the Star4Win program interpreter.
aLike(s1, s2, [n]) --> nAt function. The
standard wildcard characters are '?' and '@', but you can change them
by calling the setLike function from
ASSIST. n is an optional parameter which on the return of the
function contains the length of the found
string.aLike("ild","wildcard") == 2
aLike("l?c","wildcard") == 3
aLike("c@d","wildcard") == 5
aLike("c@p","wildcard") == 0
atLike where
you can
explicitly set all three parameters: the wildcard characters and the
delimiter.
Moreover, if you create a numeric variable and pass it to the atLike
function by reference, on return it will contain a value corresponding
to
the last symbol position of s1 within s2 - which may be
useful.
The atLike function is, in fact, the inner mechanism of aLike
implemented in C, so it works a little faster.setLikealpha(s) --> flag.T. if s is an alphabet letter
(including cyrillic
letters and STARLING-specific letters like ‰, » etc.).appBlank(n) --> NILappFrom(filename, cond, scope)
--> NILaverage([expr1], expr2) --> naverage(, "NUMBER") or
average("", "NUMBER").countborder([expr]) --> nborder()
with some parameter (e.g., border(0.3)) changes the current border
setting.
change(s, [rulefile], [refresh])change
function with a single parameter (s). However, if you wish to
renew
the information (e.g., use a different database file containing rules),
you
must specify the refresh parameter as .T.. change(), e.g. like this: change("kєetwores","testrule"). See
what happens and inspect the structure of the testrule.dbf file!
charStart(s, n1, n2)common(s1, s2) --> s3sense(s1+s2).
sense
count(cond) --> naverage
dlgString(caption, prompt) --> sOpens a single-line input window with caption caption and prompt prompt. Returns the input as a character string.
aRequest(prompt)
--> s
ends(s, s1, [s2...sn]) -->
flag.T. if the string s ends in at
least one of the strings specified as the rest parameters.
starts
epsilon([expr]) --> nepsilon(), the distances are
averaged (i.e. the distance between A&B and C is measured as
(A&C + B&C) / 2); if the distance is < epsilon(), the
minimum distance is taken (i.e. the distance between A&B and C is
measured as min(A&C, B&C)).
exclusive(s) --> flag"AND, AVA". Returns .T. if the record represents an exclusive
isogloss between the two languages. extract(s, s1) --> s2extract(LEXEME, '*'): this will result in
arranging your file according to the alphabetic order of LEXEME, but
ignoring the sign * occurring anywhere in the field). Note that s1
may be a string of several values separated by commas (e.g.
extract("abc", "a,b,c")):
all of them will be extracted from the string s.
extract("STARLING","A,L") == "STRING"
extract("STARLING","A;L") == "STARLING"
extract("STARLING","A;L",";") == "STRING"
The delimiter may only consist of one byte. For speed's sake
extract operates now directly on the passed string value,
leaving it modified. If you wish to preserve the original value, make a copy
of it beforehand. Examples:
a := "STARLING"After these operations
b := extract(a,"A,L")
b == "STRING", but a ==
"STRINGGG" (sic!). To preserve everything intact you should rather do:
a := c:= "STARLING"
b := extract(a,"A,L")
a := c
Filled(s) --> flag.T. if all the
listed fields in the current record are not empty, otherwise it returns
.F..
The notation Filled("field1, field2")is
therefore equivalent
to the expression !Empty(field1) .AND.
!Empty(field2).
Empty, FilledFields,
FilledOnly
FilledFields(s) --> nFilledFields("field1,field2,field3")will
return the number of filled fields among the set of the three mentioned
fields. FilledFields("1-20") will return the number of
filled fields among the first twenty fields of the database.
Empty, Filled,
FilledOnly
FilledOnly(s1, [s2]) -->
flagFilledOnly("field1,field2",
"field3,field4") will return .T. only if
both FIELD1 and FIELD2 are not empty, while FIELD3
and FIELD4 are empty. FilledOnly("field1,field2",
"1-18") will return .T. only if both FIELD1 and FIELD2
are not empty, while all the fields from No. 1 up to 18 (excluding, of
course,
FIELD1 and FIELD2) are empty.
Empty, Filled,
FilledFields
grammar(s, l, s2) -->
s3howMany(s, s1) --> nhowMany("papapap", "pap") == 3
in(s, s1, [s2...sn]) -->
nin("voice", "i", "b", "d") == 3
index(ntxName, expr) --> NILmatch(fieldname1, [fieldname2])
--> valuestRecordGet,
but
works on two databases, returning the first match within the database
related
to the current one through fieldname1, either as a complete
record
with field names (if no fieldname2 parameter is passed) or as
the
content of If fieldname2 is passed, but is not a valid field
name
in the related database, the record is still returned as a whole, but
with fieldname2 serving as a delimiter.
match behaves exactly like the F7 key during
database editing. It fully supports the hierarchical structure of the
STARLING wordlist and lexicostatistical files.
For programmers: matchopens the second (related) database in
the select area 15, and keeps it there. If you use matchin
programs, do not forget to close the area after it is no longer needed
(either by means of the stUse function,
or by means of DbCloseAll function).
DbCloseAll, stRecordGet,
stUse
order(s1) --> s2order function is somewhat
slower;
however, it is often useful.
An addition since STARLING 7.00 is the possibility to include digraphs
and nested elements in the ORDER string. E.g., if you wish dh to
come after d (but before e) the respective fragment of
the ORDER string in CONFIG.STR must look like this: .....d{dh}e....
If you wish „ to be
linked together with a, the respective fragment of the ORDER
string must look
like ...a(„)b...
If you write: .....(e(Џ)).....
STARLING will sort the sequence of nebo,
nЏbo, neboskrЏbas nebo,
nЏbo, neboskrЏb(with the normal order
...eЏ.... the resulting sort
sequence would be nebo,
neboskrЏb, nЏbo).
quotient(n) --> s2quotient(0.1), it will change the rate value to
0.1.
reverse(s1) --> s2reverse can not yet be combined
with INDEXes.
rLower(s1) --> s2Lower, rUpper
rUpper(s1) --> s2Upper, rLower
sense(s1, [flag]) --> s2.T., the function
sensereturns
all the semantic constituents of all the words constituting s1(excluding
articles, prepositions and some other "empty" words).
sense("tree") == "grass;leaf;root;tree;stick;forest"
sense("bush") == "root;tree;thorn;grass;fruit"
sense("tree; bush") == "grass;root;tree"
sense("tree; bush", .T.) == "grass;leaf;root;tree;stick;forest;thorn;grass;fruit"
common, similar
setLike(s1, s2, [n]) -->
NILaLike function. It changes the default wildcard
characters from '?' to s1 and from '@' to s2. Do not
forget to specify both of the two first parameters and to make them not
longer than one symbol each: otherwise the results are unpredictable.
Parameter n is optional: it specifies the ASCII code of the
symbol used as delimiter for the atLike
search (the default delimiter is space, code 32). Thus, the default
return value for the expression: aLike("these are strings","s*s")setLike("?","*",0)-
setting the delimiter value to zero, the same expression will return 4
(identifying "s*s" with the sequence "se are s").
aLike
similar(form1, form2, mean1,
mean2)sound function, while the latter two are
compared on the basis of the sense
function. The parameter mean1 is supposed to be the meaning of form1,
and the parameter mean2 - the meaning of form2. Thus, SIMILAR("hound","Hund","hound","dog") == .T.SIMILAR("dog","Hund","dog","dog") == .F.SIMILAR("hound", "Hand") == .T.SIMILAR("hound","Hand","hound","hand") is of course
.F.).
SIMILAR("","","hound","dog") == .T.SIMILAR("","","hound","hand") is .F.).
The function SIMILAR can now be automatically summoned while editing
database files. The files are presently supposed to be standard
etymological files with the fields PROTO and MEANING. Pressing Left
Shift + F11 while editing one file will result in an automatic issuing
of the Locate procedure equivalent to LOCATE FOR SIMILAR(FILE1->PROTO,FILE2->PROTO).
Pressing Right Shift + F11 will result in issuing the Locate procedure
equivalent to LOCATE FOR SIMILAR("","",FILE1->MEANING,FILE2->MEANING).
Notethat in this case only semantic matches are searched and
the performance is generally slow.
Finally, pressing Shift + F12 will summon the Locate procedure
equivalent to LOCATE FOR SIMILAR(FILE1->PROTO, FILE2->PROTO,
FILE1->MEANING, FILE2->MEANING).
By pressing F4 you can continue search and browse through the whole
second file looking for possible similarities.
SEE ALSO
sound(s1, [flag]) -->
s2sound
in index files. If for some purpose you need trimmed values, use
Trim(sound(s1))
or trimSound(s1) (the latter function works slightly
faster than sound). soundhas now become customizable. Sound values
now can
be entered and edited in the file SOUND.DBF. Local copies of SOUND.DBF
may
be placed in different subdirectories. STARLING first searches for
SOUND.DBF in the current directory, then - in the main STARLING
directory (where STAR32.EXE is located). If SOUND.DBF is not found,
default phonetic values are used. Tt®dth dht'".
sound function can accept a flag logical
parameter. If it is specified as .T., all the letters in the
sequence are analyzed, otherwise the resulting string is truncated to a
maximum of three letters. Thus, sound("letter") ==
sound("letter",.F.) == "LTT", but sound("letter",.T.) ==
"LTTR".
vocSound
starts(s, s1, [s2...sn])
--> flag.T. if the string s starts in
any of the strings specified as the rest parameters.
ends
stDbCreate(filename, aStruct)Creates a new database file named filename using database structure in array aStruct.
stDbCreate("new", { {"field1", 'C', 15, 0},
{"field2", 'N', 3, 0},
{"field3", 'N', 5, 2},
{"field4", 'V', 6, 0} })
will create a file called NEW.DBF (with a corresponding NEW.VAR) containing four fields:
| Field name | Field type | Field length | Field decimals |
|---|---|---|---|
| FIELD1 | C | 15 | |
| FIELD2 | N | 3 | |
| FIELD3 | N | 5 | 2 |
| FIELD4 | V | 6 |
stDbfName() --> sReturns the name of the currently selected database file (without extension).
stDbfNameExt
stDbfNameExt() --> sReturns the name of the currently selected database file (with extension).
stDbfName
stFieldGet(n) --> xValueReturns the value of a field in the current record of the database file currently selected. n is a positive integer specifying the ordinal position of a field in the record. n can also be a character string specifying a field name.
FieldGet with files containing
variable fields.
FieldGet, FieldPos, stFieldPut,
stReplace
stFieldPut(n, xValue) --> NIL
Works exactly like stReplace with
some optimizations turned off. n is a positive integer
specifying the ordinal position of a field in the record.
FieldGet, FieldPos, stFieldGet,
stReplace
stMemoRead(filename) --> bufferReturns the contents of the file filename as a character string.
stReadFile
stReadFile(filename) --> aStringsstMemoRead
stRecordGet(nRecord, [cField], [cFile])
--> contwhere:
nRecord - record number to return, defaults to current RecNo(). A string value (instead of numeric) means exclude field names from output.
cField - specifies the fields to be included. Can be:
NIL - all fields delimited with a space
cFieldName - a field name
cFieldRange - a range of fields
bFieldBlock - fields for which this codeblock evaluates to .T.
cAnyOtherString - all fields delimited with this string.
cFile - DBF file name. Defaults to current area.
Examples:
RECORD() - current record without delimiters
RECORD(5) - fifth record with all field names and without delimiters
RECORD("5") - fifth record without field names and without a delimiter
RECORD(5, "#") - fifth record with all field names and "#" as delimiter
RECORD("5","#") -fifth record without field names and with "#" as a
delimiter
RECORD(5, "RUS") - field RUS (with fieldname) in record 5
RECORD("5", "RUS") - field RUS (without fieldname) in record 5
RECORD(5, "2-5") - fields from 2 to 5 in record 5 (with fieldnames)
RECORD("5", "2-5") - fields from 2 to 5 in record 5 (without
fieldnames)
RECORD(5, {|field_name, field_pos| stFieldType(field_pos) != 'N' }) -
all non-numeric fields (with fieldnames)
RECORD("5", {|field_name, field_pos| stFieldType(field_pos) != 'N' }) -
all non-numeric fields (without fieldnames)
RECORD(5, "PROTO", "ALTET") - field proto (with fieldname) from record
5 in the altet.dbf
RECORD("5", "PROTO", "ALTET") - field proto (with fieldname) from
record 5 in the altet.dbf
In case a certain field is specified as 2nd param and no fieldname is included into the return value, the field type of the requested field is preserved; otherwise all fields are translated to string values.
match, stRecordStruct
stRecordStruct([n], [block]) -->
aCont.T. will be put into array.
stRecordStruct(, {|n| n==1 .OR. n==4}) will
return a 2-element array containing the 1st and the 2nd fields.
match, stRecordGet
stReplace(n, xValue) --> NILReplaces the contents of field n by the value xValue. n is a positive integer specifying the ordinal position of a field in the record. n can also be a character string specifying a field name.
stFieldPut with files containing
variable fields.
FieldPos, FieldPut, stFieldGet,
stFieldPut
strToArr(a, s1, [s2]) -->
NILstUse(dbfName, [ntxName], [areaNo])
--> dbfHandleThis is the STARLING analog of the USE command, which should always be used for using database files with fields of variable length.
syntax(s, [n])Technical notes: the first
parameter
which must always be present should be a string containing a Russian
simple
sentence (with or without stops which are not taken into account). E.
g.,
the expression syntax("У меня болит
голова") will return the following
variants
of analysis:
[The following service is available for StarLing, but not yet functioning in Star4Win]After each of these variants is displayed, the function will pause and wait for a keypress. If you press Enter, the next variant is displayed; if you press F10, a graphic tree of the sentence will be displayed. The latter is actually done by a separate program, PHRAS.EXE, written by V. Portnov. The executable file PHRAS.EXE must be either in the current directory or accessible through the AUTOEXEC.BAT PATH settings.
syntax("У меня болит голова", 1) will
return
the string "[3.1]{adv}>у 1.1|[1.1]{prep}>меня 2.1|{PRED.} болит
3.1|[3.1]{subjS}>голова 4.1|". trueDBF(dbfName) --> flag.T. if the file exists and is a
database file, or .F. if it does not exist or is not a
database file.
File
voc(s, n) --> flag.T. if the nth character s
is a vowel, .F. - otherwise. Specifying n as a
negative number changes the direction of count (the n symbol is
taken from the right side of
the word).
vocSound(s) --> svocSound("kapi") == "AI"
sound