|
Post by DARKNIGHT on Sept 14, 2023 23:00:08 GMT -5
Hello All, I am working on a new project, and am at a kind of standstill.
the code is supposed to covert each letter of the input into their ASC Val's, separated by a comma. with my current code, I only get an output of the ASC Val of the first letter, and that's all.
{*} Note: the reason I start the loop at 2, is because starting with a val of 1, would cause the first letter to appear twice in the output, in an early version of the code, which just echoed the Raw text to the screen.
here is my code:
[conv]' Convert Message into Asc Vals let a=1 cls locate 5,4:input"Enter Message to CONVERT :";Msg$ {*} for x=2 to len(Msg$) let cv(a) = asc(Msg$) print cv(a);","; let a=a+1 next x
any help would be greatly Appreciated, thanks in advance Jim
|
|
|
Post by tsh73 on Sept 14, 2023 23:04:16 GMT -5
Change let cv(a) = asc(Msg$) To let cv(a) = asc(mid$(Msg$,a,1))
|
|
|
Post by DARKNIGHT on Sept 15, 2023 13:06:21 GMT -5
I copied and pasted your sugestion into my code, but
sorry. I still just get the first ASC Val, but thanks for your input anyway. and I appreciate the effort maybe left$ would work?
|
|
|
Post by tsh73 on Sept 15, 2023 13:31:20 GMT -5
You are doing it wrong? Your code produces this
Enter Message to CONVERT :hello123 104,104,104,104,104,104,104,
Changing let cv(a) = asc(Msg$) To let cv(a) = asc(mid$(Msg$,a,1)) - here's full code
[conv]' Convert Message into Asc Vals let a=1 cls locate 5,4:input"Enter Message to CONVERT :";Msg$ ' {*} for x=2 to len(Msg$) ' let cv(a) = asc(Msg$) let cv(a) = asc(mid$(Msg$,a,1)) print cv(a);","; let a=a+1 next x
produces this:
Enter Message to CONVERT :hello123 104,101,108,108,111,49,50,
But it gives us 7 numbers, should be 8 - FOR loop should be from 1, not 2
for x=1 to len(Msg$) And it produces
Enter Message to CONVERT :hello123 104,101,108,108,111,49,50,51,
Here 49,50,51 is the codes for "1", "2" and "3".
|
|
|
Post by DARKNIGHT on Sept 15, 2023 15:18:42 GMT -5
Awesome! that did the trick!
I must had entered something wrong the first time but it works Now!
Thanks Man, You Rock !
|
|