Very simple problem. I save an integer. I call it. I print it. It prints as " integer ". In other words, it prints with a space on either side of the integer. How can I stop this and why does it happen? Thanks -Mike
for saving Integers it is much cleaner to open the file in BINARY mode and use PUT to store the data, which just lumps the data unformatted into the file and expects you to know the byte length of the individual pieces of data you store and read them in correctly. WRITE formats the file for you that's why you get spaces.
If you need an example..
Open FileName$ For BINARY as #1
PUT #1,,MyInteger
Close
To retrieve the data,
Open FileName$ For BINARY as #1
GET #1,,MyInteger
You just need to design your getting and putting so you can retrieve the data without much confusion....
The problem is that [tt]PRINT[/tt] automatically pads numeric values that it outputs. It puts an extra space after them, and it puts a space before them when they are positive (when they are negative, it puts the '-' in that space, so you can't just discard the first character). The solution is to convert it to a string, but you don't need to use a variable in the process. Consider the following example:
[tt]
x% = 5 PRINT "x"; LTRIM$(STR$(x%)); "x"
[/tt]
It should output "x5x", without any spaces.
Thanks logiclrd. Your knowledge once again amazes me. You know, I never realized that you could use Print argument;argument;argument...i thought that you had to use a seperate print statement each time. Talk about a time saver. -Mike
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.