Empty string: Difference between revisions
Content deleted Content added
m →{{header|Avail}}: replaced </avail> with </lang> |
Empty string in various BASIC dialents (BASIC256, True BASIC, QBasic and Yabasic) |
||
Line 486: | Line 486: | ||
There are other ways, such as a zero return from the <tt>LEN(s$)</tt> or <tt>ULEN(utf$)</tt> functions. <tt>EQUAL(s$, "")</tt> would be another way. |
There are other ways, such as a zero return from the <tt>LEN(s$)</tt> or <tt>ULEN(utf$)</tt> functions. <tt>EQUAL(s$, "")</tt> would be another way. |
||
==={{header|BASIC256}}=== |
|||
<lang basic256>subroutine IsEmpty (s$) |
|||
if length(s$) = 0 then |
|||
print "String is empty" |
|||
else |
|||
print "String is not empty" |
|||
end if |
|||
if s$ = "" then print "yes, the string is empty" |
|||
if s$ <> "" then print "no, the string is not empty" |
|||
end subroutine |
|||
t$ = "" |
|||
call IsEmpty (t$) |
|||
u$ = "not empty" |
|||
call IsEmpty (u$) |
|||
end</lang> |
|||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |
||
Line 497: | Line 514: | ||
If a$ <> "" Then Print a$ 'String is not empty, so print its contents.</lang> |
If a$ <> "" Then Print a$ 'String is not empty, so print its contents.</lang> |
||
=={{header| |
==={{header|QBasic}}=== |
||
<lang QBasic>SUB IsEmpty (s AS STRING) |
|||
IF LEN(s) = 0 THEN |
|||
PRINT "String is empty" |
|||
ELSE |
|||
PRINT "String is not empty" |
|||
END IF |
|||
IF s = "" THEN PRINT "yes, the string is empty" |
|||
IF s <> "" THEN PRINT "no, the string is not empty" |
|||
END SUB |
|||
DIM s AS STRING ' implicitly assigned an empty string |
|||
IsEmpty (s) |
|||
t$ = "" ' explicitly assigned an empty string |
|||
IsEmpty (t$) |
|||
u$ = "not empty" |
|||
IsEmpty (u$)</lang> |
|||
==={{header|True BASIC}}=== |
|||
<lang qbasic>SUB IsEmpty(s$) |
|||
IF Len(s$) = 0 THEN |
|||
PRINT "String is empty" |
|||
ELSE |
|||
PRINT "String is not empty" |
|||
END IF |
|||
IF s$ = "" THEN PRINT "yes, the string is empty" |
|||
IF s$ <> "" THEN PRINT "no, the string is not empty" |
|||
END SUB |
|||
LET t$ = "" |
|||
CALL IsEmpty(t$) |
|||
LET u$ = "not empty" |
|||
CALL IsEmpty(u$) |
|||
END</lang> |
|||
==={{header|Yabasic}}=== |
|||
<lang yabasic>sub IsEmpty (s$) |
|||
if len(s$) = 0 then |
|||
print "String is empty" |
|||
else |
|||
print "String is not empty" |
|||
endif |
|||
if s$ = "" print "yes, the string is empty" |
|||
if s$ <> "" print "no, the string is not empty" |
|||
end sub |
|||
t$ = "" |
|||
IsEmpty (t$) |
|||
u$ = "not empty" |
|||
IsEmpty (u$) |
|||
end</lang> |
|||
=={{header|Batch File}}== |
|||
<lang dos> |
<lang dos> |
||
@echo off |
@echo off |