can i read a ascii code from a file and get the number of the ascii code?
Professional Software Development Tools
can i read a ascii code from a file and get the number of the ascii code?
the code
code = String.Asc("h");
i get a code = 104 bat i whot to get a ascii from a file (not a text file) i dont wont the "h" i wont a ascii from a file and get the number
read the file into a string ( TextFile.ReadToString )
Then use String.Asc to get the value of the character. If you're looking to get a particualr character, then you might need to use String.Mid to single out that character. Or you could use a loop to iterate through the entire string to get the Asc value of all characters.
Are you using the io.open to read in a binary file? You then want to read the binary to an ascii character? Is that what you want to do?
If that is the case you can use some of the built-in lua functions. string.format will output your data as hex if you want or tonumber allows you to format a number in the base you want (base 2 for binary, base 10 for decimal system and base 16 for hex).
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
i dont use io.open i dont anderstent it and i wont to read the binary to an ascii character
to worm
i cnot use the TextFile.ReadToString bekose the file is not a text file
i think i need a help in io.open i need an example (not the link to the site bekose i dont andersten it)
Can you post a file you would like to read? And explain what it is you are wanting to do with that file after it has been read into AMS? And are there certain bits you are wanting to convert or is it all bits?
Tigg
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
i wont to copy a file (file.mp3) to (file2.mp3) but byte after byte ascii after ascii
Yes, but for what reason?
Never know what life is gonna throw at you.
(Based on a true story.)
i need it. can anibady help me? i wont to delete sum ascii code and chek samting
Last edited by lnd; 09-24-2006 at 12:38 PM.
if i build a code in visual basic 6 sambady can help me to save it to DLL and use it in ams6?
the code in visual basic 6
--------------------------------------------------------------
Public str1 As Byte
Open App.Path & "\1.mp3" For Binary As #1
Open App.Path & "\2.mp3" For Binary Access Write As #2
Do Until EOF(1)
Get #1, , str1
Put #2, , str1
Loop
Close #1
Close #2
-----------------------------------------------------------------
I think something like this might work
local inp = assert(io.open("1.mp3", "rb"));
local out = assert(io.open("2.mp3", "wb"));
local data = inp:read("*.all");
--make changes to the data here
out:write(data);
assert(out:close());
Tigg
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
error in - local data = inp:read("*.all"); the error is invalid format
local inp = assert(io.open("c:\\1.jpg", "rb"));
local out = assert(io.open("c:\\2.jpg", "wb"));
local data = inp:read();
Label.SetText("Label1", data);
--make changes to the data here
out:write(data);
assert(out:close());
if i set the text to a label then the data = mor the 1 ascii code and i need only 1 ascii then a loop to all the file
Last edited by lnd; 09-24-2006 at 10:42 PM.
the code to all
local inp = assert(io.open("c:\\1.jpg", "rb"));
local out = assert(io.open("c:\\2.jpg", "wb"));
-- A for loop that counts from 1 to 10
min = 1; -- The number to start at
max = 100; -- The number to stop at
for count = min, max do
local data = inp:read(1);
--Label.SetText("Label1", data);
--make changes to the data here
out:write(data);
end
assert(out:close());
local inp = assert(io.open("c:\\1.jpg", "rb"));
local out = assert(io.open("c:\\2.jpg", "wb"));
while true do
local byte = inp:read(1);
if not byte then break end
Label.SetText("Label1", byte);
--make changes to the data here
if byte == "something" then byte = "somethingelse" end
out:write(byte);
end
assert(out:close());
You could try something like the above as well. This will continue to loop until you reach the end of the file and during each loop it will return one byte at a time. You can then make your change and output that byte to the output file.
Tigg
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine