|
|
Line 1,108: |
Line 1,108: |
|
{{out}} |
|
{{out}} |
|
<pre>Igual que la entrada de FreeBASIC.</pre> |
|
<pre>Igual que la entrada de FreeBASIC.</pre> |
|
|
|
|
⚫ |
==={{header|BBC BASIC}} === |
|
⚫ |
<syntaxhighlight lang="bbcbasic">REM >strcomp |
|
⚫ |
shav$ = "Shaw, George Bernard" |
|
⚫ |
shakes$ = "Shakespeare, William" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF shav$ = shakes$ THEN PRINT "The two strings are equal" ELSE PRINT "The two strings are not equal" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF shav$ <> shakes$ THEN PRINT "The two strings are unequal" ELSE PRINT "The two strings are not unequal" |
|
⚫ |
|
|
⚫ |
REM test lexical ordering |
|
⚫ |
IF shav$ > shakes$ THEN PRINT shav$; " is lexically higher than "; shakes$ ELSE PRINT shav$; " is not lexically higher than "; shakes$ |
|
⚫ |
IF shav$ < shakes$ THEN PRINT shav$; " is lexically lower than "; shakes$ ELSE PRINT shav$; " is not lexically lower than "; shakes$ |
|
⚫ |
REM the >= and <= operators can also be used, & behave as expected |
|
⚫ |
|
|
⚫ |
REM string comparison is case-sensitive by default, and BBC BASIC |
|
⚫ |
REM does not provide built-in functions to convert to all upper |
|
⚫ |
REM or all lower case; but it is easy enough to define one |
|
⚫ |
|
|
⚫ |
IF FN_upper(shav$) = FN_upper(shakes$) THEN PRINT "The two strings are equal (disregarding case)" ELSE PRINT "The two strings are not equal (even disregarding case)" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF ASC(MID$(s$, i%, 1)) >= ASC "a" AND ASC(MID$(s$, i%, 1)) <= ASC "z" THEN ns$ += CHR$(ASC(MID$(s$, i%, 1)) - &20) ELSE ns$ += MID$(s$, i%, 1) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
<pre>The two strings are not equal |
|
⚫ |
The two strings are unequal |
|
⚫ |
Shaw, George Bernard is lexically higher than Shakespeare, William |
|
⚫ |
Shaw, George Bernard is not lexically lower than Shakespeare, William |
|
⚫ |
The two strings are not equal (even disregarding case)</pre> |
|
|
|
|
|
==={{header|QBasic}}=== |
|
==={{header|QBasic}}=== |
Line 1,277: |
Line 1,314: |
|
0 OK, 0:673 |
|
0 OK, 0:673 |
|
</pre> |
|
</pre> |
|
|
|
⚫ |
|
|
⚫ |
<syntaxhighlight lang="bbcbasic">REM >strcomp |
|
⚫ |
shav$ = "Shaw, George Bernard" |
|
⚫ |
shakes$ = "Shakespeare, William" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF shav$ = shakes$ THEN PRINT "The two strings are equal" ELSE PRINT "The two strings are not equal" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF shav$ <> shakes$ THEN PRINT "The two strings are unequal" ELSE PRINT "The two strings are not unequal" |
|
⚫ |
|
|
⚫ |
REM test lexical ordering |
|
⚫ |
IF shav$ > shakes$ THEN PRINT shav$; " is lexically higher than "; shakes$ ELSE PRINT shav$; " is not lexically higher than "; shakes$ |
|
⚫ |
IF shav$ < shakes$ THEN PRINT shav$; " is lexically lower than "; shakes$ ELSE PRINT shav$; " is not lexically lower than "; shakes$ |
|
⚫ |
REM the >= and <= operators can also be used, & behave as expected |
|
⚫ |
|
|
⚫ |
REM string comparison is case-sensitive by default, and BBC BASIC |
|
⚫ |
REM does not provide built-in functions to convert to all upper |
|
⚫ |
REM or all lower case; but it is easy enough to define one |
|
⚫ |
|
|
⚫ |
IF FN_upper(shav$) = FN_upper(shakes$) THEN PRINT "The two strings are equal (disregarding case)" ELSE PRINT "The two strings are not equal (even disregarding case)" |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
IF ASC(MID$(s$, i%, 1)) >= ASC "a" AND ASC(MID$(s$, i%, 1)) <= ASC "z" THEN ns$ += CHR$(ASC(MID$(s$, i%, 1)) - &20) ELSE ns$ += MID$(s$, i%, 1) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
<pre>The two strings are not equal |
|
⚫ |
The two strings are unequal |
|
⚫ |
Shaw, George Bernard is lexically higher than Shakespeare, William |
|
⚫ |
Shaw, George Bernard is not lexically lower than Shakespeare, William |
|
⚫ |
The two strings are not equal (even disregarding case)</pre> |
|
|
|
|
|
|
=={{header|Bracmat}}== |
|
=={{header|Bracmat}}== |