Page 1 of 2
OPEN / INPUT?
Posted: Thu Feb 10, 2005 8:33 pm
by Rattrapmax6

I've got bit of a prob with OPEN/ INPUT, all that stuff,.. if I have a file like the following..
------
word1
word2
..ect..
-------
this code only give me the "word1" and not the others:
Code: Select all
OPEN file$ FOR INPUT AS #1
INPUT #1, word$
CLOSE
Is there a code to read the whole file, I think I remember 1 back when I was a noob (noob is newbie right??), but that was ages ago and I forgot what it was...

,. so what would it be??
Thanks in advance!

Posted: Thu Feb 10, 2005 8:38 pm
by {Nathan}
simple! 2 things cause breaks. Line carrage returns and commas. If commas are a problem, do random files.

Posted: Thu Feb 10, 2005 8:58 pm
by Rattrapmax6
It works fine if I have the file like this tho,.
------
Word1 Word2 .. ect...
------
I need somthing for returns,. I know LINE INPUT sorts commas.. How do I read this?
------
Word1
Word2
... ect...
------
If that explanes it betta, um, hate to sound dumb, but I've used very little OPEN INPUT stuff.. how do u use RANDOM if this is what I need?,.
All this is for a silly prog I'm playing with on the side,.. Its not for Space Warp, just to be clear..

Posted: Thu Feb 10, 2005 9:38 pm
by Mitth'raw'nuruodo
Hmm...ok
Noob is Newbie first of all...
BTW...you should have it as CLOSE #1 instead of just CLOSE...just a thought...
anyway...
I don't know of anything to do it....There must be something though....but here's some code that will do that for me....:
Code: Select all
OPEN "FILE.txt" FOR INPUT AS #1
SPACER$ = " " 'Put whatever spacer you want between words here....
Word$ = ""
DO
IF EOF(1) = -1 THEN EXIT DO
INPUT #1, word1$
Word$ = Word$ + word1$ + SPACER$
LOOP
'do code to take off that last space here if you want to....
CLOSE #1
That code will put all the words into that one word thing with those spaces (if you choose)...there you go....
I did a coin database w/files so this is not new to me by a long shot....

Posted: Thu Feb 10, 2005 10:18 pm
by Rattrapmax6
Great, Mitth, I'll try it!!

Posted: Fri Feb 11, 2005 7:56 am
by Mitth'raw'nuruodo
Your welcome...
Let me know k?
Ummm if you want to change some things around go ahead but in order to not get into that error message when you try INPUT #ing after the End of the file is reached you MUST HAVE IF EOF(1) = -1 THEN EXIT DO BEFORE YOU INPUT #, but other than that go ahead....

Posted: Fri Feb 11, 2005 11:57 am
by Rattrapmax6
Yeah, I figured the EOF, was reading for the End Of File, heh heh, thanks,.

Posted: Fri Feb 11, 2005 3:04 pm
by Mitth'raw'nuruodo
Hey, no prob, and for any other questions about this look in the Functional KeyWord List in Help (the File input/output one)....

Posted: Sat Feb 12, 2005 9:59 am
by Rattrapmax6
Crap, its no use any way.. the MID$() statment only seems to go to 60 chars and stops scanning or something...

If you really want to know, it was to be a HTML reader in QB,.. but until I can solve the limit of chars, its pretty much messed up...
So like after so far, it stops scanning,. misses one of the </ > tags and crashes... oh well,..

Maybe it somthing simple,. but all Varible checking in debuging show it reads okay, it just stops while the DO LOOP keeps going, then it over loads...

Was going to pass it on to you Mitth, and you could have like wrote a Java script decrypter for it also,.. that been cool also..

Posted: Sat Feb 12, 2005 10:07 am
by Mitth'raw'nuruodo
Ooooookkkk....That's ambisous...
Ummm...I wouldn't be able to do it though my computer is acting funny and is appparently I can't make any my Javascripts to work.....Oh well....
Posted: Sat Feb 12, 2005 10:32 am
by Rattrapmax6

Okay maybe Java script, but HTML decrypter is rather easy, look..
Code: Select all
'Given that HTML$ is loaded from HTM file
'HTML won't load into QB...
cont = 0
DO
cont = cont + 1
IF cont = LEN(HTML$) THEN PRINT "Not HTML File ": END
IF MID$(UCASE(HTML$), cont, 5) = "<HTML>" EXIT DO
LOOP
DO
cont = cont + 1
IF cont = LEN(HTML$) THEN PRINT " No <tag>s located " : END
IF MID$(UCASE$(HTML$), cont, 5) = "<HEAD>" THEN CALL Headread
IF MID$(UCASE$(HTML$), cont, 3) = "<P>" THEN CALL Pararead
IF MID$(UCASE$(HTML$), cont, 6) = "</HTLM>" THEN END
LOOP
Works, and its caseinsesitive!! Thats just a sample, and I planned to ad on to it every so often, maybe Java script be to much, it was just a thought, heh heh,..

