Compare strings in Arrays

0 favourites
  • 5 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • Hi guys,

    I'm working on a game, where i want to compare a user text, which i write in an array, with another array.

    It should look like:

    Original(Sum) Array which get random Data from big Array every play round:

    6x3x1

    Text,Numer,Number

    Text,Numer,Number

    Text,Numer,Number

    Text,Numer,Number

    Text,Numer,Number

    Text,Numer,Number

    The user array(Namesanswer) has the same size, but get data from textboxes. In this array is the 3. height not used. The transfer into the array works fine.

    Now I want to compare the 1. and 2. height of the both arrays and if the answer is right, then the text/numbers gets green, if not, red. The Numbers works fine, but the comparison of the text fails.

    Everything I tried in construct lead to the result, that the comparison is every time wrong. This is my attempt to solve the problem. Maybe someone can say me, what I do wrong.

    Surely I could transfer first the values into variables, but is there no way to compare strings in arrays, when I know, where they are located?

  • I can not detect any errors and it is possible to compare two strings. However, it is a bad idea to filter the textbox after the UID like this. Better use an instance variable. Have you checked in the debugger, if the array values at 0, 0 are really the same?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I can not detect any errors and it is possible to compare two strings. However, it is a bad idea to filter the textbox after the UID. Better use an instance variable. Have you checked in the debugger, if the array values at 0, 0 are really the same?

    Ok, i will rebuild to instance ID later. For the moment I test some textboxes with instance ID.

    I checked it on an empty project by setting manually the values into the array(names with"") and the comparision seem to work. Maybe there is somewhere a conversion problem with reading this data with ajax. (Has somebody an idea?)

    I read the data into a big array 100x3x1 and random pick the values into the sum array.

    The Data in the arrays seems to be identical. For Test purpouse is only the first filled.

  • I tried all possibilities: both values from ajax; one value from TextBox or both values from TextBox. I never got a problem with comparing values:

  • Thank you for your Help.

    I found another Thread(https://www.construct.net/de/forum/construct-2/how-do-i-18/how-do-i-compare-text-input-wi-130709)

    Now I use "trim" with every access to the array and it seems to work. In the debugger it was not visible. Maybe throught the textfile the Linebreak was transfered in the array.

    Such a nasty thing :-)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)