Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / <> won't work!

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. <> won't work!
#5112
Posted by: JonA 2004-09-17 05:18:41

 DIM jeo1 AS QFILESTREAM
 jeo1.OPEN ("Syntax.txt", fmopenreadwrite)
 A$ = jeo1.ReadStr(1)
 A$ = LCASE$(A$)
 IF A$ <> "j" THEN
  A$ = A$
  B$ = jeo1.readstr(5)
  B$ = B$-A$
  B$ = DELETE$(B$,5,1)
 ELSE
  A$ = "*"
  B$ = jeo1.readstr(4)
 END IF

 PRINT A$
 PRINT B$
 SLEEP(5)
There is my code...and this is what gets printed on the screen:

j
eo1


Now, the text in the first part of the file is 'jeo1' (no quotes).  However, if I put in =, instead of <>, it does what is after the ELSE.  It is almost as if the commands have been switched...sort of.

How can I get it so it does what is after the ELSE with <>, since A$ does = "j".

Thanks,
JonA
Message2. Re: <> won't work!
#5114
Posted by: Nova_Shard 2004-09-18 02:33:52
   This was an odd problem.  And I must admit, even though I got it to work for me, I'm still not entirely certain why your original code failed.  It should work the way it appears.  Below is what I had to change to make it produce the desired results.  With the following changes, the code now follows the logical path it should.

DIM jeo1 AS QFILESTREAM

jeo1.Open ("Syntax.txt" , fmOpenReadWrite)

A$ = jeo1.ReadStr(1)
A$ = LCASE$(A$)

X$ = A$  '--Added this line to give value to the new variable. X$ = "j" didn't  
         '--work, so I went directly to A$ for the value needed for comparison.

IF A$ <> X$ THEN  '--Here, I compared the two variables, instead of the raw string
                  '--value. This worked!
  A$ = A$
  B$ = jeo1.ReadStr(5)
  B$ = B$ - A$
  B$ = DELETE$(B$ , 5 , 1)
ELSE
  A$ = "*"
  B$ = jeo1.ReadStr(4)
END IF

Print A$
Print B$

Sleep(5)
Message3. Re: <> won't work!
#5115
Posted by: JonA 2004-09-18 12:05:45
??? If you set up X$ to equal A$, wont the two always be equal...and so always do what is after the ELSE.  Because if the first line of the file doesn't equal "j", then I need it to do what is after the THEN.

Thank you,
JonA
Message4. Re: <> won't work!
#5118
Posted by: Nova_Shard 2004-09-19 15:29:16
   Yeah, I know.  I realize the above code won't work as an end-product unto itself.  But I thought you might be able to gain some insight into a more permanent solution by seeing that under these conditions the IF statement does work properly, even if further modifications need to be made to make it feasible for your application.

   Upon further tinkering, I've found that by altering the method of data handling, and a few other bits here and there, that the code becomes fully funtional.  Instead of pulling a single byte from the file and analyzing it from there, I changed it so that it pulls the entire string at once, stores it in a variable, and then pulls a single byte from that source.  This seems to solve the problem of the IF statement adopting it's false logic.  Hope this helps.


DIM jeo1 AS QFILESTREAM

jeo1.Open ("Syntax.txt" , fmOpenReadWrite)

Whole$ = jeo1.ReadStr(4)
A$ = LEFT$(Whole$, 1)
A$ = LCASE$(A$)


IF A$ <> "j" THEN
  A$ = A$
  B$ = (Whole$ - LEFT$(Whole$, 1))
  B$ = (B$ - A$)
  B$ = DELETE$(B$ , 5 , 1)
ELSE
  A$ = "*"
  B$ = (Whole$ - LEFT$(Whole$, 1))
END IF

Print A$
Print B$

Sleep(5)
Message5. Re: <> won't work!
#5142
Posted by: 2004-09-23 06:34:50
Greetings, I'm new to rapidq, just evaluating, so I was intrigued by the problem you described.

I tried your original code with a file "Syntax.txt" containing the three lines:

 jeo11
 something
 somethingelse

AFAICT it worked first time, i.e. it printed:

 *
 eo11

I should perhaps mention that I'm running it on Linux, quite an old distro (Mandrake 7.1).  The only modification I had to make was to add the line:

 $OPTION CONSOLE

at the start of the source.
Message6. Re: <> won't work!
#5143
Posted by: 2004-09-23 06:43:49
Oops!
 > $OPTION CONSOLE
should of course have been
 $APPTYPE CONSOLE
D'Oh.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0