On each line of the birdhouse.txt there is a description of a birdhouse, this description is sometimes has over 400 charcters in it and it will only write about 250 to the birdhouse.sql file.
Is ther a way to have it read and write the full line?
openconsole
def sqlfile,ppname:file
def pn[800]:string
def b:int
def f:int
b = 0
f = 0
openfile(ppname,"C:\\test\\" + "birdhouse.txt", "R")
do
b = b + 1
read ppname,pn
until eof(ppname) 
closefile ppname
openfile(sqlfile,"c:\\test\\birdhouse.sql", "W")
do
write sqlfile,   pn[f] 
f = f + 1
until f >= b
closefile sqlfile
print "Press Any Key To Close"
closeconsole
END
			
			
			
				you have to use ISTRING instead of STRING if you want to use strings longer than 255 characters.
	openconsole
	file sqlfile,ppname
	istring pn[1000]
	int count=0
	openfile(ppname,"C:\\test\\birdhouse.txt", "R")
	openfile(sqlfile,"c:\\test\\birdhouse.sql", "W")
	WHILE EOF(ppname) = 0
		READ ppname, pn 
		write sqlfile,pn
      count++
   ENDWHILE
	closefile ppname
	closefile sqlfile
	print "There were"+str$(COUNT)+" lines read and written"
	print
	print "Press Any Key To Close"
	waitcon
	closeconsole
	END
LarryMc
			
			
			
				thank you
			
			
			
				If I wanted to write a certain row from the birdhouse.txt using the istring, how would I do that?
I used to beable to but the birdhouse.txt content into memory by using the:
openfile(ppname,"C:\\test\\" + "birdhouse.txt", "R")
do
b = b + 1
read ppname,pn[a]
until eof(ppname) 
closefile ppname
f = 0
write sqlfile, pn[f+2]
I can do that any more becaause all it writes is numbers
is there another way of doing this using the istring
			
			
			
				Using Larry's code:
openconsole
file sqlfile,ppname
istring pn[1000]
int b=0, f=0
openfile(ppname,"C:\\test\\birdhouse.txt", "R")
openfile(sqlfile,"c:\\test\\birdhouse.sql", "W")
WHILE READ(ppname,pn) = 0
  b++
	IF b = f+2 THEN write sqlfile,pn
ENDWHILE
closefile ppname
closefile sqlfile
print "There were"+str$(COUNT)+" lines read"
print
print "Press Any Key To Close"
waitcon
closeconsole
END
The above will only print when b = f+2.
Bill
			
			
			
				ok, that is good.
but in my birdhouse.txt I have four rows that needs to be written out and then the next four rows, so on until the file has been read and written out
like the following :
IF b = f+1 THEN write sqlfile,pn
IF b = f+2 THEN write sqlfile,pn
IF b = f+3THEN write sqlfile,pn
IF b = f+4 THEN write sqlfile,pn
but after this it needs to go and get the next four and so on until the file has been read and written
			
			
			
				Based on what you are saying, it does not make any difference when it is read or written, you want to read the entire file and write it back out, more like doing a copy.  In which case, Larry's version does exactly what you are looking for.  Try and explain exactly what you are trying to do again.
It sounds like you want to read 4 records and the write 1 with all 4 read records on it with a delimiter?
Bill
			
			
			
				Based on what you are saying, it does not make any difference when it is read or written, you want to read the entire file and write it back out, more like doing a copy.  In which case, Larry's version does exactly what you are looking for.  Try and explain exactly what you are trying to do again.
It sounds like you want to read 4 records and the write 1 with all 4 read records on it with a delimiter?
Example:
Read:
a
b
c
d
Write:
a,b,c,d
Bill
			
			
			
				That is correct read 4 records and the write 1 with all 4 read records on it
a
b
c
d
Write:
 a, b, c, d
and the same with the next four records that follow until all record are completed
			
			
			
				add comment:
I can get the four record on 1
but Iam not sure how to keep getting the next four record until the record is completed
			
			
			
				Try this:
openconsole
file sqlfile,ppname
istring pn[400], ph1[400], ph2[400], ph3[400], ph4[400]		
int b, ci, co
openfile(ppname,"C:\\test\\birdhouse.txt", "R")
openfile(sqlfile,"c:\\test\\birdhouse.sql", "W")
b = 0
WHILE READ(ppname,pn) = 0
  ci++
  b++
	SELECT b
		CASE 1
			ph1 = pn
		CASE 2
			ph2 = pn
		CASE 3
			ph3 = pn
		CASE 4
			ph4 = pn
			WRITE sqlfile, ph1, ph2, ph3, ph4
                        co++
			ph1 = ""
			ph2 = ""
			ph3 = ""
			ph4 = ""
			b = 0
	ENDSELECT
ENDWHILE
WRITE sqlfile, ph1, ph2, ph3, ph4
co++
closefile ppname
closefile sqlfile
print "There were ", ci, " lines read"
print "There were ", co, " lines written"
print
print "Press Any Key To Close"
waitcon
closeconsole
END
This is a fairly simple approach, but should do what you are looking for.  Also the last write is to make sure you get all the data, in case the file does not end up on an even multiple of 4.
Bill
			
			
			
				I have a question about "pn"
like
IF b = f+4 THEN write sqlfile,pn
that record is a price like 23.50
is it possible muliply that by two
and write the total 47.00 in place of the 23.50
I have tried to using
numbers = val(pn)
price = numbers * 2
write sqlfile, price
but it just writes 23.50
or in the code by bllhsln
using ph4 = pn
			
			
			
				This should do it.
CASE 4
    ph4 = str$(val(pn)*2)
    WRITE sqlfile, ph1, ph2, ph3, ph4
    co++
    ph1 = "":ph2 = "":ph3 = "":ph4 = ""
    b = 0
LarryMc
			
			
			
				Yes, I just figure that out, also in billhsln code I change the
WRITE sqlfile, ph1, ph2, ph3, ph4 to
WRITE sqlfile, ph1 + ph2 + ph3 + ph4
the , made it have and syntax error
Thank all of you for the help