Arne Bergström
Scientor Research & Development
Essingekroken 9, S-112 65 Stockholm, Sweden
phone +46 8 695 0600 fax +46 8 695 0312
e-mail arne.bergstrom@scientor.se
Historically,
two different fields of use have converged into modern computer systems:
the typewriter and the calculator. The capability of the computer to calculate
and make logical choices are largely unexploited in today's wordprocessors.
On
the other hand Internet and web documents constitute an exciting, new development
in publishing. Now for the first time, the long-advocated "paper-free
world" seems imminent, since computer documents can indeed provide
new capabilities with which printed paper cannot compete. Computer documents
can be instantly available on Internet. Computer documents can be instantly
updated and corrected. Computer documents can contain aminations and sound
illustrations. Information on computer documents can be automatically indexed
and searched.
In
addition - and this is the subject matter of this communication - computer
documents have the potential of containing text and animations which are
the result of calculations based on data taken, e g, from external sources
and which may be used to automatically modify the text in the document
as the result of such calculations.
S_Polish
is a testbed which illustrates the advantages of permitting calculations
and logical choices hidden inside a text document, e g, to select output
depending on the outcome of such calculations.
A
typical example would be an automatic economic report prepared in a wordprocessor,
and which takes balance data from a file and chooses comments like "business
is going fine" or "unless something is done, we will go bankrupt",
depending on what is calculated from the input data.
Another
example of the use of S_Polish is the interactive mathematics programs
produced by the Swedish company SciAce AB to teach children the multiplication
tables (see poster "CAN YOUR CHILD
THE MULTIPLICATION TABLES?" to the right) or to test their
skill at elementary calculations. These programs are essentially prepared
by a teacher on an ordinary word processor, and provide a complex web of
questions, follow-up questions and pedagogical hints which depend on the
pupil's answers.
The
important feature with S_Polish compared to existing computer programming
is that the calculations are easily inserted as a kind of hypertext commands
directly in the running text when typing the text in a word processor.
As the name suggests, this is achieved by using operators in so-called
Polish notation, by which even extremely complex programming structures
can be formulated in linear form. By writing the programming commands in
straight Polish notation it is possible to obtain a structure which closely
resembles a natural language. Consider, for instance, a document in which
the following actions are to be performed:
| Choose a random number between 1 and 100. Ask the reader to guess this number and type his guess on the keyboard. If his guess is right then display a message saying: "Bingo!" |
| In S_Polish this could be performed in a running text by inserting a hypertext command as follows: ~{store_as right_guess random 1 100;write space Guess_a_number_between_1_and_100!;write Bingo! only if_equal right_guess input}. |
Most
S_Polish operators are similar to customary computer commands. There are,
however, some operators which are unique for S_Polish due to its special
linear structure. One such example is the only
command used above, by which the preceding part of a S_Polish sentence
is ignored unless the Boolean expression in the operand is true. Also the
S_Polish Boolean commands if_either
and if_both are examples of
special commands, specific to the linear structure inherent in word processing.
Summaries of the S_Polish syntax and the most common operators are listed
below.
The
present implementation of S_Polish also incorporates an intricate encryptation
of the original text from the word processor which contains the S_Polish
commands, making the text virtually impervious to pirate copying. All stored
text and data are encrypted in a form which is specific for each computer
or floppy disk with a license, and the text appears in decrypted, readable
form only when displayed. It is not possible for the reader to infer, e
g, which other alternatives are covered by the S_Polish commands besides
those particular ones which are displayed in response to the input data
in each specific case.
|
GENERAL PROPERTIES OF S_POLISH |
| S_Polish commands
can be inserted anywhere inside the running text. S_Polish commands are
hypertext commands separated from the running, visible text by being enclosed
within curly brackets and initiated by a tilde, i e like
running text ~{S_Polish command} running text ~{S_Polish command} running text |
| Straight Polish notation is used, i e commands are typed after each other with operator first and then the corresponding operands upon which the operator works. The operands may in turn consist of operators and corresponding operands. Blanks are used as separators (underline _ is used to form multi-word operators and operands; use the space command to remove the underlines at output, if desired). The expressions are evaluated from right to left. |
| Operators are
predefined and have reserved names as listed below. Operands are separated
by blanks and may be of the following types:
i) numbers like 7, 78, or 3.1416 ii) strings like elephant, or Kugeloberflächenfunktionen, of arbitrary length iii) variables with names which are strings.
Strings as names of variables |
| In order to simplify the expressions, it is permitted (and advised) to divide the S_Polish commands into sentences, separated by semicolons. With regard to the sentence structure, a S_Polish command is evaluated from left to right. |
| Type of operation | Operator &
operands
Example |
Result
Result of Example |
Comments |
| Input | input
input |
get string from keyboard
what is typed on keyboard |
|
| Output | write string
write sum 7 11 |
string
18 is displayed on screen |
|
| Addition | sum first_term
second_term
sum 7 11 |
first_term + second_term
18 |
|
| Subtraction | difference first_term
second_term
difference 11 7 |
first_term - second_term
4 |
|
| Multiplication | product first_factor
second_factor
product 9 4 |
first_factor * second_factor
36 |
|
| Division | quotient numerator
denominator
quotient 36 4 |
numerator/denominator
9 |
|
| Clear | clear variable
clear sum |
variable = 0
sum = 0 |
|
| Increment | increment variable
increment sum |
variable = variable + 1
sum = sum + 1 |
|
| Decrement | decrement variable
decrement sum |
variable = variable - 1
sum = sum - 1 |
|
| Double | double variable
double sum |
variable = variable * 2
sum = sum * 2 |
|
| Triple | triple variable
triple sum |
variable = variable * 3
sum = sum * 3 |
|
| Half | half variable
half sum |
variable = variable / 2
sum = sum / 2 |
|
| Square | square variable
square sum |
variable = variable2
sum = sum2 |
|
| Cube | cube variable
cube sum |
variable = variable3
sum = sum3 |
|
| Form floating mean | float_mean var1
var2
float_mean sum triple sum |
var1 = (var1 + var2)/2
sum = 2 * sum |
|
| Concatenation | concat first_string
second_string
concat Mr_Pre sident |
first_stringsecond_string
Mr_President |
|
| Spacing | space string_with_underlines
space Franklin_Delano_Roosevelt |
string with spaces
Franklin Delano Roosevelt |
|
| Unspacing | unspace string
unspace space F_D_R |
stringwithspacesdeleted
FDR |
|
| Upcasing | upcase string
upcase fdr |
UPCASE_STRING
FDR |
|
| Downcasing | downcase string
downcase FDR |
downcase_string
fdr |
|
| Namestyling | namestyle string
namestyle mr a von capone y d'nice |
String With Initial Capitals
Mr A von Capone y d'Nice |
von, van, d', y, af etc are displayed in downcase form |
| Timestyling | timestyle integer.decimal
timestyle 3.10 |
leading zeroes inserted
03.10 |
|
| Get time | time
time |
current time
03.06 |
|
| Add times | addclock time1
time2
addclock 19.50 05.15 |
time1 + time2
01.05 |
|
| Extract numerical part | numpart string
numpart pi=3.1416 |
numerical_substring
3.1416 |
|
| Extract textpart | textpart string
textpart pi=3.1416 |
text_substring
pi= |
|
| Extract integer part | intpart string
intpart pi=3.1416 |
integer__part_of _string
3 |
|
| Find greatest operand | greatest_of 1st_number
2nd_number
greatest_of 6 5.98 |
max(1st number,2nd number)
6 |
|
| Find smallest operand | least_of 1st_number
2nd_number
least_of 6 5.98 |
min(1st number,2nd number)
5.98 |
|
| Choose random number | random lo_limit
hi_limit
random 2.6 9 |
lo_limit<random number<hi_limit
5.3 |
rectangular distribution |
| Select random item | random_of op1
op2 ... opn end
random_of mg cg gram kg end |
one operator chosen at random
gram |
error message if end missing |
| Select item in list | select index
op1 op2 ... opn end
select 3 mg cg gram kg end |
op(index)
gram |
error message if end missing |
| Test if equal | if_equal operand1
operand2
if_equal A B |
true if operand1=operand2
true if A=B |
|
| Test if different | if_different operand1
operand2
if_different A B |
true if not operand1=operand2
true if not A=B |
|
| Test if greater | if_greater operand1
operand2
if_greater A B |
true if operand1>operand2
true if A>B |
|
| Test if less | if_less operand1
operand2
if_less A B |
true if operand1<operand2
true if A<B |
|
| Test if both true | if_both operand1
operand2
if_both if_equal A B if_less A 7 |
true if both operands are true
true if both A=B and A<7 |
|
| Test if either true | if_either operand1
operand2
if_either if_equal A B if_less A 7 |
true if either operand is true
true if either A=B or A<7 |
|
| Test for substring | if_in string
substring
if_in Napoleon leo |
true if substring in string
true |
|
| Test for previous address before jump |
if_from address
if_from #5 |
true if address before jump
true if #5 previous address |
|
| Do only if true | only Boolean
expression
write YES only if_equal 3 sum 2 1 |
continue only if true
YES is displayed on screen |
|
| Conditional jump | branch_to address
Boolean expression
branch_to adr1 if_equal A 3 |
jump to address if true
jump to adr1 if A=3 |
address may be an anchor in a HTML document |
| Unconditional jump | go_to address
go_to adr1 |
jump to address
jump to adr1 |
address may be an anchor in a HTML document |
| Store as temporary variable | store_as variable_name
value
store_as pi 3.1416 |
variable_name = value
pi=3.1416 |
|
| Save as permanent variable | save_as variable_name
value
save_as pi 3.1416 |
variable_name = value (saved)
pi=3.1416 on hard disk |
This page last updated on March 31, 1997.
Copyright © 1995-97 Scientor Innovation AB, Stockholm, Sweden. All rights reserved.