Wheel IDE

Online demo »

String, charCode

String charCode example

This example declares a string and changes the charCode of the characters in the string.

Code

#project "String charCode example"

#include "lib/modules/standard.whl"
#include "lib/modules/device.whl"
#include "lib/modules/string.whl"

proc main()
    clearConsole();

    ; Declare a string and print it in the console:
    string s = "ABCDE"
    printS(s)

    number n
    number ch
    for n = 0 to 4
        ; Get the char code at index n and print it in the console:
        ch = getCharCodeAt(s, n)
        printN(ch)
        ; Change the char code...
        ch += 5
        setCharCodeAt(s, n, ch)
    end

    ; Print the updated string:
    printS(s)
end