
-----------------------------------
mapleleaf31
Thu Jan 20, 2005 4:31 pm

ASCII to Binary?
-----------------------------------
So I need a code that converts from a sentence of characters into ASCII and into Binary displaying both on the screen, I have the ASCII part down but when I try and enter in a whole sentence I get an error 

"Parameter to "ord" is not of length one"

How can I fix this and have them display one after the other?

Heres the code so far:

var letter : string
var size : int

locatexy (50, 190)
put "Enter the letter"
get letter : *
size := length (letter)


for i : 1 .. size
    put ord (letter (i)) : 4 ..
    put intstr (ord (letter), 0, 2)
    put ""
    delay (1000)
end for

-----------------------------------
Cervantes
Thu Jan 20, 2005 4:52 pm


-----------------------------------
To fix the error, change

put intstr (ord (letter), 0, 2) 

to

put intstr (ord (letter (i)), 0, 2) 


-----------------------------------
eNc
Thu Jan 20, 2005 4:54 pm


-----------------------------------
still doesn't work, try entering y, it doesn't convert it to binary, it has a 2 in it which is not possible.

-----------------------------------
Cervantes
Thu Jan 20, 2005 5:08 pm


-----------------------------------
Comment out the first put line.

-----------------------------------
mapleleaf31
Thu Jan 20, 2005 6:25 pm


-----------------------------------
what do you mean by try entering y?

I tried your first fix Cervantes and it didn't work like eNc said. I also commented out the first put line and that didn't work, same error.

It works if I only enter in 1 character but I need to be able to type in a whole sentence.
