Please tell me this is possible.

Blitz3D Forums/Blitz3D Beginners Area/Please tell me this is possible.

Yahfree(Posted 2007) [#1]
Hey, one of the main aspects of my program is to grab a .txt file off the internet and read it like normal, right now, i have the info in a .txt file on my HD, i want to have 2 modes: internet, and HD, the internet mode grabs the info off a .txt file on the internet at the said address.

The HD mode grabs it off disk. its kinda a must to have this internet mode..

is this possible in blitz3d? or am i introuble?


SLotman(Posted 2007) [#2]
Of course it's possible. Just use TCP/IP commands for that.

There's even code in the archive to show how to retrieve an html page.

Take a look here: http://www.blitzbasic.com/codearcs/codearcs.php?cat=4


Yahfree(Posted 2007) [#3]
how would i go about grabing a .txt file off of like say:


"www.mydomain.com/mytext.txt"

what commands would i use, and how would that work?


t3K|Mac(Posted 2007) [#4]
i would use ETNA. this is ideal for dealing from b3d with websites.

http://www.blitzbasic.com/toolbox/toolbox.php?tool=160


Yahfree(Posted 2007) [#5]
is that nessisary for a simple read file off the internet type thing? above is all i need to do, no sending, no hosting ect ect, just reading a simple text file off the web


t3K|Mac(Posted 2007) [#6]
its *very* easy to use. just try it. its free, too!

i would never ever hassle with tcp commands, since ETNA is so easy to use.


Yahfree(Posted 2007) [#7]
I looked at it, its nice, but i decided to go with these set of functions in the CA, because i don't really feel like lugging another DLL around.

in the CA:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1816

anyways, i noticed when i grabs a .txt file off the internet, its all smushed into one line, theres spaces between the lines for example:

test
test
test

would become:

test test test

what would i have to do to unscramble it?


Yahfree(Posted 2007) [#8]
Buzzar... doesnt seem like its smushing it now for some reason, Wierd! well i'm not complaining :D


jfk EO-11110(Posted 2007) [#9]
Depends if you use ReadLine until you get EOF. The there's also several linebreak chars, the windows one, a simple chr$(13), unix one, combinations of line/break+line feed...

You may filter the strings by checking the ascii value of every character.


Yahfree(Posted 2007) [#10]
Now that i think about it, my program could use a way to update a file on the internet, is this possible?


Yahfree(Posted 2007) [#11]
i think i'll take a look at ENTA sense my project is becoming more web-based


Yahfree(Posted 2007) [#12]
alright looking at ENTA, i'm not sure how to make sense of it, alot of the documents are in C++...

can anyone tell me how i would read/write files to a website? like is it possible to write the file:

www.testsite.com/mytext.txt

to that domain? and if so how would i do this? what hoops do i have to jump through to make somthing like this work?


Bankie(Posted 2007) [#13]
Reading a file can be done easily with ETNA - IIRC, one of the Blitz examples does just that since it's the simplest thing that ETNA can do. However, writing to a file needs some PHP or ASP knowledge as you can't edit a web file (txt or otherwise) just by chucking a few TCP commands at it. You would use ETNA to send a command such as "addtotextfile.php?newtext=This is some test text to be added to the file". Your addtotextfile page would contain a script to take the parameter and add the text to the file.

I'm afraid there's no easy way around it if you don't know PHP, so you'd need to learn it or talk nicely to someone who can sort it out for you. Of course, you would also need web space which supported PHP.


Yahfree(Posted 2007) [#14]
yeah, i'll have to pick up a book or somthing, darn, i thought i would get through this part without having to do that :D

question: if i wrote a script, exactly like the one you discribed, wouldnt that add text to the text file as one line? and what about overwriting the file? because thats what i need to do.


Bankie(Posted 2007) [#15]
You can do whatever you need to do - it depends on the exact task you have in mind. When I've used ETNA, I've tended to need it for database (MySQL) operations on the called PHP page, so I'm not so experienced with manipulating text files so I can't guarantee that my line of thinking is the best, but I do know it would work:

- Blitz uses ETNA to call a PHP script which wipes the text file
- Blitz (ETNA) uses a FOR loop to send lines one at a time to a second PHP script which adds the lines to the text file

There may be better ways. If the text file is small, everything could be handled by a single script, with the contents of the whole text file sent at once.

There's no rocket science to any of this but a bit of (worthwhile) time and effort is required to learn this since it will be completely new to you.


Yahfree(Posted 2007) [#16]
Thanks, i'll go learn some php :D