comparing text attributes

I want to compare two text attributes to see if one comes before the other like:
if game.word1 < game.word2
or
if game.word1 is min(game.word1, game.word2)

Can it be done?

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I don't know of any way to do this.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    @pjcohen

    Hi, as @tatiang says, there's no way to do this with text attributes alone; you'd have to use more attributes. You could use a table as well, I'm thinking.

    But even without a table: use an integer called WordCount. As well, for every word used, make an integer attribute, i.e W1Pos, W2Pos, etc. and as they are used, Change Attribute WordCount to WordCount+ 1, then Change Attribute W?Pos to WordCount. Then you've got something to compare. Hope that helps out.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @gyroscope - But wouldn't you have to know in advance which word was in which position? I still don't see a way to compare text attributes without having a way to parse text such as firstLetter(game.word) or a way to convert a text attribute to letters stored in individual table cells -- which we don't have. If the user enters two words, "apple" and "banana" how could you tell which comes first alphabetically?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    Hi @tatiang Interesting, and i agree with what you're saying. But the way I saw it: although not knowing what sort of game @pjcohen is making, I assumed, by the short description, that word after word is used in some way, created one after the other; and he needs to find out an order comparison "after the event" rather than comparing any of the letters in each word...that's how I understood it anyhow. So if that's right, and the words are created one after the other as I thought, then using integer attributes linked with each word, for position as they are made, would work....

    But for what reason I can't quite work out... ;-) Which leads me to think that @pjcohen did mean alphabetical order rather than placement order..... ah well, I tried!

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • mhbartabymhbartaby Member Posts: 5

    here is a video tutorial I made comparing attributes in a table. It's a quiz style app.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @mhbartaby Please don't bump threads that are two years old. It just so happens that the current version of GameSalad Creator includes powerful text string manipulation functions that make this sort of thing quite easy now.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

This discussion has been closed.