Qbasicnews.com
April 09, 2020, 04:42:40 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Command Line basec program..  (Read 1987 times)
-(hS)-Black Sheep
New Member

Posts: 1


« on: April 21, 2003, 09:51:22 PM »

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  :Huh:

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

Thanks
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: April 21, 2003, 09:56:13 PM »

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.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!