Page 1 of 1

Me again

Posted: Fri Jul 10, 2009 7:20 am
by izidor
First:

Why a string has fixed number of characters?
I tried this:

Code: Select all

DIM s AS STRING * 10000
INPUT a
But the text stops at 4 row.

Second:

How to open whole text not just one row with OPEN statement?

Code: Select all

OPEN "abc.txt" for input as #1
input #1,a$
print a$

Posted: Fri Jul 10, 2009 11:32 am
by Harry Potter
How to open whole text not just one row with OPEN statement?
Try this:

Code: Select all

OPEN "file.txt" FOR INPUT AS #1
 S$=INPUT$(LOF(#1),#1)
CLOSE #1

Posted: Fri Jul 10, 2009 12:21 pm
by burger2227
# is not required in the INPUT$ Function or the EOF function.

Syntax: INPUT$(bytes, filenumber)

If the string exceeds 32,767 characters(bytes) there will be a string error!
So check the LOF(1) first!

Posted: Sun Jul 12, 2009 12:15 pm
by izidor

Code: Select all

OPEN "file.txt" FOR INPUT AS #1
 a$=INPUT$(LOF(1),#1)
PRINT a$
CLOSE #1
This works fine, but are there any ideas for the first one?

Thanks

Posted: Sun Jul 12, 2009 12:32 pm
by burger2227
Do you mean the fixed length string? Fixed length strings are required in Random file record fields. You can define them in a TYPE definition or a FIELD statement.

Why are you using one anyhow? Anything over 1000 characters (1000 bytes) will be lost. INPUT # is used in sequencial files normally and has problems with commas in number values. LINE INPUT # is used to read entire lines of a file as variable length text. It has no problems with commas. In fact it can return a line of data with any quotes from a file created by WRITE #.

Posted: Tue Jul 14, 2009 8:43 am
by izidor
I am trying to create text editor.