Create and test for blank and null string. AND condition

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Mike L
Newbie
Posts:1
Joined:Sat Jul 09, 2016 5:29 pm
Create and test for blank and null string. AND condition

Post by Mike L » Sat Jul 09, 2016 5:39 pm

What is the Basic code to create a blank string (say 10 bytes) and a null string ?
What is the code to test for either a blank or a null string ?

Also

I want an AND condition ... If A = 1 AND B = 2 etc....
How is this coded ?

Thanks in advance

Cobramil
Jr. Member
Posts:11
Joined:Sat Mar 05, 2016 3:22 am

Re: Create and test for blank and null string. AND condition

Post by Cobramil » Tue Jul 26, 2016 12:02 am

I do not know if I understand your question. Here are some basic tips.

Code: Select all

COLOR 7, 3: CLS
A$ = STRING$(10, 32) 'Defines string with 10 characters space
PRINT "String A$: "; A$; LEN(A$); "bytes, Code ="; ASC(MID$(A$, 1, 1))

B$ = STRING$(10, 88) 'Defines string with 10 characters X
PRINT "String B$: "; B$; LEN(B$); "bytes, Code ="; ASC(MID$(B$, 1, 1))

C$ = "" 'Defines null string
PRINT "String C$: "; C$; LEN(C$); "bytes, null string"

A = 1
B = 2
C = A + B

IF A = 1 AND B = 2 THEN PRINT "A = 1 and B = 2"
PRINT "A ="; A; " B ="; B; " C ="; C

IF A = B THEN
  PRINT "A is equal to B"
ELSE
  PRINT "A is not equal to B"
END IF

EkriirkE
Newbie
Posts:6
Joined:Sat Aug 06, 2016 5:11 am
Location:SFBA, CA
Contact:

Re: Create and test for blank and null string. AND condition

Post by EkriirkE » Sat Aug 06, 2016 5:27 am

Just so you know, QB does not use null-terminated strings. So if you mean an empty string by "null string" then simply assign the value of "" to it:

Code: Select all

MyString$ = ""
If you're looking to create a "buffer", a quick way is the SPACE$() function

Code: Select all

MyString$ = SPACE$(10)
Your AND statement is perfectly valid the way you wrote it - just add a "THEN" at the end.
I take things apart. I break them. Then I put things that don't belong back inside them.

Post Reply