2.3 version

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

Dalede wrote:
Mr. Kibernetik wrote:
Dalede wrote:Always converting binary to numbers seems a bit difficult to work with. For writing strings can also write binary data directly using strings. It would be nice to be able to also read binary data into a string so that it stays in binary form, either in 1 byte size chunks or perhaps even fixed length chunks. These days of unicode even the interpretation of text some be complicated.
I cannot understand your idea. Can you please explain it a bit more?
What I am talking about is a binary number from 0 to 255 can be stored in a single byte but a basic number can take 1 to 3 digits display the number and it is stored in memory not at the binary digit but a floating point number. However a string of one character can be store in one byte and can have all of the values from 0 to 255 although not all of them are visible to the eye when the character is prints. A string value is true binary. So long has basic can manipulate strings with compares, disassembly, and assembly it can serve as a way to manipulate true binary. This can aid in working with binary files instead of always converting to a floating point number in the range of 0 to 255.

Of course the real power will come when you can also manipulate bytes of data using AND, OR and XOR capabilities. These could be used directly to manipulate a string or if you chose you could could even implement them for numbers I suppose if you assume a binary value.

Dale
As BASIC has no types definitions, it is out of user control how to store data in memory. As you suggest, you can store byte values as string characters and save memory up to 4 times: every number internally takes 8 bytes to store, every character in string internally takes 2 bytes to store.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New command will be implemented:
FILE n$ WRITELINE x$
writes string from variable [x$] to file [n$]. Carriage return is automatically added to the string.
It is possible to specify several variables to write multiple string lines:
FILE n$ WRITELINE x$,y$,...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New command will be implemented:
FILE n$ TRIM
deletes all data after current position of file pointer in file [n$]. It is possible to specify file pointer value [x] after which data will be deleted:
FILE n$ TRIM x

Dalede
Posts: 131
Joined: Fri Dec 28, 2012 4:00 pm
Location: Grass Valley, CA, USA
Contact:

Re: 2.3 version

Post by Dalede »

Mr. Kibernetik wrote:New command will be implemented:
FILE n$ WRITELINE x$
writes string from variable [x$] to file [n$]. Carriage return is automatically added to the string.
It is possible to specify several variables to write multiple string lines:
FILE n$ WRITELINE x$,y$,...
Somehow my previous comment seems to have not gotten posted.

Would it be possible to end the Writeline with a ; (semicolon) to prevent the CR at the end of the line? This would allow us to be able to write pure binary files.

Dale

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

Dalede wrote:
Mr. Kibernetik wrote:New command will be implemented:
FILE n$ WRITELINE x$
writes string from variable [x$] to file [n$]. Carriage return is automatically added to the string.
It is possible to specify several variables to write multiple string lines:
FILE n$ WRITELINE x$,y$,...
Somehow my previous comment seems to have not gotten posted.

Would it be possible to end the Writeline with a ; (semicolon) to prevent the CR at the end of the line? This would allow us to be able to write pure binary files.

Dale
But why you will not use FILE WRITE to write binary file?
For example, this:
FOR I=0 TO 1000
FILE F$ WRITE N(I)
NEXT I
will write 1000 bytes from array N() to file.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New command will be implemented:
FILE n$ COPY d$
copies specified file [n$] to file [d$].

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New command will be implemented:
FILE n$ RENAME d$
renames specified file [n$] to new name [d$]. File pointer of file with new name is retained from file with old name.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

Dalede wrote:
Mr. Kibernetik wrote:New command will be implemented:
FILE n$ WRITELINE x$
writes string from variable [x$] to file [n$]. Carriage return is automatically added to the string.
It is possible to specify several variables to write multiple string lines:
FILE n$ WRITELINE x$,y$,...
Somehow my previous comment seems to have not gotten posted.

Would it be possible to end the Writeline with a ; (semicolon) to prevent the CR at the end of the line? This would allow us to be able to write pure binary files.

Dale
Taking your request into account, syntax of command FILE WRITELINE will be expanded:

FILE n$ WRITELINE x$
writes string from variable [x$] to file [n$]. Carriage return is automatically added to the string.
It is possible to specify several variables to write multiple string lines:
FILE n$ WRITELINE x$,y$,...
If you need to write string line without adding carriage return at the end, you can use ";" separator after variable, for example:
FILE n$ WRITELINE x$;
FILE n$ WRITELINE x$;y$;

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New commands will be implemented:

DIR n$ LIST DIRS a$,b
saves list of folder names in directory [n$] to single-dimensional string array [a$]. Number of folders is saved to numeric variable . List of folders is alphabetically sorted.
If array [a$] was declared earlier then its size is changed (increased or decreased) to store list of folders. If array was not declared before then it is automatically created with size equal to number of folders. Size of array [a$] is stored to variable .

DIR n$ LIST FILES a$,b
saves list of file names in directory [n$] to single-dimensional string array [a$]. Number of files is saved to numeric variable . List of files is alphabetically sorted.
If array [a$] was declared earlier then its size is changed (increased or decreased) to store list of files. If array was not declared before then it is automatically created with size equal to number of files. Size of array [a$] is stored to variable .

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 2.3 version

Post by Mr. Kibernetik »

New command will be implemented:
DIR n$ SET
changes current directory to [n$].

Post Reply