diff --git a/buildapp.xml b/buildapp.xml
index 3e623a92..22a941ca 100644
--- a/buildapp.xml
+++ b/buildapp.xml
@@ -15,8 +15,8 @@
name="Structorizer"
displayname="Structorizer"
identifier="lu.fisch.Structorizer"
- shortversion="3.30-02"
- version="3.30-02"
+ shortversion="3.30-03"
+ version="3.30-03"
icon="icons/Structorizer.icns"
mainclassname="Structorizer"
copyright="Bob Fisch"
diff --git a/samples/arrz/ELIZA_2.3.arrz b/samples/arrz/ELIZA_2.3.arrz
new file mode 100644
index 00000000..e7af4068
Binary files /dev/null and b/samples/arrz/ELIZA_2.3.arrz differ
diff --git a/samples/export/BASIC0/ELIZA_2.3.bas b/samples/export/BASIC0/ELIZA_2.3.bas
new file mode 100644
index 00000000..16899e1f
--- /dev/null
+++ b/samples/export/BASIC0/ELIZA_2.3.bas
@@ -0,0 +1,564 @@
+10 REM Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+20 REM "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+30 REM Computational Linguistis 1(1966)9, pp. 36-45
+40 REM Revision history:
+50 REM 2016-10-06 Initial version
+60 REM 2017-03-29 Two diagrams updated (comments translated to English)
+70 REM 2017-03-29 More keywords and replies added
+80 REM 2019-03-14 Replies and mapping reorganised for easier maintenance
+90 REM 2019-03-15 key map joined from keyword array and index map
+100 REM 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+110 REM 2019-11-28 New global type "History" (to ensure a homogenous array)
+120 REM Generated by Structorizer 3.30-03
+130 REM
+140 REM Copyright (C) 2018-05-14 Kay Gürtzig
+150 REM License: GPLv3-link
+160 REM GNU General Public License (V 3)
+170 REM https://www.gnu.org/licenses/gpl.html
+180 REM http://www.gnu.de/documents/gpl.de.html
+190 REM
+200 REM
+210 REM program ELIZA
+220 REM TODO: add the respective type suffixes to your variable names if required
+230 REM Title information
+240 PRINT "************* ELIZA **************"
+250 PRINT "* Original design by J. Weizenbaum"
+260 PRINT "**********************************"
+270 PRINT "* Adapted for Basic on IBM PC by"
+280 PRINT "* - Patricia Danielson"
+290 PRINT "* - Paul Hashfield"
+300 PRINT "**********************************"
+310 PRINT "* Adapted for Structorizer by"
+320 PRINT "* - Kay Gürtzig / FH Erfurt 2016"
+330 PRINT "* Version: 2.3 (2019-11-28)"
+340 PRINT "* (Requires at least Structorizer 3.30-03 to run)"
+350 PRINT "**********************************"
+360 REM Stores the last five inputs of the user in a ring buffer,
+370 REM the second component is the rolling (over-)write index.
+380 DIM history AS History
+390 LET history.histArray = {"", "", "", "", ""}
+400 LET history.histIndex = 0
+410 LET replies = setupReplies()
+420 LET reflexions = setupReflexions()
+430 LET byePhrases = setupGoodByePhrases()
+440 LET keyMap = setupKeywords()
+450 LET offsets(length(keyMap)-1) = 0
+460 LET isGone = false
+470 REM Starter
+480 PRINT "Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?"
+490 DO
+500 INPUT userInput
+510 REM Converts the input to lowercase, cuts out interpunctation
+520 REM and pads the string
+530 LET userInput = normalizeInput(userInput)
+540 LET isGone = checkGoodBye(userInput, byePhrases)
+550 IF NOT isGone THEN
+560 LET reply = "Please don\'t repeat yourself!"
+570 LET isRepeated = checkRepetition(history, userInput)
+580 IF NOT isRepeated THEN
+590 LET findInfo = findKeyword(keyMap, userInput)
+600 LET keyIndex = findInfo(0)
+610 IF keyIndex < 0 THEN
+620 REM Should never happen...
+630 LET keyIndex = length(keyMap)-1
+640 END IF
+650 LET var entry: KeyMapEntry = keyMap(keyIndex)
+660 REM Variable part of the reply
+670 LET varPart = ""
+680 IF length(entry.keyword) > 0 THEN
+690 LET varPart = conjugateStrings(userInput, entry.keyword, findInfo(1), reflexions)
+700 END IF
+710 LET replyRing = replies(entry.index)
+720 LET reply = replyRing(offsets(keyIndex))
+730 LET offsets(keyIndex) = (offsets(keyIndex) + 1) % length(replyRing)
+740 LET posAster = pos("*", reply)
+750 IF posAster > 0 THEN
+760 IF varPart = " " THEN
+770 LET reply = "You will have to elaborate more for me to help you."
+780 ELSE
+790 delete(reply, posAster, 1)
+800 insert(varPart, reply, posAster)
+810 END IF
+820 END IF
+830 LET reply = adjustSpelling(reply)
+840 END IF
+850 PRINT reply
+860 END IF
+870 LOOP UNTIL isGone
+880 END
+890 REM
+900 REM Cares for correct letter case among others
+910 REM TODO: Add type-specific suffixes where necessary!
+920 FUNCTION adjustSpelling(sentence AS String) AS String
+930 REM TODO: add the respective type suffixes to your variable names if required
+940 LET result = sentence
+950 LET position = 1
+960 DO WHILE (position <= length(sentence)) AND (copy(sentence, position, 1) = " ")
+970 LET position = position + 1
+980 LOOP
+990 IF position <= length(sentence) THEN
+1000 LET start = copy(sentence, 1, position)
+1010 delete(result, 1, position)
+1020 insert(uppercase(start), result, 1)
+1030 END IF
+1040 DIM array3ac43688() AS String = {" i ", " i\'"}
+1050 FOR EACH word IN array3ac43688
+1060 LET position = pos(word, result)
+1070 DO WHILE position > 0
+1080 delete(result, position+1, 1)
+1090 insert("I", result, position+1)
+1100 LET position = pos(word, result)
+1110 LOOP
+1120 NEXT word
+1130 RETURN result
+1140 END FUNCTION
+1150 REM
+1160 REM Checks whether the given text contains some kind of
+1170 REM good-bye phrase inducing the end of the conversation
+1180 REM and if so writes a correspding good-bye message and
+1190 REM returns true, otherwise false
+1200 REM TODO: Add type-specific suffixes where necessary!
+1210 FUNCTION checkGoodBye(text AS String, phrases AS array of array[0..1] of string) AS boolean
+1220 REM TODO: add the respective type suffixes to your variable names if required
+1230 FOR EACH pair IN phrases
+1240 IF pos(pair(0), text) > 0 THEN
+1250 LET saidBye = true
+1260 PRINT pair(1)
+1270 RETURN true
+1280 END IF
+1290 NEXT pair
+1300 return false
+1310 END FUNCTION
+1320 REM
+1330 REM Checks whether newInput has occurred among the recently cached
+1340 REM input strings in the histArray component of history and updates the history.
+1350 REM TODO: Add type-specific suffixes where necessary!
+1360 FUNCTION checkRepetition(history AS History, newInput AS String) AS boolean
+1370 REM TODO: add the respective type suffixes to your variable names if required
+1380 LET hasOccurred = false
+1390 IF length(newInput) > 4 THEN
+1400 LET histDepth = length(history.histArray)
+1410 FOR i = 0 TO histDepth-1
+1420 IF newInput = history.histArray(i) THEN
+1430 LET hasOccurred = true
+1440 END IF
+1450 NEXT i
+1460 LET history.histArray(history.histIndex) = newInput
+1470 LET history.histIndex = (history.histIndex + 1) % (histDepth)
+1480 END IF
+1490 return hasOccurred
+1500 END FUNCTION
+1510 REM
+1520 REM TODO: Add type-specific suffixes where necessary!
+1530 FUNCTION conjugateStrings(sentence AS String, key AS String, keyPos AS integer, flexions AS array of array[0..1] of string) AS String
+1540 REM TODO: add the respective type suffixes to your variable names if required
+1550 LET result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " "
+1560 FOR EACH pair IN flexions
+1570 LET left = ""
+1580 LET right = result
+1590 LET position = pos(pair(0), right)
+1600 DO WHILE position > 0
+1610 LET left = left + copy(right, 1, position-1) + pair(1)
+1620 LET right = copy(right, position + length(pair(0)), length(right))
+1630 LET position = pos(pair(0), right)
+1640 LOOP
+1650 LET result = left + right
+1660 NEXT pair
+1670 REM Eliminate multiple spaces
+1680 LET position = pos(" ", result)
+1690 DO WHILE position > 0
+1700 LET result = copy(result, 1, position-1) + copy(result, position+1, length(result))
+1710 LET position = pos(" ", result)
+1720 LOOP
+1730 RETURN result
+1740 END FUNCTION
+1750 REM
+1760 REM Looks for the occurrence of the first of the strings
+1770 REM contained in keywords within the given sentence (in
+1780 REM array order).
+1790 REM Returns an array of
+1800 REM 0: the index of the first identified keyword (if any, otherwise -1),
+1810 REM 1: the position inside sentence (0 if not found)
+1820 REM TODO: Add type-specific suffixes where necessary!
+1830 FUNCTION findKeyword(keyMap AS const array of KeyMapEntry, sentence AS String) AS array[0..1] of integer
+1840 REM TODO: add the respective type suffixes to your variable names if required
+1850 REM Contains the index of the keyword and its position in sentence
+1860 REM TODO: Check indexBase value (automatically generated)
+1870 LET indexBase = 0
+1880 LET result(indexBase + 0) = -1
+1890 LET result(indexBase + 1) = 0
+1900 LET i = 0
+1910 DO WHILE (result(0) < 0) AND (i < length(keyMap))
+1920 LET var entry: KeyMapEntry = keyMap(i)
+1930 LET position = pos(entry.keyword, sentence)
+1940 IF position > 0 THEN
+1950 LET result(0) = i
+1960 LET result(1) = position
+1970 END IF
+1980 LET i = i+1
+1990 LOOP
+2000 RETURN result
+2010 END FUNCTION
+2020 REM
+2030 REM Converts the sentence to lowercase, eliminates all
+2040 REM interpunction (i.e. ',', '.', ';'), and pads the
+2050 REM sentence among blanks
+2060 REM TODO: Add type-specific suffixes where necessary!
+2070 FUNCTION normalizeInput(sentence AS String) AS String
+2080 REM TODO: add the respective type suffixes to your variable names if required
+2090 LET sentence = lowercase(sentence)
+2100 REM TODO: Specify an appropriate element type for the array!
+2110 DIM arrayd492107() AS FIXME_d492107 = {'.', ',', ';', '!', '?'}
+2120 FOR EACH symbol IN arrayd492107
+2130 LET position = pos(symbol, sentence)
+2140 DO WHILE position > 0
+2150 LET sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence))
+2160 LET position = pos(symbol, sentence)
+2170 LOOP
+2180 NEXT symbol
+2190 LET result = " " + sentence + " "
+2200 RETURN result
+2210 END FUNCTION
+2220 REM
+2230 REM TODO: Add type-specific suffixes where necessary!
+2240 FUNCTION setupGoodByePhrases() AS array of array[0..1] of string
+2250 REM TODO: add the respective type suffixes to your variable names if required
+2260 REM TODO: Check indexBase value (automatically generated)
+2270 LET indexBase = 0
+2280 LET phrases(0)(indexBase + 0) = " shut"
+2290 LET phrases(0)(indexBase + 1) = "Okay. If you feel that way I\'ll shut up. ... Your choice."
+2300 REM TODO: Check indexBase value (automatically generated)
+2310 LET indexBase = 0
+2320 LET phrases(1)(indexBase + 0) = "bye"
+2330 LET phrases(1)(indexBase + 1) = "Well, let\'s end our talk for now. See you later. Bye."
+2340 return phrases
+2350 END FUNCTION
+2360 REM
+2370 REM The lower the index the higher the rank of the keyword (search is sequential).
+2380 REM The index of the first keyword found in a user sentence maps to a respective
+2390 REM reply ring as defined in `setupReplies()´.
+2400 REM TODO: Add type-specific suffixes where necessary!
+2410 FUNCTION setupKeywords() AS array of KeyMapEntry
+2420 REM TODO: add the respective type suffixes to your variable names if required
+2430 REM The empty key string (last entry) is the default clause - will always be found
+2440 LET keywords(39).keyword = ""
+2450 LET keywords(39).index = 29
+2460 LET keywords(0).keyword = "can you "
+2470 LET keywords(0).index = 0
+2480 LET keywords(1).keyword = "can i "
+2490 LET keywords(1).index = 1
+2500 LET keywords(2).keyword = "you are "
+2510 LET keywords(2).index = 2
+2520 LET keywords(3).keyword = "you\'re "
+2530 LET keywords(3).index = 2
+2540 LET keywords(4).keyword = "i don't "
+2550 LET keywords(4).index = 3
+2560 LET keywords(5).keyword = "i feel "
+2570 LET keywords(5).index = 4
+2580 LET keywords(6).keyword = "why don\'t you "
+2590 LET keywords(6).index = 5
+2600 LET keywords(7).keyword = "why can\'t i "
+2610 LET keywords(7).index = 6
+2620 LET keywords(8).keyword = "are you "
+2630 LET keywords(8).index = 7
+2640 LET keywords(9).keyword = "i can\'t "
+2650 LET keywords(9).index = 8
+2660 LET keywords(10).keyword = "i am "
+2670 LET keywords(10).index = 9
+2680 LET keywords(11).keyword = "i\'m "
+2690 LET keywords(11).index = 9
+2700 LET keywords(12).keyword = "you "
+2710 LET keywords(12).index = 10
+2720 LET keywords(13).keyword = "i want "
+2730 LET keywords(13).index = 11
+2740 LET keywords(14).keyword = "what "
+2750 LET keywords(14).index = 12
+2760 LET keywords(15).keyword = "how "
+2770 LET keywords(15).index = 12
+2780 LET keywords(16).keyword = "who "
+2790 LET keywords(16).index = 12
+2800 LET keywords(17).keyword = "where "
+2810 LET keywords(17).index = 12
+2820 LET keywords(18).keyword = "when "
+2830 LET keywords(18).index = 12
+2840 LET keywords(19).keyword = "why "
+2850 LET keywords(19).index = 12
+2860 LET keywords(20).keyword = "name "
+2870 LET keywords(20).index = 13
+2880 LET keywords(21).keyword = "cause "
+2890 LET keywords(21).index = 14
+2900 LET keywords(22).keyword = "sorry "
+2910 LET keywords(22).index = 15
+2920 LET keywords(23).keyword = "dream "
+2930 LET keywords(23).index = 16
+2940 LET keywords(24).keyword = "hello "
+2950 LET keywords(24).index = 17
+2960 LET keywords(25).keyword = "hi "
+2970 LET keywords(25).index = 17
+2980 LET keywords(26).keyword = "maybe "
+2990 LET keywords(26).index = 18
+3000 LET keywords(27).keyword = " no"
+3010 LET keywords(27).index = 19
+3020 LET keywords(28).keyword = "your "
+3030 LET keywords(28).index = 20
+3040 LET keywords(29).keyword = "always "
+3050 LET keywords(29).index = 21
+3060 LET keywords(30).keyword = "think "
+3070 LET keywords(30).index = 22
+3080 LET keywords(31).keyword = "alike "
+3090 LET keywords(31).index = 23
+3100 LET keywords(32).keyword = "yes "
+3110 LET keywords(32).index = 24
+3120 LET keywords(33).keyword = "friend "
+3130 LET keywords(33).index = 25
+3140 LET keywords(34).keyword = "computer"
+3150 LET keywords(34).index = 26
+3160 LET keywords(35).keyword = "bot "
+3170 LET keywords(35).index = 26
+3180 LET keywords(36).keyword = "smartphone"
+3190 LET keywords(36).index = 27
+3200 LET keywords(37).keyword = "father "
+3210 LET keywords(37).index = 28
+3220 LET keywords(38).keyword = "mother "
+3230 LET keywords(38).index = 28
+3240 return keywords
+3250 END FUNCTION
+3260 REM
+3270 REM Returns an array of pairs of mutualy substitutable
+3280 REM TODO: Add type-specific suffixes where necessary!
+3290 FUNCTION setupReflexions() AS array of array[0..1] of string
+3300 REM TODO: add the respective type suffixes to your variable names if required
+3310 REM TODO: Check indexBase value (automatically generated)
+3320 LET indexBase = 0
+3330 LET reflexions(0)(indexBase + 0) = " are "
+3340 LET reflexions(0)(indexBase + 1) = " am "
+3350 REM TODO: Check indexBase value (automatically generated)
+3360 LET indexBase = 0
+3370 LET reflexions(1)(indexBase + 0) = " were "
+3380 LET reflexions(1)(indexBase + 1) = " was "
+3390 REM TODO: Check indexBase value (automatically generated)
+3400 LET indexBase = 0
+3410 LET reflexions(2)(indexBase + 0) = " you "
+3420 LET reflexions(2)(indexBase + 1) = " I "
+3430 REM TODO: Check indexBase value (automatically generated)
+3440 LET indexBase = 0
+3450 LET reflexions(3)(indexBase + 0) = " your"
+3460 LET reflexions(3)(indexBase + 1) = " my"
+3470 REM TODO: Check indexBase value (automatically generated)
+3480 LET indexBase = 0
+3490 LET reflexions(4)(indexBase + 0) = " i\'ve "
+3500 LET reflexions(4)(indexBase + 1) = " you\'ve "
+3510 REM TODO: Check indexBase value (automatically generated)
+3520 LET indexBase = 0
+3530 LET reflexions(5)(indexBase + 0) = " i\'m "
+3540 LET reflexions(5)(indexBase + 1) = " you\'re "
+3550 REM TODO: Check indexBase value (automatically generated)
+3560 LET indexBase = 0
+3570 LET reflexions(6)(indexBase + 0) = " me "
+3580 LET reflexions(6)(indexBase + 1) = " you "
+3590 REM TODO: Check indexBase value (automatically generated)
+3600 LET indexBase = 0
+3610 LET reflexions(7)(indexBase + 0) = " my "
+3620 LET reflexions(7)(indexBase + 1) = " your "
+3630 REM TODO: Check indexBase value (automatically generated)
+3640 LET indexBase = 0
+3650 LET reflexions(8)(indexBase + 0) = " i "
+3660 LET reflexions(8)(indexBase + 1) = " you "
+3670 REM TODO: Check indexBase value (automatically generated)
+3680 LET indexBase = 0
+3690 LET reflexions(9)(indexBase + 0) = " am "
+3700 LET reflexions(9)(indexBase + 1) = " are "
+3710 return reflexions
+3720 END FUNCTION
+3730 REM
+3740 REM This routine sets up the reply rings addressed by the key words defined in
+3750 REM routine `setupKeywords()´ and mapped hitherto by the cross table defined
+3760 REM in `setupMapping()´
+3770 REM TODO: Add type-specific suffixes where necessary!
+3780 FUNCTION setupReplies() AS array of array of string
+3790 REM TODO: add the respective type suffixes to your variable names if required
+3800 var replies: array of array of String
+3810 REM We start with the highest index for performance reasons
+3820 REM (is to avoid frequent array resizing)
+3830 REM TODO: Check indexBase value (automatically generated)
+3840 LET indexBase = 0
+3850 LET replies(29)(indexBase + 0) = "Say, do you have any psychological problems?"
+3860 LET replies(29)(indexBase + 1) = "What does that suggest to you?"
+3870 LET replies(29)(indexBase + 2) = "I see."
+3880 LET replies(29)(indexBase + 3) = "I'm not sure I understand you fully."
+3890 LET replies(29)(indexBase + 4) = "Come come elucidate your thoughts."
+3900 LET replies(29)(indexBase + 5) = "Can you elaborate on that?"
+3910 LET replies(29)(indexBase + 6) = "That is quite interesting."
+3920 REM TODO: Check indexBase value (automatically generated)
+3930 LET indexBase = 0
+3940 LET replies(0)(indexBase + 0) = "Don't you believe that I can*?"
+3950 LET replies(0)(indexBase + 1) = "Perhaps you would like to be like me?"
+3960 LET replies(0)(indexBase + 2) = "You want me to be able to*?"
+3970 REM TODO: Check indexBase value (automatically generated)
+3980 LET indexBase = 0
+3990 LET replies(1)(indexBase + 0) = "Perhaps you don't want to*?"
+4000 LET replies(1)(indexBase + 1) = "Do you want to be able to*?"
+4010 REM TODO: Check indexBase value (automatically generated)
+4020 LET indexBase = 0
+4030 LET replies(2)(indexBase + 0) = "What makes you think I am*?"
+4040 LET replies(2)(indexBase + 1) = "Does it please you to believe I am*?"
+4050 LET replies(2)(indexBase + 2) = "Perhaps you would like to be*?"
+4060 LET replies(2)(indexBase + 3) = "Do you sometimes wish you were*?"
+4070 REM TODO: Check indexBase value (automatically generated)
+4080 LET indexBase = 0
+4090 LET replies(3)(indexBase + 0) = "Don't you really*?"
+4100 LET replies(3)(indexBase + 1) = "Why don't you*?"
+4110 LET replies(3)(indexBase + 2) = "Do you wish to be able to*?"
+4120 LET replies(3)(indexBase + 3) = "Does that trouble you*?"
+4130 REM TODO: Check indexBase value (automatically generated)
+4140 LET indexBase = 0
+4150 LET replies(4)(indexBase + 0) = "Do you often feel*?"
+4160 LET replies(4)(indexBase + 1) = "Are you afraid of feeling*?"
+4170 LET replies(4)(indexBase + 2) = "Do you enjoy feeling*?"
+4180 REM TODO: Check indexBase value (automatically generated)
+4190 LET indexBase = 0
+4200 LET replies(5)(indexBase + 0) = "Do you really believe I don't*?"
+4210 LET replies(5)(indexBase + 1) = "Perhaps in good time I will*."
+4220 LET replies(5)(indexBase + 2) = "Do you want me to*?"
+4230 REM TODO: Check indexBase value (automatically generated)
+4240 LET indexBase = 0
+4250 LET replies(6)(indexBase + 0) = "Do you think you should be able to*?"
+4260 LET replies(6)(indexBase + 1) = "Why can't you*?"
+4270 REM TODO: Check indexBase value (automatically generated)
+4280 LET indexBase = 0
+4290 LET replies(7)(indexBase + 0) = "Why are you interested in whether or not I am*?"
+4300 LET replies(7)(indexBase + 1) = "Would you prefer if I were not*?"
+4310 LET replies(7)(indexBase + 2) = "Perhaps in your fantasies I am*?"
+4320 REM TODO: Check indexBase value (automatically generated)
+4330 LET indexBase = 0
+4340 LET replies(8)(indexBase + 0) = "How do you know you can't*?"
+4350 LET replies(8)(indexBase + 1) = "Have you tried?"
+4360 LET replies(8)(indexBase + 2) = "Perhaps you can now*."
+4370 REM TODO: Check indexBase value (automatically generated)
+4380 LET indexBase = 0
+4390 LET replies(9)(indexBase + 0) = "Did you come to me because you are*?"
+4400 LET replies(9)(indexBase + 1) = "How long have you been*?"
+4410 LET replies(9)(indexBase + 2) = "Do you believe it is normal to be*?"
+4420 LET replies(9)(indexBase + 3) = "Do you enjoy being*?"
+4430 REM TODO: Check indexBase value (automatically generated)
+4440 LET indexBase = 0
+4450 LET replies(10)(indexBase + 0) = "We were discussing you--not me."
+4460 LET replies(10)(indexBase + 1) = "Oh, I*."
+4470 LET replies(10)(indexBase + 2) = "You're not really talking about me, are you?"
+4480 REM TODO: Check indexBase value (automatically generated)
+4490 LET indexBase = 0
+4500 LET replies(11)(indexBase + 0) = "What would it mean to you if you got*?"
+4510 LET replies(11)(indexBase + 1) = "Why do you want*?"
+4520 LET replies(11)(indexBase + 2) = "Suppose you soon got*..."
+4530 LET replies(11)(indexBase + 3) = "What if you never got*?"
+4540 LET replies(11)(indexBase + 4) = "I sometimes also want*."
+4550 REM TODO: Check indexBase value (automatically generated)
+4560 LET indexBase = 0
+4570 LET replies(12)(indexBase + 0) = "Why do you ask?"
+4580 LET replies(12)(indexBase + 1) = "Does that question interest you?"
+4590 LET replies(12)(indexBase + 2) = "What answer would please you the most?"
+4600 LET replies(12)(indexBase + 3) = "What do you think?"
+4610 LET replies(12)(indexBase + 4) = "Are such questions on your mind often?"
+4620 LET replies(12)(indexBase + 5) = "What is it that you really want to know?"
+4630 LET replies(12)(indexBase + 6) = "Have you asked anyone else?"
+4640 LET replies(12)(indexBase + 7) = "Have you asked such questions before?"
+4650 LET replies(12)(indexBase + 8) = "What else comes to mind when you ask that?"
+4660 REM TODO: Check indexBase value (automatically generated)
+4670 LET indexBase = 0
+4680 LET replies(13)(indexBase + 0) = "Names don't interest me."
+4690 LET replies(13)(indexBase + 1) = "I don't care about names -- please go on."
+4700 REM TODO: Check indexBase value (automatically generated)
+4710 LET indexBase = 0
+4720 LET replies(14)(indexBase + 0) = "Is that the real reason?"
+4730 LET replies(14)(indexBase + 1) = "Don't any other reasons come to mind?"
+4740 LET replies(14)(indexBase + 2) = "Does that reason explain anything else?"
+4750 LET replies(14)(indexBase + 3) = "What other reasons might there be?"
+4760 REM TODO: Check indexBase value (automatically generated)
+4770 LET indexBase = 0
+4780 LET replies(15)(indexBase + 0) = "Please don't apologize!"
+4790 LET replies(15)(indexBase + 1) = "Apologies are not necessary."
+4800 LET replies(15)(indexBase + 2) = "What feelings do you have when you apologize?"
+4810 LET replies(15)(indexBase + 3) = "Don't be so defensive!"
+4820 REM TODO: Check indexBase value (automatically generated)
+4830 LET indexBase = 0
+4840 LET replies(16)(indexBase + 0) = "What does that dream suggest to you?"
+4850 LET replies(16)(indexBase + 1) = "Do you dream often?"
+4860 LET replies(16)(indexBase + 2) = "What persons appear in your dreams?"
+4870 LET replies(16)(indexBase + 3) = "Are you disturbed by your dreams?"
+4880 REM TODO: Check indexBase value (automatically generated)
+4890 LET indexBase = 0
+4900 LET replies(17)(indexBase + 0) = "How do you do ...please state your problem."
+4910 REM TODO: Check indexBase value (automatically generated)
+4920 LET indexBase = 0
+4930 LET replies(18)(indexBase + 0) = "You don't seem quite certain."
+4940 LET replies(18)(indexBase + 1) = "Why the uncertain tone?"
+4950 LET replies(18)(indexBase + 2) = "Can't you be more positive?"
+4960 LET replies(18)(indexBase + 3) = "You aren't sure?"
+4970 LET replies(18)(indexBase + 4) = "Don't you know?"
+4980 REM TODO: Check indexBase value (automatically generated)
+4990 LET indexBase = 0
+5000 LET replies(19)(indexBase + 0) = "Are you saying no just to be negative?"
+5010 LET replies(19)(indexBase + 1) = "You are being a bit negative."
+5020 LET replies(19)(indexBase + 2) = "Why not?"
+5030 LET replies(19)(indexBase + 3) = "Are you sure?"
+5040 LET replies(19)(indexBase + 4) = "Why no?"
+5050 REM TODO: Check indexBase value (automatically generated)
+5060 LET indexBase = 0
+5070 LET replies(20)(indexBase + 0) = "Why are you concerned about my*?"
+5080 LET replies(20)(indexBase + 1) = "What about your own*?"
+5090 REM TODO: Check indexBase value (automatically generated)
+5100 LET indexBase = 0
+5110 LET replies(21)(indexBase + 0) = "Can you think of a specific example?"
+5120 LET replies(21)(indexBase + 1) = "When?"
+5130 LET replies(21)(indexBase + 2) = "What are you thinking of?"
+5140 LET replies(21)(indexBase + 3) = "Really, always?"
+5150 REM TODO: Check indexBase value (automatically generated)
+5160 LET indexBase = 0
+5170 LET replies(22)(indexBase + 0) = "Do you really think so?"
+5180 LET replies(22)(indexBase + 1) = "But you are not sure you*?"
+5190 LET replies(22)(indexBase + 2) = "Do you doubt you*?"
+5200 REM TODO: Check indexBase value (automatically generated)
+5210 LET indexBase = 0
+5220 LET replies(23)(indexBase + 0) = "In what way?"
+5230 LET replies(23)(indexBase + 1) = "What resemblance do you see?"
+5240 LET replies(23)(indexBase + 2) = "What does the similarity suggest to you?"
+5250 LET replies(23)(indexBase + 3) = "What other connections do you see?"
+5260 LET replies(23)(indexBase + 4) = "Could there really be some connection?"
+5270 LET replies(23)(indexBase + 5) = "How?"
+5280 LET replies(23)(indexBase + 6) = "You seem quite positive."
+5290 REM TODO: Check indexBase value (automatically generated)
+5300 LET indexBase = 0
+5310 LET replies(24)(indexBase + 0) = "Are you sure?"
+5320 LET replies(24)(indexBase + 1) = "I see."
+5330 LET replies(24)(indexBase + 2) = "I understand."
+5340 REM TODO: Check indexBase value (automatically generated)
+5350 LET indexBase = 0
+5360 LET replies(25)(indexBase + 0) = "Why do you bring up the topic of friends?"
+5370 LET replies(25)(indexBase + 1) = "Do your friends worry you?"
+5380 LET replies(25)(indexBase + 2) = "Do your friends pick on you?"
+5390 LET replies(25)(indexBase + 3) = "Are you sure you have any friends?"
+5400 LET replies(25)(indexBase + 4) = "Do you impose on your friends?"
+5410 LET replies(25)(indexBase + 5) = "Perhaps your love for friends worries you."
+5420 REM TODO: Check indexBase value (automatically generated)
+5430 LET indexBase = 0
+5440 LET replies(26)(indexBase + 0) = "Do computers worry you?"
+5450 LET replies(26)(indexBase + 1) = "Are you talking about me in particular?"
+5460 LET replies(26)(indexBase + 2) = "Are you frightened by machines?"
+5470 LET replies(26)(indexBase + 3) = "Why do you mention computers?"
+5480 LET replies(26)(indexBase + 4) = "What do you think machines have to do with your problem?"
+5490 LET replies(26)(indexBase + 5) = "Don't you think computers can help people?"
+5500 LET replies(26)(indexBase + 6) = "What is it about machines that worries you?"
+5510 REM TODO: Check indexBase value (automatically generated)
+5520 LET indexBase = 0
+5530 LET replies(27)(indexBase + 0) = "Do you sometimes feel uneasy without a smartphone?"
+5540 LET replies(27)(indexBase + 1) = "Have you had these phantasies before?"
+5550 LET replies(27)(indexBase + 2) = "Does the world seem more real for you via apps?"
+5560 REM TODO: Check indexBase value (automatically generated)
+5570 LET indexBase = 0
+5580 LET replies(28)(indexBase + 0) = "Tell me more about your family."
+5590 LET replies(28)(indexBase + 1) = "Who else in your family*?"
+5600 LET replies(28)(indexBase + 2) = "What does family relations mean for you?"
+5610 LET replies(28)(indexBase + 3) = "Come on, How old are you?"
+5620 LET setupReplies = replies
+5630 RETURN setupReplies
+5640 END FUNCTION
diff --git a/samples/export/BASIC0/SORTING_TEST_MAIN.bas b/samples/export/BASIC0/SORTING_TEST_MAIN.bas
index 21cf6415..fec0bd0d 100644
--- a/samples/export/BASIC0/SORTING_TEST_MAIN.bas
+++ b/samples/export/BASIC0/SORTING_TEST_MAIN.bas
@@ -2,7 +2,7 @@
20 REM to allow performance comparison via execution counting ("Collect Runtime Data" should
30 REM sensibly be switched on).
40 REM Requested input data are: Number of elements (size) and filing mode.
-50 REM Generated by Structorizer 3.30-02
+50 REM Generated by Structorizer 3.30-03
60 REM
70 REM Copyright (C) 2019-10-02 Kay Gürtzig
80 REM License: GPLv3-link
@@ -29,7 +29,7 @@
290 LET values1(i) = -i
300 END SELECT
310 NEXT i
-320 REM Kopiere das Array für exakte Vergleichbarkeit
+320 REM Copy the array for exact comparability
330 FOR i = 0 TO elementCount-1
340 LET values2(i) = values1(i)
350 LET values3(i) = values1(i)
@@ -58,9 +58,9 @@
580 REM ================== END PARALLEL SECTION ==================
590 REM ==========================================================
600
-610 LET CALL ok1 = testSorted(values1)
-620 LET CALL ok2 = testSorted(values2)
-630 LET CALL ok3 = testSorted(values3)
+610 LET ok1 = testSorted(values1)
+620 LET ok2 = testSorted(values2)
+630 LET ok3 = testSorted(values3)
640 IF NOT ok1 OR NOT ok2 OR NOT ok3 THEN
650 FOR i = 0 TO elementCount-1
660 IF values1(i) <> values2(i) OR values1(i) <> values3(i) THEN
@@ -212,7 +212,7 @@
2120 LET p = random(stop-start) + start
2130 REM Partition the array into smaller and greater elements
2140 REM Get the resulting (and final) position of the pivot element
-2150 LET CALL p = partition(values, start, stop, p)
+2150 LET p = partition(values, start, stop, p)
2160 REM Sort subsequances separately and independently ...
2170
2180 REM ==========================================================
diff --git a/samples/export/BASIC0/TextDemo.bas b/samples/export/BASIC0/TextDemo.bas
new file mode 100644
index 00000000..c36e6f08
--- /dev/null
+++ b/samples/export/BASIC0/TextDemo.bas
@@ -0,0 +1,1006 @@
+10 REM Demo program for routine drawText()
+20 REM Asks the user to enter a text, a wanted text height and colour,
+30 REM and then draws this string onto the turtle screen. Places every
+40 REM entered text to a new line.
+50 REM Generated by Structorizer 3.30-03
+60 REM
+70 REM Copyright (C) 2019-10-10 Kay Gürtzig
+80 REM License: GPLv3-link
+90 REM GNU General Public License (V 3)
+100 REM https://www.gnu.org/licenses/gpl.html
+110 REM http://www.gnu.de/documents/gpl.de.html
+120 REM
+130 REM
+140 REM program TextDemo
+150 REM TODO: add the respective type suffixes to your variable names if required
+160 PRINT "This is a demo program for text writing with Turleizer."
+170 showTurtle()
+180 penDown()
+190 LET y = 0
+200 DO
+210 PRINT "Enter some text (empty string to exit)"; : INPUT text
+220 REM Make sure the content is interpreted as string
+230 LET text = "" + text
+240 IF text <> "" THEN
+250 DO
+260 PRINT "Height of the text (pixels)"; : INPUT height
+270 LOOP UNTIL height >= 5
+280 DO
+290 PRINT "Colour (1=black, 2=red, 3=yellow, 4=green, 5=cyan, 6=blue, 7=pink, 8=gray, 9=orange, 10=violet)"; : INPUT colour
+300 LOOP UNTIL colour >= 1 AND colour <= 10
+310 LET y = y + height + 2
+320 gotoXY(0, y - 2)
+330 CALL drawText(text, height, colour)
+340 END IF
+350 LOOP UNTIL text = ""
+360 gotoXY(0, y + 15)
+370 CALL drawText("Thank you, bye.", 10, 4)
+380 hideTurtle()
+390 END
+400 REM
+410 REM Draws a blank for font height h, ignoring the colorNo
+420 REM TODO: Add type-specific suffixes where necessary!
+430 SUB blank(h, colorNo)
+440 REM TODO: add the respective type suffixes to your variable names if required
+450 LET width = h/2.0
+460 penUp()
+470 right(90)
+480 forward(width) : REM color = ffffff
+490 left(90)
+500 END SUB
+510 REM
+520 REM TODO: Add type-specific suffixes where necessary!
+530 SUB forward(len, color)
+540 REM TODO: add the respective type suffixes to your variable names if required
+550 SELECT CASE color
+560 CASE 1
+570 forward(len) : REM color = ffffff
+580 CASE 2
+590 forward(len) : REM color = ff8080
+600 CASE 3
+610 forward(len) : REM color = ffff80
+620 CASE 4
+630 forward(len) : REM color = 80ff80
+640 CASE 5
+650 forward(len) : REM color = 80ffff
+660 CASE 6
+670 forward(len) : REM color = 0080ff
+680 CASE 7
+690 forward(len) : REM color = ff80c0
+700 CASE 8
+710 forward(len) : REM color = c0c0c0
+720 CASE 9
+730 forward(len) : REM color = ff8000
+740 CASE 10
+750 forward(len) : REM color = 8080ff
+760 END SELECT
+770 END SUB
+780 REM
+790 REM Draws letter A in colour specified by colorNo with font height h
+800 REM from the current turtle position.
+810 REM TODO: Add type-specific suffixes where necessary!
+820 SUB letterA(h, colorNo)
+830 REM TODO: add the respective type suffixes to your variable names if required
+840 LET width = h/2.0
+850 LET hypo = sqrt(h*h + width*width/4.0)
+860 LET rotAngle = toDegrees(atan(width/2.0/h))
+870 right(rotAngle)
+880 CALL forward(hypo/2.0, colorNo)
+890 right(90 - rotAngle)
+900 CALL forward(width/2.0, colorNo)
+910 penUp()
+920 backward(width/2.0) : REM color = ffffff
+930 penDown()
+940 left(90 - rotAngle)
+950 CALL forward(hypo/2.0, colorNo)
+960 left(2*rotAngle)
+970 CALL forward(-hypo, colorNo)
+980 right(rotAngle)
+990 END SUB
+1000 REM
+1010 REM Draws letter E in colour specified by colorNo with font height h
+1020 REM from the current turtle position.
+1030 REM TODO: Add type-specific suffixes where necessary!
+1040 SUB letterE(h, colorNo)
+1050 REM TODO: add the respective type suffixes to your variable names if required
+1060 LET width = h/2.0
+1070 CALL forward(h, colorNo)
+1080 right(90)
+1090 CALL forward(width, colorNo)
+1100 right(90)
+1110 penUp()
+1120 forward(h/2.0) : REM color = ffffff
+1130 right(90)
+1140 penDown()
+1150 CALL forward(width, colorNo)
+1160 left(90)
+1170 penUp()
+1180 forward(h/2.0) : REM color = ffffff
+1190 left(90)
+1200 penDown()
+1210 CALL forward(width, colorNo)
+1220 left(90)
+1230 END SUB
+1240 REM
+1250 REM Draws letter F in colour specified by colorNo with font height h
+1260 REM from the current turtle position.
+1270 REM TODO: Add type-specific suffixes where necessary!
+1280 SUB letterF(h, colorNo)
+1290 REM TODO: add the respective type suffixes to your variable names if required
+1300 LET width = h/2.0
+1310 CALL forward(h, colorNo)
+1320 right(90)
+1330 CALL forward(width, colorNo)
+1340 right(90)
+1350 penUp()
+1360 forward(h/2.0) : REM color = ffffff
+1370 right(90)
+1380 penDown()
+1390 CALL forward(width, colorNo)
+1400 left(90)
+1410 penUp()
+1420 forward(h/2.0) : REM color = ffffff
+1430 left(90)
+1440 forward(width) : REM color = ffffff
+1450 penDown()
+1460 left(90)
+1470 END SUB
+1480 REM
+1490 REM Draws letter H in colour specified by colorNo with font height h
+1500 REM from the current turtle position.
+1510 REM TODO: Add type-specific suffixes where necessary!
+1520 SUB letterH(h, colorNo)
+1530 REM TODO: add the respective type suffixes to your variable names if required
+1540 LET width = h/2.0
+1550 CALL forward(h, colorNo)
+1560 penUp()
+1570 right(90)
+1580 forward(width) : REM color = ffffff
+1590 right(90)
+1600 penDown()
+1610 CALL forward(h/2.0, colorNo)
+1620 right(90)
+1630 CALL forward(width, colorNo)
+1640 penUp()
+1650 backward(width) : REM color = ffffff
+1660 left(90)
+1670 penDown()
+1680 CALL forward(h/2.0, colorNo)
+1690 left(180)
+1700 END SUB
+1710 REM
+1720 REM Draws letter I in colour specified by colorNo with font height h
+1730 REM from the current turtle position.
+1740 REM TODO: Add type-specific suffixes where necessary!
+1750 SUB letterI(h, colorNo)
+1760 REM TODO: add the respective type suffixes to your variable names if required
+1770 REM Octagon edge length
+1780 LET b = h * 0.5 / (sqrt(2.0) + 1)
+1790 REM Cathetus of the corner triangle outside the octagon
+1800 LET c = b / sqrt(2.0)
+1810 penUp()
+1820 right(90)
+1830 forward(c) : REM color = ffffff
+1840 penDown()
+1850 CALL forward(b, colorNo)
+1860 penUp()
+1870 backward(b/2.0) : REM color = ffffff
+1880 left(90)
+1890 penDown()
+1900 CALL forward(h, colorNo)
+1910 penUp()
+1920 right(90)
+1930 backward(b/2.0) : REM color = ffffff
+1940 penDown()
+1950 CALL forward(b, colorNo)
+1960 penUp()
+1970 forward(b/2 + c) : REM color = ffffff
+1980 left(90)
+1990 backward(h) : REM color = ffffff
+2000 penDown()
+2010 END SUB
+2020 REM
+2030 REM Draws letter K in colour specified by colorNo with font height h
+2040 REM from the current turtle position.
+2050 REM TODO: Add type-specific suffixes where necessary!
+2060 SUB letterK(h, colorNo)
+2070 REM TODO: add the respective type suffixes to your variable names if required
+2080 LET width = h/2.0
+2090 LET diag = h/sqrt(2.0)
+2100 CALL forward(h, colorNo)
+2110 penUp()
+2120 right(90)
+2130 forward(width) : REM color = ffffff
+2140 right(135)
+2150 penDown()
+2160 CALL forward(diag, colorNo)
+2170 left(90)
+2180 CALL forward(diag, colorNo)
+2190 left(135)
+2200 END SUB
+2210 REM
+2220 REM Draws letter L in colour specified by colorNo with font height h
+2230 REM from the current turtle position.
+2240 REM TODO: Add type-specific suffixes where necessary!
+2250 SUB letterL(h, colorNo)
+2260 REM TODO: add the respective type suffixes to your variable names if required
+2270 LET width = h/2.0
+2280 CALL forward(h, colorNo)
+2290 penUp()
+2300 backward(h) : REM color = ffffff
+2310 right(90)
+2320 penDown()
+2330 CALL forward(width, colorNo)
+2340 left(90)
+2350 END SUB
+2360 REM
+2370 REM Draws letter M in colour specified by colorNo with font height h
+2380 REM from the current turtle position.
+2390 REM TODO: Add type-specific suffixes where necessary!
+2400 SUB letterM(h, colorNo)
+2410 REM TODO: add the respective type suffixes to your variable names if required
+2420 LET width = h/2.0
+2430 LET hypo = sqrt(width*width + h*h)/2.0
+2440 LET rotAngle = toDegrees(atan(width/h))
+2450 CALL forward(h, colorNo)
+2460 left(rotAngle)
+2470 CALL forward(-hypo, colorNo)
+2480 right(2*rotAngle)
+2490 CALL forward(hypo, colorNo)
+2500 left(rotAngle)
+2510 CALL forward(-h, colorNo)
+2520 END SUB
+2530 REM
+2540 REM Draws letter N in colour specified by colorNo with font height h
+2550 REM from the current turtle position.
+2560 REM TODO: Add type-specific suffixes where necessary!
+2570 SUB letterN(h, colorNo)
+2580 REM TODO: add the respective type suffixes to your variable names if required
+2590 LET width = h/2.0
+2600 LET hypo = sqrt(width*width + h*h)
+2610 LET rotAngle = toDegrees(atan(width/h))
+2620 CALL forward(h, colorNo)
+2630 left(rotAngle)
+2640 CALL forward(-hypo, colorNo)
+2650 right(rotAngle)
+2660 CALL forward(h, colorNo)
+2670 penUp()
+2680 backward(h) : REM color = ffffff
+2690 penDown()
+2700 END SUB
+2710 REM
+2720 REM Draws letter T in colour specified by colorNo with font height h
+2730 REM from the current turtle position.
+2740 REM TODO: Add type-specific suffixes where necessary!
+2750 SUB letterT(h, colorNo)
+2760 REM TODO: add the respective type suffixes to your variable names if required
+2770 LET width = h/2.0
+2780 penUp()
+2790 forward(h) : REM color = ffffff
+2800 penDown()
+2810 right(90)
+2820 CALL forward(width, colorNo)
+2830 penUp()
+2840 backward(width/2.0) : REM color = ffffff
+2850 penDown()
+2860 right(90)
+2870 CALL forward(h, colorNo)
+2880 left(90)
+2890 penUp()
+2900 forward(width/2.0) : REM color = ffffff
+2910 penDown()
+2920 left(90)
+2930 END SUB
+2940 REM
+2950 REM Draws letter V in colour specified by colorNo with font height h
+2960 REM from the current turtle position.
+2970 REM TODO: Add type-specific suffixes where necessary!
+2980 SUB letterV(h, colorNo)
+2990 REM TODO: add the respective type suffixes to your variable names if required
+3000 LET width = h/2.0
+3010 LET hypo = sqrt(h*h + width*width/4.0)
+3020 LET rotAngle = toDegrees(atan(width/2.0/h))
+3030 penUp()
+3040 forward(h) : REM color = ffffff
+3050 left(rotAngle)
+3060 penDown()
+3070 CALL forward(-hypo, colorNo)
+3080 right(2*rotAngle)
+3090 CALL forward(hypo, colorNo)
+3100 penUp()
+3110 left(rotAngle)
+3120 backward(h) : REM color = ffffff
+3130 penDown()
+3140 END SUB
+3150 REM
+3160 REM Draws letter W in colour specified by colorNo with font height h
+3170 REM from the current turtle position.
+3180 REM TODO: Add type-specific suffixes where necessary!
+3190 SUB letterW(h, colorNo)
+3200 REM TODO: add the respective type suffixes to your variable names if required
+3210 LET width = h/2.0
+3220 LET width_3 = width/3.0
+3230 LET hypo = sqrt(width_3*width_3 + h*h)
+3240 LET rotAngle = toDegrees(atan(width_3/h))
+3250 penUp()
+3260 forward(h) : REM color = ffffff
+3270 left(rotAngle)
+3280 penDown()
+3290 CALL forward(-hypo, colorNo)
+3300 right(2*rotAngle)
+3310 CALL forward(hypo, colorNo)
+3320 penUp()
+3330 left(90+rotAngle)
+3340 forward(width_3) : REM color = ffffff
+3350 right(90-rotAngle)
+3360 penDown()
+3370 CALL forward(-hypo, colorNo)
+3380 right(2*rotAngle)
+3390 CALL forward(hypo, colorNo)
+3400 penUp()
+3410 left(rotAngle)
+3420 backward(h) : REM color = ffffff
+3430 penDown()
+3440 END SUB
+3450 REM
+3460 REM Draws letter X in colour specified by colorNo with font height h
+3470 REM from the current turtle position.
+3480 REM TODO: Add type-specific suffixes where necessary!
+3490 SUB letterX(h, colorNo)
+3500 REM TODO: add the respective type suffixes to your variable names if required
+3510 LET width = h/2.0
+3520 LET hypo = sqrt(width*width + h*h)
+3530 LET rotAngle = toDegrees(atan(width/h))
+3540 right(rotAngle)
+3550 CALL forward(hypo, colorNo)
+3560 penUp()
+3570 left(90+rotAngle)
+3580 forward(width) : REM color = ffffff
+3590 right(90-rotAngle)
+3600 penDown()
+3610 CALL forward(-hypo, colorNo)
+3620 right(rotAngle)
+3630 END SUB
+3640 REM
+3650 REM Draws letter Y in colour specified by colorNo with font height h
+3660 REM from the current turtle position.
+3670 REM TODO: Add type-specific suffixes where necessary!
+3680 SUB letterY(h, colorNo)
+3690 REM TODO: add the respective type suffixes to your variable names if required
+3700 LET width = h/2.0
+3710 LET hypo = sqrt(width*width + h*h)/2.0
+3720 LET rotAngle = toDegrees(atan(width/h))
+3730 penUp()
+3740 forward(h) : REM color = ffffff
+3750 left(rotAngle)
+3760 penDown()
+3770 CALL forward(-hypo, colorNo)
+3780 right(rotAngle)
+3790 penUp()
+3800 backward(h/2.0) : REM color = ffffff
+3810 penDown()
+3820 CALL forward(h/2.0, colorNo)
+3830 right(rotAngle)
+3840 CALL forward(hypo, colorNo)
+3850 left(rotAngle)
+3860 penUp()
+3870 backward(h) : REM color = ffffff
+3880 penDown()
+3890 END SUB
+3900 REM
+3910 REM Draws letter Z in colour specified by colorNo with font height h
+3920 REM from the current turtle position.
+3930 REM TODO: Add type-specific suffixes where necessary!
+3940 SUB letterZ(h, colorNo)
+3950 REM TODO: add the respective type suffixes to your variable names if required
+3960 LET width = h/2.0
+3970 LET hypo = sqrt(width*width + h*h)
+3980 LET rotAngle = toDegrees(atan(width/h))
+3990 penUp()
+4000 forward(h) : REM color = ffffff
+4010 right(90)
+4020 penDown()
+4030 CALL forward(width, colorNo)
+4040 left(90-rotAngle)
+4050 CALL forward(-hypo, colorNo)
+4060 right(90-rotAngle)
+4070 CALL forward(width, colorNo)
+4080 left(90)
+4090 END SUB
+4100 REM
+4110 REM Draws nEdges edges of a regular n-polygon with edge length a
+4120 REM counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.
+4130 REM TODO: Add type-specific suffixes where necessary!
+4140 SUB polygonPart(a AS double, n AS integer, ctrclkws AS boolean, nEdges AS integer, color AS Integer)
+4150 REM TODO: add the respective type suffixes to your variable names if required
+4160 LET rotAngle = 360.0/n
+4170 IF ctrclkws THEN
+4180 LET rotAngle = -rotAngle
+4190 END IF
+4200 FOR k = 1 TO nEdges
+4210 right(rotAngle)
+4220 CALL forward(a, color)
+4230 NEXT k
+4240 END SUB
+4250 REM
+4260 REM Draws a dummy character (small centered square) with font height h and
+4270 REM the colour encoded by colorNo
+4280 REM TODO: Add type-specific suffixes where necessary!
+4290 SUB charDummy(h, colorNo)
+4300 REM TODO: add the respective type suffixes to your variable names if required
+4310 LET width = h / 2.0
+4320 REM Octagon edge length (here: edge lengzh of the square)
+4330 LET b = width / (sqrt(2.0) + 1)
+4340 REM Cathetus of the corner triangle outside the octagon
+4350 LET c = (width - b) / 2.0
+4360 LET d = b / sqrt(2.0)
+4370 penUp()
+4380 forward(h/2.0-b/2.0) : REM color = ffffff
+4390 right(90)
+4400 forward(c) : REM color = ffffff
+4410 right(90)
+4420 penDown()
+4430 REM Draws the square with edge length b
+4440 CALL polygonPart(b, 4, true, 4, colorNo)
+4450 penUp()
+4460 left(90)
+4470 forward(b + c) : REM color = ffffff
+4480 left(90)
+4490 backward(h/2.0-b/2.0) : REM color = ffffff
+4500 penDown()
+4510 END SUB
+4520 REM
+4530 REM Draws a comma in colour specified by colorNo with font height h
+4540 REM from the current turtle position.
+4550 REM TODO: Add type-specific suffixes where necessary!
+4560 SUB comma(h, colorNo)
+4570 REM TODO: add the respective type suffixes to your variable names if required
+4580 REM Achteck-Kantenlänge
+4590 LET b = h * 0.5 / (sqrt(2.0) + 1)
+4600 REM Eckenlänge außen am Achteck
+4610 LET c = b / sqrt(2.0)
+4620 LET rotAngle = toDegrees(atan(0.5))
+4630 LET hypo = c * sqrt(1.25)
+4640 penUp()
+4650 right(90)
+4660 forward((c+b)/2.0 + c) : REM color = ffffff
+4670 penDown()
+4680 REM Counterclockwise draw 3 edges of a square with edge length c
+4690 REM in the colour endcoded by colorNo
+4700 CALL polygonPart(c, 4, true, 3, colorNo)
+4710 left(90)
+4720 CALL forward(c/2.0, colorNo)
+4730 right(90)
+4740 CALL forward(c, colorNo)
+4750 left(180 - rotAngle)
+4760 CALL forward(hypo, colorNo)
+4770 penUp()
+4780 right(90 - rotAngle)
+4790 forward((c + b)/2.0) : REM color = ffffff
+4800 left(90)
+4810 penDown()
+4820 END SUB
+4830 REM
+4840 REM Draws an exclamation mark in the colour encoded by colorNo with font height h
+4850 REM from the current turtle position.
+4860 REM TODO: Add type-specific suffixes where necessary!
+4870 SUB exclMk(h, colorNo)
+4880 REM TODO: add the respective type suffixes to your variable names if required
+4890 REM Achteck-Kantenlänge
+4900 LET b = h * 0.5 / (sqrt(2.0) + 1)
+4910 REM Eckenlänge außen am Achteck
+4920 LET c = b / sqrt(2.0)
+4930 LET width = h/2.0
+4940 LET length1 = h - (b+c)/2.0
+4950 LET length2 = length1 - 2*c
+4960 LET hypo = sqrt(width*width/16.0 + length2*length2)
+4970 REM 360°/8
+4980 LET rotAngle = 45
+4990 LET rotAngle2 = toDegrees(atan(width/4.0/length2))
+5000 penUp()
+5010 forward(length1) : REM color = ffffff
+5020 right(90)
+5030 forward(width/2.0) : REM color = ffffff
+5040 left(90 + rotAngle)
+5050 penDown()
+5060 REM Clockwise draw 5 edges of an octagon with edge length b/2
+5070 REM in the colour endcoded by colorNo
+5080 CALL polygonPart(b/2.0, 8, false, 5, colorNo)
+5090 right(rotAngle2)
+5100 CALL forward(hypo, colorNo)
+5110 left(2*rotAngle2)
+5120 CALL forward(-hypo, colorNo)
+5130 penUp()
+5140 forward(hypo) : REM color = ffffff
+5150 right(rotAngle2)
+5160 forward(c) : REM color = ffffff
+5170 left(90)
+5180 forward(c/2.0) : REM color = ffffff
+5190 penDown()
+5200 REM Counterclockwise draw all 4 edges of a squarfe with edge length c
+5210 REM in the colour endcoded by colorNo
+5220 CALL polygonPart(c, 4, false, 4, colorNo)
+5230 penUp()
+5240 forward((c + b)/2.0) : REM color = ffffff
+5250 left(90)
+5260 backward(c) : REM color = ffffff
+5270 penDown()
+5280 END SUB
+5290 REM
+5300 REM Draws a full stop in colour specified by colorNo with font height h
+5310 REM from the current turtle position.
+5320 REM TODO: Add type-specific suffixes where necessary!
+5330 SUB fullSt(h, colorNo)
+5340 REM TODO: add the respective type suffixes to your variable names if required
+5350 REM Achteck-Kantenlänge
+5360 LET b = h * 0.5 / (sqrt(2.0) + 1)
+5370 REM Eckenlänge außen am Achteck
+5380 LET c = b / sqrt(2.0)
+5390 penUp()
+5400 right(90)
+5410 forward((c+b)/2.0 + c) : REM color = ffffff
+5420 penDown()
+5430 REM Counterclockwise draw all 4 edges of a squarfe with edge length c
+5440 REM in the colour endcoded by colorNo
+5450 CALL polygonPart(c, 4, true, 4, colorNo)
+5460 penUp()
+5470 forward((c + b)/2.0) : REM color = ffffff
+5480 left(90)
+5490 penDown()
+5500 END SUB
+5510 REM
+5520 REM Draws letter B in colour specified by colorNo with font height h
+5530 REM from the current turtle position.
+5540 REM TODO: Add type-specific suffixes where necessary!
+5550 SUB letterB(h, colorNo)
+5560 REM TODO: add the respective type suffixes to your variable names if required
+5570 REM Octagon edge length
+5580 LET b = h * 0.5 / (sqrt(2.0) + 1)
+5590 REM Cathetus of the outer corner triangle of the octagon
+5600 LET c = b / sqrt(2.0)
+5610 CALL forward(h, colorNo)
+5620 right(90)
+5630 CALL forward(c+b, colorNo)
+5640 REM Clockwise draw 4 edges of an octagon with edge length b
+5650 CALL polygonPart(b, 8, false, 4, colorNo)
+5660 CALL forward(c, colorNo)
+5670 penUp()
+5680 left(180)
+5690 forward(b + c) : REM color = ffffff
+5700 penDown()
+5710 REM Clockwise draw 4 edges of an octagon with edge length b
+5720 CALL polygonPart(b, 8, false, 4, colorNo)
+5730 CALL forward(c, colorNo)
+5740 penUp()
+5750 left(180)
+5760 forward(b + 2*c) : REM color = ffffff
+5770 penDown()
+5780 left(90)
+5790 END SUB
+5800 REM
+5810 REM Draws letter C in the colour encoded by colorNo with font height h
+5820 REM from the current turtle position.
+5830 REM TODO: Add type-specific suffixes where necessary!
+5840 SUB letterC(h, colorNo)
+5850 REM TODO: add the respective type suffixes to your variable names if required
+5860 REM Octagon edge length
+5870 LET b = h * 0.5 / (sqrt(2.0) + 1)
+5880 REM Cathetus of the outer trinagle at the octagon corner
+5890 LET c = b / sqrt(2.0)
+5900 REM 360°/8
+5910 LET rotAngle = 45
+5920 penUp()
+5930 forward(c) : REM color = ffffff
+5940 penDown()
+5950 right(180)
+5960 REM Clockwise draws 3 edges of an octagon with edge length b in the colour
+5970 REM encoded by colorNo
+5980 CALL polygonPart(b, 8, true, 3, colorNo)
+5990 left(rotAngle)
+6000 penUp()
+6010 forward(2*b + 2*c) : REM color = ffffff
+6020 penDown()
+6030 REM Counterclockwise draws 4 edges of an octagon with edge length b
+6040 REM iin the colour encoded by colorNo
+6050 CALL polygonPart(b, 8, true, 4, colorNo)
+6060 CALL forward(b + 2*c, colorNo)
+6070 penUp()
+6080 forward(c) : REM color = ffffff
+6090 left(90)
+6100 CALL forward(b + 2*c, colorNo)
+6110 penDown()
+6120 left(90)
+6130 END SUB
+6140 REM
+6150 REM Draws letter D in colour specified by colorNo with font height h
+6160 REM from the current turtle position.
+6170 REM TODO: Add type-specific suffixes where necessary!
+6180 SUB letterD(h, colorNo)
+6190 REM TODO: add the respective type suffixes to your variable names if required
+6200 REM Achteck-Kantenlänge
+6210 LET b = h * 0.5 / (sqrt(2.0) + 1)
+6220 REM Eckenlänge außen am Achteck
+6230 LET c = b / sqrt(2.0)
+6240 CALL forward(h, colorNo)
+6250 right(90)
+6260 CALL forward(c+b, colorNo)
+6270 REM Clockwise draw 2 edges of an octagon with edge length b in the colour
+6280 REM encoded by colorNo
+6290 CALL polygonPart(b, 8, false, 2, colorNo)
+6300 CALL forward(b + 2*c, colorNo)
+6310 REM Clockwise draw 2 edges of an octagon with edge length b in the colour
+6320 REM encoded by colorNo
+6330 CALL polygonPart(b, 8, false, 2, colorNo)
+6340 CALL forward(c, colorNo)
+6350 penUp()
+6360 left(180)
+6370 forward(b + 2*c) : REM color = ffffff
+6380 penDown()
+6390 left(90)
+6400 END SUB
+6410 REM
+6420 REM Draws letter G in colour specified by colorNo with font height h
+6430 REM from the current turtle position.
+6440 REM TODO: Add type-specific suffixes where necessary!
+6450 SUB letterG(h, colorNo)
+6460 REM TODO: add the respective type suffixes to your variable names if required
+6470 REM Octagon edge length
+6480 LET b = h * 0.5 / (sqrt(2.0) + 1)
+6490 REM Cathetus of the corner triangle outside the octagon.
+6500 LET c = b / sqrt(2.0)
+6510 penUp()
+6520 forward(c) : REM color = ffffff
+6530 penDown()
+6540 right(180)
+6550 REM Counterclockwise draw 4 edges of an octagon with edge length b in
+6560 REM the colour encoded by colorNo
+6570 CALL polygonPart(b, 8, true, 4, colorNo)
+6580 CALL forward(c, colorNo)
+6590 left(90)
+6600 CALL forward(b/2.0 + c, colorNo)
+6610 penUp()
+6620 backward(b/2.0 + c) : REM color = ffffff
+6630 right(90)
+6640 forward(b + c) : REM color = ffffff
+6650 penDown()
+6660 REM Counterclockwise draw 4 edges of an octagon with edge length b in
+6670 REM the colour encoded by colorNo
+6680 CALL polygonPart(b, 8, true, 4, colorNo)
+6690 CALL forward(b + 2*c, colorNo)
+6700 penUp()
+6710 forward(c) : REM color = ffffff
+6720 left(90)
+6730 CALL forward(b + 2*c, colorNo)
+6740 penDown()
+6750 left(90)
+6760 END SUB
+6770 REM
+6780 REM Draws letter J in colour encoded by colorNo with font height h
+6790 REM from the current turtle position.
+6800 REM TODO: Add type-specific suffixes where necessary!
+6810 SUB letterJ(h, colorNo)
+6820 REM TODO: add the respective type suffixes to your variable names if required
+6830 REM Achteck-Kantenlänge
+6840 LET b = h * 0.5 / (sqrt(2.0) + 1)
+6850 REM Eckenlänge außen am Achteck
+6860 LET c = b / sqrt(2.0)
+6870 REM 360°/8
+6880 LET rotAngle = 45
+6890 penUp()
+6900 forward(c) : REM color = ffffff
+6910 penDown()
+6920 right(180)
+6930 REM Counterclockwise draw 3 edges of an octagon with edge length b in
+6940 REM the colour encoded by colorNo
+6950 CALL polygonPart(b, 8, true, 3, colorNo)
+6960 left(rotAngle)
+6970 CALL forward(h - c, colorNo)
+6980 penUp()
+6990 backward(h) : REM color = ffffff
+7000 penDown()
+7010 END SUB
+7020 REM
+7030 REM Draws letter O in colour specified by colorNo with font height h
+7040 REM from the current turtle position.
+7050 REM TODO: Add type-specific suffixes where necessary!
+7060 SUB letterO(h, colorNo)
+7070 REM TODO: add the respective type suffixes to your variable names if required
+7080 REM Octagon edge length
+7090 LET b = h * 0.5 / (sqrt(2.0) + 1)
+7100 REM Cathetus of the corner triangle outside the octagon
+7110 LET c = b / sqrt(2.0)
+7120 penUp()
+7130 forward(c) : REM color = ffffff
+7140 penDown()
+7150 right(180)
+7160 REM Counterclockwise draw 4 edges of an octagon with edge length b
+7170 REM in the colour endcoded by colorNo
+7180 CALL polygonPart(b, 8, true, 4, colorNo)
+7190 CALL forward(b + 2*c, colorNo)
+7200 REM Counterclockwise draw 4 edges of an octagon with edge length b
+7210 REM in the colour endcoded by colorNo
+7220 CALL polygonPart(b, 8, true, 4, colorNo)
+7230 CALL forward(b + 2*c, colorNo)
+7240 penUp()
+7250 forward(c) : REM color = ffffff
+7260 left(90)
+7270 forward(b + 2*c) : REM color = ffffff
+7280 penDown()
+7290 left(90)
+7300 END SUB
+7310 REM
+7320 REM Draws letter P in colour specified by colorNo with font height h
+7330 REM from the current turtle position.
+7340 REM TODO: Add type-specific suffixes where necessary!
+7350 SUB letterP(h, colorNo)
+7360 REM TODO: add the respective type suffixes to your variable names if required
+7370 REM Octagon edge length
+7380 LET b = h * 0.5 / (sqrt(2.0) + 1)
+7390 REM Cathetus of the corner triangle outside the octagon
+7400 LET c = b / sqrt(2.0)
+7410 CALL forward(h, colorNo)
+7420 right(90)
+7430 CALL forward(c+b, colorNo)
+7440 REM Clockwise draw 4 edges of an octagon with edge length b
+7450 REM in the colour endcoded by colorNo
+7460 CALL polygonPart(b, 8, false, 4, colorNo)
+7470 CALL forward(c, colorNo)
+7480 penUp()
+7490 backward(b + 2*c) : REM color = ffffff
+7500 left(90)
+7510 forward(b + 2*c) : REM color = ffffff
+7520 penDown()
+7530 left(180)
+7540 END SUB
+7550 REM
+7560 REM Draws letter Q in colour specified by colorNo with font height h
+7570 REM from the current turtle position.
+7580 REM TODO: Add type-specific suffixes where necessary!
+7590 SUB letterQ(h, colorNo)
+7600 REM TODO: add the respective type suffixes to your variable names if required
+7610 REM Achteck-Kantenlänge
+7620 LET b = h * 0.5 / (sqrt(2.0) + 1)
+7630 REM Eckenlänge außen am Achteck
+7640 LET c = b / sqrt(2.0)
+7650 REM 360°/8
+7660 LET rotAngle = 45
+7670 penUp()
+7680 forward(c) : REM color = ffffff
+7690 penDown()
+7700 right(180)
+7710 REM Counterclockwise draw 4 edges of an octagon with edge length b
+7720 REM in the colour endcoded by colorNo
+7730 CALL polygonPart(b, 8, true, 4, colorNo)
+7740 CALL forward(b + 2*c, colorNo)
+7750 REM Counterclockwise draw 4 edges of an octagon with edge length b
+7760 REM in the colour endcoded by colorNo
+7770 CALL polygonPart(b, 8, true, 4, colorNo)
+7780 CALL forward(b + 2*c, colorNo)
+7790 penUp()
+7800 forward(c) : REM color = ffffff
+7810 left(90)
+7820 forward(b + 2*c) : REM color = ffffff
+7830 right(rotAngle)
+7840 backward(b) : REM color = ffffff
+7850 penDown()
+7860 CALL forward(b, colorNo)
+7870 left(90 + rotAngle)
+7880 END SUB
+7890 REM
+7900 REM Zeichnet den Buchstaben R von der Turtleposition aus
+7910 REM mit Zeilenhöhe h
+7920 REM TODO: Add type-specific suffixes where necessary!
+7930 SUB letterR(h, colorNo)
+7940 REM TODO: add the respective type suffixes to your variable names if required
+7950 REM Achteck-Kantenlänge
+7960 LET b = h * 0.5 / (sqrt(2.0) + 1)
+7970 REM Eckenlänge außen am Achteck
+7980 LET c = b / sqrt(2.0)
+7990 REM 360°/8
+8000 LET rotAngle = 45
+8010 CALL forward(h, colorNo)
+8020 right(90)
+8030 CALL forward(c+b, colorNo)
+8040 REM Clockwise draw 4 edges of an octagon with edge length b
+8050 REM in the colour endcoded by colorNo
+8060 CALL polygonPart(b, 8, false, 4, colorNo)
+8070 CALL forward(c, colorNo)
+8080 left(90 + rotAngle)
+8090 CALL forward(sqrt(2.0)*(b + 2*c), colorNo)
+8100 left(90 + rotAngle)
+8110 END SUB
+8120 REM
+8130 REM Draws letter S in colour specified by colorNo with font height h
+8140 REM from the current turtle position.
+8150 REM TODO: Add type-specific suffixes where necessary!
+8160 SUB letterS(h, colorNo)
+8170 REM TODO: add the respective type suffixes to your variable names if required
+8180 REM Achteck-Kantenlänge
+8190 LET b = h * 0.5 / (sqrt(2.0) + 1)
+8200 REM Eckenlänge außen am Achteck
+8210 LET c = b / sqrt(2.0)
+8220 REM 360°/8
+8230 LET rotAngle = 45
+8240 penUp()
+8250 forward(c) : REM color = ffffff
+8260 penDown()
+8270 right(180)
+8280 REM Counterclockwise draw 6 edges of an octagon with edge length b
+8290 REM in the colour endcoded by colorNo
+8300 CALL polygonPart(b, 8, true, 6, colorNo)
+8310 REM Clockwise draw 5 edges of an octagon with edge length b
+8320 REM in the colour endcoded by colorNo
+8330 CALL polygonPart(b, 8, false, 5, colorNo)
+8340 right(rotAngle)
+8350 penUp()
+8360 forward(2*b + 3*c) : REM color = ffffff
+8370 penDown()
+8380 left(180)
+8390 END SUB
+8400 REM
+8410 REM Draws letter U in colour specified by colorNo with font height h
+8420 REM from the current turtle position.
+8430 REM TODO: Add type-specific suffixes where necessary!
+8440 SUB letterU(h, colorNo)
+8450 REM TODO: add the respective type suffixes to your variable names if required
+8460 REM edge length of a regular octagon
+8470 LET b = h * 0.5 / (sqrt(2.0) + 1)
+8480 REM Eckenlänge außen am Achteck
+8490 LET c = b / sqrt(2.0)
+8500 REM 360°/8
+8510 LET rotAngle = 45
+8520 penUp()
+8530 forward(c) : REM color = ffffff
+8540 penDown()
+8550 CALL forward(h - c, colorNo)
+8560 penUp()
+8570 backward(h-c) : REM color = ffffff
+8580 penDown()
+8590 right(180)
+8600 REM Counterclockwise draw 3 edges of an octagoin with edge length b in colour specified by colorNo
+8610 CALL polygonPart(b, 8, true, 3, colorNo)
+8620 left(rotAngle)
+8630 CALL forward(h - c, colorNo)
+8640 penUp()
+8650 backward(h) : REM color = ffffff
+8660 penDown()
+8670 END SUB
+8680 REM
+8690 REM Draws a question mark in colour specified by colorNo with font height h
+8700 REM from the current turtle position.
+8710 REM TODO: Add type-specific suffixes where necessary!
+8720 SUB qstnMk(h, colorNo)
+8730 REM TODO: add the respective type suffixes to your variable names if required
+8740 REM Achteck-Kantenlänge
+8750 LET b = h * 0.5 / (sqrt(2.0) + 1)
+8760 REM Eckenlänge außen am Achteck
+8770 LET c = b / sqrt(2.0)
+8780 REM 360°/8
+8790 LET rotAngle = 45
+8800 penUp()
+8810 forward(h-c) : REM color = ffffff
+8820 penDown()
+8830 REM Counterclockwise draw 5 edges of an octagon with edge length b
+8840 REM in the colour endcoded by colorNo
+8850 CALL polygonPart(b, 8, false, 5, colorNo)
+8860 CALL forward(c, colorNo)
+8870 left(rotAngle)
+8880 CALL forward(b/2.0, colorNo)
+8890 penUp()
+8900 forward(c) : REM color = ffffff
+8910 left(90)
+8920 forward(c/2.0) : REM color = ffffff
+8930 penDown()
+8940 REM Counterclockwise draw all 4 edges of a squarfe with edge length c
+8950 REM in the colour endcoded by colorNo
+8960 CALL polygonPart(c, 4, false, 4, colorNo)
+8970 penUp()
+8980 forward((c + b)/2.0) : REM color = ffffff
+8990 left(90)
+9000 backward(c) : REM color = ffffff
+9010 penDown()
+9020 END SUB
+9030 REM
+9040 REM Has the turtle draw the given string 'text´ with font height 'h´ (in
+9050 REM pixels) and the colour coded by integer 'c´ from the current Turtle
+9060 REM position to the Turtle canvas. If the turtle looks North then
+9070 REM the text will be written rightwards. In the event, the turtle will be
+9080 REM placed behind the text in original orientation (such that the next text
+9090 REM would be written like a continuation. Colour codes:
+9100 REM 1 = black
+9110 REM 2 = red
+9120 REM 3 = yellow
+9130 REM 4 = green
+9140 REM 5 = cyan
+9150 REM 6 = blue
+9160 REM 7 = pink
+9170 REM 8 = grey
+9180 REM 9 = orange
+9190 REM 10 = violet
+9200 REM All letters (ASCII) will be converted to uppercase, digits cannot
+9210 REM be represented, the set of representable special characters is:
+9220 REM '.', ',', '!', '?'. Other characters will be shown as a small
+9230 REM centred square (dummy character).
+9240 REM TODO: Add type-specific suffixes where necessary!
+9250 SUB drawText(text AS String, h AS integer, c AS integer)
+9260 REM TODO: add the respective type suffixes to your variable names if required
+9270 LET gap = h/10.0
+9280 FOR k = 1 TO length(text)
+9290 LET letter = uppercase(copy(text, k, 1))
+9300 IF letter = "," THEN
+9310 CALL comma(h,c)
+9320 ELSE
+9330 REM "," cannot be chacked against because the comma is misinterpreted
+9340 REM as selector list separator.
+9350 SELECT CASE letter
+9360 CASE "A"
+9370 CALL letterA(h,c)
+9380 CASE "B"
+9390 CALL letterB(h,c)
+9400 CASE "C"
+9410 CALL letterC(h,c)
+9420 CASE "D"
+9430 CALL letterD(h,c)
+9440 CASE "E"
+9450 CALL letterE(h,c)
+9460 CASE "F"
+9470 CALL letterF(h,c)
+9480 CASE "G"
+9490 CALL letterG(h,c)
+9500 CASE "H"
+9510 CALL letterH(h,c)
+9520 CASE "I"
+9530 CALL letterI(h,c)
+9540 CASE "J"
+9550 CALL letterJ(h,c)
+9560 CASE "K"
+9570 CALL letterK(h,c)
+9580 CASE "L"
+9590 CALL letterL(h,c)
+9600 CASE "M"
+9610 CALL letterM(h,c)
+9620 CASE "N"
+9630 CALL letterN(h,c)
+9640 CASE "O"
+9650 CALL letterO(h,c)
+9660 CASE "P"
+9670 CALL letterP(h,c)
+9680 CASE "Q"
+9690 CALL letterQ(h,c)
+9700 CASE "R"
+9710 CALL letterR(h,c)
+9720 CASE "S"
+9730 CALL letterS(h,c)
+9740 CASE "T"
+9750 CALL letterT(h,c)
+9760 CASE "U"
+9770 CALL letterU(h,c)
+9780 CASE "V"
+9790 CALL letterV(h,c)
+9800 CASE "W"
+9810 CALL letterW(h,c)
+9820 CASE "X"
+9830 CALL letterX(h,c)
+9840 CASE "Y"
+9850 CALL letterY(h,c)
+9860 CASE "Z"
+9870 CALL letterZ(h,c)
+9880 CASE " "
+9890 CALL blank(h,c)
+9900 CASE "!"
+9910 CALL exclMk(h,c)
+9920 CASE "?"
+9930 CALL qstnMk(h,c)
+9940 CASE "."
+9950 CALL fullSt(h,c)
+9960 CASE ELSE
+9970 CALL charDummy(h,c)
+9980 END SELECT
+9990 END IF
+10000 right(90)
+10010 penUp()
+10020 forward(gap) : REM color = ffffff
+10030 penDown()
+10040 left(90)
+10050 NEXT k
+10060 END SUB
diff --git a/samples/export/BASIC1/ELIZA_2.3.bas b/samples/export/BASIC1/ELIZA_2.3.bas
new file mode 100644
index 00000000..d480526a
--- /dev/null
+++ b/samples/export/BASIC1/ELIZA_2.3.bas
@@ -0,0 +1,428 @@
+Rem Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+Rem "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+Rem Computational Linguistis 1(1966)9, pp. 36-45
+Rem Revision history:
+Rem 2016-10-06 Initial version
+Rem 2017-03-29 Two diagrams updated (comments translated to English)
+Rem 2017-03-29 More keywords and replies added
+Rem 2019-03-14 Replies and mapping reorganised for easier maintenance
+Rem 2019-03-15 key map joined from keyword array and index map
+Rem 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+Rem 2019-11-28 New global type "History" (to ensure a homogenous array)
+Rem Generated by Structorizer 3.30-03
+Rem
+Rem Copyright (C) 2018-05-14 Kay Gürtzig
+Rem License: GPLv3-link
+Rem GNU General Public License (V 3)
+Rem https://www.gnu.org/licenses/gpl.html
+Rem http://www.gnu.de/documents/gpl.de.html
+Rem
+Rem
+Rem program ELIZA
+Rem TODO: Check and accomplish your variable declarations here:
+Dim varPart As String
+Dim userInput As String
+Dim replyRing As ???
+Dim reply As String
+Dim replies()() As String
+Dim reflexions()() As String
+Dim posAster As Integer
+Dim offsets() As Integer
+Dim keyMap() As KeyMapEntry
+Dim keyIndex As ???
+Dim isRepeated As boolean
+Dim isGone As boolean
+Dim history As History
+Dim findInfo() As integer
+Dim entry As KeyMapEntry
+Dim byePhrases()() As String
+Rem
+Rem Title information
+PRINT "************* ELIZA **************"
+PRINT "* Original design by J. Weizenbaum"
+PRINT "**********************************"
+PRINT "* Adapted for Basic on IBM PC by"
+PRINT "* - Patricia Danielson"
+PRINT "* - Paul Hashfield"
+PRINT "**********************************"
+PRINT "* Adapted for Structorizer by"
+PRINT "* - Kay Gürtzig / FH Erfurt 2016"
+PRINT "* Version: 2.3 (2019-11-28)"
+PRINT "* (Requires at least Structorizer 3.30-03 to run)"
+PRINT "**********************************"
+Rem Stores the last five inputs of the user in a ring buffer,
+Rem the second component is the rolling (over-)write index.
+Let history.histArray = Array("", "", "", "", "")
+Let history.histIndex = 0
+const replies = setupReplies()
+const reflexions = setupReflexions()
+const byePhrases = setupGoodByePhrases()
+const keyMap = setupKeywords()
+offsets(length(keyMap)-1) = 0
+isGone = false
+Rem Starter
+PRINT "Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?"
+Do
+ INPUT userInput
+ Rem Converts the input to lowercase, cuts out interpunctation
+ Rem and pads the string
+ userInput = normalizeInput(userInput)
+ isGone = checkGoodBye(userInput, byePhrases)
+ If NOT isGone Then
+ reply = "Please don\'t repeat yourself!"
+ isRepeated = checkRepetition(history, userInput)
+ If NOT isRepeated Then
+ findInfo = findKeyword(keyMap, userInput)
+ keyIndex = findInfo(0)
+ If keyIndex < 0 Then
+ Rem Should never happen...
+ keyIndex = length(keyMap)-1
+ End If
+ var entry: KeyMapEntry = keyMap(keyIndex)
+ Rem Variable part of the reply
+ varPart = ""
+ If length(entry.keyword) > 0 Then
+ varPart = conjugateStrings(userInput, entry.keyword, findInfo(1), reflexions)
+ End If
+ replyRing = replies(entry.index)
+ reply = replyRing(offsets(keyIndex))
+ offsets(keyIndex) = (offsets(keyIndex) + 1) % length(replyRing)
+ posAster = pos("*", reply)
+ If posAster > 0 Then
+ If varPart = " " Then
+ reply = "You will have to elaborate more for me to help you."
+ Else
+ delete(reply, posAster, 1)
+ insert(varPart, reply, posAster)
+ End If
+ End If
+ reply = adjustSpelling(reply)
+ End If
+ PRINT reply
+ End If
+Loop Until isGone
+End
+Rem
+Rem Cares for correct letter case among others
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function adjustSpelling(sentence AS String) As String
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim word As String
+ Dim start As String
+ Dim result As String
+ Dim position As Integer
+ Rem
+ result = sentence
+ position = 1
+ Do While (position <= length(sentence)) AND (copy(sentence, position, 1) = " ")
+ position = position + 1
+ Loop
+ If position <= length(sentence) Then
+ start = copy(sentence, 1, position)
+ delete(result, 1, position)
+ insert(uppercase(start), result, 1)
+ End If
+ Dim array53d059() As String = {" i ", " i\'"}
+ For Each word In array53d059
+ position = pos(word, result)
+ Do While position > 0
+ delete(result, position+1, 1)
+ insert("I", result, position+1)
+ position = pos(word, result)
+ Loop
+ Next word
+ Return result
+End Function
+Rem
+Rem Checks whether the given text contains some kind of
+Rem good-bye phrase inducing the end of the conversation
+Rem and if so writes a correspding good-bye message and
+Rem returns true, otherwise false
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function checkGoodBye(text AS String, phrases AS array of array[0..1] of string) As boolean
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim saidBye As boolean
+ Dim pair() As String
+ Rem
+ For Each pair In phrases
+ If pos(pair(0), text) > 0 Then
+ saidBye = true
+ PRINT pair(1)
+ Return true
+ End If
+ Next pair
+ return false
+End Function
+Rem
+Rem Checks whether newInput has occurred among the recently cached
+Rem input strings in the histArray component of history and updates the history.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function checkRepetition(history AS History, newInput AS String) As boolean
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim i As Integer
+ Dim histDepth As Integer
+ Dim hasOccurred As boolean
+ Rem
+ hasOccurred = false
+ If length(newInput) > 4 Then
+ histDepth = length(history.histArray)
+ For i = 0 To histDepth-1
+ If newInput = history.histArray(i) Then
+ hasOccurred = true
+ End If
+ Next i
+ history.histArray(history.histIndex) = newInput
+ history.histIndex = (history.histIndex + 1) % (histDepth)
+ End If
+ return hasOccurred
+End Function
+Rem
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function conjugateStrings(sentence AS String, key AS String, keyPos AS integer, flexions AS array of array[0..1] of string) As String
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim right As String
+ Dim result As String
+ Dim position As Integer
+ Dim pair() As String
+ Dim left As String
+ Rem
+ result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " "
+ For Each pair In flexions
+ left = ""
+ right = result
+ position = pos(pair(0), right)
+ Do While position > 0
+ left = left + copy(right, 1, position-1) + pair(1)
+ right = copy(right, position + length(pair(0)), length(right))
+ position = pos(pair(0), right)
+ Loop
+ result = left + right
+ Next pair
+ Rem Eliminate multiple spaces
+ position = pos(" ", result)
+ Do While position > 0
+ result = copy(result, 1, position-1) + copy(result, position+1, length(result))
+ position = pos(" ", result)
+ Loop
+ Return result
+End Function
+Rem
+Rem Looks for the occurrence of the first of the strings
+Rem contained in keywords within the given sentence (in
+Rem array order).
+Rem Returns an array of
+Rem 0: the index of the first identified keyword (if any, otherwise -1),
+Rem 1: the position inside sentence (0 if not found)
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function findKeyword(keyMap AS const array of KeyMapEntry, sentence AS String) As array[0..1] of integer
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim result() As Integer
+ Dim position As Integer
+ Dim i As Integer
+ Dim entry As KeyMapEntry
+ Rem
+ Rem Contains the index of the keyword and its position in sentence
+ Let result = Array(-1, 0)
+ i = 0
+ Do While (result(0) < 0) AND (i < length(keyMap))
+ var entry: KeyMapEntry = keyMap(i)
+ position = pos(entry.keyword, sentence)
+ If position > 0 Then
+ result(0) = i
+ result(1) = position
+ End If
+ i = i+1
+ Loop
+ Return result
+End Function
+Rem
+Rem Converts the sentence to lowercase, eliminates all
+Rem interpunction (i.e. ',', '.', ';'), and pads the
+Rem sentence among blanks
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function normalizeInput(sentence AS String) As String
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim symbol As String
+ Dim result As String
+ Dim position As Integer
+ Rem
+ sentence = lowercase(sentence)
+ Rem TODO: Specify an appropriate element type for the array!
+ Dim array450125a4() As FIXME_450125a4 = {'.', ',', ';', '!', '?'}
+ For Each symbol In array450125a4
+ position = pos(symbol, sentence)
+ Do While position > 0
+ sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence))
+ position = pos(symbol, sentence)
+ Loop
+ Next symbol
+ result = " " + sentence + " "
+ Return result
+End Function
+Rem
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function setupGoodByePhrases() As array of array[0..1] of string
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim phrases()() As String
+ Rem
+ Let phrases(0) = Array(" shut", "Okay. If you feel that way I\'ll shut up. ... Your choice.")
+ Let phrases(1) = Array("bye", "Well, let\'s end our talk for now. See you later. Bye.")
+ return phrases
+End Function
+Rem
+Rem The lower the index the higher the rank of the keyword (search is sequential).
+Rem The index of the first keyword found in a user sentence maps to a respective
+Rem reply ring as defined in `setupReplies()´.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function setupKeywords() As array of KeyMapEntry
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim keywords() As KeyMapEntry
+ Rem
+ Rem The empty key string (last entry) is the default clause - will always be found
+ Let keywords(39).keyword = ""
+ Let keywords(39).index = 29
+ Let keywords(0).keyword = "can you "
+ Let keywords(0).index = 0
+ Let keywords(1).keyword = "can i "
+ Let keywords(1).index = 1
+ Let keywords(2).keyword = "you are "
+ Let keywords(2).index = 2
+ Let keywords(3).keyword = "you\'re "
+ Let keywords(3).index = 2
+ Let keywords(4).keyword = "i don't "
+ Let keywords(4).index = 3
+ Let keywords(5).keyword = "i feel "
+ Let keywords(5).index = 4
+ Let keywords(6).keyword = "why don\'t you "
+ Let keywords(6).index = 5
+ Let keywords(7).keyword = "why can\'t i "
+ Let keywords(7).index = 6
+ Let keywords(8).keyword = "are you "
+ Let keywords(8).index = 7
+ Let keywords(9).keyword = "i can\'t "
+ Let keywords(9).index = 8
+ Let keywords(10).keyword = "i am "
+ Let keywords(10).index = 9
+ Let keywords(11).keyword = "i\'m "
+ Let keywords(11).index = 9
+ Let keywords(12).keyword = "you "
+ Let keywords(12).index = 10
+ Let keywords(13).keyword = "i want "
+ Let keywords(13).index = 11
+ Let keywords(14).keyword = "what "
+ Let keywords(14).index = 12
+ Let keywords(15).keyword = "how "
+ Let keywords(15).index = 12
+ Let keywords(16).keyword = "who "
+ Let keywords(16).index = 12
+ Let keywords(17).keyword = "where "
+ Let keywords(17).index = 12
+ Let keywords(18).keyword = "when "
+ Let keywords(18).index = 12
+ Let keywords(19).keyword = "why "
+ Let keywords(19).index = 12
+ Let keywords(20).keyword = "name "
+ Let keywords(20).index = 13
+ Let keywords(21).keyword = "cause "
+ Let keywords(21).index = 14
+ Let keywords(22).keyword = "sorry "
+ Let keywords(22).index = 15
+ Let keywords(23).keyword = "dream "
+ Let keywords(23).index = 16
+ Let keywords(24).keyword = "hello "
+ Let keywords(24).index = 17
+ Let keywords(25).keyword = "hi "
+ Let keywords(25).index = 17
+ Let keywords(26).keyword = "maybe "
+ Let keywords(26).index = 18
+ Let keywords(27).keyword = " no"
+ Let keywords(27).index = 19
+ Let keywords(28).keyword = "your "
+ Let keywords(28).index = 20
+ Let keywords(29).keyword = "always "
+ Let keywords(29).index = 21
+ Let keywords(30).keyword = "think "
+ Let keywords(30).index = 22
+ Let keywords(31).keyword = "alike "
+ Let keywords(31).index = 23
+ Let keywords(32).keyword = "yes "
+ Let keywords(32).index = 24
+ Let keywords(33).keyword = "friend "
+ Let keywords(33).index = 25
+ Let keywords(34).keyword = "computer"
+ Let keywords(34).index = 26
+ Let keywords(35).keyword = "bot "
+ Let keywords(35).index = 26
+ Let keywords(36).keyword = "smartphone"
+ Let keywords(36).index = 27
+ Let keywords(37).keyword = "father "
+ Let keywords(37).index = 28
+ Let keywords(38).keyword = "mother "
+ Let keywords(38).index = 28
+ return keywords
+End Function
+Rem
+Rem Returns an array of pairs of mutualy substitutable
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function setupReflexions() As array of array[0..1] of string
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim reflexions()() As String
+ Rem
+ Let reflexions(0) = Array(" are ", " am ")
+ Let reflexions(1) = Array(" were ", " was ")
+ Let reflexions(2) = Array(" you ", " I ")
+ Let reflexions(3) = Array(" your", " my")
+ Let reflexions(4) = Array(" i\'ve ", " you\'ve ")
+ Let reflexions(5) = Array(" i\'m ", " you\'re ")
+ Let reflexions(6) = Array(" me ", " you ")
+ Let reflexions(7) = Array(" my ", " your ")
+ Let reflexions(8) = Array(" i ", " you ")
+ Let reflexions(9) = Array(" am ", " are ")
+ return reflexions
+End Function
+Rem
+Rem This routine sets up the reply rings addressed by the key words defined in
+Rem routine `setupKeywords()´ and mapped hitherto by the cross table defined
+Rem in `setupMapping()´
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function setupReplies() As array of array of string
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim setupReplies()() As String
+ Dim replies()() As String
+ Rem
+ var replies: array of array of String
+ Rem We start with the highest index for performance reasons
+ Rem (is to avoid frequent array resizing)
+ Let replies(29) = Array( "Say, do you have any psychological problems?", "What does that suggest to you?", "I see.", "I'm not sure I understand you fully.", "Come come elucidate your thoughts.", "Can you elaborate on that?", "That is quite interesting.")
+ Let replies(0) = Array( "Don't you believe that I can*?", "Perhaps you would like to be like me?", "You want me to be able to*?")
+ Let replies(1) = Array( "Perhaps you don't want to*?", "Do you want to be able to*?")
+ Let replies(2) = Array( "What makes you think I am*?", "Does it please you to believe I am*?", "Perhaps you would like to be*?", "Do you sometimes wish you were*?")
+ Let replies(3) = Array( "Don't you really*?", "Why don't you*?", "Do you wish to be able to*?", "Does that trouble you*?")
+ Let replies(4) = Array( "Do you often feel*?", "Are you afraid of feeling*?", "Do you enjoy feeling*?")
+ Let replies(5) = Array( "Do you really believe I don't*?", "Perhaps in good time I will*.", "Do you want me to*?")
+ Let replies(6) = Array( "Do you think you should be able to*?", "Why can't you*?")
+ Let replies(7) = Array( "Why are you interested in whether or not I am*?", "Would you prefer if I were not*?", "Perhaps in your fantasies I am*?")
+ Let replies(8) = Array( "How do you know you can't*?", "Have you tried?","Perhaps you can now*.")
+ Let replies(9) = Array( "Did you come to me because you are*?", "How long have you been*?", "Do you believe it is normal to be*?", "Do you enjoy being*?")
+ Let replies(10) = Array( "We were discussing you--not me.", "Oh, I*.", "You're not really talking about me, are you?")
+ Let replies(11) = Array( "What would it mean to you if you got*?", "Why do you want*?", "Suppose you soon got*...", "What if you never got*?", "I sometimes also want*.")
+ Let replies(12) = Array( "Why do you ask?", "Does that question interest you?", "What answer would please you the most?", "What do you think?", "Are such questions on your mind often?", "What is it that you really want to know?", "Have you asked anyone else?", "Have you asked such questions before?", "What else comes to mind when you ask that?")
+ Let replies(13) = Array( "Names don't interest me.", "I don't care about names -- please go on.")
+ Let replies(14) = Array( "Is that the real reason?", "Don't any other reasons come to mind?", "Does that reason explain anything else?", "What other reasons might there be?")
+ Let replies(15) = Array( "Please don't apologize!", "Apologies are not necessary.", "What feelings do you have when you apologize?", "Don't be so defensive!")
+ Let replies(16) = Array( "What does that dream suggest to you?", "Do you dream often?", "What persons appear in your dreams?", "Are you disturbed by your dreams?")
+ Let replies(17) = Array( "How do you do ...please state your problem.")
+ Let replies(18) = Array( "You don't seem quite certain.", "Why the uncertain tone?", "Can't you be more positive?", "You aren't sure?", "Don't you know?")
+ Let replies(19) = Array( "Are you saying no just to be negative?", "You are being a bit negative.", "Why not?", "Are you sure?", "Why no?")
+ Let replies(20) = Array( "Why are you concerned about my*?", "What about your own*?")
+ Let replies(21) = Array( "Can you think of a specific example?", "When?", "What are you thinking of?", "Really, always?")
+ Let replies(22) = Array( "Do you really think so?", "But you are not sure you*?", "Do you doubt you*?")
+ Let replies(23) = Array( "In what way?", "What resemblance do you see?", "What does the similarity suggest to you?", "What other connections do you see?", "Could there really be some connection?", "How?", "You seem quite positive.")
+ Let replies(24) = Array( "Are you sure?", "I see.", "I understand.")
+ Let replies(25) = Array( "Why do you bring up the topic of friends?", "Do your friends worry you?", "Do your friends pick on you?", "Are you sure you have any friends?", "Do you impose on your friends?", "Perhaps your love for friends worries you.")
+ Let replies(26) = Array( "Do computers worry you?", "Are you talking about me in particular?", "Are you frightened by machines?", "Why do you mention computers?", "What do you think machines have to do with your problem?", "Don't you think computers can help people?", "What is it about machines that worries you?")
+ Let replies(27) = Array( "Do you sometimes feel uneasy without a smartphone?", "Have you had these phantasies before?", "Does the world seem more real for you via apps?")
+ Let replies(28) = Array( "Tell me more about your family.", "Who else in your family*?", "What does family relations mean for you?", "Come on, How old are you?")
+ setupReplies = replies
+ Return setupReplies
+End Function
diff --git a/samples/export/BASIC1/SORTING_TEST_MAIN.bas b/samples/export/BASIC1/SORTING_TEST_MAIN.bas
index 16446657..bd3d1b78 100644
--- a/samples/export/BASIC1/SORTING_TEST_MAIN.bas
+++ b/samples/export/BASIC1/SORTING_TEST_MAIN.bas
@@ -1,294 +1,294 @@
-REM Creates three equal arrays of numbers and has them sorted with different sorting algorithms
-REM to allow performance comparison via execution counting ("Collect Runtime Data" should
-REM sensibly be switched on).
-REM Requested input data are: Number of elements (size) and filing mode.
-REM Generated by Structorizer 3.30-02
-REM
-REM Copyright (C) 2019-10-02 Kay Gürtzig
-REM License: GPLv3-link
-REM GNU General Public License (V 3)
-REM https://www.gnu.org/licenses/gpl.html
-REM http://www.gnu.de/documents/gpl.de.html
-REM
-REM
-REM program SORTING_TEST_MAIN
-REM TODO: declare your variables here:
- REM DIM values3 AS
- REM DIM values2 AS
- REM DIM values1 AS
- REM DIM show AS
- REM DIM ok3 AS
- REM DIM ok2 AS
- REM DIM ok1 AS
- REM DIM modus AS
- REM DIM i AS
- REM DIM elementCount AS
-REM
-DO
+Rem Creates three equal arrays of numbers and has them sorted with different sorting algorithms
+Rem to allow performance comparison via execution counting ("Collect Runtime Data" should
+Rem sensibly be switched on).
+Rem Requested input data are: Number of elements (size) and filing mode.
+Rem Generated by Structorizer 3.30-03
+Rem
+Rem Copyright (C) 2019-10-02 Kay Gürtzig
+Rem License: GPLv3-link
+Rem GNU General Public License (V 3)
+Rem https://www.gnu.org/licenses/gpl.html
+Rem http://www.gnu.de/documents/gpl.de.html
+Rem
+Rem
+Rem program SORTING_TEST_MAIN
+Rem TODO: Check and accomplish your variable declarations here:
+Dim values3() As ???
+Dim values2() As ???
+Dim values1() As Integer
+Dim show As ???
+Dim ok3 As bool
+Dim ok2 As bool
+Dim ok1 As bool
+Dim modus As ???
+Dim i As Integer
+Dim elementCount As ???
+Rem
+Do
INPUT elementCount
-LOOP UNTIL elementCount >= 1
-DO
+Loop Until elementCount >= 1
+Do
PRINT "Filling: 1 = random, 2 = increasing, 3 = decreasing"; : INPUT modus
-LOOP UNTIL modus = 1 OR modus = 2 OR modus = 3
-FOR i = 0 TO elementCount-1
- SELECT CASE modus
- CASE 1
+Loop Until modus = 1 OR modus = 2 OR modus = 3
+For i = 0 To elementCount-1
+ Select Case modus
+ Case 1
values1(i) = random(10000)
- CASE 2
+ Case 2
values1(i) = i
- CASE 3
+ Case 3
values1(i) = -i
- END SELECT
-NEXT i
-REM Kopiere das Array für exakte Vergleichbarkeit
-FOR i = 0 TO elementCount-1
+ End Select
+Next i
+Rem Copy the array for exact comparability
+For i = 0 To elementCount-1
values2(i) = values1(i)
values3(i) = values1(i)
-NEXT i
+Next i
-REM ==========================================================
-REM ================= START PARALLEL SECTION =================
-REM ==========================================================
-REM TODO: add the necessary code to run the threads concurrently
+Rem ==========================================================
+Rem ================= START PARALLEL SECTION =================
+Rem ==========================================================
+Rem TODO: add the necessary code to run the threads concurrently
- REM ----------------- START THREAD 0 -----------------
- CALL bubbleSort(values1)
- REM ------------------ END THREAD 0 ------------------
+ Rem ----------------- START THREAD 0 -----------------
+ Call bubbleSort(values1)
+ Rem ------------------ END THREAD 0 ------------------
- REM ----------------- START THREAD 1 -----------------
- CALL quickSort(values2, 0, elementCount)
- REM ------------------ END THREAD 1 ------------------
+ Rem ----------------- START THREAD 1 -----------------
+ Call quickSort(values2, 0, elementCount)
+ Rem ------------------ END THREAD 1 ------------------
- REM ----------------- START THREAD 2 -----------------
- CALL heapSort(values3)
- REM ------------------ END THREAD 2 ------------------
+ Rem ----------------- START THREAD 2 -----------------
+ Call heapSort(values3)
+ Rem ------------------ END THREAD 2 ------------------
-REM ==========================================================
-REM ================== END PARALLEL SECTION ==================
-REM ==========================================================
+Rem ==========================================================
+Rem ================== END PARALLEL SECTION ==================
+Rem ==========================================================
-CALL ok1 = testSorted(values1)
-CALL ok2 = testSorted(values2)
-CALL ok3 = testSorted(values3)
-IF NOT ok1 OR NOT ok2 OR NOT ok3 THEN
- FOR i = 0 TO elementCount-1
- IF values1(i) <> values2(i) OR values1(i) <> values3(i) THEN
+ok1 = testSorted(values1)
+ok2 = testSorted(values2)
+ok3 = testSorted(values3)
+If NOT ok1 OR NOT ok2 OR NOT ok3 Then
+ For i = 0 To elementCount-1
+ If values1(i) <> values2(i) OR values1(i) <> values3(i) Then
PRINT "Difference at ["; i; "]: "; values1(i); " <-> "; values2(i); " <-> "; values3(i)
- END IF
- NEXT i
-END IF
-DO
+ End If
+ Next i
+End If
+Do
PRINT "Show arrays (yes/no)?"; : INPUT show
-LOOP UNTIL show = "yes" OR show = "no"
-IF show = "yes" THEN
- FOR i = 0 TO elementCount - 1
+Loop Until show = "yes" OR show = "no"
+If show = "yes" Then
+ For i = 0 To elementCount - 1
PRINT "["; i; "]:\t"; values1(i); "\t"; values2(i); "\t"; values3(i)
- NEXT i
-END IF
-END
-REM
-REM Implements the well-known BubbleSort algorithm.
-REM Compares neigbouring elements and swaps them in case of an inversion.
-REM Repeats this while inversions have been found. After every
-REM loop passage at least one element (the largest one out of the
-REM processed subrange) finds its final place at the end of the
-REM subrange.
-REM TODO: Check (and specify if needed) the argument and result types!
-SUB bubbleSort(values)
- REM TODO: declare your variables here:
- REM DIM temp AS
- REM DIM posSwapped AS
- REM DIM i AS
- REM DIM ende AS
- REM
+ Next i
+End If
+End
+Rem
+Rem Implements the well-known BubbleSort algorithm.
+Rem Compares neigbouring elements and swaps them in case of an inversion.
+Rem Repeats this while inversions have been found. After every
+Rem loop passage at least one element (the largest one out of the
+Rem processed subrange) finds its final place at the end of the
+Rem subrange.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub bubbleSort(values)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim temp As ???
+ Dim posSwapped As ???
+ Dim i As Integer
+ Dim ende As ???
+ Rem
ende = length(values) - 2
- DO
- REM The index of the most recent swapping (-1 means no swapping done).
+ Do
+ Rem The index of the most recent swapping (-1 means no swapping done).
posSwapped = -1
- FOR i = 0 TO ende
- IF values(i) > values(i+1) THEN
+ For i = 0 To ende
+ If values(i) > values(i+1) Then
temp = values(i)
values(i) = values(i+1)
values(i+1) = temp
posSwapped = i
- END IF
- NEXT i
+ End If
+ Next i
ende = posSwapped - 1
- LOOP UNTIL posSwapped < 0
-END SUB
-REM
-REM Given a max-heap 'heap´ with element at index 'i´ possibly
-REM violating the heap property wrt. its subtree upto and including
-REM index range-1, restores heap property in the subtree at index i
-REM again.
-REM TODO: Check (and specify if needed) the argument and result types!
-SUB maxHeapify(heap, i, range)
- REM TODO: declare your variables here:
- REM DIM temp AS
- REM DIM right AS
- REM DIM max AS
- REM DIM left AS
- REM
- REM Indices of left and right child of node i
+ Loop Until posSwapped < 0
+End Sub
+Rem
+Rem Given a max-heap 'heap´ with element at index 'i´ possibly
+Rem violating the heap property wrt. its subtree upto and including
+Rem index range-1, restores heap property in the subtree at index i
+Rem again.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub maxHeapify(heap, i, range)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim temp As ???
+ Dim right As ???
+ Dim max As ???
+ Dim left As ???
+ Rem
+ Rem Indices of left and right child of node i
right = (i+1) * 2
left = right - 1
- REM Index of the (local) maximum
+ Rem Index of the (local) maximum
max = i
- IF left < range AND heap(left) > heap(i) THEN
+ If left < range AND heap(left) > heap(i) Then
max = left
- END IF
- IF right < range AND heap(right) > heap(max) THEN
+ End If
+ If right < range AND heap(right) > heap(max) Then
max = right
- END IF
- IF max <> i THEN
+ End If
+ If max <> i Then
temp = heap(i)
heap(i) = heap(max)
heap(max) = temp
- CALL maxHeapify(heap, max, range)
- END IF
-END SUB
-REM
-REM Partitions array values between indices start und stop-1 with
-REM respect to the pivot element initially at index p into smaller
-REM and greater elements.
-REM Returns the new (and final) index of the pivot element (which
-REM separates the sequence of smaller from the sequence of greater
-REM elements).
-REM This is not the most efficient algorithm (about half the swapping
-REM might still be avoided) but it is pretty clear.
-REM TODO: Check (and specify if needed) the argument and result types!
-FUNCTION partition(values, start, stop, p) AS Integer
- REM TODO: declare your variables here:
- REM DIM seen AS
- REM DIM pivot AS
- REM
+ Call maxHeapify(heap, max, range)
+ End If
+End Sub
+Rem
+Rem Partitions array values between indices start und stop-1 with
+Rem respect to the pivot element initially at index p into smaller
+Rem and greater elements.
+Rem Returns the new (and final) index of the pivot element (which
+Rem separates the sequence of smaller from the sequence of greater
+Rem elements).
+Rem This is not the most efficient algorithm (about half the swapping
+Rem might still be avoided) but it is pretty clear.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function partition(values, start, stop, p) As Integer
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim seen As ???
+ Dim pivot As ???
+ Rem
pivot = values(p)
- REM Tausche das Pivot-Element an den start
+ Rem Tausche das Pivot-Element an den start
values(p) = values(start)
values(start) = pivot
p = start
- REM Beginning and end of the remaining unknown range
+ Rem Beginning and end of the remaining unknown range
start = start + 1
stop = stop - 1
- REM Still unseen elements?
- DO WHILE stop >= start
+ Rem Still unseen elements?
+ Do While stop >= start
seen = values(start)
- IF values(start) <= pivot THEN
- REM Swap pivot element with start element
+ If values(start) <= pivot Then
+ Rem Swap pivot element with start element
values(p) = seen
values(start) = pivot
p = p + 1
start = start + 1
- ELSE
- REM Put the found element to the end of the unknown area
+ Else
+ Rem Put the found element to the end of the unknown area
values(start) = values(stop)
values(stop) = seen
stop = stop - 1
- END IF
- LOOP
+ End If
+ Loop
return p
-END FUNCTION
-REM
-REM Checks whether or not the passed-in array is (ascendingly) sorted.
-REM TODO: Check (and specify if needed) the argument and result types!
-FUNCTION testSorted(numbers) AS bool
- REM TODO: declare your variables here:
- REM DIM isSorted AS
- REM DIM i AS
- REM
+End Function
+Rem
+Rem Checks whether or not the passed-in array is (ascendingly) sorted.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function testSorted(numbers) As bool
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim isSorted As boolean
+ Dim i As Integer
+ Rem
isSorted = true
i = 0
- REM As we compare with the following element, we must stop at the penultimate index
- DO WHILE isSorted AND (i <= length(numbers)-2)
- REM Is there an inversion?
- IF numbers(i) > numbers(i+1) THEN
+ Rem As we compare with the following element, we must stop at the penultimate index
+ Do While isSorted AND (i <= length(numbers)-2)
+ Rem Is there an inversion?
+ If numbers(i) > numbers(i+1) Then
isSorted = false
- ELSE
+ Else
i = i + 1
- END IF
- LOOP
+ End If
+ Loop
return isSorted
-END FUNCTION
-REM
-REM Runs through the array heap and converts it to a max-heap
-REM in a bottom-up manner, i.e. starts above the "leaf" level
-REM (index >= length(heap) div 2) and goes then up towards
-REM the root.
-REM TODO: Check (and specify if needed) the argument and result types!
-FUNCTION buildMaxHeap(heap)
- REM TODO: declare your variables here:
- REM DIM lgth AS
- REM DIM k AS
- REM
+End Function
+Rem
+Rem Runs through the array heap and converts it to a max-heap
+Rem in a bottom-up manner, i.e. starts above the "leaf" level
+Rem (index >= length(heap) div 2) and goes then up towards
+Rem the root.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function buildMaxHeap(heap)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim lgth As Integer
+ Dim k As Integer
+ Rem
lgth = length(heap)
- FOR k = lgth / 2 - 1 TO 0 STEP -1
- CALL maxHeapify(heap, k, lgth)
- NEXT k
- RETURN 0
-END FUNCTION
-REM
-REM Recursively sorts a subrange of the given array 'values´.
-REM start is the first index of the subsequence to be sorted,
-REM stop is the index BEHIND the subsequence to be sorted.
-REM TODO: Check (and specify if needed) the argument and result types!
-FUNCTION quickSort(values, start, stop)
- REM TODO: declare your variables here:
- REM DIM p AS
- REM
- REM At least 2 elements? (Less don't make sense.)
- IF stop >= start + 2 THEN
- REM Select a pivot element, be p its index.
- REM (here: randomly chosen element out of start ... stop-1)
+ For k = lgth / 2 - 1 To 0 Step -1
+ Call maxHeapify(heap, k, lgth)
+ Next k
+ Return 0
+End Function
+Rem
+Rem Recursively sorts a subrange of the given array 'values´.
+Rem start is the first index of the subsequence to be sorted,
+Rem stop is the index BEHIND the subsequence to be sorted.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function quickSort(values, start, stop)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim p As ???
+ Rem
+ Rem At least 2 elements? (Less don't make sense.)
+ If stop >= start + 2 Then
+ Rem Select a pivot element, be p its index.
+ Rem (here: randomly chosen element out of start ... stop-1)
p = random(stop-start) + start
- REM Partition the array into smaller and greater elements
- REM Get the resulting (and final) position of the pivot element
- CALL p = partition(values, start, stop, p)
- REM Sort subsequances separately and independently ...
+ Rem Partition the array into smaller and greater elements
+ Rem Get the resulting (and final) position of the pivot element
+ p = partition(values, start, stop, p)
+ Rem Sort subsequances separately and independently ...
- REM ==========================================================
- REM ================= START PARALLEL SECTION =================
- REM ==========================================================
- REM TODO: add the necessary code to run the threads concurrently
+ Rem ==========================================================
+ Rem ================= START PARALLEL SECTION =================
+ Rem ==========================================================
+ Rem TODO: add the necessary code to run the threads concurrently
- REM ----------------- START THREAD 0 -----------------
- REM Sort left (lower) array part
- CALL quickSort(values, start, p)
- REM ------------------ END THREAD 0 ------------------
+ Rem ----------------- START THREAD 0 -----------------
+ Rem Sort left (lower) array part
+ Call quickSort(values, start, p)
+ Rem ------------------ END THREAD 0 ------------------
- REM ----------------- START THREAD 1 -----------------
- REM Sort right (higher) array part
- CALL quickSort(values, p+1, stop)
- REM ------------------ END THREAD 1 ------------------
+ Rem ----------------- START THREAD 1 -----------------
+ Rem Sort right (higher) array part
+ Call quickSort(values, p+1, stop)
+ Rem ------------------ END THREAD 1 ------------------
- REM ==========================================================
- REM ================== END PARALLEL SECTION ==================
- REM ==========================================================
+ Rem ==========================================================
+ Rem ================== END PARALLEL SECTION ==================
+ Rem ==========================================================
- END IF
- RETURN 0
-END FUNCTION
-REM
-REM Sorts the array 'values´ of numbers according to he heap sort
-REM algorithm
-REM TODO: Check (and specify if needed) the argument and result types!
-FUNCTION heapSort(values)
- REM TODO: declare your variables here:
- REM DIM maximum AS
- REM DIM k AS
- REM DIM heapRange AS
- REM
- CALL buildMaxHeap(values)
+ End If
+ Return 0
+End Function
+Rem
+Rem Sorts the array 'values´ of numbers according to he heap sort
+Rem algorithm
+Rem TODO: Check (and specify if needed) the argument and result types!
+Function heapSort(values)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim maximum As ???
+ Dim k As Integer
+ Dim heapRange As Integer
+ Rem
+ Call buildMaxHeap(values)
heapRange = length(values)
- FOR k = heapRange - 1 TO 1 STEP -1
+ For k = heapRange - 1 To 1 Step -1
heapRange = heapRange - 1
- REM Swap the maximum value (root of the heap) to the heap end
+ Rem Swap the maximum value (root of the heap) to the heap end
maximum = values(0)
values(0) = values(heapRange)
values(heapRange) = maximum
- CALL maxHeapify(values, 0, heapRange)
- NEXT k
- RETURN 0
-END FUNCTION
+ Call maxHeapify(values, 0, heapRange)
+ Next k
+ Return 0
+End Function
diff --git a/samples/export/BASIC1/TextDemo.bas b/samples/export/BASIC1/TextDemo.bas
new file mode 100644
index 00000000..d1fb1d2e
--- /dev/null
+++ b/samples/export/BASIC1/TextDemo.bas
@@ -0,0 +1,1135 @@
+Rem Demo program for routine drawText()
+Rem Asks the user to enter a text, a wanted text height and colour,
+Rem and then draws this string onto the turtle screen. Places every
+Rem entered text to a new line.
+Rem Generated by Structorizer 3.30-03
+Rem
+Rem Copyright (C) 2019-10-10 Kay Gürtzig
+Rem License: GPLv3-link
+Rem GNU General Public License (V 3)
+Rem https://www.gnu.org/licenses/gpl.html
+Rem http://www.gnu.de/documents/gpl.de.html
+Rem
+Rem
+Rem program TextDemo
+Rem TODO: Check and accomplish your variable declarations here:
+Dim y As Integer
+Dim text As ???
+Dim height As ???
+Dim colour As ???
+Rem
+PRINT "This is a demo program for text writing with Turleizer."
+showTurtle()
+penDown()
+y = 0
+Do
+ PRINT "Enter some text (empty string to exit)"; : INPUT text
+ Rem Make sure the content is interpreted as string
+ text = "" + text
+ If text <> "" Then
+ Do
+ PRINT "Height of the text (pixels)"; : INPUT height
+ Loop Until height >= 5
+ Do
+ PRINT "Colour (1=black, 2=red, 3=yellow, 4=green, 5=cyan, 6=blue, 7=pink, 8=gray, 9=orange, 10=violet)"; : INPUT colour
+ Loop Until colour >= 1 AND colour <= 10
+ y = y + height + 2
+ gotoXY(0, y - 2)
+ Call drawText(text, height, colour)
+ End If
+Loop Until text = ""
+gotoXY(0, y + 15)
+Call drawText("Thank you, bye.", 10, 4)
+hideTurtle()
+End
+Rem
+Rem Draws a blank for font height h, ignoring the colorNo
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub blank(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ penUp()
+ right(90)
+ forward(width) : Rem color = ffffff
+ left(90)
+End Sub
+Rem
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub forward(len, color)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Rem
+ Select Case color
+ Case 1
+ forward(len) : Rem color = ffffff
+ Case 2
+ forward(len) : Rem color = ff8080
+ Case 3
+ forward(len) : Rem color = ffff80
+ Case 4
+ forward(len) : Rem color = 80ff80
+ Case 5
+ forward(len) : Rem color = 80ffff
+ Case 6
+ forward(len) : Rem color = 0080ff
+ Case 7
+ forward(len) : Rem color = ff80c0
+ Case 8
+ forward(len) : Rem color = c0c0c0
+ Case 9
+ forward(len) : Rem color = ff8000
+ Case 10
+ forward(len) : Rem color = 8080ff
+ End Select
+End Sub
+Rem
+Rem Draws letter A in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterA(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ hypo = sqrt(h*h + width*width/4.0)
+ rotAngle = toDegrees(atan(width/2.0/h))
+ right(rotAngle)
+ Call forward(hypo/2.0, colorNo)
+ right(90 - rotAngle)
+ Call forward(width/2.0, colorNo)
+ penUp()
+ backward(width/2.0) : Rem color = ffffff
+ penDown()
+ left(90 - rotAngle)
+ Call forward(hypo/2.0, colorNo)
+ left(2*rotAngle)
+ Call forward(-hypo, colorNo)
+ right(rotAngle)
+End Sub
+Rem
+Rem Draws letter L in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterL(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ Call forward(h, colorNo)
+ penUp()
+ backward(h) : Rem color = ffffff
+ right(90)
+ penDown()
+ Call forward(width, colorNo)
+ left(90)
+End Sub
+Rem
+Rem Draws letter N in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterN(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ hypo = sqrt(width*width + h*h)
+ rotAngle = toDegrees(atan(width/h))
+ Call forward(h, colorNo)
+ left(rotAngle)
+ Call forward(-hypo, colorNo)
+ right(rotAngle)
+ Call forward(h, colorNo)
+ penUp()
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter E in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterE(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(width, colorNo)
+ right(90)
+ penUp()
+ forward(h/2.0) : Rem color = ffffff
+ right(90)
+ penDown()
+ Call forward(width, colorNo)
+ left(90)
+ penUp()
+ forward(h/2.0) : Rem color = ffffff
+ left(90)
+ penDown()
+ Call forward(width, colorNo)
+ left(90)
+End Sub
+Rem
+Rem Draws letter V in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterV(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ hypo = sqrt(h*h + width*width/4.0)
+ rotAngle = toDegrees(atan(width/2.0/h))
+ penUp()
+ forward(h) : Rem color = ffffff
+ left(rotAngle)
+ penDown()
+ Call forward(-hypo, colorNo)
+ right(2*rotAngle)
+ Call forward(hypo, colorNo)
+ penUp()
+ left(rotAngle)
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter F in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterF(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(width, colorNo)
+ right(90)
+ penUp()
+ forward(h/2.0) : Rem color = ffffff
+ right(90)
+ penDown()
+ Call forward(width, colorNo)
+ left(90)
+ penUp()
+ forward(h/2.0) : Rem color = ffffff
+ left(90)
+ forward(width) : Rem color = ffffff
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws letter I in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterI(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0)
+ penUp()
+ right(90)
+ forward(c) : Rem color = ffffff
+ penDown()
+ Call forward(b, colorNo)
+ penUp()
+ backward(b/2.0) : Rem color = ffffff
+ left(90)
+ penDown()
+ Call forward(h, colorNo)
+ penUp()
+ right(90)
+ backward(b/2.0) : Rem color = ffffff
+ penDown()
+ Call forward(b, colorNo)
+ penUp()
+ forward(b/2 + c) : Rem color = ffffff
+ left(90)
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter W in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterW(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width_3 As ???
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ width_3 = width/3.0
+ hypo = sqrt(width_3*width_3 + h*h)
+ rotAngle = toDegrees(atan(width_3/h))
+ penUp()
+ forward(h) : Rem color = ffffff
+ left(rotAngle)
+ penDown()
+ Call forward(-hypo, colorNo)
+ right(2*rotAngle)
+ Call forward(hypo, colorNo)
+ penUp()
+ left(90+rotAngle)
+ forward(width_3) : Rem color = ffffff
+ right(90-rotAngle)
+ penDown()
+ Call forward(-hypo, colorNo)
+ right(2*rotAngle)
+ Call forward(hypo, colorNo)
+ penUp()
+ left(rotAngle)
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws nEdges edges of a regular n-polygon with edge length a
+Rem counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub polygonPart(a AS double, n AS integer, ctrclkws AS boolean, nEdges AS integer, color AS Integer)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As ???
+ Dim k As Integer
+ Rem
+ rotAngle = 360.0/n
+ If ctrclkws Then
+ rotAngle = -rotAngle
+ End If
+ For k = 1 To nEdges
+ right(rotAngle)
+ Call forward(a, color)
+ Next k
+End Sub
+Rem
+Rem Draws letter H in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterH(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ Call forward(h, colorNo)
+ penUp()
+ right(90)
+ forward(width) : Rem color = ffffff
+ right(90)
+ penDown()
+ Call forward(h/2.0, colorNo)
+ right(90)
+ Call forward(width, colorNo)
+ penUp()
+ backward(width) : Rem color = ffffff
+ left(90)
+ penDown()
+ Call forward(h/2.0, colorNo)
+ left(180)
+End Sub
+Rem
+Rem Draws letter K in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterK(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim diag As ???
+ Rem
+ width = h/2.0
+ diag = h/sqrt(2.0)
+ Call forward(h, colorNo)
+ penUp()
+ right(90)
+ forward(width) : Rem color = ffffff
+ right(135)
+ penDown()
+ Call forward(diag, colorNo)
+ left(90)
+ Call forward(diag, colorNo)
+ left(135)
+End Sub
+Rem
+Rem Draws letter Y in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterY(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As ???
+ Rem
+ width = h/2.0
+ hypo = sqrt(width*width + h*h)/2.0
+ rotAngle = toDegrees(atan(width/h))
+ penUp()
+ forward(h) : Rem color = ffffff
+ left(rotAngle)
+ penDown()
+ Call forward(-hypo, colorNo)
+ right(rotAngle)
+ penUp()
+ backward(h/2.0) : Rem color = ffffff
+ penDown()
+ Call forward(h/2.0, colorNo)
+ right(rotAngle)
+ Call forward(hypo, colorNo)
+ left(rotAngle)
+ penUp()
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter X in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterX(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ hypo = sqrt(width*width + h*h)
+ rotAngle = toDegrees(atan(width/h))
+ right(rotAngle)
+ Call forward(hypo, colorNo)
+ penUp()
+ left(90+rotAngle)
+ forward(width) : Rem color = ffffff
+ right(90-rotAngle)
+ penDown()
+ Call forward(-hypo, colorNo)
+ right(rotAngle)
+End Sub
+Rem
+Rem Draws letter T in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterT(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Rem
+ width = h/2.0
+ penUp()
+ forward(h) : Rem color = ffffff
+ penDown()
+ right(90)
+ Call forward(width, colorNo)
+ penUp()
+ backward(width/2.0) : Rem color = ffffff
+ penDown()
+ right(90)
+ Call forward(h, colorNo)
+ left(90)
+ penUp()
+ forward(width/2.0) : Rem color = ffffff
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws letter Z in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterZ(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As double
+ Rem
+ width = h/2.0
+ hypo = sqrt(width*width + h*h)
+ rotAngle = toDegrees(atan(width/h))
+ penUp()
+ forward(h) : Rem color = ffffff
+ right(90)
+ penDown()
+ Call forward(width, colorNo)
+ left(90-rotAngle)
+ Call forward(-hypo, colorNo)
+ right(90-rotAngle)
+ Call forward(width, colorNo)
+ left(90)
+End Sub
+Rem
+Rem Draws letter M in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterM(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle As double
+ Dim hypo As ???
+ Rem
+ width = h/2.0
+ hypo = sqrt(width*width + h*h)/2.0
+ rotAngle = toDegrees(atan(width/h))
+ Call forward(h, colorNo)
+ left(rotAngle)
+ Call forward(-hypo, colorNo)
+ right(2*rotAngle)
+ Call forward(hypo, colorNo)
+ left(rotAngle)
+ Call forward(-h, colorNo)
+End Sub
+Rem
+Rem Draws letter Q in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterQ(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ penUp()
+ forward(c) : Rem color = ffffff
+ left(90)
+ forward(b + 2*c) : Rem color = ffffff
+ right(rotAngle)
+ backward(b) : Rem color = ffffff
+ penDown()
+ Call forward(b, colorNo)
+ left(90 + rotAngle)
+End Sub
+Rem
+Rem Draws letter O in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterO(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0)
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ penUp()
+ forward(c) : Rem color = ffffff
+ left(90)
+ forward(b + 2*c) : Rem color = ffffff
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws a question mark in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub qstnMk(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(h-c) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw 5 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, false, 5, colorNo)
+ Call forward(c, colorNo)
+ left(rotAngle)
+ Call forward(b/2.0, colorNo)
+ penUp()
+ forward(c) : Rem color = ffffff
+ left(90)
+ forward(c/2.0) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw all 4 edges of a squarfe with edge length c
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(c, 4, false, 4, colorNo)
+ penUp()
+ forward((c + b)/2.0) : Rem color = ffffff
+ left(90)
+ backward(c) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter C in the colour encoded by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterC(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the outer trinagle at the octagon corner
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Clockwise draws 3 edges of an octagon with edge length b in the colour
+ Rem encoded by colorNo
+ Call polygonPart(b, 8, true, 3, colorNo)
+ left(rotAngle)
+ penUp()
+ forward(2*b + 2*c) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draws 4 edges of an octagon with edge length b
+ Rem iin the colour encoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ penUp()
+ forward(c) : Rem color = ffffff
+ left(90)
+ Call forward(b + 2*c, colorNo)
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws a comma in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub comma(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As double
+ Dim hypo As ???
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ rotAngle = toDegrees(atan(0.5))
+ hypo = c * sqrt(1.25)
+ penUp()
+ right(90)
+ forward((c+b)/2.0 + c) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw 3 edges of a square with edge length c
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(c, 4, true, 3, colorNo)
+ left(90)
+ Call forward(c/2.0, colorNo)
+ right(90)
+ Call forward(c, colorNo)
+ left(180 - rotAngle)
+ Call forward(hypo, colorNo)
+ penUp()
+ right(90 - rotAngle)
+ forward((c + b)/2.0) : Rem color = ffffff
+ left(90)
+ penDown()
+End Sub
+Rem
+Rem Zeichnet den Buchstaben R von der Turtleposition aus
+Rem mit Zeilenhöhe h
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterR(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(c+b, colorNo)
+ Rem Clockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, false, 4, colorNo)
+ Call forward(c, colorNo)
+ left(90 + rotAngle)
+ Call forward(sqrt(2.0)*(b + 2*c), colorNo)
+ left(90 + rotAngle)
+End Sub
+Rem
+Rem Draws a full stop in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub fullSt(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ penUp()
+ right(90)
+ forward((c+b)/2.0 + c) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw all 4 edges of a squarfe with edge length c
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(c, 4, true, 4, colorNo)
+ penUp()
+ forward((c + b)/2.0) : Rem color = ffffff
+ left(90)
+ penDown()
+End Sub
+Rem
+Rem Draws letter G in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterG(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the corner triangle outside the octagon.
+ c = b / sqrt(2.0)
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b in
+ Rem the colour encoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(c, colorNo)
+ left(90)
+ Call forward(b/2.0 + c, colorNo)
+ penUp()
+ backward(b/2.0 + c) : Rem color = ffffff
+ right(90)
+ forward(b + c) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw 4 edges of an octagon with edge length b in
+ Rem the colour encoded by colorNo
+ Call polygonPart(b, 8, true, 4, colorNo)
+ Call forward(b + 2*c, colorNo)
+ penUp()
+ forward(c) : Rem color = ffffff
+ left(90)
+ Call forward(b + 2*c, colorNo)
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws letter D in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterD(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(c+b, colorNo)
+ Rem Clockwise draw 2 edges of an octagon with edge length b in the colour
+ Rem encoded by colorNo
+ Call polygonPart(b, 8, false, 2, colorNo)
+ Call forward(b + 2*c, colorNo)
+ Rem Clockwise draw 2 edges of an octagon with edge length b in the colour
+ Rem encoded by colorNo
+ Call polygonPart(b, 8, false, 2, colorNo)
+ Call forward(c, colorNo)
+ penUp()
+ left(180)
+ forward(b + 2*c) : Rem color = ffffff
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Draws letter P in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterP(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0)
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(c+b, colorNo)
+ Rem Clockwise draw 4 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, false, 4, colorNo)
+ Call forward(c, colorNo)
+ penUp()
+ backward(b + 2*c) : Rem color = ffffff
+ left(90)
+ forward(b + 2*c) : Rem color = ffffff
+ penDown()
+ left(180)
+End Sub
+Rem
+Rem Draws letter U in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterU(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem edge length of a regular octagon
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ Call forward(h - c, colorNo)
+ penUp()
+ backward(h-c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 3 edges of an octagoin with edge length b in colour specified by colorNo
+ Call polygonPart(b, 8, true, 3, colorNo)
+ left(rotAngle)
+ Call forward(h - c, colorNo)
+ penUp()
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter J in colour encoded by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterJ(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 3 edges of an octagon with edge length b in
+ Rem the colour encoded by colorNo
+ Call polygonPart(b, 8, true, 3, colorNo)
+ left(rotAngle)
+ Call forward(h - c, colorNo)
+ penUp()
+ backward(h) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter S in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterS(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim rotAngle As Integer
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ Rem 360°/8
+ rotAngle = 45
+ penUp()
+ forward(c) : Rem color = ffffff
+ penDown()
+ right(180)
+ Rem Counterclockwise draw 6 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, true, 6, colorNo)
+ Rem Clockwise draw 5 edges of an octagon with edge length b
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b, 8, false, 5, colorNo)
+ right(rotAngle)
+ penUp()
+ forward(2*b + 3*c) : Rem color = ffffff
+ penDown()
+ left(180)
+End Sub
+Rem
+Rem Draws a dummy character (small centered square) with font height h and
+Rem the colour encoded by colorNo
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub charDummy(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim d As ???
+ Dim c As ???
+ Dim b As ???
+ Rem
+ width = h / 2.0
+ Rem Octagon edge length (here: edge lengzh of the square)
+ b = width / (sqrt(2.0) + 1)
+ Rem Cathetus of the corner triangle outside the octagon
+ c = (width - b) / 2.0
+ d = b / sqrt(2.0)
+ penUp()
+ forward(h/2.0-b/2.0) : Rem color = ffffff
+ right(90)
+ forward(c) : Rem color = ffffff
+ right(90)
+ penDown()
+ Rem Draws the square with edge length b
+ Call polygonPart(b, 4, true, 4, colorNo)
+ penUp()
+ left(90)
+ forward(b + c) : Rem color = ffffff
+ left(90)
+ backward(h/2.0-b/2.0) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws an exclamation mark in the colour encoded by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub exclMk(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim width As ???
+ Dim rotAngle2 As double
+ Dim rotAngle As Integer
+ Dim length2 As ???
+ Dim length1 As ???
+ Dim hypo As double
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Eckenlänge außen am Achteck
+ c = b / sqrt(2.0)
+ width = h/2.0
+ length1 = h - (b+c)/2.0
+ length2 = length1 - 2*c
+ hypo = sqrt(width*width/16.0 + length2*length2)
+ Rem 360°/8
+ rotAngle = 45
+ rotAngle2 = toDegrees(atan(width/4.0/length2))
+ penUp()
+ forward(length1) : Rem color = ffffff
+ right(90)
+ forward(width/2.0) : Rem color = ffffff
+ left(90 + rotAngle)
+ penDown()
+ Rem Clockwise draw 5 edges of an octagon with edge length b/2
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(b/2.0, 8, false, 5, colorNo)
+ right(rotAngle2)
+ Call forward(hypo, colorNo)
+ left(2*rotAngle2)
+ Call forward(-hypo, colorNo)
+ penUp()
+ forward(hypo) : Rem color = ffffff
+ right(rotAngle2)
+ forward(c) : Rem color = ffffff
+ left(90)
+ forward(c/2.0) : Rem color = ffffff
+ penDown()
+ Rem Counterclockwise draw all 4 edges of a squarfe with edge length c
+ Rem in the colour endcoded by colorNo
+ Call polygonPart(c, 4, false, 4, colorNo)
+ penUp()
+ forward((c + b)/2.0) : Rem color = ffffff
+ left(90)
+ backward(c) : Rem color = ffffff
+ penDown()
+End Sub
+Rem
+Rem Draws letter B in colour specified by colorNo with font height h
+Rem from the current turtle position.
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub letterB(h, colorNo)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim c As ???
+ Dim b As ???
+ Rem
+ Rem Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1)
+ Rem Cathetus of the outer corner triangle of the octagon
+ c = b / sqrt(2.0)
+ Call forward(h, colorNo)
+ right(90)
+ Call forward(c+b, colorNo)
+ Rem Clockwise draw 4 edges of an octagon with edge length b
+ Call polygonPart(b, 8, false, 4, colorNo)
+ Call forward(c, colorNo)
+ penUp()
+ left(180)
+ forward(b + c) : Rem color = ffffff
+ penDown()
+ Rem Clockwise draw 4 edges of an octagon with edge length b
+ Call polygonPart(b, 8, false, 4, colorNo)
+ Call forward(c, colorNo)
+ penUp()
+ left(180)
+ forward(b + 2*c) : Rem color = ffffff
+ penDown()
+ left(90)
+End Sub
+Rem
+Rem Has the turtle draw the given string 'text´ with font height 'h´ (in
+Rem pixels) and the colour coded by integer 'c´ from the current Turtle
+Rem position to the Turtle canvas. If the turtle looks North then
+Rem the text will be written rightwards. In the event, the turtle will be
+Rem placed behind the text in original orientation (such that the next text
+Rem would be written like a continuation. Colour codes:
+Rem 1 = black
+Rem 2 = red
+Rem 3 = yellow
+Rem 4 = green
+Rem 5 = cyan
+Rem 6 = blue
+Rem 7 = pink
+Rem 8 = grey
+Rem 9 = orange
+Rem 10 = violet
+Rem All letters (ASCII) will be converted to uppercase, digits cannot
+Rem be represented, the set of representable special characters is:
+Rem '.', ',', '!', '?'. Other characters will be shown as a small
+Rem centred square (dummy character).
+Rem TODO: Check (and specify if needed) the argument and result types!
+Sub drawText(text AS String, h AS integer, c AS integer)
+ Rem TODO: Check and accomplish your variable declarations here:
+ Dim letter As String
+ Dim k As Integer
+ Dim gap As ???
+ Rem
+ gap = h/10.0
+ For k = 1 To length(text)
+ letter = uppercase(copy(text, k, 1))
+ If letter = "," Then
+ Call comma(h,c)
+ Else
+ Rem "," cannot be chacked against because the comma is misinterpreted
+ Rem as selector list separator.
+ Select Case letter
+ Case "A"
+ Call letterA(h,c)
+ Case "B"
+ Call letterB(h,c)
+ Case "C"
+ Call letterC(h,c)
+ Case "D"
+ Call letterD(h,c)
+ Case "E"
+ Call letterE(h,c)
+ Case "F"
+ Call letterF(h,c)
+ Case "G"
+ Call letterG(h,c)
+ Case "H"
+ Call letterH(h,c)
+ Case "I"
+ Call letterI(h,c)
+ Case "J"
+ Call letterJ(h,c)
+ Case "K"
+ Call letterK(h,c)
+ Case "L"
+ Call letterL(h,c)
+ Case "M"
+ Call letterM(h,c)
+ Case "N"
+ Call letterN(h,c)
+ Case "O"
+ Call letterO(h,c)
+ Case "P"
+ Call letterP(h,c)
+ Case "Q"
+ Call letterQ(h,c)
+ Case "R"
+ Call letterR(h,c)
+ Case "S"
+ Call letterS(h,c)
+ Case "T"
+ Call letterT(h,c)
+ Case "U"
+ Call letterU(h,c)
+ Case "V"
+ Call letterV(h,c)
+ Case "W"
+ Call letterW(h,c)
+ Case "X"
+ Call letterX(h,c)
+ Case "Y"
+ Call letterY(h,c)
+ Case "Z"
+ Call letterZ(h,c)
+ Case " "
+ Call blank(h,c)
+ Case "!"
+ Call exclMk(h,c)
+ Case "?"
+ Call qstnMk(h,c)
+ Case "."
+ Call fullSt(h,c)
+ Case Else
+ Call charDummy(h,c)
+ End Select
+ End If
+ right(90)
+ penUp()
+ forward(gap) : Rem color = ffffff
+ penDown()
+ left(90)
+ Next k
+End Sub
diff --git a/samples/export/C#/ELIZA_2.3.cs b/samples/export/C#/ELIZA_2.3.cs
new file mode 100644
index 00000000..39c0e9f6
--- /dev/null
+++ b/samples/export/C#/ELIZA_2.3.cs
@@ -0,0 +1,488 @@
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2018-05-14 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+
+using System;
+
+
+///
+/// Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+/// "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+/// Computational Linguistis 1(1966)9, pp. 36-45
+/// Revision history:
+/// 2016-10-06 Initial version
+/// 2017-03-29 Two diagrams updated (comments translated to English)
+/// 2017-03-29 More keywords and replies added
+/// 2019-03-14 Replies and mapping reorganised for easier maintenance
+/// 2019-03-15 key map joined from keyword array and index map
+/// 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+/// 2019-11-28 New global type "History" (to ensure a homogenous array)
+///
+public class ELIZA {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // histArray contains the most recent user replies as ring buffer;
+ // histIndex is the index where the next reply is to be stored (= index of the oldest
+ // cached user reply).
+ // Note: The depth of the history is to be specified by initializing a variable of this type,
+ // e.g. for a history of depth 5:
+ // myhistory <- History{{"", "", "", "", ""}, 0}
+ public struct History{
+ public string[] histArray;
+ public int histIndex;
+ public History(string[] p_histArray, int p_histIndex)
+ {
+ histArray = p_histArray;
+ histIndex = p_histIndex;
+ }
+ };
+
+ // Associates a key word in the text with an index in the reply ring array
+ public struct KeyMapEntry{
+ public string keyword;
+ public int index;
+ public KeyMapEntry(string p_keyword, int p_index)
+ {
+ keyword = p_keyword;
+ index = p_index;
+ }
+ };
+
+
+ /// array of command line arguments
+ public static void Main(string[] args) {
+
+ // BEGIN initialization for "History"
+ // END initialization for "History"
+ // BEGIN initialization for "KeyMapEntry"
+ // END initialization for "KeyMapEntry"
+
+ // TODO: Check and accomplish variable declarations:
+ string varPart;
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ string userInput;
+ string reply;
+ int posAster;
+ int[] offsets;
+ bool isRepeated;
+ bool isGone;
+ int[] findInfo;
+
+
+ // TODO: You may have to modify input instructions,
+ // possibly by enclosing Console.ReadLine() calls with
+ // Parse methods according to the variable type, e.g.:
+ // i = int.Parse(Console.ReadLine());
+
+ // Title information
+ Console.WriteLine("************* ELIZA **************");
+ Console.WriteLine("* Original design by J. Weizenbaum");
+ Console.WriteLine("**********************************");
+ Console.WriteLine("* Adapted for Basic on IBM PC by");
+ Console.WriteLine("* - Patricia Danielson");
+ Console.WriteLine("* - Paul Hashfield");
+ Console.WriteLine("**********************************");
+ Console.WriteLine("* Adapted for Structorizer by");
+ Console.WriteLine("* - Kay Gürtzig / FH Erfurt 2016");
+ Console.WriteLine("* Version: 2.3 (2019-11-28)");
+ Console.WriteLine("* (Requires at least Structorizer 3.30-03 to run)");
+ Console.WriteLine("**********************************");
+ // Stores the last five inputs of the user in a ring buffer,
+ // the second component is the rolling (over-)write index.
+ History history = new History(new string[]{"", "", "", "", ""}, 0);
+ const string[,] replies = setupReplies();
+ const string[,] reflexions = setupReflexions();
+ const string[,] byePhrases = setupGoodByePhrases();
+ const KeyMapEntry[] keyMap = setupKeywords();
+ offsets[length(keyMap)-1] = 0;
+ isGone = false;
+ // Starter
+ Console.WriteLine("Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?");
+ do {
+ userInput = Console.ReadLine();
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ userInput = normalizeInput(userInput);
+ isGone = checkGoodBye(userInput, byePhrases);
+ if (! isGone) {
+ reply = "Please don\'t repeat yourself!";
+ isRepeated = checkRepetition(history, userInput);
+ if (! isRepeated) {
+ findInfo = findKeyword(keyMap, userInput);
+ ??? keyIndex = findInfo[0];
+ if (keyIndex < 0) {
+ // Should never happen...
+ keyIndex = length(keyMap)-1;
+ }
+ KeyMapEntry entry = keyMap[keyIndex];
+ // Variable part of the reply
+ varPart = "";
+ if (length(entry.keyword) > 0) {
+ varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions);
+ }
+ ??? replyRing = replies[entry.index];
+ reply = replyRing[offsets[keyIndex]];
+ offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing);
+ posAster = pos("*", reply);
+ if (posAster > 0) {
+ if (varPart == " ") {
+ reply = "You will have to elaborate more for me to help you.";
+ }
+ else {
+ delete(reply, posAster, 1);
+ insert(varPart, reply, posAster);
+ }
+ }
+ reply = adjustSpelling(reply);
+ }
+ Console.WriteLine(reply);
+ }
+ } while (!(isGone));
+ }
+
+ ///
+ /// Cares for correct letter case among others
+ ///
+ /// TODO
+ /// TODO
+ private static string adjustSpelling(string sentence) {
+ // TODO: Check and accomplish variable declarations:
+ string word;
+ string start;
+ string result;
+ int position;
+
+
+ result = sentence;
+ position = 1;
+ while ((position <= length(sentence)) && (copy(sentence, position, 1) == " ")) {
+ position = position + 1;
+ }
+ if (position <= length(sentence)) {
+ start = copy(sentence, 1, position);
+ delete(result, 1, position);
+ insert(uppercase(start), result, 1);
+ }
+ foreach (String word in new String[]{" i ", " i\'"}) {
+ position = pos(word, result);
+ while (position > 0) {
+ delete(result, position+1, 1);
+ insert("I", result, position+1);
+ position = pos(word, result);
+ }
+ }
+
+ return result;
+ }
+
+ ///
+ /// Checks whether the given text contains some kind of
+ /// good-bye phrase inducing the end of the conversation
+ /// and if so writes a correspding good-bye message and
+ /// returns true, otherwise false
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ private static bool checkGoodBye(string text, string[,] phrases) {
+ // TODO: Check and accomplish variable declarations:
+ bool saidBye;
+ string[] pair;
+
+
+ foreach (@string pair in phrases) {
+ if (pos(pair[0], text) > 0) {
+ saidBye = true;
+ Console.WriteLine(pair[1]);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// Checks whether newInput has occurred among the recently cached
+ /// input strings in the histArray component of history and updates the history.
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ private static bool checkRepetition(History history, string newInput) {
+ // TODO: Check and accomplish variable declarations:
+ int histDepth;
+ bool hasOccurred;
+
+
+ hasOccurred = false;
+ if (length(newInput) > 4) {
+ histDepth = length(history.histArray);
+ for (int i = 0; i <= histDepth-1; i += (1)) {
+ if (newInput == history.histArray[i]) {
+ hasOccurred = true;
+ }
+ }
+ history.histArray[history.histIndex] = newInput;
+ history.histIndex = (history.histIndex + 1) % (histDepth);
+ }
+ return hasOccurred;
+ }
+
+ ///
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ /// TODO
+ /// TODO
+ private static string conjugateStrings(string sentence, string key, int keyPos, string[,] flexions) {
+ // TODO: Check and accomplish variable declarations:
+ string right;
+ string result;
+ int position;
+ string[] pair;
+ string left;
+
+
+ result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " ";
+ foreach (@string pair in flexions) {
+ left = "";
+ right = result;
+ position = pos(pair[0], right);
+ while (position > 0) {
+ left = left + copy(right, 1, position-1) + pair[1];
+ right = copy(right, position + length(pair[0]), length(right));
+ position = pos(pair[0], right);
+ }
+ result = left + right;
+ }
+ // Eliminate multiple spaces
+ position = pos(" ", result);
+ while (position > 0) {
+ result = copy(result, 1, position-1) + copy(result, position+1, length(result));
+ position = pos(" ", result);
+ }
+
+ return result;
+ }
+
+ ///
+ /// Looks for the occurrence of the first of the strings
+ /// contained in keywords within the given sentence (in
+ /// array order).
+ /// Returns an array of
+ /// 0: the index of the first identified keyword (if any, otherwise -1),
+ /// 1: the position inside sentence (0 if not found)
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ private static int[] findKeyword(const array of KeyMapEntry keyMap, string sentence) {
+ // TODO: Check and accomplish variable declarations:
+ int[] result;
+ int position;
+ int i;
+
+
+ // Contains the index of the keyword and its position in sentence
+ result = new int[]{-1, 0};
+ i = 0;
+ while ((result[0] < 0) && (i < length(keyMap))) {
+ KeyMapEntry entry = keyMap[i];
+ position = pos(entry.keyword, sentence);
+ if (position > 0) {
+ result[0] = i;
+ result[1] = position;
+ }
+ i = i+1;
+ }
+
+ return result;
+ }
+
+ ///
+ /// Converts the sentence to lowercase, eliminates all
+ /// interpunction (i.e. ',', '.', ';'), and pads the
+ /// sentence among blanks
+ ///
+ /// TODO
+ /// TODO
+ private static string normalizeInput(string sentence) {
+ // TODO: Check and accomplish variable declarations:
+ string symbol;
+ string result;
+ int position;
+
+
+ sentence = lowercase(sentence);
+ foreach (String symbol in new String[]{'.', ',', ';', '!', '?'}) {
+ position = pos(symbol, sentence);
+ while (position > 0) {
+ sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence));
+ position = pos(symbol, sentence);
+ }
+ }
+ result = " " + sentence + " ";
+
+ return result;
+ }
+
+ ///
+ ///
+ /// TODO
+ private static string[,] setupGoodByePhrases() {
+ // TODO: Check and accomplish variable declarations:
+ string[,] phrases;
+
+
+ phrases[0] = new string[]{" shut", "Okay. If you feel that way I\'ll shut up. ... Your choice."};
+ phrases[1] = new string[]{"bye", "Well, let\'s end our talk for now. See you later. Bye."};
+ return phrases;
+ }
+
+ ///
+ /// The lower the index the higher the rank of the keyword (search is sequential).
+ /// The index of the first keyword found in a user sentence maps to a respective
+ /// reply ring as defined in `setupReplies()´.
+ ///
+ /// TODO
+ private static KeyMapEntry[] setupKeywords() {
+ // TODO: Check and accomplish variable declarations:
+ // The empty key string (last entry) is the default clause - will always be found
+ KeyMapEntry[] keywords;
+
+
+ // The empty key string (last entry) is the default clause - will always be found
+ keywords[39] = new KeyMapEntry("", 29);
+ keywords[0] = new KeyMapEntry("can you ", 0);
+ keywords[1] = new KeyMapEntry("can i ", 1);
+ keywords[2] = new KeyMapEntry("you are ", 2);
+ keywords[3] = new KeyMapEntry("you\'re ", 2);
+ keywords[4] = new KeyMapEntry("i don't ", 3);
+ keywords[5] = new KeyMapEntry("i feel ", 4);
+ keywords[6] = new KeyMapEntry("why don\'t you ", 5);
+ keywords[7] = new KeyMapEntry("why can\'t i ", 6);
+ keywords[8] = new KeyMapEntry("are you ", 7);
+ keywords[9] = new KeyMapEntry("i can\'t ", 8);
+ keywords[10] = new KeyMapEntry("i am ", 9);
+ keywords[11] = new KeyMapEntry("i\'m ", 9);
+ keywords[12] = new KeyMapEntry("you ", 10);
+ keywords[13] = new KeyMapEntry("i want ", 11);
+ keywords[14] = new KeyMapEntry("what ", 12);
+ keywords[15] = new KeyMapEntry("how ", 12);
+ keywords[16] = new KeyMapEntry("who ", 12);
+ keywords[17] = new KeyMapEntry("where ", 12);
+ keywords[18] = new KeyMapEntry("when ", 12);
+ keywords[19] = new KeyMapEntry("why ", 12);
+ keywords[20] = new KeyMapEntry("name ", 13);
+ keywords[21] = new KeyMapEntry("cause ", 14);
+ keywords[22] = new KeyMapEntry("sorry ", 15);
+ keywords[23] = new KeyMapEntry("dream ", 16);
+ keywords[24] = new KeyMapEntry("hello ", 17);
+ keywords[25] = new KeyMapEntry("hi ", 17);
+ keywords[26] = new KeyMapEntry("maybe ", 18);
+ keywords[27] = new KeyMapEntry(" no", 19);
+ keywords[28] = new KeyMapEntry("your ", 20);
+ keywords[29] = new KeyMapEntry("always ", 21);
+ keywords[30] = new KeyMapEntry("think ", 22);
+ keywords[31] = new KeyMapEntry("alike ", 23);
+ keywords[32] = new KeyMapEntry("yes ", 24);
+ keywords[33] = new KeyMapEntry("friend ", 25);
+ keywords[34] = new KeyMapEntry("computer", 26);
+ keywords[35] = new KeyMapEntry("bot ", 26);
+ keywords[36] = new KeyMapEntry("smartphone", 27);
+ keywords[37] = new KeyMapEntry("father ", 28);
+ keywords[38] = new KeyMapEntry("mother ", 28);
+ return keywords;
+ }
+
+ ///
+ /// Returns an array of pairs of mutualy substitutable
+ ///
+ /// TODO
+ private static string[,] setupReflexions() {
+ // TODO: Check and accomplish variable declarations:
+ string[,] reflexions;
+
+
+ reflexions[0] = new string[]{" are ", " am "};
+ reflexions[1] = new string[]{" were ", " was "};
+ reflexions[2] = new string[]{" you ", " I "};
+ reflexions[3] = new string[]{" your", " my"};
+ reflexions[4] = new string[]{" i\'ve ", " you\'ve "};
+ reflexions[5] = new string[]{" i\'m ", " you\'re "};
+ reflexions[6] = new string[]{" me ", " you "};
+ reflexions[7] = new string[]{" my ", " your "};
+ reflexions[8] = new string[]{" i ", " you "};
+ reflexions[9] = new string[]{" am ", " are "};
+ return reflexions;
+ }
+
+ ///
+ /// This routine sets up the reply rings addressed by the key words defined in
+ /// routine `setupKeywords()´ and mapped hitherto by the cross table defined
+ /// in `setupMapping()´
+ ///
+ /// TODO
+ private static string[,] setupReplies() {
+ // TODO: Check and accomplish variable declarations:
+ string[,] setupReplies;
+
+
+ String[,] replies;
+ // We start with the highest index for performance reasons
+ // (is to avoid frequent array resizing)
+ replies[29] = new string[]{"Say, do you have any psychological problems?", "What does that suggest to you?", "I see.", "I'm not sure I understand you fully.", "Come come elucidate your thoughts.", "Can you elaborate on that?", "That is quite interesting."};
+ replies[0] = new string[]{"Don't you believe that I can*?", "Perhaps you would like to be like me?", "You want me to be able to*?"};
+ replies[1] = new string[]{"Perhaps you don't want to*?", "Do you want to be able to*?"};
+ replies[2] = new string[]{"What makes you think I am*?", "Does it please you to believe I am*?", "Perhaps you would like to be*?", "Do you sometimes wish you were*?"};
+ replies[3] = new string[]{"Don't you really*?", "Why don't you*?", "Do you wish to be able to*?", "Does that trouble you*?"};
+ replies[4] = new string[]{"Do you often feel*?", "Are you afraid of feeling*?", "Do you enjoy feeling*?"};
+ replies[5] = new string[]{"Do you really believe I don't*?", "Perhaps in good time I will*.", "Do you want me to*?"};
+ replies[6] = new string[]{"Do you think you should be able to*?", "Why can't you*?"};
+ replies[7] = new string[]{"Why are you interested in whether or not I am*?", "Would you prefer if I were not*?", "Perhaps in your fantasies I am*?"};
+ replies[8] = new string[]{"How do you know you can't*?", "Have you tried?", "Perhaps you can now*."};
+ replies[9] = new string[]{"Did you come to me because you are*?", "How long have you been*?", "Do you believe it is normal to be*?", "Do you enjoy being*?"};
+ replies[10] = new string[]{"We were discussing you--not me.", "Oh, I*.", "You're not really talking about me, are you?"};
+ replies[11] = new string[]{"What would it mean to you if you got*?", "Why do you want*?", "Suppose you soon got*...", "What if you never got*?", "I sometimes also want*."};
+ replies[12] = new string[]{"Why do you ask?", "Does that question interest you?", "What answer would please you the most?", "What do you think?", "Are such questions on your mind often?", "What is it that you really want to know?", "Have you asked anyone else?", "Have you asked such questions before?", "What else comes to mind when you ask that?"};
+ replies[13] = new string[]{"Names don't interest me.", "I don't care about names -- please go on."};
+ replies[14] = new string[]{"Is that the real reason?", "Don't any other reasons come to mind?", "Does that reason explain anything else?", "What other reasons might there be?"};
+ replies[15] = new string[]{"Please don't apologize!", "Apologies are not necessary.", "What feelings do you have when you apologize?", "Don't be so defensive!"};
+ replies[16] = new string[]{"What does that dream suggest to you?", "Do you dream often?", "What persons appear in your dreams?", "Are you disturbed by your dreams?"};
+ replies[17] = new string[]{"How do you do ...please state your problem."};
+ replies[18] = new string[]{"You don't seem quite certain.", "Why the uncertain tone?", "Can't you be more positive?", "You aren't sure?", "Don't you know?"};
+ replies[19] = new string[]{"Are you saying no just to be negative?", "You are being a bit negative.", "Why not?", "Are you sure?", "Why no?"};
+ replies[20] = new string[]{"Why are you concerned about my*?", "What about your own*?"};
+ replies[21] = new string[]{"Can you think of a specific example?", "When?", "What are you thinking of?", "Really, always?"};
+ replies[22] = new string[]{"Do you really think so?", "But you are not sure you*?", "Do you doubt you*?"};
+ replies[23] = new string[]{"In what way?", "What resemblance do you see?", "What does the similarity suggest to you?", "What other connections do you see?", "Could there really be some connection?", "How?", "You seem quite positive."};
+ replies[24] = new string[]{"Are you sure?", "I see.", "I understand."};
+ replies[25] = new string[]{"Why do you bring up the topic of friends?", "Do your friends worry you?", "Do your friends pick on you?", "Are you sure you have any friends?", "Do you impose on your friends?", "Perhaps your love for friends worries you."};
+ replies[26] = new string[]{"Do computers worry you?", "Are you talking about me in particular?", "Are you frightened by machines?", "Why do you mention computers?", "What do you think machines have to do with your problem?", "Don't you think computers can help people?", "What is it about machines that worries you?"};
+ replies[27] = new string[]{"Do you sometimes feel uneasy without a smartphone?", "Have you had these phantasies before?", "Does the world seem more real for you via apps?"};
+ replies[28] = new string[]{"Tell me more about your family.", "Who else in your family*?", "What does family relations mean for you?", "Come on, How old are you?"};
+ setupReplies = replies;
+
+ return setupReplies;
+ }
+
+}
diff --git a/samples/export/C#/SORTING_TEST_MAIN.cs b/samples/export/C#/SORTING_TEST_MAIN.cs
index 0f0d7bf7..725858b2 100644
--- a/samples/export/C#/SORTING_TEST_MAIN.cs
+++ b/samples/export/C#/SORTING_TEST_MAIN.cs
@@ -1,4 +1,4 @@
-// Generated by Structorizer 3.30-02
+// Generated by Structorizer 3.30-03
//
// Copyright (C) 2019-10-02 Kay Gürtzig
// License: GPLv3-link
@@ -20,10 +20,10 @@
public class SORTING_TEST_MAIN {
// =========== START PARALLEL WORKER DEFINITIONS ============
- class Worker4f085546_0{
+ class Worker247e34b9_0{
// TODO: Check and accomplish the member declarations here
- private /*type?*/ values1;
- public Worker4f085546_0(/*type?*/ values1)
+ private int[] values1;
+ public Worker247e34b9_0(int[] values1)
{
this.values1 = values1;
}
@@ -33,11 +33,11 @@ public void DoWork()
}
};
- class Worker4f085546_1{
+ class Worker247e34b9_1{
// TODO: Check and accomplish the member declarations here
- private /*type?*/ values2;
- private /*type?*/ elementCount;
- public Worker4f085546_1(/*type?*/ values2, /*type?*/ elementCount)
+ private ???[] values2;
+ private ??? elementCount;
+ public Worker247e34b9_1(???[] values2, ??? elementCount)
{
this.values2 = values2;
this.elementCount = elementCount;
@@ -48,10 +48,10 @@ public void DoWork()
}
};
- class Worker4f085546_2{
+ class Worker247e34b9_2{
// TODO: Check and accomplish the member declarations here
- private /*type?*/ values3;
- public Worker4f085546_2(/*type?*/ values3)
+ private ???[] values3;
+ public Worker247e34b9_2(???[] values3)
{
this.values3 = values3;
}
@@ -68,12 +68,12 @@ public void DoWork()
// =========== START PARALLEL WORKER DEFINITIONS ============
- class Worker3dfab37d_0{
+ class Worker7fed1521_0{
// TODO: Check and accomplish the member declarations here
- private /*type?*/ values;
- private /*type?*/ start;
- private /*type?*/ p;
- public Worker3dfab37d_0(/*type?*/ values, /*type?*/ start, /*type?*/ p)
+ private ??? values;
+ private ??? start;
+ private ??? p;
+ public Worker7fed1521_0(??? values, ??? start, ??? p)
{
this.values = values;
this.start = start;
@@ -86,12 +86,12 @@ public void DoWork()
}
};
- class Worker3dfab37d_1{
+ class Worker7fed1521_1{
// TODO: Check and accomplish the member declarations here
- private /*type?*/ values;
- private /*type?*/ p;
- private /*type?*/ stop;
- public Worker3dfab37d_1(/*type?*/ values, /*type?*/ p, /*type?*/ stop)
+ private ??? values;
+ private ??? p;
+ private ??? stop;
+ public Worker7fed1521_1(??? values, ??? p, ??? stop)
{
this.values = values;
this.p = p;
@@ -112,10 +112,13 @@ public void DoWork()
public static void Main(string[] args) {
// TODO: Check and accomplish variable declarations:
- ??? values3;
- ??? values2;
- ??? values1;
+ ???[] values3;
+ ???[] values2;
+ int[] values1;
??? show;
+ bool ok3;
+ bool ok2;
+ bool ok1;
??? modus;
??? elementCount;
@@ -144,7 +147,7 @@ public static void Main(string[] args) {
break;
}
}
- // Kopiere das Array für exakte Vergleichbarkeit
+ // Copy the array for exact comparability
for (int i = 0; i <= elementCount-1; i += (1)) {
values2[i] = values1[i];
values3[i] = values1[i];
@@ -154,21 +157,21 @@ public static void Main(string[] args) {
// ================= START PARALLEL SECTION =================
// ==========================================================
{
- Worker4f085546_0 worker4f085546_0 = new Worker4f085546_0(values1);
- Thread thr4f085546_0 = new Thread(worker4f085546_0.DoWork);
- thr4f085546_0.Start();
+ Worker247e34b9_0 worker247e34b9_0 = new Worker247e34b9_0(values1);
+ Thread thr247e34b9_0 = new Thread(worker247e34b9_0.DoWork);
+ thr247e34b9_0.Start();
- Worker4f085546_1 worker4f085546_1 = new Worker4f085546_1(values2, elementCount);
- Thread thr4f085546_1 = new Thread(worker4f085546_1.DoWork);
- thr4f085546_1.Start();
+ Worker247e34b9_1 worker247e34b9_1 = new Worker247e34b9_1(values2, elementCount);
+ Thread thr247e34b9_1 = new Thread(worker247e34b9_1.DoWork);
+ thr247e34b9_1.Start();
- Worker4f085546_2 worker4f085546_2 = new Worker4f085546_2(values3);
- Thread thr4f085546_2 = new Thread(worker4f085546_2.DoWork);
- thr4f085546_2.Start();
+ Worker247e34b9_2 worker247e34b9_2 = new Worker247e34b9_2(values3);
+ Thread thr247e34b9_2 = new Thread(worker247e34b9_2.DoWork);
+ thr247e34b9_2.Start();
- thr4f085546_0.Join();
- thr4f085546_1.Join();
- thr4f085546_2.Join();
+ thr247e34b9_0.Join();
+ thr247e34b9_1.Join();
+ thr247e34b9_2.Join();
}
// ==========================================================
// ================== END PARALLEL SECTION ==================
@@ -203,16 +206,16 @@ public static void Main(string[] args) {
/// subrange.
///
/// TODO
- private static void bubbleSort(/*type?*/ values) {
+ private static void bubbleSort(??? values) {
// TODO: Check and accomplish variable declarations:
- ende = length(values) - 2;
+ ??? ende = length(values) - 2;
do {
// The index of the most recent swapping (-1 means no swapping done).
- posSwapped = -1;
+ ??? posSwapped = -1;
for (int i = 0; i <= ende; i += (1)) {
if (values[i] > values[i+1]) {
- temp = values[i];
+ ??? temp = values[i];
values[i] = values[i+1];
values[i+1] = temp;
posSwapped = i;
@@ -231,14 +234,14 @@ private static void bubbleSort(/*type?*/ values) {
/// TODO
/// TODO
/// TODO
- private static void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range) {
+ private static void maxHeapify(??? heap, ??? i, ??? range) {
// TODO: Check and accomplish variable declarations:
// Indices of left and right child of node i
- right = (i+1) * 2;
- left = right - 1;
+ ??? right = (i+1) * 2;
+ ??? left = right - 1;
// Index of the (local) maximum
- max = i;
+ ??? max = i;
if (left < range && heap[left] > heap[i]) {
max = left;
}
@@ -246,7 +249,7 @@ private static void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range) {
max = right;
}
if (max != i) {
- temp = heap[i];
+ ??? temp = heap[i];
heap[i] = heap[max];
heap[max] = temp;
maxHeapify(heap, max, range);
@@ -268,10 +271,10 @@ private static void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range) {
/// TODO
/// TODO
/// TODO
- private static int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p) {
+ private static int partition(??? values, ??? start, ??? stop, ??? p) {
// TODO: Check and accomplish variable declarations:
- pivot = values[p];
+ ??? pivot = values[p];
// Tausche das Pivot-Element an den start
values[p] = values[start];
values[start] = pivot;
@@ -281,7 +284,7 @@ private static int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop,
stop = stop - 1;
// Still unseen elements?
while (stop >= start) {
- seen = values[start];
+ ??? seen = values[start];
if (values[start] <= pivot) {
// Swap pivot element with start element
values[p] = seen;
@@ -304,7 +307,7 @@ private static int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop,
///
/// TODO
/// TODO
- private static bool testSorted(/*type?*/ numbers) {
+ private static bool testSorted(??? numbers) {
// TODO: Check and accomplish variable declarations:
bool isSorted;
int i;
@@ -333,7 +336,7 @@ private static bool testSorted(/*type?*/ numbers) {
///
/// TODO
/// TODO
- private static int buildMaxHeap(/*type?*/ heap) {
+ private static int buildMaxHeap(??? heap) {
// TODO: Check and accomplish variable declarations:
int lgth;
@@ -355,14 +358,14 @@ private static int buildMaxHeap(/*type?*/ heap) {
/// TODO
/// TODO
/// TODO
- private static int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop) {
+ private static int quickSort(??? values, ??? start, ??? stop) {
// TODO: Check and accomplish variable declarations:
// At least 2 elements? (Less don't make sense.)
if (stop >= start + 2) {
// Select a pivot element, be p its index.
// (here: randomly chosen element out of start ... stop-1)
- p = random(stop-start) + start;
+ ??? p = random(stop-start) + start;
// Partition the array into smaller and greater elements
// Get the resulting (and final) position of the pivot element
// Partition the array into smaller and greater elements
@@ -374,16 +377,16 @@ private static int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
// ================= START PARALLEL SECTION =================
// ==========================================================
{
- Worker3dfab37d_0 worker3dfab37d_0 = new Worker3dfab37d_0(values, start, p);
- Thread thr3dfab37d_0 = new Thread(worker3dfab37d_0.DoWork);
- thr3dfab37d_0.Start();
+ Worker7fed1521_0 worker7fed1521_0 = new Worker7fed1521_0(values, start, p);
+ Thread thr7fed1521_0 = new Thread(worker7fed1521_0.DoWork);
+ thr7fed1521_0.Start();
- Worker3dfab37d_1 worker3dfab37d_1 = new Worker3dfab37d_1(values, p, stop);
- Thread thr3dfab37d_1 = new Thread(worker3dfab37d_1.DoWork);
- thr3dfab37d_1.Start();
+ Worker7fed1521_1 worker7fed1521_1 = new Worker7fed1521_1(values, p, stop);
+ Thread thr7fed1521_1 = new Thread(worker7fed1521_1.DoWork);
+ thr7fed1521_1.Start();
- thr3dfab37d_0.Join();
- thr3dfab37d_1.Join();
+ thr7fed1521_0.Join();
+ thr7fed1521_1.Join();
}
// ==========================================================
// ================== END PARALLEL SECTION ==================
@@ -400,7 +403,7 @@ private static int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
///
/// TODO
/// TODO
- private static int heapSort(/*type?*/ values) {
+ private static int heapSort(??? values) {
// TODO: Check and accomplish variable declarations:
int heapRange;
@@ -410,7 +413,7 @@ private static int heapSort(/*type?*/ values) {
for (int k = heapRange - 1; k >= 1; k += (-1)) {
heapRange = heapRange - 1;
// Swap the maximum value (root of the heap) to the heap end
- maximum = values[0];
+ ??? maximum = values[0];
values[0] = values[heapRange];
values[heapRange] = maximum;
maxHeapify(values, 0, heapRange);
diff --git a/samples/export/C#/TextDemo.cs b/samples/export/C#/TextDemo.cs
new file mode 100644
index 00000000..4b87bd61
--- /dev/null
+++ b/samples/export/C#/TextDemo.cs
@@ -0,0 +1,1302 @@
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2019-10-10 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+
+using System;
+
+
+///
+/// Demo program for routine drawText()
+/// Asks the user to enter a text, a wanted text height and colour,
+/// and then draws this string onto the turtle screen. Places every
+/// entered text to a new line.
+///
+public class TextDemo {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /// array of command line arguments
+ public static void Main(string[] args) {
+
+ // TODO: Check and accomplish variable declarations:
+ int y;
+ ??? height;
+ ??? colour;
+
+
+ // TODO: You may have to modify input instructions,
+ // possibly by enclosing Console.ReadLine() calls with
+ // Parse methods according to the variable type, e.g.:
+ // i = int.Parse(Console.ReadLine());
+
+ Console.WriteLine("This is a demo program for text writing with Turleizer.");
+ showTurtle();
+ penDown();
+ y = 0;
+ do {
+ Console.Write("Enter some text (empty string to exit)"); text = Console.ReadLine();
+ // Make sure the content is interpreted as string
+ ??? text = "" + text;
+ if (text != "") {
+ do {
+ Console.Write("Height of the text (pixels)"); height = Console.ReadLine();
+ } while (!(height >= 5));
+ do {
+ Console.Write("Colour (1=black, 2=red, 3=yellow, 4=green, 5=cyan, 6=blue, 7=pink, 8=gray, 9=orange, 10=violet)"); colour = Console.ReadLine();
+ } while (!(colour >= 1 && colour <= 10));
+ y = y + height + 2;
+ gotoXY(0, y - 2);
+ drawText(text, height, colour);
+ }
+ } while (!(text == ""));
+ gotoXY(0, y + 15);
+ drawText("Thank you, bye.", 10, 4);
+ hideTurtle();
+ }
+
+ ///
+ /// Draws a blank for font height h, ignoring the colorNo
+ ///
+ /// TODO
+ /// TODO
+ private static void blank(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ left(90);
+ }
+
+ ///
+ ///
+ /// TODO
+ /// TODO
+ private static void forward(??? len, ??? color) {
+ // TODO: Check and accomplish variable declarations:
+
+ switch (color) {
+ case 1:
+ forward(len); // color = ffffff
+ break;
+ case 2:
+ forward(len); // color = ff8080
+ break;
+ case 3:
+ forward(len); // color = ffff80
+ break;
+ case 4:
+ forward(len); // color = 80ff80
+ break;
+ case 5:
+ forward(len); // color = 80ffff
+ break;
+ case 6:
+ forward(len); // color = 0080ff
+ break;
+ case 7:
+ forward(len); // color = ff80c0
+ break;
+ case 8:
+ forward(len); // color = c0c0c0
+ break;
+ case 9:
+ forward(len); // color = ff8000
+ break;
+ case 10:
+ forward(len); // color = 8080ff
+ break;
+ }
+ }
+
+ ///
+ /// Draws letter A in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterA(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ right(rotAngle);
+ forward(hypo/2.0, colorNo);
+ right(90 - rotAngle);
+ forward(width/2.0, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ left(90 - rotAngle);
+ forward(hypo/2.0, colorNo);
+ left(2*rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ }
+
+ ///
+ /// Draws letter E in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterE(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ }
+
+ ///
+ /// Draws letter F in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterF(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ forward(width); // color = ffffff
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter H in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterH(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width); // color = ffffff
+ left(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ left(180);
+ }
+
+ ///
+ /// Draws letter I in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterI(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward(c); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ backward(b/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ backward(b/2.0); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ forward(b/2 + c); // color = ffffff
+ left(90);
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter K in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterK(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ ??? diag = h/sqrt(2.0);
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(135);
+ penDown();
+ forward(diag, colorNo);
+ left(90);
+ forward(diag, colorNo);
+ left(135);
+ }
+
+ ///
+ /// Draws letter L in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterL(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ }
+
+ ///
+ /// Draws letter M in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterM(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ ??? width = h/2.0;
+ ??? hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ forward(-h, colorNo);
+ }
+
+ ///
+ /// Draws letter N in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterN(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter T in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterT(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ penUp();
+ forward(h); // color = ffffff
+ penDown();
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ right(90);
+ forward(h, colorNo);
+ left(90);
+ penUp();
+ forward(width/2.0); // color = ffffff
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter V in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterV(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter W in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterW(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ ??? width_3 = width/3.0;
+ hypo = sqrt(width_3*width_3 + h*h);
+ rotAngle = toDegrees(atan(width_3/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width_3); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter X in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterX(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ right(rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ }
+
+ ///
+ /// Draws letter Y in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterY(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ ??? width = h/2.0;
+ ??? hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ penUp();
+ backward(h/2.0); // color = ffffff
+ penDown();
+ forward(h/2.0, colorNo);
+ right(rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter Z in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterZ(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90-rotAngle);
+ forward(-hypo, colorNo);
+ right(90-rotAngle);
+ forward(width, colorNo);
+ left(90);
+ }
+
+ ///
+ /// Draws nEdges edges of a regular n-polygon with edge length a
+ /// counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ /// TODO
+ /// TODO
+ private static void polygonPart(double a, int n, bool ctrclkws, int nEdges, int color) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? rotAngle = 360.0/n;
+ if (ctrclkws) {
+ rotAngle = -rotAngle;
+ }
+ for (int k = 1; k <= nEdges; k += (1)) {
+ right(rotAngle);
+ forward(a, color);
+ }
+ }
+
+ ///
+ /// Draws a dummy character (small centered square) with font height h and
+ /// the colour encoded by colorNo
+ ///
+ /// TODO
+ /// TODO
+ private static void charDummy(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h / 2.0;
+ // Octagon edge length (here: edge lengzh of the square)
+ ??? b = width / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = (width - b) / 2.0;
+ ??? d = b / sqrt(2.0);
+ penUp();
+ forward(h/2.0-b/2.0); // color = ffffff
+ right(90);
+ forward(c); // color = ffffff
+ right(90);
+ penDown();
+ // Draws the square with edge length b
+ polygonPart(b, 4, true, 4, colorNo);
+ penUp();
+ left(90);
+ forward(b + c); // color = ffffff
+ left(90);
+ backward(h/2.0-b/2.0); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws a comma in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void comma(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ rotAngle = toDegrees(atan(0.5));
+ ??? hypo = c * sqrt(1.25);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 3 edges of a square with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 3, colorNo);
+ left(90);
+ forward(c/2.0, colorNo);
+ right(90);
+ forward(c, colorNo);
+ left(180 - rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ right(90 - rotAngle);
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+ }
+
+ ///
+ /// Draws an exclamation mark in the colour encoded by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void exclMk(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle2;
+ // 360°/8
+ int rotAngle;
+ double hypo;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ ??? width = h/2.0;
+ ??? length1 = h - (b+c)/2.0;
+ ??? length2 = length1 - 2*c;
+ hypo = sqrt(width*width/16.0 + length2*length2);
+ // 360°/8
+ rotAngle = 45;
+ rotAngle2 = toDegrees(atan(width/4.0/length2));
+ penUp();
+ forward(length1); // color = ffffff
+ right(90);
+ forward(width/2.0); // color = ffffff
+ left(90 + rotAngle);
+ penDown();
+ // Clockwise draw 5 edges of an octagon with edge length b/2
+ // in the colour endcoded by colorNo
+ polygonPart(b/2.0, 8, false, 5, colorNo);
+ right(rotAngle2);
+ forward(hypo, colorNo);
+ left(2*rotAngle2);
+ forward(-hypo, colorNo);
+ penUp();
+ forward(hypo); // color = ffffff
+ right(rotAngle2);
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws a full stop in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void fullSt(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+ }
+
+ ///
+ /// Draws letter B in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterB(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer corner triangle of the octagon
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter C in the colour encoded by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterC(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer trinagle at the octagon corner
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Clockwise draws 3 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ penUp();
+ forward(2*b + 2*c); // color = ffffff
+ penDown();
+ // Counterclockwise draws 4 edges of an octagon with edge length b
+ // iin the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter D in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterD(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(b + 2*c, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter G in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterG(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon.
+ ??? c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(c, colorNo);
+ left(90);
+ forward(b/2.0 + c, colorNo);
+ penUp();
+ backward(b/2.0 + c); // color = ffffff
+ right(90);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter J in colour encoded by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterJ(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws letter O in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterO(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+ }
+
+ ///
+ /// Draws letter P in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterP(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ backward(b + 2*c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(180);
+ }
+
+ ///
+ /// Draws letter Q in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterQ(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ right(rotAngle);
+ backward(b); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ left(90 + rotAngle);
+ }
+
+ ///
+ /// Zeichnet den Buchstaben R von der Turtleposition aus
+ /// mit Zeilenhöhe h
+ ///
+ /// TODO
+ /// TODO
+ private static void letterR(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ left(90 + rotAngle);
+ forward(sqrt(2.0)*(b + 2*c), colorNo);
+ left(90 + rotAngle);
+ }
+
+ ///
+ /// Draws letter S in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterS(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 6 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 6, colorNo);
+ // Clockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ right(rotAngle);
+ penUp();
+ forward(2*b + 3*c); // color = ffffff
+ penDown();
+ left(180);
+ }
+
+ ///
+ /// Draws letter U in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void letterU(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // edge length of a regular octagon
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ forward(h - c, colorNo);
+ penUp();
+ backward(h-c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagoin with edge length b in colour specified by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Draws a question mark in colour specified by colorNo with font height h
+ /// from the current turtle position.
+ ///
+ /// TODO
+ /// TODO
+ private static void qstnMk(??? h, ??? colorNo) {
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(h-c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ forward(c, colorNo);
+ left(rotAngle);
+ forward(b/2.0, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+ }
+
+ ///
+ /// Has the turtle draw the given string 'text´ with font height 'h´ (in
+ /// pixels) and the colour coded by integer 'c´ from the current Turtle
+ /// position to the Turtle canvas. If the turtle looks North then
+ /// the text will be written rightwards. In the event, the turtle will be
+ /// placed behind the text in original orientation (such that the next text
+ /// would be written like a continuation. Colour codes:
+ /// 1 = black
+ /// 2 = red
+ /// 3 = yellow
+ /// 4 = green
+ /// 5 = cyan
+ /// 6 = blue
+ /// 7 = pink
+ /// 8 = grey
+ /// 9 = orange
+ /// 10 = violet
+ /// All letters (ASCII) will be converted to uppercase, digits cannot
+ /// be represented, the set of representable special characters is:
+ /// '.', ',', '!', '?'. Other characters will be shown as a small
+ /// centred square (dummy character).
+ ///
+ /// TODO
+ /// TODO
+ /// TODO
+ private static void drawText(string text, int h, int c) {
+ // TODO: Check and accomplish variable declarations:
+ string letter;
+
+
+ ??? gap = h/10.0;
+ for (int k = 1; k <= length(text); k += (1)) {
+ letter = uppercase(copy(text, k, 1));
+ if (letter == ",") {
+ comma(h,c);
+ }
+ else {
+ // "," cannot be chacked against because the comma is misinterpreted
+ // as selector list separator.
+ switch (letter) {
+ case "A":
+ letterA(h,c);
+ break;
+ case "B":
+ letterB(h,c);
+ break;
+ case "C":
+ letterC(h,c);
+ break;
+ case "D":
+ letterD(h,c);
+ break;
+ case "E":
+ letterE(h,c);
+ break;
+ case "F":
+ letterF(h,c);
+ break;
+ case "G":
+ letterG(h,c);
+ break;
+ case "H":
+ letterH(h,c);
+ break;
+ case "I":
+ letterI(h,c);
+ break;
+ case "J":
+ letterJ(h,c);
+ break;
+ case "K":
+ letterK(h,c);
+ break;
+ case "L":
+ letterL(h,c);
+ break;
+ case "M":
+ letterM(h,c);
+ break;
+ case "N":
+ letterN(h,c);
+ break;
+ case "O":
+ letterO(h,c);
+ break;
+ case "P":
+ letterP(h,c);
+ break;
+ case "Q":
+ letterQ(h,c);
+ break;
+ case "R":
+ letterR(h,c);
+ break;
+ case "S":
+ letterS(h,c);
+ break;
+ case "T":
+ letterT(h,c);
+ break;
+ case "U":
+ letterU(h,c);
+ break;
+ case "V":
+ letterV(h,c);
+ break;
+ case "W":
+ letterW(h,c);
+ break;
+ case "X":
+ letterX(h,c);
+ break;
+ case "Y":
+ letterY(h,c);
+ break;
+ case "Z":
+ letterZ(h,c);
+ break;
+ case " ":
+ blank(h,c);
+ break;
+ case "!":
+ exclMk(h,c);
+ break;
+ case "?":
+ qstnMk(h,c);
+ break;
+ case ".":
+ fullSt(h,c);
+ break;
+ default:
+ charDummy(h,c);
+ }
+ }
+ right(90);
+ penUp();
+ forward(gap); // color = ffffff
+ penDown();
+ left(90);
+ }
+ }
+
+}
diff --git a/samples/export/C++/ELIZA_2.3.cpp b/samples/export/C++/ELIZA_2.3.cpp
new file mode 100644
index 00000000..eefa0afe
--- /dev/null
+++ b/samples/export/C++/ELIZA_2.3.cpp
@@ -0,0 +1,587 @@
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2018-05-14 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+#include
+
+// histArray contains the most recent user replies as ring buffer;
+// histIndex is the index where the next reply is to be stored (= index of the oldest
+// cached user reply).
+// Note: The depth of the history is to be specified by initializing a variable of this type,
+// e.g. for a history of depth 5:
+// myhistory <- History{{"", "", "", "", ""}, 0}
+struct History {
+ string[] histArray;
+ int histIndex;
+};
+
+// Associates a key word in the text with an index in the reply ring array
+struct KeyMapEntry {
+ string keyword;
+ int index;
+};
+
+
+// Cares for correct letter case among others
+// function adjustSpelling(sentence: string): string
+// TODO Revise the return type and declare the parameters!
+string adjustSpelling(string sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ string word;
+ string start;
+ string result;
+ int position;
+
+
+ result = sentence;
+ position = 1;
+ while ((position <= length(sentence)) && (copy(sentence, position, 1) == " ")) {
+ position = position + 1;
+ }
+ if (position <= length(sentence)) {
+ start = copy(sentence, 1, position);
+ delete(result, 1, position);
+ insert(uppercase(start), result, 1);
+ }
+ for (auto word : {" i ", " i\'"}) {
+ position = pos(word, result);
+ while (position > 0) {
+ delete(result, position+1, 1);
+ insert("I", result, position+1);
+ position = pos(word, result);
+ }
+ }
+
+ return result;
+}
+
+// Checks whether the given text contains some kind of
+// good-bye phrase inducing the end of the conversation
+// and if so writes a correspding good-bye message and
+// returns true, otherwise false
+// function checkGoodBye(text: string; phrases: array of array[0..1] of string): boolean
+// TODO Revise the return type and declare the parameters!
+bool checkGoodBye(string text, string phrases[][2])
+{
+ // TODO: Check and accomplish variable declarations:
+ bool saidBye;
+ string pair[];
+
+
+ for (auto pair : phrases) {
+ if (pos(pair[0], text) > 0) {
+ saidBye = true;
+ std::cout << pair[1] << std::endl;
+ return true;
+ }
+ }
+ return false;
+}
+
+// Checks whether newInput has occurred among the recently cached
+// input strings in the histArray component of history and updates the history.
+// function checkRepetition(history: History; newInput: string): boolean
+// TODO Revise the return type and declare the parameters!
+bool checkRepetition(History history, string newInput)
+{
+ // TODO: Check and accomplish variable declarations:
+ int histDepth;
+ bool hasOccurred;
+
+
+ hasOccurred = false;
+ if (length(newInput) > 4) {
+ histDepth = length(history.histArray);
+ for (int i = 0; i <= histDepth-1; i += (1)) {
+ if (newInput == history.histArray[i]) {
+ hasOccurred = true;
+ }
+ }
+ history.histArray[history.histIndex] = newInput;
+ history.histIndex = (history.histIndex + 1) % (histDepth);
+ }
+ return hasOccurred;
+}
+
+// function conjugateStrings(sentence: string; key: string; keyPos: integer; flexions: array of array[0..1] of string): string
+// TODO Revise the return type and declare the parameters!
+string conjugateStrings(string sentence, string key, int keyPos, string flexions[][2])
+{
+ // TODO: Check and accomplish variable declarations:
+ string right;
+ string result;
+ int position;
+ string pair[];
+ string left;
+
+
+ result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " ";
+ for (auto pair : flexions) {
+ left = "";
+ right = result;
+ position = pos(pair[0], right);
+ while (position > 0) {
+ left = left + copy(right, 1, position-1) + pair[1];
+ right = copy(right, position + length(pair[0]), length(right));
+ position = pos(pair[0], right);
+ }
+ result = left + right;
+ }
+ // Eliminate multiple spaces
+ position = pos(" ", result);
+ while (position > 0) {
+ result = copy(result, 1, position-1) + copy(result, position+1, length(result));
+ position = pos(" ", result);
+ }
+
+ return result;
+}
+
+// Looks for the occurrence of the first of the strings
+// contained in keywords within the given sentence (in
+// array order).
+// Returns an array of
+// 0: the index of the first identified keyword (if any, otherwise -1),
+// 1: the position inside sentence (0 if not found)
+// function findKeyword(const keyMap: array of KeyMapEntry; sentence: string): array[0..1] of integer
+// C++ may not permit to return arrays like this - find an other way to pass the result!
+// TODO Revise the return type and declare the parameters!
+int[2] findKeyword(const array of KeyMapEntry keyMap, string sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ int result[2];
+ int position;
+ int i;
+
+
+ result[0] = -1;
+ result[1] = 0;
+ i = 0;
+ while ((result[0] < 0) && (i < length(keyMap))) {
+ KeyMapEntry entry = keyMap[i];
+ position = pos(entry.keyword, sentence);
+ if (position > 0) {
+ result[0] = i;
+ result[1] = position;
+ }
+ i = i+1;
+ }
+
+ return result;
+}
+
+// Converts the sentence to lowercase, eliminates all
+// interpunction (i.e. ',', '.', ';'), and pads the
+// sentence among blanks
+// function normalizeInput(sentence: string): string
+// TODO Revise the return type and declare the parameters!
+string normalizeInput(string sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ string symbol;
+ string result;
+ int position;
+
+
+ sentence = lowercase(sentence);
+ for (auto symbol : {'.', ',', ';', '!', '?'}) {
+ position = pos(symbol, sentence);
+ while (position > 0) {
+ sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence));
+ position = pos(symbol, sentence);
+ }
+ }
+ result = " " + sentence + " ";
+
+ return result;
+}
+
+// function setupGoodByePhrases(): array of array[0..1] of string
+// C++ may not permit to return arrays like this - find an other way to pass the result!
+// TODO Revise the return type and declare the parameters!
+string[][2] setupGoodByePhrases()
+{
+ // TODO: Check and accomplish variable declarations:
+ string phrases[][2];
+
+
+ phrases[0][0] = " shut";
+ phrases[0][1] = "Okay. If you feel that way I\'ll shut up. ... Your choice.";
+ phrases[1][0] = "bye";
+ phrases[1][1] = "Well, let\'s end our talk for now. See you later. Bye.";
+ return phrases;
+}
+
+// The lower the index the higher the rank of the keyword (search is sequential).
+// The index of the first keyword found in a user sentence maps to a respective
+// reply ring as defined in `setupReplies()´.
+// function setupKeywords(): array of KeyMapEntry
+// C++ may not permit to return arrays like this - find an other way to pass the result!
+// TODO Revise the return type and declare the parameters!
+KeyMapEntry[] setupKeywords()
+{
+ // TODO: Check and accomplish variable declarations:
+ // The empty key string (last entry) is the default clause - will always be found
+ KeyMapEntry keywords[];
+
+
+ // The empty key string (last entry) is the default clause - will always be found
+ keywords[39].keyword = "";
+ keywords[39].index = 29;
+ keywords[0].keyword = "can you ";
+ keywords[0].index = 0;
+ keywords[1].keyword = "can i ";
+ keywords[1].index = 1;
+ keywords[2].keyword = "you are ";
+ keywords[2].index = 2;
+ keywords[3].keyword = "you\'re ";
+ keywords[3].index = 2;
+ keywords[4].keyword = "i don't ";
+ keywords[4].index = 3;
+ keywords[5].keyword = "i feel ";
+ keywords[5].index = 4;
+ keywords[6].keyword = "why don\'t you ";
+ keywords[6].index = 5;
+ keywords[7].keyword = "why can\'t i ";
+ keywords[7].index = 6;
+ keywords[8].keyword = "are you ";
+ keywords[8].index = 7;
+ keywords[9].keyword = "i can\'t ";
+ keywords[9].index = 8;
+ keywords[10].keyword = "i am ";
+ keywords[10].index = 9;
+ keywords[11].keyword = "i\'m ";
+ keywords[11].index = 9;
+ keywords[12].keyword = "you ";
+ keywords[12].index = 10;
+ keywords[13].keyword = "i want ";
+ keywords[13].index = 11;
+ keywords[14].keyword = "what ";
+ keywords[14].index = 12;
+ keywords[15].keyword = "how ";
+ keywords[15].index = 12;
+ keywords[16].keyword = "who ";
+ keywords[16].index = 12;
+ keywords[17].keyword = "where ";
+ keywords[17].index = 12;
+ keywords[18].keyword = "when ";
+ keywords[18].index = 12;
+ keywords[19].keyword = "why ";
+ keywords[19].index = 12;
+ keywords[20].keyword = "name ";
+ keywords[20].index = 13;
+ keywords[21].keyword = "cause ";
+ keywords[21].index = 14;
+ keywords[22].keyword = "sorry ";
+ keywords[22].index = 15;
+ keywords[23].keyword = "dream ";
+ keywords[23].index = 16;
+ keywords[24].keyword = "hello ";
+ keywords[24].index = 17;
+ keywords[25].keyword = "hi ";
+ keywords[25].index = 17;
+ keywords[26].keyword = "maybe ";
+ keywords[26].index = 18;
+ keywords[27].keyword = " no";
+ keywords[27].index = 19;
+ keywords[28].keyword = "your ";
+ keywords[28].index = 20;
+ keywords[29].keyword = "always ";
+ keywords[29].index = 21;
+ keywords[30].keyword = "think ";
+ keywords[30].index = 22;
+ keywords[31].keyword = "alike ";
+ keywords[31].index = 23;
+ keywords[32].keyword = "yes ";
+ keywords[32].index = 24;
+ keywords[33].keyword = "friend ";
+ keywords[33].index = 25;
+ keywords[34].keyword = "computer";
+ keywords[34].index = 26;
+ keywords[35].keyword = "bot ";
+ keywords[35].index = 26;
+ keywords[36].keyword = "smartphone";
+ keywords[36].index = 27;
+ keywords[37].keyword = "father ";
+ keywords[37].index = 28;
+ keywords[38].keyword = "mother ";
+ keywords[38].index = 28;
+ return keywords;
+}
+
+// Returns an array of pairs of mutualy substitutable
+// function setupReflexions(): array of array[0..1] of string
+// C++ may not permit to return arrays like this - find an other way to pass the result!
+// TODO Revise the return type and declare the parameters!
+string[][2] setupReflexions()
+{
+ // TODO: Check and accomplish variable declarations:
+ string reflexions[][2];
+
+
+ reflexions[0][0] = " are ";
+ reflexions[0][1] = " am ";
+ reflexions[1][0] = " were ";
+ reflexions[1][1] = " was ";
+ reflexions[2][0] = " you ";
+ reflexions[2][1] = " I ";
+ reflexions[3][0] = " your";
+ reflexions[3][1] = " my";
+ reflexions[4][0] = " i\'ve ";
+ reflexions[4][1] = " you\'ve ";
+ reflexions[5][0] = " i\'m ";
+ reflexions[5][1] = " you\'re ";
+ reflexions[6][0] = " me ";
+ reflexions[6][1] = " you ";
+ reflexions[7][0] = " my ";
+ reflexions[7][1] = " your ";
+ reflexions[8][0] = " i ";
+ reflexions[8][1] = " you ";
+ reflexions[9][0] = " am ";
+ reflexions[9][1] = " are ";
+ return reflexions;
+}
+
+// This routine sets up the reply rings addressed by the key words defined in
+// routine `setupKeywords()´ and mapped hitherto by the cross table defined
+// in `setupMapping()´
+// function setupReplies(): array of array of string
+// C++ may not permit to return arrays like this - find an other way to pass the result!
+// TODO Revise the return type and declare the parameters!
+string[][/*???*/] setupReplies()
+{
+ // TODO: Check and accomplish variable declarations:
+ string setupReplies[][/*???*/];
+
+
+ string replies[][/*???*/];
+ replies[29][0] = "Say, do you have any psychological problems?";
+ replies[29][1] = "What does that suggest to you?";
+ replies[29][2] = "I see.";
+ replies[29][3] = "I'm not sure I understand you fully.";
+ replies[29][4] = "Come come elucidate your thoughts.";
+ replies[29][5] = "Can you elaborate on that?";
+ replies[29][6] = "That is quite interesting.";
+ replies[0][0] = "Don't you believe that I can*?";
+ replies[0][1] = "Perhaps you would like to be like me?";
+ replies[0][2] = "You want me to be able to*?";
+ replies[1][0] = "Perhaps you don't want to*?";
+ replies[1][1] = "Do you want to be able to*?";
+ replies[2][0] = "What makes you think I am*?";
+ replies[2][1] = "Does it please you to believe I am*?";
+ replies[2][2] = "Perhaps you would like to be*?";
+ replies[2][3] = "Do you sometimes wish you were*?";
+ replies[3][0] = "Don't you really*?";
+ replies[3][1] = "Why don't you*?";
+ replies[3][2] = "Do you wish to be able to*?";
+ replies[3][3] = "Does that trouble you*?";
+ replies[4][0] = "Do you often feel*?";
+ replies[4][1] = "Are you afraid of feeling*?";
+ replies[4][2] = "Do you enjoy feeling*?";
+ replies[5][0] = "Do you really believe I don't*?";
+ replies[5][1] = "Perhaps in good time I will*.";
+ replies[5][2] = "Do you want me to*?";
+ replies[6][0] = "Do you think you should be able to*?";
+ replies[6][1] = "Why can't you*?";
+ replies[7][0] = "Why are you interested in whether or not I am*?";
+ replies[7][1] = "Would you prefer if I were not*?";
+ replies[7][2] = "Perhaps in your fantasies I am*?";
+ replies[8][0] = "How do you know you can't*?";
+ replies[8][1] = "Have you tried?";
+ replies[8][2] = "Perhaps you can now*.";
+ replies[9][0] = "Did you come to me because you are*?";
+ replies[9][1] = "How long have you been*?";
+ replies[9][2] = "Do you believe it is normal to be*?";
+ replies[9][3] = "Do you enjoy being*?";
+ replies[10][0] = "We were discussing you--not me.";
+ replies[10][1] = "Oh, I*.";
+ replies[10][2] = "You're not really talking about me, are you?";
+ replies[11][0] = "What would it mean to you if you got*?";
+ replies[11][1] = "Why do you want*?";
+ replies[11][2] = "Suppose you soon got*...";
+ replies[11][3] = "What if you never got*?";
+ replies[11][4] = "I sometimes also want*.";
+ replies[12][0] = "Why do you ask?";
+ replies[12][1] = "Does that question interest you?";
+ replies[12][2] = "What answer would please you the most?";
+ replies[12][3] = "What do you think?";
+ replies[12][4] = "Are such questions on your mind often?";
+ replies[12][5] = "What is it that you really want to know?";
+ replies[12][6] = "Have you asked anyone else?";
+ replies[12][7] = "Have you asked such questions before?";
+ replies[12][8] = "What else comes to mind when you ask that?";
+ replies[13][0] = "Names don't interest me.";
+ replies[13][1] = "I don't care about names -- please go on.";
+ replies[14][0] = "Is that the real reason?";
+ replies[14][1] = "Don't any other reasons come to mind?";
+ replies[14][2] = "Does that reason explain anything else?";
+ replies[14][3] = "What other reasons might there be?";
+ replies[15][0] = "Please don't apologize!";
+ replies[15][1] = "Apologies are not necessary.";
+ replies[15][2] = "What feelings do you have when you apologize?";
+ replies[15][3] = "Don't be so defensive!";
+ replies[16][0] = "What does that dream suggest to you?";
+ replies[16][1] = "Do you dream often?";
+ replies[16][2] = "What persons appear in your dreams?";
+ replies[16][3] = "Are you disturbed by your dreams?";
+ replies[17][0] = "How do you do ...please state your problem.";
+ replies[18][0] = "You don't seem quite certain.";
+ replies[18][1] = "Why the uncertain tone?";
+ replies[18][2] = "Can't you be more positive?";
+ replies[18][3] = "You aren't sure?";
+ replies[18][4] = "Don't you know?";
+ replies[19][0] = "Are you saying no just to be negative?";
+ replies[19][1] = "You are being a bit negative.";
+ replies[19][2] = "Why not?";
+ replies[19][3] = "Are you sure?";
+ replies[19][4] = "Why no?";
+ replies[20][0] = "Why are you concerned about my*?";
+ replies[20][1] = "What about your own*?";
+ replies[21][0] = "Can you think of a specific example?";
+ replies[21][1] = "When?";
+ replies[21][2] = "What are you thinking of?";
+ replies[21][3] = "Really, always?";
+ replies[22][0] = "Do you really think so?";
+ replies[22][1] = "But you are not sure you*?";
+ replies[22][2] = "Do you doubt you*?";
+ replies[23][0] = "In what way?";
+ replies[23][1] = "What resemblance do you see?";
+ replies[23][2] = "What does the similarity suggest to you?";
+ replies[23][3] = "What other connections do you see?";
+ replies[23][4] = "Could there really be some connection?";
+ replies[23][5] = "How?";
+ replies[23][6] = "You seem quite positive.";
+ replies[24][0] = "Are you sure?";
+ replies[24][1] = "I see.";
+ replies[24][2] = "I understand.";
+ replies[25][0] = "Why do you bring up the topic of friends?";
+ replies[25][1] = "Do your friends worry you?";
+ replies[25][2] = "Do your friends pick on you?";
+ replies[25][3] = "Are you sure you have any friends?";
+ replies[25][4] = "Do you impose on your friends?";
+ replies[25][5] = "Perhaps your love for friends worries you.";
+ replies[26][0] = "Do computers worry you?";
+ replies[26][1] = "Are you talking about me in particular?";
+ replies[26][2] = "Are you frightened by machines?";
+ replies[26][3] = "Why do you mention computers?";
+ replies[26][4] = "What do you think machines have to do with your problem?";
+ replies[26][5] = "Don't you think computers can help people?";
+ replies[26][6] = "What is it about machines that worries you?";
+ replies[27][0] = "Do you sometimes feel uneasy without a smartphone?";
+ replies[27][1] = "Have you had these phantasies before?";
+ replies[27][2] = "Does the world seem more real for you via apps?";
+ replies[28][0] = "Tell me more about your family.";
+ replies[28][1] = "Who else in your family*?";
+ replies[28][2] = "What does family relations mean for you?";
+ replies[28][3] = "Come on, How old are you?";
+ setupReplies = replies;
+
+ return setupReplies;
+}
+
+// Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+// "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+// Computational Linguistis 1(1966)9, pp. 36-45
+// Revision history:
+// 2016-10-06 Initial version
+// 2017-03-29 Two diagrams updated (comments translated to English)
+// 2017-03-29 More keywords and replies added
+// 2019-03-14 Replies and mapping reorganised for easier maintenance
+// 2019-03-15 key map joined from keyword array and index map
+// 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+// 2019-11-28 New global type "History" (to ensure a homogenous array)
+// program ELIZA
+int main(void)
+{
+ // BEGIN initialization for "History"
+ // END initialization for "History"
+ // BEGIN initialization for "KeyMapEntry"
+ // END initialization for "KeyMapEntry"
+
+ // TODO: Check and accomplish variable declarations:
+ string varPart;
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ string userInput;
+ string reply;
+ int posAster;
+ int offsets[];
+ bool isRepeated;
+ bool isGone;
+ int findInfo[2];
+
+
+ // Title information
+ std::cout << "************* ELIZA **************" << std::endl;
+ std::cout << "* Original design by J. Weizenbaum" << std::endl;
+ std::cout << "**********************************" << std::endl;
+ std::cout << "* Adapted for Basic on IBM PC by" << std::endl;
+ std::cout << "* - Patricia Danielson" << std::endl;
+ std::cout << "* - Paul Hashfield" << std::endl;
+ std::cout << "**********************************" << std::endl;
+ std::cout << "* Adapted for Structorizer by" << std::endl;
+ std::cout << "* - Kay Gürtzig / FH Erfurt 2016" << std::endl;
+ std::cout << "* Version: 2.3 (2019-11-28)" << std::endl;
+ std::cout << "* (Requires at least Structorizer 3.30-03 to run)" << std::endl;
+ std::cout << "**********************************" << std::endl;
+ // Stores the last five inputs of the user in a ring buffer,
+ // the second component is the rolling (over-)write index.
+ History history = {{"", "", "", "", ""}, 0};
+ const string replies[][/*???*/] = setupReplies();
+ const string reflexions[][2] = setupReflexions();
+ const string byePhrases[][2] = setupGoodByePhrases();
+ const KeyMapEntry keyMap[] = setupKeywords();
+ offsets[length(keyMap)-1] = 0;
+ isGone = false;
+ // Starter
+ std::cout << "Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?" << std::endl;
+ do {
+ std::cin >> userInput;
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ userInput = normalizeInput(userInput);
+ isGone = checkGoodBye(userInput, byePhrases);
+ if (! isGone) {
+ reply = "Please don\'t repeat yourself!";
+ isRepeated = checkRepetition(history, userInput);
+ if (! isRepeated) {
+ findInfo = findKeyword(keyMap, userInput);
+ ??? keyIndex = findInfo[0];
+ if (keyIndex < 0) {
+ // Should never happen...
+ keyIndex = length(keyMap)-1;
+ }
+ KeyMapEntry entry = keyMap[keyIndex];
+ // Variable part of the reply
+ varPart = "";
+ if (length(entry.keyword) > 0) {
+ varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions);
+ }
+ ??? replyRing = replies[entry.index];
+ reply = replyRing[offsets[keyIndex]];
+ offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing);
+ posAster = pos("*", reply);
+ if (posAster > 0) {
+ if (varPart == " ") {
+ reply = "You will have to elaborate more for me to help you.";
+ }
+ else {
+ delete(reply, posAster, 1);
+ insert(varPart, reply, posAster);
+ }
+ }
+ reply = adjustSpelling(reply);
+ }
+ std::cout << reply << std::endl;
+ }
+ } while (!(isGone));
+
+ return 0;
+}
diff --git a/samples/export/C++/SORTING_TEST_MAIN.cpp b/samples/export/C++/SORTING_TEST_MAIN.cpp
index c2878a88..a7b3e340 100644
--- a/samples/export/C++/SORTING_TEST_MAIN.cpp
+++ b/samples/export/C++/SORTING_TEST_MAIN.cpp
@@ -1,4 +1,4 @@
-// Generated by Structorizer 3.30-02
+// Generated by Structorizer 3.30-03
//
// Copyright (C) 2019-10-02 Kay Gürtzig
// License: GPLv3-link
@@ -18,17 +18,17 @@
// subrange.
// function bubbleSort(values)
// TODO Revise the return type and declare the parameters!
-void bubbleSort(/*type?*/ values)
+void bubbleSort(??? values)
{
// TODO: Check and accomplish variable declarations:
- ende = length(values) - 2;
+ ??? ende = length(values) - 2;
do {
// The index of the most recent swapping (-1 means no swapping done).
- posSwapped = -1;
+ ??? posSwapped = -1;
for (int i = 0; i <= ende; i += (1)) {
if (values[i] > values[i+1]) {
- temp = values[i];
+ ??? temp = values[i];
values[i] = values[i+1];
values[i+1] = temp;
posSwapped = i;
@@ -44,15 +44,15 @@ void bubbleSort(/*type?*/ values)
// again.
// function maxHeapify(heap, i, range)
// TODO Revise the return type and declare the parameters!
-void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range)
+void maxHeapify(??? heap, ??? i, ??? range)
{
// TODO: Check and accomplish variable declarations:
// Indices of left and right child of node i
- right = (i+1) * 2;
- left = right - 1;
+ ??? right = (i+1) * 2;
+ ??? left = right - 1;
// Index of the (local) maximum
- max = i;
+ ??? max = i;
if (left < range && heap[left] > heap[i]) {
max = left;
}
@@ -60,7 +60,7 @@ void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range)
max = right;
}
if (max != i) {
- temp = heap[i];
+ ??? temp = heap[i];
heap[i] = heap[max];
heap[max] = temp;
maxHeapify(heap, max, range);
@@ -77,11 +77,11 @@ void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range)
// might still be avoided) but it is pretty clear.
// function partition(values, start, stop, p): int
// TODO Revise the return type and declare the parameters!
-int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p)
+int partition(??? values, ??? start, ??? stop, ??? p)
{
// TODO: Check and accomplish variable declarations:
- pivot = values[p];
+ ??? pivot = values[p];
// Tausche das Pivot-Element an den start
values[p] = values[start];
values[start] = pivot;
@@ -91,7 +91,7 @@ int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p)
stop = stop - 1;
// Still unseen elements?
while (stop >= start) {
- seen = values[start];
+ ??? seen = values[start];
if (values[start] <= pivot) {
// Swap pivot element with start element
values[p] = seen;
@@ -112,7 +112,7 @@ int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p)
// Checks whether or not the passed-in array is (ascendingly) sorted.
// function testSorted(numbers): bool
// TODO Revise the return type and declare the parameters!
-bool testSorted(/*type?*/ numbers)
+bool testSorted(??? numbers)
{
// TODO: Check and accomplish variable declarations:
bool isSorted;
@@ -140,7 +140,7 @@ bool testSorted(/*type?*/ numbers)
// the root.
// function buildMaxHeap(heap)
// TODO Revise the return type and declare the parameters!
-int buildMaxHeap(/*type?*/ heap)
+int buildMaxHeap(??? heap)
{
// TODO: Check and accomplish variable declarations:
int lgth;
@@ -159,19 +159,19 @@ int buildMaxHeap(/*type?*/ heap)
// stop is the index BEHIND the subsequence to be sorted.
// function quickSort(values, start, stop)
// TODO Revise the return type and declare the parameters!
-int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
+int quickSort(??? values, ??? start, ??? stop)
{
- class ThrFunc3dfab37d_0{
+ class ThrFunc7fed1521_0{
public:
- void operator()(/*type?*/& values, /*type?*/& start, /*type?*/& p) {
+ void operator()(???& values, ???& start, ???& p) {
// Sort left (lower) array part
quickSort(values, start, p);
}
};
- class ThrFunc3dfab37d_1{
+ class ThrFunc7fed1521_1{
public:
- void operator()(/*type?*/& values, /*type?*/& p, /*type?*/& stop) {
+ void operator()(???& values, ???& p, ???& stop) {
// Sort right (higher) array part
quickSort(values, p+1, stop);
}
@@ -183,7 +183,7 @@ int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
if (stop >= start + 2) {
// Select a pivot element, be p its index.
// (here: randomly chosen element out of start ... stop-1)
- p = random(stop-start) + start;
+ ??? p = random(stop-start) + start;
// Partition the array into smaller and greater elements
// Get the resulting (and final) position of the pivot element
// Partition the array into smaller and greater elements
@@ -193,14 +193,14 @@ int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
// Parallel section
{
- ThrFunc3dfab37d_0 thrfunc3dfab37d_0;
- std::thread thr3dfab37d_0(thrfunc3dfab37d_0, values, start, p);
+ ThrFunc7fed1521_0 thrfunc7fed1521_0;
+ std::thread thr7fed1521_0(thrfunc7fed1521_0, values, start, p);
- ThrFunc3dfab37d_1 thrfunc3dfab37d_1;
- std::thread thr3dfab37d_1(thrfunc3dfab37d_1, values, p, stop);
+ ThrFunc7fed1521_1 thrfunc7fed1521_1;
+ std::thread thr7fed1521_1(thrfunc7fed1521_1, values, p, stop);
- thr3dfab37d_0.join();
- thr3dfab37d_1.join();
+ thr7fed1521_0.join();
+ thr7fed1521_1.join();
}
}
@@ -212,7 +212,7 @@ int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
// algorithm
// function heapSort(values)
// TODO Revise the return type and declare the parameters!
-int heapSort(/*type?*/ values)
+int heapSort(??? values)
{
// TODO: Check and accomplish variable declarations:
int heapRange;
@@ -223,7 +223,7 @@ int heapSort(/*type?*/ values)
for (int k = heapRange - 1; k >= 1; k += (-1)) {
heapRange = heapRange - 1;
// Swap the maximum value (root of the heap) to the heap end
- maximum = values[0];
+ ??? maximum = values[0];
values[0] = values[heapRange];
values[heapRange] = maximum;
maxHeapify(values, 0, heapRange);
@@ -239,32 +239,35 @@ int heapSort(/*type?*/ values)
// program SORTING_TEST_MAIN
int main(void)
{
- class ThrFunc4f085546_0{
+ class ThrFunc247e34b9_0{
public:
- void operator()(/*type?*/& values1) {
+ void operator()(int values1[]) {
bubbleSort(values1);
}
};
- class ThrFunc4f085546_1{
+ class ThrFunc247e34b9_1{
public:
- void operator()(/*type?*/& values2, /*type?*/& elementCount) {
+ void operator()(??? values2[], ???& elementCount) {
quickSort(values2, 0, elementCount);
}
};
- class ThrFunc4f085546_2{
+ class ThrFunc247e34b9_2{
public:
- void operator()(/*type?*/& values3) {
+ void operator()(??? values3[]) {
heapSort(values3);
}
};
// TODO: Check and accomplish variable declarations:
- ??? values3;
- ??? values2;
- ??? values1;
+ ??? values3[];
+ ??? values2[];
+ int values1[];
??? show;
+ bool ok3;
+ bool ok2;
+ bool ok1;
??? modus;
??? elementCount;
@@ -288,7 +291,7 @@ int main(void)
break;
}
}
- // Kopiere das Array für exakte Vergleichbarkeit
+ // Copy the array for exact comparability
for (int i = 0; i <= elementCount-1; i += (1)) {
values2[i] = values1[i];
values3[i] = values1[i];
@@ -296,18 +299,18 @@ int main(void)
// Parallel section
{
- ThrFunc4f085546_0 thrfunc4f085546_0;
- std::thread thr4f085546_0(thrfunc4f085546_0, values1);
+ ThrFunc247e34b9_0 thrfunc247e34b9_0;
+ std::thread thr247e34b9_0(thrfunc247e34b9_0, values1);
- ThrFunc4f085546_1 thrfunc4f085546_1;
- std::thread thr4f085546_1(thrfunc4f085546_1, values2, elementCount);
+ ThrFunc247e34b9_1 thrfunc247e34b9_1;
+ std::thread thr247e34b9_1(thrfunc247e34b9_1, values2, elementCount);
- ThrFunc4f085546_2 thrfunc4f085546_2;
- std::thread thr4f085546_2(thrfunc4f085546_2, values3);
+ ThrFunc247e34b9_2 thrfunc247e34b9_2;
+ std::thread thr247e34b9_2(thrfunc247e34b9_2, values3);
- thr4f085546_0.join();
- thr4f085546_1.join();
- thr4f085546_2.join();
+ thr247e34b9_0.join();
+ thr247e34b9_1.join();
+ thr247e34b9_2.join();
}
ok1 = testSorted(values1);
diff --git a/samples/export/C++/TextDemo.cpp b/samples/export/C++/TextDemo.cpp
new file mode 100644
index 00000000..511870cb
--- /dev/null
+++ b/samples/export/C++/TextDemo.cpp
@@ -0,0 +1,1215 @@
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2019-10-10 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+#include
+
+
+// Draws a blank for font height h, ignoring the colorNo
+// function blank(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void blank(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ left(90);
+}
+
+// function forward(len, color)
+// TODO Revise the return type and declare the parameters!
+void forward(??? len, ??? color)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ switch (color) {
+ case 1:
+ forward(len); // color = ffffff
+ break;
+ case 2:
+ forward(len); // color = ff8080
+ break;
+ case 3:
+ forward(len); // color = ffff80
+ break;
+ case 4:
+ forward(len); // color = 80ff80
+ break;
+ case 5:
+ forward(len); // color = 80ffff
+ break;
+ case 6:
+ forward(len); // color = 0080ff
+ break;
+ case 7:
+ forward(len); // color = ff80c0
+ break;
+ case 8:
+ forward(len); // color = c0c0c0
+ break;
+ case 9:
+ forward(len); // color = ff8000
+ break;
+ case 10:
+ forward(len); // color = 8080ff
+ break;
+ }
+}
+
+// Draws letter A in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterA(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterA(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ right(rotAngle);
+ forward(hypo/2.0, colorNo);
+ right(90 - rotAngle);
+ forward(width/2.0, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ left(90 - rotAngle);
+ forward(hypo/2.0, colorNo);
+ left(2*rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+}
+
+// Draws letter E in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterE(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterE(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+}
+
+// Draws letter F in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterF(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterF(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ forward(width); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// Draws letter H in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterH(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterH(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width); // color = ffffff
+ left(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ left(180);
+}
+
+// Draws letter I in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterI(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterI(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward(c); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ backward(b/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ backward(b/2.0); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ forward(b/2 + c); // color = ffffff
+ left(90);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter K in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterK(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterK(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ ??? diag = h/sqrt(2.0);
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(135);
+ penDown();
+ forward(diag, colorNo);
+ left(90);
+ forward(diag, colorNo);
+ left(135);
+}
+
+// Draws letter L in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterL(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterL(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+}
+
+// Draws letter M in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterM(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterM(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ ??? width = h/2.0;
+ ??? hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ forward(-h, colorNo);
+}
+
+// Draws letter N in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterN(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterN(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter T in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterT(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterT(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h/2.0;
+ penUp();
+ forward(h); // color = ffffff
+ penDown();
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ right(90);
+ forward(h, colorNo);
+ left(90);
+ penUp();
+ forward(width/2.0); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// Draws letter V in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterV(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterV(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter W in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterW(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterW(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ ??? width_3 = width/3.0;
+ hypo = sqrt(width_3*width_3 + h*h);
+ rotAngle = toDegrees(atan(width_3/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width_3); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter X in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterX(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterX(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ right(rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+}
+
+// Draws letter Y in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterY(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterY(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ ??? width = h/2.0;
+ ??? hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ penUp();
+ backward(h/2.0); // color = ffffff
+ penDown();
+ forward(h/2.0, colorNo);
+ right(rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter Z in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterZ(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterZ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ double hypo;
+
+
+ ??? width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90-rotAngle);
+ forward(-hypo, colorNo);
+ right(90-rotAngle);
+ forward(width, colorNo);
+ left(90);
+}
+
+// Draws nEdges edges of a regular n-polygon with edge length a
+// counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.
+// function polygonPart(a: double; n: integer; ctrclkws: boolean; nEdges: integer; color: int)
+// TODO Revise the return type and declare the parameters!
+void polygonPart(double a, int n, bool ctrclkws, int nEdges, int color)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? rotAngle = 360.0/n;
+ if (ctrclkws) {
+ rotAngle = -rotAngle;
+ }
+ for (int k = 1; k <= nEdges; k += (1)) {
+ right(rotAngle);
+ forward(a, color);
+ }
+}
+
+// Draws a dummy character (small centered square) with font height h and
+// the colour encoded by colorNo
+// function charDummy(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void charDummy(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ ??? width = h / 2.0;
+ // Octagon edge length (here: edge lengzh of the square)
+ ??? b = width / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = (width - b) / 2.0;
+ ??? d = b / sqrt(2.0);
+ penUp();
+ forward(h/2.0-b/2.0); // color = ffffff
+ right(90);
+ forward(c); // color = ffffff
+ right(90);
+ penDown();
+ // Draws the square with edge length b
+ polygonPart(b, 4, true, 4, colorNo);
+ penUp();
+ left(90);
+ forward(b + c); // color = ffffff
+ left(90);
+ backward(h/2.0-b/2.0); // color = ffffff
+ penDown();
+}
+
+// Draws a comma in colour specified by colorNo with font height h
+// from the current turtle position.
+// function comma(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void comma(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ rotAngle = toDegrees(atan(0.5));
+ ??? hypo = c * sqrt(1.25);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 3 edges of a square with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 3, colorNo);
+ left(90);
+ forward(c/2.0, colorNo);
+ right(90);
+ forward(c, colorNo);
+ left(180 - rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ right(90 - rotAngle);
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+}
+
+// Draws an exclamation mark in the colour encoded by colorNo with font height h
+// from the current turtle position.
+// function exclMk(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void exclMk(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle2;
+ // 360°/8
+ int rotAngle;
+ double hypo;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ ??? width = h/2.0;
+ ??? length1 = h - (b+c)/2.0;
+ ??? length2 = length1 - 2*c;
+ hypo = sqrt(width*width/16.0 + length2*length2);
+ // 360°/8
+ rotAngle = 45;
+ rotAngle2 = toDegrees(atan(width/4.0/length2));
+ penUp();
+ forward(length1); // color = ffffff
+ right(90);
+ forward(width/2.0); // color = ffffff
+ left(90 + rotAngle);
+ penDown();
+ // Clockwise draw 5 edges of an octagon with edge length b/2
+ // in the colour endcoded by colorNo
+ polygonPart(b/2.0, 8, false, 5, colorNo);
+ right(rotAngle2);
+ forward(hypo, colorNo);
+ left(2*rotAngle2);
+ forward(-hypo, colorNo);
+ penUp();
+ forward(hypo); // color = ffffff
+ right(rotAngle2);
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+}
+
+// Draws a full stop in colour specified by colorNo with font height h
+// from the current turtle position.
+// function fullSt(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void fullSt(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+}
+
+// Draws letter B in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterB(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterB(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer corner triangle of the octagon
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// Draws letter C in the colour encoded by colorNo with font height h
+// from the current turtle position.
+// function letterC(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterC(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer trinagle at the octagon corner
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Clockwise draws 3 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ penUp();
+ forward(2*b + 2*c); // color = ffffff
+ penDown();
+ // Counterclockwise draws 4 edges of an octagon with edge length b
+ // iin the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+}
+
+// Draws letter D in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterD(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterD(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(b + 2*c, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// Draws letter G in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterG(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterG(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon.
+ ??? c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(c, colorNo);
+ left(90);
+ forward(b/2.0 + c, colorNo);
+ penUp();
+ backward(b/2.0 + c); // color = ffffff
+ right(90);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+}
+
+// Draws letter J in colour encoded by colorNo with font height h
+// from the current turtle position.
+// function letterJ(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterJ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws letter O in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterO(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterO(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// Draws letter P in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterP(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterP(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ // Octagon edge length
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ ??? c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ backward(b + 2*c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(180);
+}
+
+// Draws letter Q in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterQ(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterQ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ right(rotAngle);
+ backward(b); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ left(90 + rotAngle);
+}
+
+// Zeichnet den Buchstaben R von der Turtleposition aus
+// mit Zeilenhöhe h
+// function letterR(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterR(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ left(90 + rotAngle);
+ forward(sqrt(2.0)*(b + 2*c), colorNo);
+ left(90 + rotAngle);
+}
+
+// Draws letter S in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterS(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterS(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 6 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 6, colorNo);
+ // Clockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ right(rotAngle);
+ penUp();
+ forward(2*b + 3*c); // color = ffffff
+ penDown();
+ left(180);
+}
+
+// Draws letter U in colour specified by colorNo with font height h
+// from the current turtle position.
+// function letterU(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void letterU(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // edge length of a regular octagon
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ forward(h - c, colorNo);
+ penUp();
+ backward(h-c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagoin with edge length b in colour specified by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// Draws a question mark in colour specified by colorNo with font height h
+// from the current turtle position.
+// function qstnMk(h, colorNo)
+// TODO Revise the return type and declare the parameters!
+void qstnMk(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+
+
+ // Achteck-Kantenlänge
+ ??? b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ ??? c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(h-c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ forward(c, colorNo);
+ left(rotAngle);
+ forward(b/2.0, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+}
+
+// Has the turtle draw the given string 'text´ with font height 'h´ (in
+// pixels) and the colour coded by integer 'c´ from the current Turtle
+// position to the Turtle canvas. If the turtle looks North then
+// the text will be written rightwards. In the event, the turtle will be
+// placed behind the text in original orientation (such that the next text
+// would be written like a continuation. Colour codes:
+// 1 = black
+// 2 = red
+// 3 = yellow
+// 4 = green
+// 5 = cyan
+// 6 = blue
+// 7 = pink
+// 8 = grey
+// 9 = orange
+// 10 = violet
+// All letters (ASCII) will be converted to uppercase, digits cannot
+// be represented, the set of representable special characters is:
+// '.', ',', '!', '?'. Other characters will be shown as a small
+// centred square (dummy character).
+// function drawText(text: string; h: integer; c: integer)
+// TODO Revise the return type and declare the parameters!
+void drawText(string text, int h, int c)
+{
+ // TODO: Check and accomplish variable declarations:
+ string letter;
+
+
+ ??? gap = h/10.0;
+ for (int k = 1; k <= length(text); k += (1)) {
+ letter = uppercase(copy(text, k, 1));
+ if (letter == ",") {
+ comma(h,c);
+ }
+ else {
+ // "," cannot be chacked against because the comma is misinterpreted
+ // as selector list separator.
+ switch (letter) {
+ case "A":
+ letterA(h,c);
+ break;
+ case "B":
+ letterB(h,c);
+ break;
+ case "C":
+ letterC(h,c);
+ break;
+ case "D":
+ letterD(h,c);
+ break;
+ case "E":
+ letterE(h,c);
+ break;
+ case "F":
+ letterF(h,c);
+ break;
+ case "G":
+ letterG(h,c);
+ break;
+ case "H":
+ letterH(h,c);
+ break;
+ case "I":
+ letterI(h,c);
+ break;
+ case "J":
+ letterJ(h,c);
+ break;
+ case "K":
+ letterK(h,c);
+ break;
+ case "L":
+ letterL(h,c);
+ break;
+ case "M":
+ letterM(h,c);
+ break;
+ case "N":
+ letterN(h,c);
+ break;
+ case "O":
+ letterO(h,c);
+ break;
+ case "P":
+ letterP(h,c);
+ break;
+ case "Q":
+ letterQ(h,c);
+ break;
+ case "R":
+ letterR(h,c);
+ break;
+ case "S":
+ letterS(h,c);
+ break;
+ case "T":
+ letterT(h,c);
+ break;
+ case "U":
+ letterU(h,c);
+ break;
+ case "V":
+ letterV(h,c);
+ break;
+ case "W":
+ letterW(h,c);
+ break;
+ case "X":
+ letterX(h,c);
+ break;
+ case "Y":
+ letterY(h,c);
+ break;
+ case "Z":
+ letterZ(h,c);
+ break;
+ case " ":
+ blank(h,c);
+ break;
+ case "!":
+ exclMk(h,c);
+ break;
+ case "?":
+ qstnMk(h,c);
+ break;
+ case ".":
+ fullSt(h,c);
+ break;
+ default:
+ charDummy(h,c);
+ }
+ }
+ right(90);
+ penUp();
+ forward(gap); // color = ffffff
+ penDown();
+ left(90);
+ }
+}
+
+// Demo program for routine drawText()
+// Asks the user to enter a text, a wanted text height and colour,
+// and then draws this string onto the turtle screen. Places every
+// entered text to a new line.
+// program TextDemo
+int main(void)
+{
+ // TODO: Check and accomplish variable declarations:
+ int y;
+ ??? height;
+ ??? colour;
+
+
+ std::cout << "This is a demo program for text writing with Turleizer." << std::endl;
+ showTurtle();
+ penDown();
+ y = 0;
+ do {
+ std::cout << "Enter some text (empty string to exit)"; std::cin >> text;
+ // Make sure the content is interpreted as string
+ ??? text = "" + text;
+ if (text != "") {
+ do {
+ std::cout << "Height of the text (pixels)"; std::cin >> height;
+ } while (!(height >= 5));
+ do {
+ std::cout << "Colour (1=black, 2=red, 3=yellow, 4=green, 5=cyan, 6=blue, 7=pink, 8=gray, 9=orange, 10=violet)"; std::cin >> colour;
+ } while (!(colour >= 1 && colour <= 10));
+ y = y + height + 2;
+ gotoXY(0, y - 2);
+ drawText(text, height, colour);
+ }
+ } while (!(text == ""));
+ gotoXY(0, y + 15);
+ drawText("Thank you, bye.", 10, 4);
+ hideTurtle();
+
+ return 0;
+}
diff --git a/samples/export/C/ELIZA_2.3.c b/samples/export/C/ELIZA_2.3.c
new file mode 100644
index 00000000..370e87bd
--- /dev/null
+++ b/samples/export/C/ELIZA_2.3.c
@@ -0,0 +1,640 @@
+// program ELIZA
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2018-05-14 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+
+#define _CRT_SECURE_NO_WARNINGS
+#include
+#include
+
+#include
+
+
+// histArray contains the most recent user replies as ring buffer;
+// histIndex is the index where the next reply is to be stored (= index of the oldest
+// cached user reply).
+// Note: The depth of the history is to be specified by initializing a variable of this type,
+// e.g. for a history of depth 5:
+// myhistory <- History{{"", "", "", "", ""}, 0}
+struct History {
+ char*[] histArray;
+ int histIndex;
+};
+
+// Associates a key word in the text with an index in the reply ring array
+struct KeyMapEntry {
+ char* keyword;
+ int index;
+};
+
+
+// function adjustSpelling(sentence: string): string
+// Cares for correct letter case among others
+// TODO: Revise the return type and declare the parameters.
+char* adjustSpelling(char* sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ char* word;
+ char* start;
+ char* result;
+ int position;
+
+
+ result = sentence;
+ position = 1;
+ while ((position <= length(sentence)) && (copy(sentence, position, 1) == " ")) {
+ position = position + 1;
+ }
+ if (position <= length(sentence)) {
+ start = copy(sentence, 1, position);
+ delete(result, 1, position);
+ insert(uppercase(start), result, 1);
+ }
+ {
+ char* array324bf690[2] = {" i ", " i\'"};
+ int index324bf690;
+ for (index324bf690 = 0; index324bf690 < 2; index324bf690++) {
+ char* word = array324bf690[index324bf690];
+ position = pos(word, result);
+ while (position > 0) {
+ delete(result, position+1, 1);
+ insert("I", result, position+1);
+ position = pos(word, result);
+ }
+ }
+ }
+
+ return result;
+}
+
+// function checkGoodBye(text: string; phrases: array of array[0..1] of string): boolean
+// Checks whether the given text contains some kind of
+// good-bye phrase inducing the end of the conversation
+// and if so writes a correspding good-bye message and
+// returns true, otherwise false
+// TODO: Revise the return type and declare the parameters.
+bool checkGoodBye(char* text, char* phrases[][2])
+{
+ // TODO: Check and accomplish variable declarations:
+ bool saidBye;
+ char* pair[];
+
+
+ // TODO:
+ // For any output using the 'printf' function you need to fill the first argument:
+ // http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
+
+ {
+ // TODO: Find out and fill in the number of elements of the array phrases here!
+ int count14015767 = ???;
+ int index14015767;
+ for (index14015767 = 0; index14015767 < count14015767; index14015767++) {
+ char* pair[] = phrases[index14015767];
+ if (pos(pair[0], text) > 0) {
+ saidBye = true;
+ printf("TODO: specify format\n", pair[1]);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// function checkRepetition(history: History; newInput: string): boolean
+// Checks whether newInput has occurred among the recently cached
+// input strings in the histArray component of history and updates the history.
+// TODO: Revise the return type and declare the parameters.
+bool checkRepetition(struct History history, char* newInput)
+{
+ // TODO: Check and accomplish variable declarations:
+ int i;
+ int histDepth;
+ bool hasOccurred;
+
+
+ hasOccurred = false;
+ if (length(newInput) > 4) {
+ histDepth = length(history.histArray);
+ for (i = 0; i <= histDepth-1; i += (1)) {
+ if (newInput == history.histArray[i]) {
+ hasOccurred = true;
+ }
+ }
+ history.histArray[history.histIndex] = newInput;
+ history.histIndex = (history.histIndex + 1) % (histDepth);
+ }
+ return hasOccurred;
+}
+
+// function conjugateStrings(sentence: string; key: string; keyPos: integer; flexions: array of array[0..1] of string): string
+// TODO: Revise the return type and declare the parameters.
+char* conjugateStrings(char* sentence, char* key, int keyPos, char* flexions[][2])
+{
+ // TODO: Check and accomplish variable declarations:
+ char* right;
+ char* result;
+ int position;
+ char* pair[];
+ char* left;
+
+
+ result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " ";
+ {
+ // TODO: Find out and fill in the number of elements of the array flexions here!
+ int count6e7cbe69 = ???;
+ int index6e7cbe69;
+ for (index6e7cbe69 = 0; index6e7cbe69 < count6e7cbe69; index6e7cbe69++) {
+ char* pair[] = flexions[index6e7cbe69];
+ left = "";
+ right = result;
+ position = pos(pair[0], right);
+ while (position > 0) {
+ left = left + copy(right, 1, position-1) + pair[1];
+ right = copy(right, position + length(pair[0]), length(right));
+ position = pos(pair[0], right);
+ }
+ result = left + right;
+ }
+ }
+ // Eliminate multiple spaces
+ position = pos(" ", result);
+ while (position > 0) {
+ result = copy(result, 1, position-1) + copy(result, position+1, length(result));
+ position = pos(" ", result);
+ }
+
+ return result;
+}
+
+// function findKeyword(const keyMap: array of KeyMapEntry; sentence: string): array[0..1] of integer
+// Looks for the occurrence of the first of the strings
+// contained in keywords within the given sentence (in
+// array order).
+// Returns an array of
+// 0: the index of the first identified keyword (if any, otherwise -1),
+// 1: the position inside sentence (0 if not found)
+// TODO: Revise the return type and declare the parameters.
+// C does not permit to return arrays - find an other way to pass the result!
+int[2] findKeyword(const array of KeyMapEntry keyMap, char* sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ const array of KeyMapEntry keyMap;
+ int result[2];
+ int position;
+ int i;
+ struct KeyMapEntry entry;
+
+
+ result[0] = -1;
+ result[1] = 0;
+ i = 0;
+ while ((result[0] < 0) && (i < length(keyMap))) {
+ entry = keyMap[i];
+ position = pos(entry.keyword, sentence);
+ if (position > 0) {
+ result[0] = i;
+ result[1] = position;
+ }
+ i = i+1;
+ }
+
+ return result;
+}
+
+// function normalizeInput(sentence: string): string
+// Converts the sentence to lowercase, eliminates all
+// interpunction (i.e. ',', '.', ';'), and pads the
+// sentence among blanks
+// TODO: Revise the return type and declare the parameters.
+char* normalizeInput(char* sentence)
+{
+ // TODO: Check and accomplish variable declarations:
+ char symbol;
+ char* result;
+ int position;
+
+
+ sentence = lowercase(sentence);
+ {
+ char arrayb4f79f[5] = {'.', ',', ';', '!', '?'};
+ int indexb4f79f;
+ for (indexb4f79f = 0; indexb4f79f < 5; indexb4f79f++) {
+ char symbol = arrayb4f79f[indexb4f79f];
+ position = pos(symbol, sentence);
+ while (position > 0) {
+ sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence));
+ position = pos(symbol, sentence);
+ }
+ }
+ }
+ result = " " + sentence + " ";
+
+ return result;
+}
+
+// function setupGoodByePhrases(): array of array[0..1] of string
+// TODO: Revise the return type and declare the parameters.
+// C does not permit to return arrays - find an other way to pass the result!
+char*[][2] setupGoodByePhrases()
+{
+ // TODO: Check and accomplish variable declarations:
+ char* phrases[][2];
+
+
+ phrases[0][0] = " shut";
+ phrases[0][1] = "Okay. If you feel that way I\'ll shut up. ... Your choice.";
+ phrases[1][0] = "bye";
+ phrases[1][1] = "Well, let\'s end our talk for now. See you later. Bye.";
+ return phrases;
+}
+
+// function setupKeywords(): array of KeyMapEntry
+// The lower the index the higher the rank of the keyword (search is sequential).
+// The index of the first keyword found in a user sentence maps to a respective
+// reply ring as defined in `setupReplies()´.
+// TODO: Revise the return type and declare the parameters.
+// C does not permit to return arrays - find an other way to pass the result!
+KeyMapEntry[] setupKeywords()
+{
+ // TODO: Check and accomplish variable declarations:
+ // The empty key string (last entry) is the default clause - will always be found
+ KeyMapEntry keywords[];
+
+
+ // The empty key string (last entry) is the default clause - will always be found
+ keywords[39].keyword = "";
+ keywords[39].index = 29;
+ keywords[0].keyword = "can you ";
+ keywords[0].index = 0;
+ keywords[1].keyword = "can i ";
+ keywords[1].index = 1;
+ keywords[2].keyword = "you are ";
+ keywords[2].index = 2;
+ keywords[3].keyword = "you\'re ";
+ keywords[3].index = 2;
+ keywords[4].keyword = "i don't ";
+ keywords[4].index = 3;
+ keywords[5].keyword = "i feel ";
+ keywords[5].index = 4;
+ keywords[6].keyword = "why don\'t you ";
+ keywords[6].index = 5;
+ keywords[7].keyword = "why can\'t i ";
+ keywords[7].index = 6;
+ keywords[8].keyword = "are you ";
+ keywords[8].index = 7;
+ keywords[9].keyword = "i can\'t ";
+ keywords[9].index = 8;
+ keywords[10].keyword = "i am ";
+ keywords[10].index = 9;
+ keywords[11].keyword = "i\'m ";
+ keywords[11].index = 9;
+ keywords[12].keyword = "you ";
+ keywords[12].index = 10;
+ keywords[13].keyword = "i want ";
+ keywords[13].index = 11;
+ keywords[14].keyword = "what ";
+ keywords[14].index = 12;
+ keywords[15].keyword = "how ";
+ keywords[15].index = 12;
+ keywords[16].keyword = "who ";
+ keywords[16].index = 12;
+ keywords[17].keyword = "where ";
+ keywords[17].index = 12;
+ keywords[18].keyword = "when ";
+ keywords[18].index = 12;
+ keywords[19].keyword = "why ";
+ keywords[19].index = 12;
+ keywords[20].keyword = "name ";
+ keywords[20].index = 13;
+ keywords[21].keyword = "cause ";
+ keywords[21].index = 14;
+ keywords[22].keyword = "sorry ";
+ keywords[22].index = 15;
+ keywords[23].keyword = "dream ";
+ keywords[23].index = 16;
+ keywords[24].keyword = "hello ";
+ keywords[24].index = 17;
+ keywords[25].keyword = "hi ";
+ keywords[25].index = 17;
+ keywords[26].keyword = "maybe ";
+ keywords[26].index = 18;
+ keywords[27].keyword = " no";
+ keywords[27].index = 19;
+ keywords[28].keyword = "your ";
+ keywords[28].index = 20;
+ keywords[29].keyword = "always ";
+ keywords[29].index = 21;
+ keywords[30].keyword = "think ";
+ keywords[30].index = 22;
+ keywords[31].keyword = "alike ";
+ keywords[31].index = 23;
+ keywords[32].keyword = "yes ";
+ keywords[32].index = 24;
+ keywords[33].keyword = "friend ";
+ keywords[33].index = 25;
+ keywords[34].keyword = "computer";
+ keywords[34].index = 26;
+ keywords[35].keyword = "bot ";
+ keywords[35].index = 26;
+ keywords[36].keyword = "smartphone";
+ keywords[36].index = 27;
+ keywords[37].keyword = "father ";
+ keywords[37].index = 28;
+ keywords[38].keyword = "mother ";
+ keywords[38].index = 28;
+ return keywords;
+}
+
+// function setupReflexions(): array of array[0..1] of string
+// Returns an array of pairs of mutualy substitutable
+// TODO: Revise the return type and declare the parameters.
+// C does not permit to return arrays - find an other way to pass the result!
+char*[][2] setupReflexions()
+{
+ // TODO: Check and accomplish variable declarations:
+ char* reflexions[][2];
+
+
+ reflexions[0][0] = " are ";
+ reflexions[0][1] = " am ";
+ reflexions[1][0] = " were ";
+ reflexions[1][1] = " was ";
+ reflexions[2][0] = " you ";
+ reflexions[2][1] = " I ";
+ reflexions[3][0] = " your";
+ reflexions[3][1] = " my";
+ reflexions[4][0] = " i\'ve ";
+ reflexions[4][1] = " you\'ve ";
+ reflexions[5][0] = " i\'m ";
+ reflexions[5][1] = " you\'re ";
+ reflexions[6][0] = " me ";
+ reflexions[6][1] = " you ";
+ reflexions[7][0] = " my ";
+ reflexions[7][1] = " your ";
+ reflexions[8][0] = " i ";
+ reflexions[8][1] = " you ";
+ reflexions[9][0] = " am ";
+ reflexions[9][1] = " are ";
+ return reflexions;
+}
+
+// function setupReplies(): array of array of string
+// This routine sets up the reply rings addressed by the key words defined in
+// routine `setupKeywords()´ and mapped hitherto by the cross table defined
+// in `setupMapping()´
+// TODO: Revise the return type and declare the parameters.
+// C does not permit to return arrays - find an other way to pass the result!
+char*[][/*???*/] setupReplies()
+{
+ // TODO: Check and accomplish variable declarations:
+ char* setupReplies[][/*???*/];
+ char* replies[][/*???*/];
+
+
+ replies[29][0] = "Say, do you have any psychological problems?";
+ replies[29][1] = "What does that suggest to you?";
+ replies[29][2] = "I see.";
+ replies[29][3] = "I'm not sure I understand you fully.";
+ replies[29][4] = "Come come elucidate your thoughts.";
+ replies[29][5] = "Can you elaborate on that?";
+ replies[29][6] = "That is quite interesting.";
+ replies[0][0] = "Don't you believe that I can*?";
+ replies[0][1] = "Perhaps you would like to be like me?";
+ replies[0][2] = "You want me to be able to*?";
+ replies[1][0] = "Perhaps you don't want to*?";
+ replies[1][1] = "Do you want to be able to*?";
+ replies[2][0] = "What makes you think I am*?";
+ replies[2][1] = "Does it please you to believe I am*?";
+ replies[2][2] = "Perhaps you would like to be*?";
+ replies[2][3] = "Do you sometimes wish you were*?";
+ replies[3][0] = "Don't you really*?";
+ replies[3][1] = "Why don't you*?";
+ replies[3][2] = "Do you wish to be able to*?";
+ replies[3][3] = "Does that trouble you*?";
+ replies[4][0] = "Do you often feel*?";
+ replies[4][1] = "Are you afraid of feeling*?";
+ replies[4][2] = "Do you enjoy feeling*?";
+ replies[5][0] = "Do you really believe I don't*?";
+ replies[5][1] = "Perhaps in good time I will*.";
+ replies[5][2] = "Do you want me to*?";
+ replies[6][0] = "Do you think you should be able to*?";
+ replies[6][1] = "Why can't you*?";
+ replies[7][0] = "Why are you interested in whether or not I am*?";
+ replies[7][1] = "Would you prefer if I were not*?";
+ replies[7][2] = "Perhaps in your fantasies I am*?";
+ replies[8][0] = "How do you know you can't*?";
+ replies[8][1] = "Have you tried?";
+ replies[8][2] = "Perhaps you can now*.";
+ replies[9][0] = "Did you come to me because you are*?";
+ replies[9][1] = "How long have you been*?";
+ replies[9][2] = "Do you believe it is normal to be*?";
+ replies[9][3] = "Do you enjoy being*?";
+ replies[10][0] = "We were discussing you--not me.";
+ replies[10][1] = "Oh, I*.";
+ replies[10][2] = "You're not really talking about me, are you?";
+ replies[11][0] = "What would it mean to you if you got*?";
+ replies[11][1] = "Why do you want*?";
+ replies[11][2] = "Suppose you soon got*...";
+ replies[11][3] = "What if you never got*?";
+ replies[11][4] = "I sometimes also want*.";
+ replies[12][0] = "Why do you ask?";
+ replies[12][1] = "Does that question interest you?";
+ replies[12][2] = "What answer would please you the most?";
+ replies[12][3] = "What do you think?";
+ replies[12][4] = "Are such questions on your mind often?";
+ replies[12][5] = "What is it that you really want to know?";
+ replies[12][6] = "Have you asked anyone else?";
+ replies[12][7] = "Have you asked such questions before?";
+ replies[12][8] = "What else comes to mind when you ask that?";
+ replies[13][0] = "Names don't interest me.";
+ replies[13][1] = "I don't care about names -- please go on.";
+ replies[14][0] = "Is that the real reason?";
+ replies[14][1] = "Don't any other reasons come to mind?";
+ replies[14][2] = "Does that reason explain anything else?";
+ replies[14][3] = "What other reasons might there be?";
+ replies[15][0] = "Please don't apologize!";
+ replies[15][1] = "Apologies are not necessary.";
+ replies[15][2] = "What feelings do you have when you apologize?";
+ replies[15][3] = "Don't be so defensive!";
+ replies[16][0] = "What does that dream suggest to you?";
+ replies[16][1] = "Do you dream often?";
+ replies[16][2] = "What persons appear in your dreams?";
+ replies[16][3] = "Are you disturbed by your dreams?";
+ replies[17][0] = "How do you do ...please state your problem.";
+ replies[18][0] = "You don't seem quite certain.";
+ replies[18][1] = "Why the uncertain tone?";
+ replies[18][2] = "Can't you be more positive?";
+ replies[18][3] = "You aren't sure?";
+ replies[18][4] = "Don't you know?";
+ replies[19][0] = "Are you saying no just to be negative?";
+ replies[19][1] = "You are being a bit negative.";
+ replies[19][2] = "Why not?";
+ replies[19][3] = "Are you sure?";
+ replies[19][4] = "Why no?";
+ replies[20][0] = "Why are you concerned about my*?";
+ replies[20][1] = "What about your own*?";
+ replies[21][0] = "Can you think of a specific example?";
+ replies[21][1] = "When?";
+ replies[21][2] = "What are you thinking of?";
+ replies[21][3] = "Really, always?";
+ replies[22][0] = "Do you really think so?";
+ replies[22][1] = "But you are not sure you*?";
+ replies[22][2] = "Do you doubt you*?";
+ replies[23][0] = "In what way?";
+ replies[23][1] = "What resemblance do you see?";
+ replies[23][2] = "What does the similarity suggest to you?";
+ replies[23][3] = "What other connections do you see?";
+ replies[23][4] = "Could there really be some connection?";
+ replies[23][5] = "How?";
+ replies[23][6] = "You seem quite positive.";
+ replies[24][0] = "Are you sure?";
+ replies[24][1] = "I see.";
+ replies[24][2] = "I understand.";
+ replies[25][0] = "Why do you bring up the topic of friends?";
+ replies[25][1] = "Do your friends worry you?";
+ replies[25][2] = "Do your friends pick on you?";
+ replies[25][3] = "Are you sure you have any friends?";
+ replies[25][4] = "Do you impose on your friends?";
+ replies[25][5] = "Perhaps your love for friends worries you.";
+ replies[26][0] = "Do computers worry you?";
+ replies[26][1] = "Are you talking about me in particular?";
+ replies[26][2] = "Are you frightened by machines?";
+ replies[26][3] = "Why do you mention computers?";
+ replies[26][4] = "What do you think machines have to do with your problem?";
+ replies[26][5] = "Don't you think computers can help people?";
+ replies[26][6] = "What is it about machines that worries you?";
+ replies[27][0] = "Do you sometimes feel uneasy without a smartphone?";
+ replies[27][1] = "Have you had these phantasies before?";
+ replies[27][2] = "Does the world seem more real for you via apps?";
+ replies[28][0] = "Tell me more about your family.";
+ replies[28][1] = "Who else in your family*?";
+ replies[28][2] = "What does family relations mean for you?";
+ replies[28][3] = "Come on, How old are you?";
+ setupReplies = replies;
+
+ return setupReplies;
+}
+// Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+// "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+// Computational Linguistis 1(1966)9, pp. 36-45
+// Revision history:
+// 2016-10-06 Initial version
+// 2017-03-29 Two diagrams updated (comments translated to English)
+// 2017-03-29 More keywords and replies added
+// 2019-03-14 Replies and mapping reorganised for easier maintenance
+// 2019-03-15 key map joined from keyword array and index map
+// 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+// 2019-11-28 New global type "History" (to ensure a homogenous array)
+int main(void)
+{
+ // BEGIN initialization for "History"
+ // END initialization for "History"
+ // BEGIN initialization for "KeyMapEntry"
+ // END initialization for "KeyMapEntry"
+
+ // TODO: Check and accomplish variable declarations:
+ const char* replies[][/*???*/] = setupReplies();
+ const char* reflexions[][2] = setupReflexions();
+ const char* byePhrases[][2] = setupGoodByePhrases();
+ const KeyMapEntry keyMap[] = setupKeywords();
+ char* varPart;
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ char* userInput;
+ ??? replyRing;
+ char* reply;
+ int posAster;
+ int offsets[];
+ ??? keyIndex;
+ bool isRepeated;
+ bool isGone;
+ // Stores the last five inputs of the user in a ring buffer,
+ // the second component is the rolling (over-)write index.
+ struct History history;
+ int findInfo[2];
+ struct KeyMapEntry entry;
+
+
+ // TODO:
+ // For any input using the 'scanf' function you need to fill the first argument.
+ // http://en.wikipedia.org/wiki/Scanf#Format_string_specifications
+
+ // TODO:
+ // For any output using the 'printf' function you need to fill the first argument:
+ // http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
+
+ // Title information
+ printf("TODO: specify format\n", "************* ELIZA **************");
+ printf("TODO: specify format\n", "* Original design by J. Weizenbaum");
+ printf("TODO: specify format\n", "**********************************");
+ printf("TODO: specify format\n", "* Adapted for Basic on IBM PC by");
+ printf("TODO: specify format\n", "* - Patricia Danielson");
+ printf("TODO: specify format\n", "* - Paul Hashfield");
+ printf("TODO: specify format\n", "**********************************");
+ printf("TODO: specify format\n", "* Adapted for Structorizer by");
+ printf("TODO: specify format\n", "* - Kay Gürtzig / FH Erfurt 2016");
+ printf("TODO: specify format\n", "* Version: 2.3 (2019-11-28)");
+ printf("TODO: specify format\n", "* (Requires at least Structorizer 3.30-03 to run)");
+ printf("TODO: specify format\n", "**********************************");
+ // Stores the last five inputs of the user in a ring buffer,
+ // the second component is the rolling (over-)write index.
+ history.histArray[0] = "";
+ history.histArray[1] = "";
+ history.histArray[2] = "";
+ history.histArray[3] = "";
+ history.histArray[4] = "";
+ history.histIndex = 0;
+ offsets[length(keyMap)-1] = 0;
+ isGone = false;
+ // Starter
+ printf("TODO: specify format\n", "Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?");
+ do {
+ scanf("TODO: specify format", &userInput);
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ userInput = normalizeInput(userInput);
+ isGone = checkGoodBye(userInput, byePhrases);
+ if (! isGone) {
+ reply = "Please don\'t repeat yourself!";
+ isRepeated = checkRepetition(history, userInput);
+ if (! isRepeated) {
+ findInfo = findKeyword(keyMap, userInput);
+ keyIndex = findInfo[0];
+ if (keyIndex < 0) {
+ // Should never happen...
+ keyIndex = length(keyMap)-1;
+ }
+ entry = keyMap[keyIndex];
+ // Variable part of the reply
+ varPart = "";
+ if (length(entry.keyword) > 0) {
+ varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions);
+ }
+ replyRing = replies[entry.index];
+ reply = replyRing[offsets[keyIndex]];
+ offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing);
+ posAster = pos("*", reply);
+ if (posAster > 0) {
+ if (varPart == " ") {
+ reply = "You will have to elaborate more for me to help you.";
+ }
+ else {
+ delete(reply, posAster, 1);
+ insert(varPart, reply, posAster);
+ }
+ }
+ reply = adjustSpelling(reply);
+ }
+ printf("TODO: specify format\n", reply);
+ }
+ } while (!(isGone));
+
+ return 0;
+}
diff --git a/samples/export/C/SORTING_TEST_MAIN.c b/samples/export/C/SORTING_TEST_MAIN.c
index 75e03a3b..835b21e5 100644
--- a/samples/export/C/SORTING_TEST_MAIN.c
+++ b/samples/export/C/SORTING_TEST_MAIN.c
@@ -1,5 +1,5 @@
// program SORTING_TEST_MAIN
-// Generated by Structorizer 3.30-02
+// Generated by Structorizer 3.30-03
//
// Copyright (C) 2019-10-02 Kay Gürtzig
// License: GPLv3-link
@@ -24,7 +24,7 @@
// processed subrange) finds its final place at the end of the
// subrange.
// TODO: Revise the return type and declare the parameters.
-void bubbleSort(/*type?*/ values)
+void bubbleSort(??? values)
{
// TODO: Check and accomplish variable declarations:
??? temp;
@@ -55,7 +55,7 @@ void bubbleSort(/*type?*/ values)
// index range-1, restores heap property in the subtree at index i
// again.
// TODO: Revise the return type and declare the parameters.
-void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range)
+void maxHeapify(??? heap, ??? i, ??? range)
{
// TODO: Check and accomplish variable declarations:
??? temp;
@@ -93,7 +93,7 @@ void maxHeapify(/*type?*/ heap, /*type?*/ i, /*type?*/ range)
// This is not the most efficient algorithm (about half the swapping
// might still be avoided) but it is pretty clear.
// TODO: Revise the return type and declare the parameters.
-int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p)
+int partition(??? values, ??? start, ??? stop, ??? p)
{
// TODO: Check and accomplish variable declarations:
??? seen;
@@ -131,7 +131,7 @@ int partition(/*type?*/ values, /*type?*/ start, /*type?*/ stop, /*type?*/ p)
// function testSorted(numbers): bool
// Checks whether or not the passed-in array is (ascendingly) sorted.
// TODO: Revise the return type and declare the parameters.
-bool testSorted(/*type?*/ numbers)
+bool testSorted(??? numbers)
{
// TODO: Check and accomplish variable declarations:
bool isSorted;
@@ -159,7 +159,7 @@ bool testSorted(/*type?*/ numbers)
// (index >= length(heap) div 2) and goes then up towards
// the root.
// TODO: Revise the return type and declare the parameters.
-int buildMaxHeap(/*type?*/ heap)
+int buildMaxHeap(??? heap)
{
// TODO: Check and accomplish variable declarations:
int lgth;
@@ -179,7 +179,7 @@ int buildMaxHeap(/*type?*/ heap)
// start is the first index of the subsequence to be sorted,
// stop is the index BEHIND the subsequence to be sorted.
// TODO: Revise the return type and declare the parameters.
-int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
+int quickSort(??? values, ??? start, ??? stop)
{
// TODO: Check and accomplish variable declarations:
??? p;
@@ -232,7 +232,7 @@ int quickSort(/*type?*/ values, /*type?*/ start, /*type?*/ stop)
// Sorts the array 'values´ of numbers according to he heap sort
// algorithm
// TODO: Revise the return type and declare the parameters.
-int heapSort(/*type?*/ values)
+int heapSort(??? values)
{
// TODO: Check and accomplish variable declarations:
??? maximum;
@@ -260,13 +260,13 @@ int heapSort(/*type?*/ values)
int main(void)
{
// TODO: Check and accomplish variable declarations:
- ??? values3;
- ??? values2;
- ??? values1;
+ ??? values3[];
+ ??? values2[];
+ int values1[];
??? show;
- ??? ok3;
- ??? ok2;
- ??? ok1;
+ bool ok3;
+ bool ok2;
+ bool ok1;
??? modus;
int i;
??? elementCount;
@@ -299,7 +299,7 @@ int main(void)
break;
}
}
- // Kopiere das Array für exakte Vergleichbarkeit
+ // Copy the array for exact comparability
for (i = 0; i <= elementCount-1; i += (1)) {
values2[i] = values1[i];
values3[i] = values1[i];
diff --git a/samples/export/C/TextDemo.c b/samples/export/C/TextDemo.c
new file mode 100644
index 00000000..7905ca62
--- /dev/null
+++ b/samples/export/C/TextDemo.c
@@ -0,0 +1,1308 @@
+// program TextDemo
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2019-10-10 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+
+#define _CRT_SECURE_NO_WARNINGS
+#include
+#include
+
+#include
+
+
+
+// function blank(h, colorNo)
+// Draws a blank for font height h, ignoring the colorNo
+// TODO: Revise the return type and declare the parameters.
+void blank(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ left(90);
+}
+
+// function forward(len, color)
+// TODO: Revise the return type and declare the parameters.
+void forward(??? len, ??? color)
+{
+ // TODO: Check and accomplish variable declarations:
+
+ switch (color) {
+ case 1:
+ forward(len); // color = ffffff
+ break;
+ case 2:
+ forward(len); // color = ff8080
+ break;
+ case 3:
+ forward(len); // color = ffff80
+ break;
+ case 4:
+ forward(len); // color = 80ff80
+ break;
+ case 5:
+ forward(len); // color = 80ffff
+ break;
+ case 6:
+ forward(len); // color = 0080ff
+ break;
+ case 7:
+ forward(len); // color = ff80c0
+ break;
+ case 8:
+ forward(len); // color = c0c0c0
+ break;
+ case 9:
+ forward(len); // color = ff8000
+ break;
+ case 10:
+ forward(len); // color = 8080ff
+ break;
+ }
+}
+
+// function letterA(h, colorNo)
+// Draws letter A in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterA(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ right(rotAngle);
+ forward(hypo/2.0, colorNo);
+ right(90 - rotAngle);
+ forward(width/2.0, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ left(90 - rotAngle);
+ forward(hypo/2.0, colorNo);
+ left(2*rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+}
+
+// function letterE(h, colorNo)
+// Draws letter E in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterE(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+}
+
+// function letterF(h, colorNo)
+// Draws letter F in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterF(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ forward(h, colorNo);
+ right(90);
+ forward(width, colorNo);
+ right(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+ penUp();
+ forward(h/2.0); // color = ffffff
+ left(90);
+ forward(width); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// function letterH(h, colorNo)
+// Draws letter H in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterH(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width); // color = ffffff
+ left(90);
+ penDown();
+ forward(h/2.0, colorNo);
+ left(180);
+}
+
+// function letterI(h, colorNo)
+// Draws letter I in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterI(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward(c); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ backward(b/2.0); // color = ffffff
+ left(90);
+ penDown();
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ backward(b/2.0); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ penUp();
+ forward(b/2 + c); // color = ffffff
+ left(90);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterK(h, colorNo)
+// Draws letter K in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterK(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ ??? diag;
+
+
+ width = h/2.0;
+ diag = h/sqrt(2.0);
+ forward(h, colorNo);
+ penUp();
+ right(90);
+ forward(width); // color = ffffff
+ right(135);
+ penDown();
+ forward(diag, colorNo);
+ left(90);
+ forward(diag, colorNo);
+ left(135);
+}
+
+// function letterL(h, colorNo)
+// Draws letter L in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterL(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90);
+}
+
+// function letterM(h, colorNo)
+// Draws letter M in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterM(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ ??? hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ forward(-h, colorNo);
+}
+
+// function letterN(h, colorNo)
+// Draws letter N in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterN(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ forward(h, colorNo);
+ left(rotAngle);
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ forward(h, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterT(h, colorNo)
+// Draws letter T in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterT(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+
+
+ width = h/2.0;
+ penUp();
+ forward(h); // color = ffffff
+ penDown();
+ right(90);
+ forward(width, colorNo);
+ penUp();
+ backward(width/2.0); // color = ffffff
+ penDown();
+ right(90);
+ forward(h, colorNo);
+ left(90);
+ penUp();
+ forward(width/2.0); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// function letterV(h, colorNo)
+// Draws letter V in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterV(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(h*h + width*width/4.0);
+ rotAngle = toDegrees(atan(width/2.0/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterW(h, colorNo)
+// Draws letter W in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterW(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width_3;
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ width_3 = width/3.0;
+ hypo = sqrt(width_3*width_3 + h*h);
+ rotAngle = toDegrees(atan(width_3/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width_3); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(2*rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(rotAngle);
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterX(h, colorNo)
+// Draws letter X in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterX(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ right(rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ left(90+rotAngle);
+ forward(width); // color = ffffff
+ right(90-rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+}
+
+// function letterY(h, colorNo)
+// Draws letter Y in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterY(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ ??? hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(width*width + h*h)/2.0;
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ left(rotAngle);
+ penDown();
+ forward(-hypo, colorNo);
+ right(rotAngle);
+ penUp();
+ backward(h/2.0); // color = ffffff
+ penDown();
+ forward(h/2.0, colorNo);
+ right(rotAngle);
+ forward(hypo, colorNo);
+ left(rotAngle);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterZ(h, colorNo)
+// Draws letter Z in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterZ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle;
+ double hypo;
+
+
+ width = h/2.0;
+ hypo = sqrt(width*width + h*h);
+ rotAngle = toDegrees(atan(width/h));
+ penUp();
+ forward(h); // color = ffffff
+ right(90);
+ penDown();
+ forward(width, colorNo);
+ left(90-rotAngle);
+ forward(-hypo, colorNo);
+ right(90-rotAngle);
+ forward(width, colorNo);
+ left(90);
+}
+
+// function polygonPart(a: double; n: integer; ctrclkws: boolean; nEdges: integer; color: int)
+// Draws nEdges edges of a regular n-polygon with edge length a
+// counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.
+// TODO: Revise the return type and declare the parameters.
+void polygonPart(double a, int n, bool ctrclkws, int nEdges, int color)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? rotAngle;
+ int k;
+
+
+ rotAngle = 360.0/n;
+ if (ctrclkws) {
+ rotAngle = -rotAngle;
+ }
+ for (k = 1; k <= nEdges; k += (1)) {
+ right(rotAngle);
+ forward(a, color);
+ }
+}
+
+// function charDummy(h, colorNo)
+// Draws a dummy character (small centered square) with font height h and
+// the colour encoded by colorNo
+// TODO: Revise the return type and declare the parameters.
+void charDummy(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ ??? d;
+ ??? c;
+ ??? b;
+
+
+ width = h / 2.0;
+ // Octagon edge length (here: edge lengzh of the square)
+ b = width / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ c = (width - b) / 2.0;
+ d = b / sqrt(2.0);
+ penUp();
+ forward(h/2.0-b/2.0); // color = ffffff
+ right(90);
+ forward(c); // color = ffffff
+ right(90);
+ penDown();
+ // Draws the square with edge length b
+ polygonPart(b, 4, true, 4, colorNo);
+ penUp();
+ left(90);
+ forward(b + c); // color = ffffff
+ left(90);
+ backward(h/2.0-b/2.0); // color = ffffff
+ penDown();
+}
+
+// function comma(h, colorNo)
+// Draws a comma in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void comma(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ double rotAngle;
+ ??? hypo;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ rotAngle = toDegrees(atan(0.5));
+ hypo = c * sqrt(1.25);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 3 edges of a square with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 3, colorNo);
+ left(90);
+ forward(c/2.0, colorNo);
+ right(90);
+ forward(c, colorNo);
+ left(180 - rotAngle);
+ forward(hypo, colorNo);
+ penUp();
+ right(90 - rotAngle);
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+}
+
+// function exclMk(h, colorNo)
+// Draws an exclamation mark in the colour encoded by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void exclMk(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? width;
+ double rotAngle2;
+ // 360°/8
+ int rotAngle;
+ ??? length2;
+ ??? length1;
+ double hypo;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ width = h/2.0;
+ length1 = h - (b+c)/2.0;
+ length2 = length1 - 2*c;
+ hypo = sqrt(width*width/16.0 + length2*length2);
+ // 360°/8
+ rotAngle = 45;
+ rotAngle2 = toDegrees(atan(width/4.0/length2));
+ penUp();
+ forward(length1); // color = ffffff
+ right(90);
+ forward(width/2.0); // color = ffffff
+ left(90 + rotAngle);
+ penDown();
+ // Clockwise draw 5 edges of an octagon with edge length b/2
+ // in the colour endcoded by colorNo
+ polygonPart(b/2.0, 8, false, 5, colorNo);
+ right(rotAngle2);
+ forward(hypo, colorNo);
+ left(2*rotAngle2);
+ forward(-hypo, colorNo);
+ penUp();
+ forward(hypo); // color = ffffff
+ right(rotAngle2);
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+}
+
+// function fullSt(h, colorNo)
+// Draws a full stop in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void fullSt(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ penUp();
+ right(90);
+ forward((c+b)/2.0 + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, true, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ penDown();
+}
+
+// function letterB(h, colorNo)
+// Draws letter B in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterB(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer corner triangle of the octagon
+ c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Clockwise draw 4 edges of an octagon with edge length b
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// function letterC(h, colorNo)
+// Draws letter C in the colour encoded by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterC(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the outer trinagle at the octagon corner
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Clockwise draws 3 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ penUp();
+ forward(2*b + 2*c); // color = ffffff
+ penDown();
+ // Counterclockwise draws 4 edges of an octagon with edge length b
+ // iin the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+}
+
+// function letterD(h, colorNo)
+// Draws letter D in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterD(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(b + 2*c, colorNo);
+ // Clockwise draw 2 edges of an octagon with edge length b in the colour
+ // encoded by colorNo
+ polygonPart(b, 8, false, 2, colorNo);
+ forward(c, colorNo);
+ penUp();
+ left(180);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// function letterG(h, colorNo)
+// Draws letter G in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterG(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon.
+ c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(c, colorNo);
+ left(90);
+ forward(b/2.0 + c, colorNo);
+ penUp();
+ backward(b/2.0 + c); // color = ffffff
+ right(90);
+ forward(b + c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 4 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c, colorNo);
+ penDown();
+ left(90);
+}
+
+// function letterJ(h, colorNo)
+// Draws letter J in colour encoded by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterJ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagon with edge length b in
+ // the colour encoded by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function letterO(h, colorNo)
+// Draws letter O in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterO(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0);
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(90);
+}
+
+// function letterP(h, colorNo)
+// Draws letter P in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterP(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ ??? c;
+ ??? b;
+
+
+ // Octagon edge length
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Cathetus of the corner triangle outside the octagon
+ c = b / sqrt(2.0);
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ penUp();
+ backward(b + 2*c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ penDown();
+ left(180);
+}
+
+// function letterQ(h, colorNo)
+// Draws letter Q in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterQ(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ // Counterclockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 4, colorNo);
+ forward(b + 2*c, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(b + 2*c); // color = ffffff
+ right(rotAngle);
+ backward(b); // color = ffffff
+ penDown();
+ forward(b, colorNo);
+ left(90 + rotAngle);
+}
+
+// function letterR(h, colorNo)
+// Zeichnet den Buchstaben R von der Turtleposition aus
+// mit Zeilenhöhe h
+// TODO: Revise the return type and declare the parameters.
+void letterR(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ forward(h, colorNo);
+ right(90);
+ forward(c+b, colorNo);
+ // Clockwise draw 4 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 4, colorNo);
+ forward(c, colorNo);
+ left(90 + rotAngle);
+ forward(sqrt(2.0)*(b + 2*c), colorNo);
+ left(90 + rotAngle);
+}
+
+// function letterS(h, colorNo)
+// Draws letter S in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterS(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 6 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, true, 6, colorNo);
+ // Clockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ right(rotAngle);
+ penUp();
+ forward(2*b + 3*c); // color = ffffff
+ penDown();
+ left(180);
+}
+
+// function letterU(h, colorNo)
+// Draws letter U in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void letterU(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // edge length of a regular octagon
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(c); // color = ffffff
+ penDown();
+ forward(h - c, colorNo);
+ penUp();
+ backward(h-c); // color = ffffff
+ penDown();
+ right(180);
+ // Counterclockwise draw 3 edges of an octagoin with edge length b in colour specified by colorNo
+ polygonPart(b, 8, true, 3, colorNo);
+ left(rotAngle);
+ forward(h - c, colorNo);
+ penUp();
+ backward(h); // color = ffffff
+ penDown();
+}
+
+// function qstnMk(h, colorNo)
+// Draws a question mark in colour specified by colorNo with font height h
+// from the current turtle position.
+// TODO: Revise the return type and declare the parameters.
+void qstnMk(??? h, ??? colorNo)
+{
+ // TODO: Check and accomplish variable declarations:
+ // 360°/8
+ int rotAngle;
+ ??? c;
+ ??? b;
+
+
+ // Achteck-Kantenlänge
+ b = h * 0.5 / (sqrt(2.0) + 1);
+ // Eckenlänge außen am Achteck
+ c = b / sqrt(2.0);
+ // 360°/8
+ rotAngle = 45;
+ penUp();
+ forward(h-c); // color = ffffff
+ penDown();
+ // Counterclockwise draw 5 edges of an octagon with edge length b
+ // in the colour endcoded by colorNo
+ polygonPart(b, 8, false, 5, colorNo);
+ forward(c, colorNo);
+ left(rotAngle);
+ forward(b/2.0, colorNo);
+ penUp();
+ forward(c); // color = ffffff
+ left(90);
+ forward(c/2.0); // color = ffffff
+ penDown();
+ // Counterclockwise draw all 4 edges of a squarfe with edge length c
+ // in the colour endcoded by colorNo
+ polygonPart(c, 4, false, 4, colorNo);
+ penUp();
+ forward((c + b)/2.0); // color = ffffff
+ left(90);
+ backward(c); // color = ffffff
+ penDown();
+}
+
+// function drawText(text: string; h: integer; c: integer)
+// Has the turtle draw the given string 'text´ with font height 'h´ (in
+// pixels) and the colour coded by integer 'c´ from the current Turtle
+// position to the Turtle canvas. If the turtle looks North then
+// the text will be written rightwards. In the event, the turtle will be
+// placed behind the text in original orientation (such that the next text
+// would be written like a continuation. Colour codes:
+// 1 = black
+// 2 = red
+// 3 = yellow
+// 4 = green
+// 5 = cyan
+// 6 = blue
+// 7 = pink
+// 8 = grey
+// 9 = orange
+// 10 = violet
+// All letters (ASCII) will be converted to uppercase, digits cannot
+// be represented, the set of representable special characters is:
+// '.', ',', '!', '?'. Other characters will be shown as a small
+// centred square (dummy character).
+// TODO: Revise the return type and declare the parameters.
+void drawText(char* text, int h, int c)
+{
+ // TODO: Check and accomplish variable declarations:
+ char* letter;
+ int k;
+ ??? gap;
+
+
+ gap = h/10.0;
+ for (k = 1; k <= length(text); k += (1)) {
+ letter = uppercase(copy(text, k, 1));
+ if (letter == ",") {
+ comma(h,c);
+ }
+ else {
+ // "," cannot be chacked against because the comma is misinterpreted
+ // as selector list separator.
+ switch (letter) {
+ case "A":
+ letterA(h,c);
+ break;
+ case "B":
+ letterB(h,c);
+ break;
+ case "C":
+ letterC(h,c);
+ break;
+ case "D":
+ letterD(h,c);
+ break;
+ case "E":
+ letterE(h,c);
+ break;
+ case "F":
+ letterF(h,c);
+ break;
+ case "G":
+ letterG(h,c);
+ break;
+ case "H":
+ letterH(h,c);
+ break;
+ case "I":
+ letterI(h,c);
+ break;
+ case "J":
+ letterJ(h,c);
+ break;
+ case "K":
+ letterK(h,c);
+ break;
+ case "L":
+ letterL(h,c);
+ break;
+ case "M":
+ letterM(h,c);
+ break;
+ case "N":
+ letterN(h,c);
+ break;
+ case "O":
+ letterO(h,c);
+ break;
+ case "P":
+ letterP(h,c);
+ break;
+ case "Q":
+ letterQ(h,c);
+ break;
+ case "R":
+ letterR(h,c);
+ break;
+ case "S":
+ letterS(h,c);
+ break;
+ case "T":
+ letterT(h,c);
+ break;
+ case "U":
+ letterU(h,c);
+ break;
+ case "V":
+ letterV(h,c);
+ break;
+ case "W":
+ letterW(h,c);
+ break;
+ case "X":
+ letterX(h,c);
+ break;
+ case "Y":
+ letterY(h,c);
+ break;
+ case "Z":
+ letterZ(h,c);
+ break;
+ case " ":
+ blank(h,c);
+ break;
+ case "!":
+ exclMk(h,c);
+ break;
+ case "?":
+ qstnMk(h,c);
+ break;
+ case ".":
+ fullSt(h,c);
+ break;
+ default:
+ charDummy(h,c);
+ }
+ }
+ right(90);
+ penUp();
+ forward(gap); // color = ffffff
+ penDown();
+ left(90);
+ }
+}
+// Demo program for routine drawText()
+// Asks the user to enter a text, a wanted text height and colour,
+// and then draws this string onto the turtle screen. Places every
+// entered text to a new line.
+int main(void)
+{
+ // TODO: Check and accomplish variable declarations:
+ int y;
+ ??? text;
+ ??? height;
+ ??? colour;
+
+
+ // TODO:
+ // For any input using the 'scanf' function you need to fill the first argument.
+ // http://en.wikipedia.org/wiki/Scanf#Format_string_specifications
+
+ // TODO:
+ // For any output using the 'printf' function you need to fill the first argument:
+ // http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
+
+ printf("TODO: specify format\n", "This is a demo program for text writing with Turleizer.");
+ showTurtle();
+ penDown();
+ y = 0;
+ do {
+ printf("Enter some text (empty string to exit)"); scanf("TODO: specify format", &text);
+ // Make sure the content is interpreted as string
+ text = "" + text;
+ if (text != "") {
+ do {
+ printf("Height of the text (pixels)"); scanf("TODO: specify format", &height);
+ } while (!(height >= 5));
+ do {
+ printf("Colour (1=black, 2=red, 3=yellow, 4=green, 5=cyan, 6=blue, 7=pink, 8=gray, 9=orange, 10=violet)"); scanf("TODO: specify format", &colour);
+ } while (!(colour >= 1 && colour <= 10));
+ y = y + height + 2;
+ gotoXY(0, y - 2);
+ drawText(text, height, colour);
+ }
+ } while (!(text == ""));
+ gotoXY(0, y + 15);
+ drawText("Thank you, bye.", 10, 4);
+ hideTurtle();
+
+ return 0;
+}
diff --git a/samples/export/Java/ELIZA_2.3.java b/samples/export/Java/ELIZA_2.3.java
new file mode 100644
index 00000000..215955ed
--- /dev/null
+++ b/samples/export/Java/ELIZA_2.3.java
@@ -0,0 +1,477 @@
+// Generated by Structorizer 3.30-03
+//
+// Copyright (C) 2018-05-14 Kay Gürtzig
+// License: GPLv3-link
+// GNU General Public License (V 3)
+// https://www.gnu.org/licenses/gpl.html
+// http://www.gnu.de/documents/gpl.de.html
+//
+
+import java.util.Scanner;
+
+import javax.swing.*;
+/**
+ * Concept and lisp implementation published by Joseph Weizenbaum (MIT):
+ * "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In:
+ * Computational Linguistis 1(1966)9, pp. 36-45
+ * Revision history:
+ * 2016-10-06 Initial version
+ * 2017-03-29 Two diagrams updated (comments translated to English)
+ * 2017-03-29 More keywords and replies added
+ * 2019-03-14 Replies and mapping reorganised for easier maintenance
+ * 2019-03-15 key map joined from keyword array and index map
+ * 2019-03-28 Keyword "bot" inserted (same reply ring as "computer")
+ * 2019-11-28 New global type "History" (to ensure a homogenous array)
+ */
+public class ELIZA {
+
+
+ // histArray contains the most recent user replies as ring buffer;
+ // histIndex is the index where the next reply is to be stored (= index of the oldest
+ // cached user reply).
+ // Note: The depth of the history is to be specified by initializing a variable of this type,
+ // e.g. for a history of depth 5:
+ // myhistory <- History{{"", "", "", "", ""}, 0}
+ private class History{
+ public String[] histArray;
+ public int histIndex;
+ public History(String[] p_histArray, int p_histIndex)
+ {
+ histArray = p_histArray;
+ histIndex = p_histIndex;
+ }
+ };
+
+ // Associates a key word in the text with an index in the reply ring array
+ private class KeyMapEntry{
+ public String keyword;
+ public int index;
+ public KeyMapEntry(String p_keyword, int p_index)
+ {
+ keyword = p_keyword;
+ index = p_index;
+ }
+ };
+
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // BEGIN initialization for "History"
+ // END initialization for "History"
+ // BEGIN initialization for "KeyMapEntry"
+ // END initialization for "KeyMapEntry"
+
+ // TODO: Check and accomplish variable declarations:
+ String varPart;
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ String userInput;
+ String reply;
+ int posAster;
+ int[] offsets;
+ boolean isRepeated;
+ boolean isGone;
+ int[] findInfo;
+
+
+ // TODO: You may have to modify input instructions,
+ // e.g. by replacing nextLine() with a more suitable call
+ // according to the variable type, say nextInt().
+
+ // Title information
+ System.out.println("************* ELIZA **************");
+ System.out.println("* Original design by J. Weizenbaum");
+ System.out.println("**********************************");
+ System.out.println("* Adapted for Basic on IBM PC by");
+ System.out.println("* - Patricia Danielson");
+ System.out.println("* - Paul Hashfield");
+ System.out.println("**********************************");
+ System.out.println("* Adapted for Structorizer by");
+ System.out.println("* - Kay Gürtzig / FH Erfurt 2016");
+ System.out.println("* Version: 2.3 (2019-11-28)");
+ System.out.println("* (Requires at least Structorizer 3.30-03 to run)");
+ System.out.println("**********************************");
+ // Stores the last five inputs of the user in a ring buffer,
+ // the second component is the rolling (over-)write index.
+ History history = new History(new String[]{"", "", "", "", ""}, 0);
+ final String[][] replies = setupReplies();
+ final String[][] reflexions = setupReflexions();
+ final String[][] byePhrases = setupGoodByePhrases();
+ final KeyMapEntry[] keyMap = setupKeywords();
+ offsets[length(keyMap)-1] = 0;
+ isGone = false;
+ // Starter
+ System.out.println("Hi! I\'m your new therapist. My name is Eliza. What\'s your problem?");
+ do {
+ userInput = (new Scanner(System.in)).nextLine();
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ // Converts the input to lowercase, cuts out interpunctation
+ // and pads the string
+ userInput = normalizeInput(userInput);
+ isGone = checkGoodBye(userInput, byePhrases);
+ if (! isGone) {
+ reply = "Please don\'t repeat yourself!";
+ isRepeated = checkRepetition(history, userInput);
+ if (! isRepeated) {
+ findInfo = findKeyword(keyMap, userInput);
+ ??? keyIndex = findInfo[0];
+ if (keyIndex < 0) {
+ // Should never happen...
+ keyIndex = length(keyMap)-1;
+ }
+ KeyMapEntry entry = keyMap[keyIndex];
+ // Variable part of the reply
+ varPart = "";
+ if (length(entry.keyword) > 0) {
+ varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions);
+ }
+ ??? replyRing = replies[entry.index];
+ reply = replyRing[offsets[keyIndex]];
+ offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing);
+ posAster = pos("*", reply);
+ if (posAster > 0) {
+ if (varPart == " ") {
+ reply = "You will have to elaborate more for me to help you.";
+ }
+ else {
+ delete(reply, posAster, 1);
+ insert(varPart, reply, posAster);
+ }
+ }
+ reply = adjustSpelling(reply);
+ }
+ System.out.println(reply);
+ }
+ } while (!(isGone));
+ }
+
+ /**
+ * Cares for correct letter case among others
+ * @param sentence
+ * @return
+ */
+ private static String adjustSpelling(String sentence) {
+ // TODO: Check and accomplish variable declarations:
+ String word;
+ String start;
+ String result;
+ int position;
+
+
+ result = sentence;
+ position = 1;
+ while ((position <= length(sentence)) && (copy(sentence, position, 1) == " ")) {
+ position = position + 1;
+ }
+ if (position <= length(sentence)) {
+ start = copy(sentence, 1, position);
+ delete(result, 1, position);
+ insert(uppercase(start), result, 1);
+ }
+ for (String word : new String[]{" i ", " i\'"}) {
+ position = pos(word, result);
+ while (position > 0) {
+ delete(result, position+1, 1);
+ insert("I", result, position+1);
+ position = pos(word, result);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Checks whether the given text contains some kind of
+ * good-bye phrase inducing the end of the conversation
+ * and if so writes a correspding good-bye message and
+ * returns true, otherwise false
+ * @param text
+ * @param phrases
+ * @return
+ */
+ private static boolean checkGoodBye(String text, String[][] phrases) {
+ // TODO: Check and accomplish variable declarations:
+ boolean saidBye;
+ String[] pair;
+
+
+ for (@String pair : phrases) {
+ if (pos(pair[0], text) > 0) {
+ saidBye = true;
+ System.out.println(pair[1]);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks whether newInput has occurred among the recently cached
+ * input strings in the histArray component of history and updates the history.
+ * @param history
+ * @param newInput
+ * @return
+ */
+ private static boolean checkRepetition(History history, String newInput) {
+ // TODO: Check and accomplish variable declarations:
+ int histDepth;
+ boolean hasOccurred;
+
+
+ hasOccurred = false;
+ if (length(newInput) > 4) {
+ histDepth = length(history.histArray);
+ for (int i = 0; i <= histDepth-1; i += (1)) {
+ if (newInput == history.histArray[i]) {
+ hasOccurred = true;
+ }
+ }
+ history.histArray[history.histIndex] = newInput;
+ history.histIndex = (history.histIndex + 1) % (histDepth);
+ }
+ return hasOccurred;
+ }
+
+ /**
+ * @param sentence
+ * @param key
+ * @param keyPos
+ * @param flexions
+ * @return
+ */
+ private static String conjugateStrings(String sentence, String key, int keyPos, String[][] flexions) {
+ // TODO: Check and accomplish variable declarations:
+ String right;
+ String result;
+ int position;
+ String[] pair;
+ String left;
+
+
+ result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " ";
+ for (@String pair : flexions) {
+ left = "";
+ right = result;
+ position = pos(pair[0], right);
+ while (position > 0) {
+ left = left + copy(right, 1, position-1) + pair[1];
+ right = copy(right, position + length(pair[0]), length(right));
+ position = pos(pair[0], right);
+ }
+ result = left + right;
+ }
+ // Eliminate multiple spaces
+ position = pos(" ", result);
+ while (position > 0) {
+ result = copy(result, 1, position-1) + copy(result, position+1, length(result));
+ position = pos(" ", result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Looks for the occurrence of the first of the strings
+ * contained in keywords within the given sentence (in
+ * array order).
+ * Returns an array of
+ * 0: the index of the first identified keyword (if any, otherwise -1),
+ * 1: the position inside sentence (0 if not found)
+ * @param keyMap
+ * @param sentence
+ * @return
+ */
+ private static int[] findKeyword(final array of KeyMapEntry keyMap, String sentence) {
+ // TODO: Check and accomplish variable declarations:
+ int[] result;
+ int position;
+ int i;
+
+
+ // Contains the index of the keyword and its position in sentence
+ result = new int[]{-1, 0};
+ i = 0;
+ while ((result[0] < 0) && (i < length(keyMap))) {
+ KeyMapEntry entry = keyMap[i];
+ position = pos(entry.keyword, sentence);
+ if (position > 0) {
+ result[0] = i;
+ result[1] = position;
+ }
+ i = i+1;
+ }
+
+ return result;
+ }
+
+ /**
+ * Converts the sentence to lowercase, eliminates all
+ * interpunction (i.e. ',', '.', ';'), and pads the
+ * sentence among blanks
+ * @param sentence
+ * @return
+ */
+ private static String normalizeInput(String sentence) {
+ // TODO: Check and accomplish variable declarations:
+ String symbol;
+ String result;
+ int position;
+
+
+ sentence = lowercase(sentence);
+ for (String symbol : new String[]{'.', ',', ';', '!', '?'}) {
+ position = pos(symbol, sentence);
+ while (position > 0) {
+ sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence));
+ position = pos(symbol, sentence);
+ }
+ }
+ result = " " + sentence + " ";
+
+ return result;
+ }
+
+ /**
+ * @return
+ */
+ private static String[][] setupGoodByePhrases() {
+ // TODO: Check and accomplish variable declarations:
+ String[][] phrases;
+
+
+ phrases[0] = new String[]{" shut", "Okay. If you feel that way I\'ll shut up. ... Your choice."};
+ phrases[1] = new String[]{"bye", "Well, let\'s end our talk for now. See you later. Bye."};
+ return phrases;
+ }
+
+ /**
+ * The lower the index the higher the rank of the keyword (search is sequential).
+ * The index of the first keyword found in a user sentence maps to a respective
+ * reply ring as defined in `setupReplies()´.
+ * @return
+ */
+ private static KeyMapEntry[] setupKeywords() {
+ // TODO: Check and accomplish variable declarations:
+ // The empty key string (last entry) is the default clause - will always be found
+ KeyMapEntry[] keywords;
+
+
+ // The empty key string (last entry) is the default clause - will always be found
+ keywords[39] = new KeyMapEntry("", 29);
+ keywords[0] = new KeyMapEntry("can you ", 0);
+ keywords[1] = new KeyMapEntry("can i ", 1);
+ keywords[2] = new KeyMapEntry("you are ", 2);
+ keywords[3] = new KeyMapEntry("you\'re ", 2);
+ keywords[4] = new KeyMapEntry("i don't ", 3);
+ keywords[5] = new KeyMapEntry("i feel ", 4);
+ keywords[6] = new KeyMapEntry("why don\'t you ", 5);
+ keywords[7] = new KeyMapEntry("why can\'t i ", 6);
+ keywords[8] = new KeyMapEntry("are you ", 7);
+ keywords[9] = new KeyMapEntry("i can\'t ", 8);
+ keywords[10] = new KeyMapEntry("i am ", 9);
+ keywords[11] = new KeyMapEntry("i\'m ", 9);
+ keywords[12] = new KeyMapEntry("you ", 10);
+ keywords[13] = new KeyMapEntry("i want ", 11);
+ keywords[14] = new KeyMapEntry("what ", 12);
+ keywords[15] = new KeyMapEntry("how ", 12);
+ keywords[16] = new KeyMapEntry("who ", 12);
+ keywords[17] = new KeyMapEntry("where ", 12);
+ keywords[18] = new KeyMapEntry("when ", 12);
+ keywords[19] = new KeyMapEntry("why ", 12);
+ keywords[20] = new KeyMapEntry("name ", 13);
+ keywords[21] = new KeyMapEntry("cause ", 14);
+ keywords[22] = new KeyMapEntry("sorry ", 15);
+ keywords[23] = new KeyMapEntry("dream ", 16);
+ keywords[24] = new KeyMapEntry("hello ", 17);
+ keywords[25] = new KeyMapEntry("hi ", 17);
+ keywords[26] = new KeyMapEntry("maybe ", 18);
+ keywords[27] = new KeyMapEntry(" no", 19);
+ keywords[28] = new KeyMapEntry("your ", 20);
+ keywords[29] = new KeyMapEntry("always ", 21);
+ keywords[30] = new KeyMapEntry("think ", 22);
+ keywords[31] = new KeyMapEntry("alike ", 23);
+ keywords[32] = new KeyMapEntry("yes ", 24);
+ keywords[33] = new KeyMapEntry("friend ", 25);
+ keywords[34] = new KeyMapEntry("computer", 26);
+ keywords[35] = new KeyMapEntry("bot ", 26);
+ keywords[36] = new KeyMapEntry("smartphone", 27);
+ keywords[37] = new KeyMapEntry("father ", 28);
+ keywords[38] = new KeyMapEntry("mother ", 28);
+ return keywords;
+ }
+
+ /**
+ * Returns an array of pairs of mutualy substitutable
+ * @return
+ */
+ private static String[][] setupReflexions() {
+ // TODO: Check and accomplish variable declarations:
+ String[][] reflexions;
+
+
+ reflexions[0] = new String[]{" are ", " am "};
+ reflexions[1] = new String[]{" were ", " was "};
+ reflexions[2] = new String[]{" you ", " I "};
+ reflexions[3] = new String[]{" your", " my"};
+ reflexions[4] = new String[]{" i\'ve ", " you\'ve "};
+ reflexions[5] = new String[]{" i\'m ", " you\'re "};
+ reflexions[6] = new String[]{" me ", " you "};
+ reflexions[7] = new String[]{" my ", " your "};
+ reflexions[8] = new String[]{" i ", " you "};
+ reflexions[9] = new String[]{" am ", " are "};
+ return reflexions;
+ }
+
+ /**
+ * This routine sets up the reply rings addressed by the key words defined in
+ * routine `setupKeywords()´ and mapped hitherto by the cross table defined
+ * in `setupMapping()´
+ * @return
+ */
+ private static String[][] setupReplies() {
+ // TODO: Check and accomplish variable declarations:
+ String[][] setupReplies;
+
+
+ String[][] replies;
+ // We start with the highest index for performance reasons
+ // (is to avoid frequent array resizing)
+ replies[29] = new String[]{"Say, do you have any psychological problems?", "What does that suggest to you?", "I see.", "I'm not sure I understand you fully.", "Come come elucidate your thoughts.", "Can you elaborate on that?", "That is quite interesting."};
+ replies[0] = new String[]{"Don't you believe that I can*?", "Perhaps you would like to be like me?", "You want me to be able to*?"};
+ replies[1] = new String[]{"Perhaps you don't want to*?", "Do you want to be able to*?"};
+ replies[2] = new String[]{"What makes you think I am*?", "Does it please you to believe I am*?", "Perhaps you would like to be*?", "Do you sometimes wish you were*?"};
+ replies[3] = new String[]{"Don't you really*?", "Why don't you*?", "Do you wish to be able to*?", "Does that trouble you*?"};
+ replies[4] = new String[]{"Do you often feel*?", "Are you afraid of feeling*?", "Do you enjoy feeling*?"};
+ replies[5] = new String[]{"Do you really believe I don't*?", "Perhaps in good time I will*.", "Do you want me to*?"};
+ replies[6] = new String[]{"Do you think you should be able to*?", "Why can't you*?"};
+ replies[7] = new String[]{"Why are you interested in whether or not I am*?", "Would you prefer if I were not*?", "Perhaps in your fantasies I am*?"};
+ replies[8] = new String[]{"How do you know you can't*?", "Have you tried?", "Perhaps you can now*."};
+ replies[9] = new String[]{"Did you come to me because you are*?", "How long have you been*?", "Do you believe it is normal to be*?", "Do you enjoy being*?"};
+ replies[10] = new String[]{"We were discussing you--not me.", "Oh, I*.", "You're not really talking about me, are you?"};
+ replies[11] = new String[]{"What would it mean to you if you got*?", "Why do you want*?", "Suppose you soon got*...", "What if you never got*?", "I sometimes also want*."};
+ replies[12] = new String[]{"Why do you ask?", "Does that question interest you?", "What answer would please you the most?", "What do you think?", "Are such questions on your mind often?", "What is it that you really want to know?", "Have you asked anyone else?", "Have you asked such questions before?", "What else comes to mind when you ask that?"};
+ replies[13] = new String[]{"Names don't interest me.", "I don't care about names -- please go on."};
+ replies[14] = new String[]{"Is that the real reason?", "Don't any other reasons come to mind?", "Does that reason explain anything else?", "What other reasons might there be?"};
+ replies[15] = new String[]{"Please don't apologize!", "Apologies are not necessary.", "What feelings do you have when you apologize?", "Don't be so defensive!"};
+ replies[16] = new String[]{"What does that dream suggest to you?", "Do you dream often?", "What persons appear in your dreams?", "Are you disturbed by your dreams?"};
+ replies[17] = new String[]{"How do you do ...please state your problem."};
+ replies[18] = new String[]{"You don't seem quite certain.", "Why the uncertain tone?", "Can't you be more positive?", "You aren't sure?", "Don't you know?"};
+ replies[19] = new String[]{"Are you saying no just to be negative?", "You are being a bit negative.", "Why not?", "Are you sure?", "Why no?"};
+ replies[20] = new String[]{"Why are you concerned about my*?", "What about your own*?"};
+ replies[21] = new String[]{"Can you think of a specific example?", "When?", "What are you thinking of?", "Really, always?"};
+ replies[22] = new String[]{"Do you really think so?", "But you are not sure you*?", "Do you doubt you*?"};
+ replies[23] = new String[]{"In what way?", "What resemblance do you see?", "What does the similarity suggest to you?", "What other connections do you see?", "Could there really be some connection?", "How?", "You seem quite positive."};
+ replies[24] = new String[]{"Are you sure?", "I see.", "I understand."};
+ replies[25] = new String[]{"Why do you bring up the topic of friends?", "Do your friends worry you?", "Do your friends pick on you?", "Are you sure you have any friends?", "Do you impose on your friends?", "Perhaps your love for friends worries you."};
+ replies[26] = new String[]{"Do computers worry you?", "Are you talking about me in particular?", "Are you frightened by machines?", "Why do you mention computers?", "What do you think machines have to do with your problem?", "Don't you think computers can help people?", "What is it about machines that worries you?"};
+ replies[27] = new String[]{"Do you sometimes feel uneasy without a smartphone?", "Have you had these phantasies before?", "Does the world seem more real for you via apps?"};
+ replies[28] = new String[]{"Tell me more about your family.", "Who else in your family*?", "What does family relations mean for you?", "Come on, How old are you?"};
+ setupReplies = replies;
+
+ return setupReplies;
+ }
+
+}
diff --git a/samples/export/Java/SORTING_TEST_MAIN.java b/samples/export/Java/SORTING_TEST_MAIN.java
index 5f8b4377..e8067857 100644
--- a/samples/export/Java/SORTING_TEST_MAIN.java
+++ b/samples/export/Java/SORTING_TEST_MAIN.java
@@ -1,4 +1,4 @@
-// Generated by Structorizer 3.30-02
+// Generated by Structorizer 3.30-03
//
// Copyright (C) 2019-10-02 Kay Gürtzig
// License: GPLv3-link
@@ -29,9 +29,9 @@ public class SORTING_TEST_MAIN {
*/
public static void main(String[] args) {
// =========== START PARALLEL WORKER DEFINITIONS ============
- class Worker4f085546_0 implements Callable
*
Original author: Robert Harder, rharder@usa.net
*
2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
+ *
2019-11-21 Kay Gürtzig -- Warnings eliminated by modernizing the code.
*
* @author Robert Harder
* @author rharder@users.sf.net
@@ -314,9 +313,9 @@ public void drop( java.awt.dnd.DropTargetDropEvent evt )
log( out, "FileDrop: file list accepted." );
// Get a useful list
- java.util.List fileList = (java.util.List)
+ java.util.List> fileList = (java.util.List>)
tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor);
- java.util.Iterator iterator = fileList.iterator();
+ //java.util.Iterator> iterator = fileList.iterator();
// Convert list to array
java.io.File[] filesTemp = new java.io.File[ fileList.size() ];
@@ -426,13 +425,13 @@ private static boolean supportsDnD()
{
boolean support = false;
try
- { Class arbitraryDndClass = Class.forName( "java.awt.dnd.DnDConstants" );
+ { Class.forName( "java.awt.dnd.DnDConstants" );
support = true;
} // end try
catch( Exception e )
{ support = false;
} // end catch
- supportsDnD = new Boolean( support );
+ supportsDnD = Boolean.valueOf( support );
} // end if: first time through
return supportsDnD.booleanValue();
} // end supportsDnD
@@ -443,7 +442,7 @@ private static boolean supportsDnD()
private static File[] createFileArray(BufferedReader bReader, PrintStream out)
{
try {
- java.util.List list = new java.util.ArrayList();
+ java.util.List list = new java.util.ArrayList();
java.lang.String line = null;
while ((line = bReader.readLine()) != null) {
try {
@@ -625,7 +624,7 @@ public static void main( String[] args )
}); // end FileDrop.Listener
frame.setBounds( 100, 100, 300, 400 );
- frame.setDefaultCloseOperation( frame.EXIT_ON_CLOSE );
+ frame.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE );
//frame.show();
} // end main