Posted: Sat Feb 12, 2005 11:25 am
by Mitth'raw'nuruodo
Hey Looks simple but you have and error...
Look at the second to last line of that code (which I thought was inginues, but remeber the length of a $ can only go a little above 200 characters just so you know...)
Do you see anything wrong?
how about "</HTLM>"
Umm I never heard of that tag lol..
Try "</HTML>"
he he....
Oh ya let me guess that after you call headread or pararead if the mid$ of Ucase$ of HTML$ = "</head>" or "</p>" then it goes back to the main loop...AFTER it sets cont to the index in your call....
BTW you don't need the CALL in order to call you can just type headread or pararead....
you should also have to consider that you can't have two "<HEAD>"s in a HTML program or two "<BODY>"s either....
Well there you go....

Posted: Sat Feb 12, 2005 11:30 am
by Rattrapmax6
That was just a sample, my real source has loads of CALLs GOTOs (sorry, working them out

) checks and rechecks, it will only CALL Headread and Bodyread once,.. also titleread once also..
Say, how would I make OPEN open a .html,.. it only does .htm for now??
Posted: Sat Feb 12, 2005 11:37 am
by Mitth'raw'nuruodo
I don't know but mabey you should ask notepad to convert it to .txt first then load it in as a .txt, just a thought...
You should have seen the way I jumped when I saw GOTO...he he....
BE MINDFUL THAT STRINGS HAVE A LIMIT TO CHARACTERS! ONLY LIKE 200, WHICH IS LESS THAN MY WEBSITE!!!!(you know the smily one?)
Posted: Sat Feb 12, 2005 4:28 pm
by Rattrapmax6

, Yeah,. I'm realesing the source over in QB in general topic..
Its limited sofar to 200chars and the HTML satments <html>, <head>, <title>, <body>, and <p> along with all there reverse statments..
Go look at it, heh heh..

Posted: Sat Feb 12, 2005 9:48 pm
by Mitth'raw'nuruodo
dude use FB for this I believe you can have a little more chars in a string (I thought it was around a couple thousand, or was that 2 bill, or was that VBA...) Umm just look it up, cause a only 200 chars is useless....

.
Quick Q: Does FB have the same graphics stuff as QB?
Posted: Sat Feb 12, 2005 9:56 pm
by MystikShadows
using the gfxlib (supplied with FB ... ) it gives you stuff like draw and other QB commands

.
2^31 or 2147483648 bytes long

.
Posted: Sat Feb 12, 2005 10:35 pm
by Mitth'raw'nuruodo
Hmmm ya well that's like 2 Gigs...wait

...TWO GIGS a string can be!
So ummmm...How many chars is that?
Here's code to find out:
Code: Select all
String$ = ""
count = 0 'make sure this is long BTW
DO
count = count + 1
String$ = String$ + "A"
LOOP
This might take awhile and you may have to use two count vars...(1 for higher digits above long limit)
When you get the error you need to look at the output screen if your using QB, which your not you would press 'F4'.
I calculated it out (Now I have a 3.0Ghz processer, remember that).
It will take QB at that processing speed to do a Do:Loop, without calculations, a deciquintillion times (a half a google, 1 followed by 50 0s) a
DECITRILLION YEARS(two places less than a deciquintillion)!!!!! Give or take a few septillions (ummm...you know like if a million is 1, billion is 2, and a trillion is 3, a septillion would be 7)...
Don't ask on how I know that please....
Oh ya there's no such thing as a zillion.....
But there is a googleplex.....Which is a HUGE number imagine a 1 followed by a 100 zeros....Now imagine that number to the power of another 1 followed by a hundred zeros...ya that's big...
google ^ google
or
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000^1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Heh....
and that's the equation, not the accual number.....
the highest number there is is:
Code: Select all
number = number + 1
highestnumber = infinity
DO
number = number + 1
IF number = highestnumber THEN highestnumber = highestnumber + 1
LOOP UNTIL sunexploads = 1
Well that's it, good luck and don't think about ti for too long...
Oh ya BTW I'm sorry if this put a lot of lines under google...he he

Posted: Sun Feb 13, 2005 9:10 am
by Rattrapmax6

, Yeah, but that wouldn't be amazing if FB read a HTML code now would it... But it would make my passtime alot easier, altough I really don't like things easy(DO NOT comment on that please, I don't know how many gg owers program QB/FB!!)

, and if there are any here, they might know what I just said,
Yeah, maybe I'll load up the souce and see if I can't get it to read my site, with is very well over 200 chars,. maybe a good 20000 chars.. heh heh.. and maybe FB is more passive on 4 char dubs and I can use ".HTML" ensted of ".HTM"

Posted: Sun Feb 13, 2005 4:34 pm
by Mitth'raw'nuruodo
Well, ok try it...
