detect string length ???

PeeCeePeeCee Member Posts: 107
edited January 2012 in Working with GS (Mac)
Hi.
is there a way to detect string lenght of characters in a string attribute.????

Cheers

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    edited January 2012
    is it a string you entered? or the player enters? and, what you want to do with the results … are important in considering how to help.

    (for comparison of yours/players entry)
    make an attribute integer type: correctStringCount
    make an attribute integer type: playerStringCount

    In yourEntry: count the letters,#,punctuation, spaces
    that count would be in game.correctStringCount

    In playerEntry: whenever they tap the keyboard and that action adds to string include:
    a changeAttribute: game.playerStringCount To: playerStringCount+1
    (when they enter [delete X] changeAttribute: game.playerStringCount To: game.playerStringCount-1)

    Rule: when game.playerStringCount = game.correctStringCount
    --do this or that
    Otherwise:
    --do something else

    MH
  • EbreezeEbreeze Member, PRO Posts: 481
    edited January 2012
    Most of us here are non programmers mate :)
  • MotherHooseMotherHoose Member Posts: 2,456
    @Ebreeze … but, most of them do want to be programmers! ;)
  • EbreezeEbreeze Member, PRO Posts: 481
    Programming is hard...that's why GS is awesome...but yeah I wish I could program in at least java or csharp..
  • MotherHooseMotherHoose Member Posts: 2,456
    programming is not hard … after all it is a language … and, you can learn any language!

    what daunts us: it is all so foreign looking …

    while the word/vocabulary can be learned without difficulty … (focus on this, first!)
    the grammatical structure/punctuation upsets all our previous learning of how things should be said/written!
    and ultimately, stating things so a linear and logical (but, unreasonable) computer can/does … read/write/manipulate our instructions.

    GS is a great place to start learning the language!

    MH
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    MH summed it up nicely.

    Hard no, taking time and effort, yes.

    You just have to learn what words represent what, and what punctuation follows them.
  • PeeCeePeeCee Member Posts: 107
    Thanks to all who commented on here :).lol JP(John). I guess i want to be able to restrict a DISPLAY TEXT to only ever
    contain 2 characters. is there such as thing ???.
    e.g. string attrib/var is string1="AB"
    display test(string1)

    so now if a user hit other letters then i dont want it to add any more.

    Appreciate your help guys.


  • MotherHooseMotherHoose Member Posts: 2,456
    as displayText uses very,very little of the device's resources:

    2 text gameAttributes … text1 and text2
    2 actors … one for 10ths and one for ones
    -have the width just large enough to show 1 digit in the font and fontSize you want … (actually fontSize should work for most widths)
    -have the height = to your fontSize - 5 or 6

    10thsText actor
    Rule: when
    game.Text1 is (and, leave that blank)
    -Keyboard Input behavior

    Display Text behavior
    Text: text1
    Align: left … and √ Wrap inside Actor

    same for 1sText actor (but text2 display)

    MH
  • PeeCeePeeCee Member Posts: 107
    thankyou MH. Appreciate your nice touch and feedback on this.
    your logic sounds great. will attempt.
Sign In or Register to comment.