Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2005
    Posts
    572

    read a ascii code from a file and get the number of the ascii code

    can i read a ascii code from a file and get the number of the ascii code?

  2. #2
    Join Date
    Oct 2005
    Posts
    572

    help me

    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

  3. #3
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    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.

  4. #4
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Quote Originally Posted by lnd View Post
    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
    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

  5. #5
    Join Date
    Oct 2005
    Posts
    572

    i dont use io.open i dont anderstent it

    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)

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    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

  7. #7
    Join Date
    Oct 2005
    Posts
    572

    i wont to copy a file (file.mp3) to (file2.mp3) but byte after byte asci after asci

    i wont to copy a file (file.mp3) to (file2.mp3) but byte after byte ascii after ascii

  8. #8
    Join Date
    May 2005
    Posts
    1,115
    Yes, but for what reason?
    Never know what life is gonna throw at you.
    (Based on a true story.)

  9. #9
    Join Date
    Oct 2005
    Posts
    572

    i need it. can anibady help me?

    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.

  10. #10
    Join Date
    Oct 2005
    Posts
    572

    Smile help

    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
    -----------------------------------------------------------------

  11. #11
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    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

  12. #12
    Join Date
    Oct 2005
    Posts
    572

    error in - local data = inp:read("*.all"); the error is invalid format

    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.

  13. #13
    Join Date
    Oct 2005
    Posts
    572

    its work thens

    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());

  14. #14
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts