Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/String-comparison/True-BASIC/string-comparison.basic
Normal file
34
Task/String-comparison/True-BASIC/string-comparison.basic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
FUNCTION StringCompare$(s1$, s2$, ignorecase)
|
||||
IF ignorecase = True then
|
||||
LET s$ = LCASE$(s1$)
|
||||
LET t$ = LCASE$(s2$)
|
||||
ELSE
|
||||
LET s$ = s1$
|
||||
LET t$ = s2$
|
||||
END IF
|
||||
IF s$ < t$ then
|
||||
LET StringCompare$ = " comes before "
|
||||
ELSE
|
||||
IF s$ = t$ then
|
||||
LET StringCompare$ = " is equal to "
|
||||
ELSE
|
||||
LET StringCompare$ = " comes after "
|
||||
END IF
|
||||
END IF
|
||||
END FUNCTION
|
||||
|
||||
LET s1$ = "Dog"
|
||||
LET s2$ = "Dog"
|
||||
PRINT s1$; StringCompare$(s1$, s2$, False); s2$
|
||||
LET s2$ = "Cat"
|
||||
PRINT s1$; StringCompare$(s1$, s2$, False); s2$
|
||||
LET s2$ = "Rat"
|
||||
PRINT s1$; StringCompare$(s1$, s2$, False); s2$
|
||||
LET s2$ = "dog"
|
||||
PRINT s1$; StringCompare$(s1$, s2$, False); s2$
|
||||
PRINT s1$; StringCompare$(s1$, s2$, True); s2$; " if case is ignored"
|
||||
LET s1$ = "Dog"
|
||||
LET s2$ = "Pig"
|
||||
LET s3$ = StringCompare$(s1$, s2$, 0)
|
||||
IF s3$ <> " is equal to " then PRINT s1$; " is not equal to "; s2$
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue