Qbasicnews.com
April 10, 2020, 04:04:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Help with do while not eof for ftp program  (Read 2891 times)
Ruudboy
Ancient Guru
****
Posts: 544



« on: August 25, 2003, 03:03:22 PM »

i have this so far and want it to print the whole file from one variable.
any help would be useful. if your thinking it's abit strange then it's because it's for my ftp program


Code:
PRINT "Opening file"
OPEN "a:\test.bas" FOR INPUT AS #1
DO WHILE NOT EOF(1)
    INPUT #1, msg3$
    PRINT "test line: ";
    PRINT msg3$
LOOP
CLOSE #1
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #1 on: August 25, 2003, 04:01:35 PM »

what do you need help on?
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #2 on: August 25, 2003, 07:33:47 PM »

You mean that you want the whole file contents as one variable? Well... you'll need to make a *big* string, and add CHR$(13) and CHR$(10) between the lines, like this: (untested)

Code:
PRINT "Opening file"
OPEN "a:\test.bas" FOR INPUT AS #1
DO WHILE NOT EOF(1)
    INPUT #1, currentline$
    wholefile$ = wholefile$ + CHR$(13) + CHR$(10) + currentline$
LOOP
CLOSE #1

PRINT "The whole file as one variable:"
PRINT: PRINT wholefile$


See what that does, and post any problems.
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #3 on: August 25, 2003, 09:06:17 PM »

This will only work for short files. QB string limitation ...
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #4 on: August 26, 2003, 02:07:05 PM »

thanx for the help. how long is the string limitation.

because of this is there anyway of getting the code to reach the string limitation. then save the rest of the file to another string and so on.
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
ak00ma
Ancient Guru
****
Posts: 669



« Reply #5 on: August 26, 2003, 02:27:54 PM »

One string's maximum length = 32768 ASCIIs
Logged

B 4 EVER
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #6 on: August 27, 2003, 02:55:03 PM »

i've just thought that i'll only be able to send text and ascii files. unless them 8mb ones you view which display about four characters mean somin
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #7 on: August 27, 2003, 07:42:28 PM »

You could save some in one string and some in the other, but before wasting so much memory, why do you need to have the contents of an entire file in a single variable? Post up here some psuedo code for your routine, and we can see if there is a better way.
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #8 on: August 27, 2003, 11:30:53 PM »

I have coded FTP servers in Unix minicomputers, and you sent "packets" of data. You opened the file, sent X characters, sent X characters, ... until you completed the file.  Your buffer shouldn't  be so big. In FTP protocol, frames have a max length that you have to take in account. So to make a big transfer you have to split files in many frames.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ak00ma
Ancient Guru
****
Posts: 669



« Reply #9 on: August 28, 2003, 01:25:07 AM »

You can use XMS. You  simply make something like a normal screen buffer with 1024x786 or so (804864 Bytes) with 8bits per pixel, so you can save one ASCII character per pixel.
Logged

B 4 EVER
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #10 on: August 28, 2003, 10:14:09 AM »

my buffer is 256
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
Neo
Na_th_an
*****
Posts: 2150



« Reply #11 on: August 28, 2003, 10:45:41 AM »

256 bytes? That's a whole lot smaller than what you first had Smiley.

Ok, when I use buffers for fast file reading/writing I usually take buffers with size 1 to 4 kB, because the speed and the memory usage are balanced at that point.

But I'm thus suggesting this:

Code:
DEFINT A-Z

CONST BUFFERSIZE = 4096
CONST PACKET = 0
CONST STARTPACKET = PACKET + 1
CONST STOPPACKET = PACKET - 1

got& = 0

'Send a create-file command to server
SendFTP "ftp://Idontknow", "bla.BAS", STARTPACKET

OPEN "bla.BAS" FOR BINARY AS #1
   flen& = LOF(1)
   DO
      bufsiz = BUFFERSIZE
      IF got& + BUFFERSIZE > flen& THEN bufsiz = flen& - got&
      buffer$ = SPACE$(bufsiz)
      GET #1, , buffer$

      'send  a packet to ftp server
      SendFTP "ftp://Idontknow", buffer$, PACKET

      got& = got& + bufsiz
   LOOP UNTIL got& = flen&

   'tell the ftp server file is completed and can be closed
   SendFTP "ftp://Idontknow", "", STOPPACKET
CLOSE #1


Do you get that Wink?

Btw, SendFTP is a SUB-procedure you write yourself for handling the FTP-command and -protocol etc..
Logged
Ruudboy
Ancient Guru
****
Posts: 544



« Reply #12 on: August 28, 2003, 02:43:56 PM »

i don't think you get my ftp program do you. it is a straight link computer to computer.

like running laplink.
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=0&t=79][/url]
Neo
Na_th_an
*****
Posts: 2150



« Reply #13 on: September 01, 2003, 04:36:23 AM »

Then I think you can use OUTs to send the messages to the port which the other computer is connected to. The other computer should be running a program then which reads the values transferred and put it back in a file.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!