I was trying some tests with binary numbers.
If I put in "w" and convert it to binary I get
"01110111" which is correct. If I then write
it out to a file, and read it back in again and
then convert it back I get "01110111" correctly,
but when converted to a character I get a "_"
which is completely wrong.
Thanks,
Rick
Code follows:
set the defaultFolder to specialFolderPath ("desktop")
put "w" into varText
answer "varText = " & varText
repeat for each char tChar in varText
put charToNum(tChar) into theNum
put baseConvert(theNum,10,2) into tBaseConverted
put char -8 to -1 of ("00000000" & tBaseConverted ) into
tBaseConverted
put tBaseConverted into tConverted
end repeat
answer "tConverted = " & tConverted
put binaryencode("a*",tConverted) into VarBinaryCodedResult
put the defaultFolder & "/" & "TestFile" into TestFileName
open file TestFileName for binary write
write VarBinaryCodedResult to file TestFileName
close file TestFileName
open file TestFileName for binary read
read from file TestFileName until EOF
close file TestFileName
put it into VarTestFileData
put binaryDecode(a8,VarTestFileData,VarDecoded) into VarDisplayData
answer "VarDecoded = " & VarDecoded
answer "VarDisplayData = " & VarDisplayData
put the numToChar of VarDecoded into CharToDisplay
answer "CharToDisplay = " & CharToDisplay
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode