Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Command Line basec program..
#1
Hi There,
I'm mostly a total newbie to QBasic. I know the base..:/ But I would like to work with variable, for the begining. Lately, I got an idea about command line based program but I don't know how to separate a sentence and make piece of this stock as variable.
Ex:
INPUT "Enter Information"; command$
If the user answer :Simon 123 Hi
I would like to make Simon variable A, 123 variable B, and Hi variable 3.

Could someone help me? Sad :???:

Exscuse my bad english btw, I'm french ://

Thanks
Reply
#2
Well, you have to use several commands. The simplest way is going accross the string, and stopping on each word. You can use an array:

Code:
DIM word$(100) ' 100 words maximum.

INPUT "Enter phrase : ";phrase$

word$(0)=""

index%=0
FOR i%=1 TO LEN(phrase$)
   m$ = MID$(phrase$, i%, 1)
   IF m$ = " " THEN
      IF word$(index%)<>"" THEN
         index%=index%+1
         word$(index%)=""
      END IF
   ELSE
      word$(index%) = word$(index%) + m$
   END IF
NEXT i%

FOR i%=0 TO index%
   PRINT "Word #";i%;" -> ";word$(i%)
NEXT i%

Check on QB help if you don't know some commands.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)