How to convert a string to character?

About Monkey 2 Forums Monkey 2 Programming Help How to convert a string to character?

This topic contains 7 replies, has 5 voices, and was last updated by  codifies 2 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6760

    cocon
    Participant

    How do you convert a string character into an int character?

    I tried casting but it does not work.

    Also I tried indexing it as an array “a”[0]  also, it works, but it does not seem very good idea.

    #6761

    codifies
    Participant

    you can only convert *one* character to a value

    [/crayon]
    #6762

    Mark Sibly
    Keymaster

    “a”[0] is fine!

    #6765

    Danilo
    Participant

    s[0] is what Asc(s) is in BASIC programming languages.
    If you like functions like Asc(), make it a function. 😉

    Calling an extra function like Asc() has some overhead,
    and we don’t have Macro’s in MX2, but it can be helpful
    in the process of learning and converting older codes.

    #6779

    abakobo
    Participant

    Yes it would be nice is thoses good old BASIC functions where included in std or any core module..

    #6782

    codifies
    Participant

    …yeah macros would be useful…

    anyone happen to know how to do the equivalent of chr$(n)

    …edit $ ah those were the days…..

    #6792

    Danilo
    Participant

    > anyone happen to know how to do the equivalent of chr$(n)

    It is

    If you like to make it a function for compatibility with some old code:

    #6793

    codifies
    Participant

    ..ah of course, thanks…

    although I probably wouldn;t wrap in in an asc function what you’ve made there makes for a nice little example.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.