Qbasicnews.com

Full Version: why doesnt this work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
CLS
SCREEN 12
LOCATE 1,1:INPUT "?";USER$
LENGTH=LEN(USER$)
D$=""
DO UNTIL T=LENGTH
C$=LEFT$(USER$,T)
IF C$="A"  THEN D$=D$+"A"
IF C$="B"  THEN D$=D$+"B"
IF C$="C"  THEN D$=D$+"C"
IF C$="D"  THEN D$=D$+"D"
IF C$="E"  THEN D$=D$+"E"
IF C$="F"  THEN D$=D$+"F"
IF C$="G"  THEN D$=D$+"G"
IF C$="H"  THEN D$=D$+"H"
IF C$="I" THEN D$=D$+"I"
IF C$="J"  THEN D$=D$+"J"
IF C$="K"  THEN D$=D$+"K"
IF C$="L"  THEN D$=D$+"L"
IF C$="M"  THEN D$=D$+"M"
IF C$="N"  THEN D$=D$+"N"
IF C$="O"  THEN D$=D$+"O"
IF C$="P"  THEN D$=D$+"P"
IF C$="Q"  THEN D$=D$+"Q"
IF C$="R"  THEN D$=D$+"R"
IF C$="S"  THEN D$=D$+"S"
IF C$="T"  THEN D$=D$+"T"
IF C$="U"  THEN D$=D$+"U"
IF C$="V"  THEN D$=D$+"V"
IF C$="W"  THEN D$=D$+"W"
IF C$="X"  THEN D$=D$+"X"
IF C$="Y"  THEN D$=D$+"Y"
IF C$="Z"  THEN D$=D$+"Z"
WORD$=D$
LOOP

LOCATE 20,1:PRINT WORD$
Where do you initialize and update the "T" variable?

T = 0

T = T + 1
at first look (and the knowledge of knowing that I have NO CLUE what it's supposed to do)

Code:
C$=LEFT$(USER$,T)
First! J00 never increment T.... ever... it stays at 0 indefinatly

I also think you mean
Code:
T = T + 1
C$=MID$(USER$,T,1)
LEFT$ get T characters starting from the leftmost



ALSO! Unless that program isn't done you can make that very shorter.

Code:
CLS
SCREEN 12
LOCATE 1,1:INPUT "?";USER$
LOCATE 20,1:PRINT USER$ [/code]

Anonymous

Code:
for t = 1 to length

c$ = right$(left$(t))

next

show that code to your teacher
well for 1 im not in school so im not going to show anything to a teacher i posted this for my own personal program and i realize that i had left a couple things out on my post but i still cant get the desired results what i am trying to do is be able to list every word separatly within an input for example the sentence hello my name is should return word$(1)="hello" word$(2)="my" word$(3)="name" word$(4)="is" but i cant figure out how to break down the input and put the words into separate blocks i know that when a space " " is encountered this would tell it to add another word exmp word$(6)(7)(8) and so forth i just cant figure out the comand line i need but if somebody understands what i am trying to do would you please help?

Anonymous

Code:
screen 13

stringy$ = "hey dude whats up oh you dont say no way wow crazy peace"

dim words$(99)


for t = 1 to len(stringy$)

c$ = mid$(stringy$, t, 1)

if c$ <> " " then
    
    words$(wordindex%) = words$(wordindex%) + mid$(stringy$, t, 1)

else

    wordindex% = wordindex% + 1
    
end if


next

for p = 0 to wordindex%
    
    ? words$(p)
    
next


sleep
for 1 thank you ChaOs, i really dont understand using mid left right strings so i just decided to use inkey to separate the words heres how i did it
Code:
cls
screen 12
dim word$(100)
w=1
t=1
do
w$=inkey$
word$(w)=word$(w)+w$
if w$=" " then  
  w=w+1
   t=t+l+1
end if
l=len(word$(w))
locate 10,1:print word$(w)
locate 22,1:print t
locate 20,t:print word$(w)
if w$=chr$(13) then exit do
loop

but thanks anyway for the help i will save it and may use it for later (learning) which we all have room to do