Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Qbasic reads my .bas wrong

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
In qbasic it reads:

ELSEIF comm$ = "INPUT" THEN INPUT ;
END IF
ELSEIF comm$ = "OUTPUT" THEN PRINT filesrch%(prog%, varin1$), varin2$



In Wordpad it reads:

ELSEIF comm$ = "INPUT" THEN INPUT filesrch%(prog%, varin1$), var$(searchvar%(varin2$, prog%), prog%)
ELSEIF varin2$ = "=" THEN
IF varin4$ = "+" THEN
IF STR$(VAL(varin3$)) = varin3$ AND STR$(VAL(varin5$)) = varin5$ THEN
var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin3$) + VAL(varin5$))
ELSE
var$(searchvar%(varin1$, prog%), prog%) = varin3$ + varin5$
END IF
ELSEIF varin4$ = "-" THEN var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin3$) - VAL(varin5$))
ELSEIF varin4$ = "*" THEN var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin3$) * VAL(varin5$))
ELSEIF varin4$ = "/" THEN var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin3$) / VAL(varin5$))
ELSEIF varin4$ = "/-" THEN var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin5$) ^ (1 / VAL(varin3$)))
ELSEIF varin4$ = "^" THEN var$(searchvar%(varin1$, prog%), prog%) = STR$(VAL(varin3$) ^ VAL(varin5$))
ELSE
var$(searchvar%(varin1$, prog%), prog%) = varin3$
END IF
ELSEIF comm$ = "OUTPUT" THEN PRINT filesrch%(prog%, varin1$), varin2$


All of the rest of that code is supposed to be there, and the program won't work without it. It also gives me a variable required error because of it. Why does it do this and how do I fix it?
 
i find that if i write anything outside of qbasic that wordpad works the best because it has never ending lines and can save as the following format (any file ".")

i dont know if this will be helpfull but i hope it will help a little.
 
lol!

i'll post your question at qbasicnews, and see if the folks there can answer it. don't worry, help is on the way!
 
using wordpad, cut that extra text right out of the program using (appropriately enough) the cut command. Then save the file. Now open the file in QB, and make it into a window. point your text cursor to where the code started before, right click on the top of the window, go to edit, and hit paste. (if you're using 9x/ME, there's a paste button at the top already). This will sort of 'type' the code out in the editor, so you can see where it all is. Then just correct your alignment, and you shouldn't have any more problems.
 
You can't paste something into qbasic from windows, you can only paste from qbasic to itself.

Futhermore I noticed that it does indeed load it corretly, it changes it when I hit the F5 key. ???
 
You most certainly can, I just told you how. :p

If that's the case, perhaps something else is going wrong?
 
R@dioman
Wandering Guru


Joined: 16 May 2002
Posts: 300
Location: Winnipeg, Manitoba

Posted: Fri Mar 05, 2004 6:06 am Post subject:

--------------------------------------------------------------------------------

How big is your bas file. Maybe it's too big for the IDE.
_________________
-This statement is false.
-Ignore this advice.
T.A.N.K : (right click, save-as...)

Back to top


Antoni Gual
Mayor Afiliación


Joined: 08 Dec 2002
Posts: 591
Location: Barcelona, Spain

Posted: Fri Mar 05, 2004 12:46 pm Post subject:

--------------------------------------------------------------------------------

If you copied it from Inet it probably has the end of line format of unix and QB can't read it. Some browsers convert it automatically, some not.
Try to open it with W9x DOS Edit (it should display ok there) then save it. The saved file should work with qb
_________________
Antoni
 
No, I wrote it myself in Wordpad, and it is less than 20K
 
qbasicking:

As SJZero said (and I have done this on several occasions) you can copy from a Window's Textbox, such as wordpad, and directly paste it to QB or Qbasic.

--MiggyD
 
well, you learn something new every day. :D

yeah, well it probably has something to do with the way notepad saves files.
 
If I copy your code from the forum, paste it to W2000 wordpad, save it with .bas extension and open it with QBN45, everything shows ok.
Are you sure you have not introduced any char >128? The forum would probably filter it. Maybe you could copy and paste the missing part from your own post :D
If you don't have an hex editor you could check it with DOS Edit, it has an option to display a file as binary. Look for any non printable caracter different from the CR+LF pairs.

Antoni
 
It shows the code corretly, it just changes it after pressing F5, then it gives me an error.

I am sure that there is no weird characters, what you see in the forum is a perfect duplicate of my original code. Notepad saves files as simple text files, which is the same way that I normally save code in qbasic.
 
Almost sounds like a memory issue, especially in the lower 640K zone.

Do you have a memory chip tester? or how about too low on memory?

--MiggyD
 
qbasicking,
could you post the file?
Also interesting if it happens in other Basic versions.
It could be some glitch in Basic.
My students several time make Basic say "Out of memory for strings" or something like that - and then program became corrupted. And it was rather small (screen-size or two) program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top