Entry
BBCBASIC: Windows: How to possibly input yes and no in different natural languages?
Apr 23rd, 2006 13:08
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 23 April 2021 - 08:01 pm ----------------------
BBCBASIC: Windows: How to possibly input yes and no in different
natural languages?
---
Because the total amount of data (e.g. the foreign language
information might grow or change)
might vary, it is best to separate the data from your procedures.
You could then e.g. read your DATA from a file (so completely external
from your program).
---
Steps: Overview:
1. E.g. create the following program
--- cut here: begin --------------------------------------------------
REM --- MAIN --- REM
PROCLanguageGetNaturalData
:
REPEAT
READ languageNaturalName$, question$, yes$, no$
stopB% = FNStringCheckEqualCaseInsensitiveB(
languageNaturalName$, "End" )
IF NOT stopB% THEN PRINT FNStringGetInputYesB( languageNaturalName$,
question$, yes$, no$ )
UNTIL stopB%
END
:
REM --- LIBRARY --- REM
:
REM library: language: get: natural: data (filenamemacro=getlanda.bbc)
[kn, ri, su, 23-04-2021 19:22:53]
DEF PROCLanguageGetNaturalData
DATA "Danish", "Fortsette", "Ja", "Nej"
DATA "Dutch", "Verdergaan", "Ja", "Nee"
DATA "English", "Continue", "Yes", "No"
DATA "Finnish", "Continue", "Joo", "Ei"
DATA "French", "Continuer", "Oui", "Non"
DATA "German", "Fortsetzen", "Ja", "Nein"
DATA "Hungarian", "Folytat", "Igen", "Nem"
DATA "Italian", "Continuare", "Si", "Non"
DATA "Norwegian", "Fortsette", "Ja", "Nei"
DATA "Portuguese", "Continuar", "Sim", "Nao"
DATA "Russian", "Prodolsjat", "Da", "Het"
DATA "Serbo-Croatian", "Nastaviti", "Da", "Ne"
DATA "Spanish", "Continuar", "Si", "No"
DATA "Swedish", "Forts<a..>tta", "Ja", "Nej"
DATA "End", "End", "End", "End"
ENDPROC
:
REM library: string: check: equal: case: insensitive
(filenamemacro=checstci.bbc) [kn, ri, su, 23-04-2021 17:51:20]
DEF FNStringCheckEqualCaseInsensitiveB( s1$, s2$ )
REM e.g. PRINT FNStringCheckEqualCaseInsensitiveB( "Test", "test" ) :
REM gives TRUE, because "Test" equals "test" if you do not look if
upper or lower case
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
= FNStringCheckEqualB( FNStringGetCaseUpperS( s1$ ),
FNStringGetCaseUpperS( s2$ ) )
:
REM library: string: get: input: yes (filenamemacro=getstiye.bbc) [kn,
ri, su, 23-04-2021 19:07:57]
DEF FNStringGetInputYesB( languageNaturalNameInput$, question$, yes$,
no$ )
REM e.g. PROCLanguageGetNaturalData
REM e.g. :
REM e.g. REPEAT
REM e.g. READ languageNaturalName$, question$, yes$, no$
REM e.g. stopB% = FNStringCheckEqualCaseInsensitiveB(
languageNaturalName$, "End" )
REM e.g. IF NOT stopB% THEN PRINT FNStringGetInputYesB(
languageNaturalName$, question$, yes$, no$ )
REM e.g. UNTIL stopB%
REM e.g. END
REM e.g. :
LOCAL answer$
PRINT; question$ + " " + "(" + FNStringGetCaseUpperS(
FNStringGetCharacterFirstS( yes$ ) ) + "/" + FNStringGetCaseLowerS(
FNStringGetCharacterFirstS( no$ ) ) + ")" + " ";
INPUT; answer$
= FNStringCheckEqualCaseInsensitiveB( FNStringGetCharacterFirstS(
answer$ ), FNStringGetCharacterFirstS( yes$ ) )
:
REM library: string: check: equal (string1 equal to string2?)
(filenamemacro=checstce.bbc) [kn, ri, we, 09-05-2021 19:47:51]
DEF FNStringCheckEqualB( s1$, s2$ )
REM e.g. PRINT FNStringCheckEqualB( "test", "test" ) : REM gives
true, because "test" equals "test"
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
= s1$ = s2$
:
REM library: string: get: case: upper (convert characters in string to
upper case) (filenamemacro=getstcuq.s) [kn, zoe, wo, 30-06-2021
01:21:07]
DEF FNStringGetCaseUpperS( s$ )
REM e.g. PRINT( FNStringGetCaseUpperS( "this is a test" ) ) : REM
gives e.g. "THIS IS A TEST"
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
PROCLibraryInstallString
= FNupper( s$ )
ENDPROC
:
REM library: string: get: character: first (string: character: token:
get: first: return the first single character in the given string)
(filenamemacro=getstcfi.bbc) [kn, ri, wo, 24-03-2021 23:21:02]
DEF FNStringGetCharacterFirstS( s$ )
REM e.g. PRINT; FNStringGetCharacterFirstS( "knud" ) : REM gives "k"
REM e.g. PRINT; FNStringGetCharacterFirstS( "the" ) : REM gives "t"
REM e.g. END
= FNStringGetCharacterS( s$, 1 )
:
REM library: string: get: case: lower (convert characters in string to
lower case) (filenamemacro=getstclo.bbc) [kn, zoe, wo, 30-06-2021
01:21:07]
DEF FNStringGetCaseLowerS( s$ )
REM e.g. PRINT( FNStringGetCaseLowerS( "this is a test" ) ) : REM
gives e.g. "THIS IS A TEST"
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
PROCLibraryInstallString
= FNlower( s$ )
:
REM library: library: install: string (filenamemacro=instliis.bbc)
[kn, ri, su, 23-04-2021 19:52:18]
DEF PROCLibraryInstallString
REM e.g. PROCLibraryInstallString
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
INSTALL @lib$+"FNUsing"
ENDPROC
:
REM library: string: character: token: get: return the character in
the given string on the given position [kn, ri, vr, 25-12-2020
23:35:43]
DEF FNStringGetCharacterS( s$, positionT% )
REM e.g. PRINT; FNStringGetCharacterS( "knud", 3 ) : REM gives "u"
= FNStringGetMidStringS( s$, positionT%, 1 )
:
REM library: string: word: token: get: middle: return a given integer
amount of characters from the a given startposition (=MID$ in BASIC)
[kn, ri, di, 13-10-2020 20:29:00]
DEF FNStringGetMidStringS( s$, beginT%, totalT% )
REM e.g. PRINT; FNStringGetMidStringS( "knud", 2, 3 ) ) : REM
gives "nud"
REM e.g. PRINT; FNStringGetMidStringS( "knud", 3, 2 ) ) : REM
gives "ud"
REM e.g. END
= MID$( s$, beginT%, totalT% )
--- cut here: end ----------------------------------------------------
2. -If will read the example data for e.g. 14 different natural
languages
3. -It puts to upper case the first character of the yes string
(e.g. 'Y'es)
it puts to lower case the first character of the no string, and
concatenates
this to your question string.
4. -It takes the first character input and compares this case
insensitive to the
first character of the "yes" string of your natural language
1. -If this characters are equal, the function returns TRUE,
otherwise FALSE
5. -Run the program
6. -That will show a screen output similar to the following:
--- cut here: begin --------------------------------------------------
Fortsette (J/n) J
-1
Verdergaan (J/n) J
-1
Continue (Y/n) Y
-1
Continue (J/e) J
-1
Continuer (O/n) O
-1
Fortsetzen (J/n) J
-1
Folytat (I/n) n
0
Continuare (S/n) n
0
Fortsette (J/n) j
-1
Continuar (S/n) N
0
Prodolsjat (D/h) H
0
Nastaviti (D/n) D
-1
Continuar (S/n) s
-1
Forts<a..>tta (J/n) n
0
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
----------------------------------------------------------------------