Expressions inside an array

0 favourites
  • 4 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • Good day

    Is there a way to use expressions in array cells?

    For example:

    In the cell, the value is 5 + 5, when loading this value from the array, get 10.

    Or use the system expression - newline?

    Sorry for the bad english and thanks

    Tagged:

  • It depends on how many math operations you need to support. If it's only "A+B", then it's easy. Use tokenat() expression:

    int(tokenat(text,0,"+"))+int(tokenat(text,1,"+"))

    However, if the text can contain other operations like "A+B*C-D/E", then it will become really difficult to do with events. You can use a JS library though, for example this one:

    mathjs.org/docs/expressions/parsing.html

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It depends on how many math operations you need to support. If it's only "A+B", then it's easy. Use tokenat() expression:

    int(tokenat(text,0,"+"))+int(tokenat(text,1,"+"))

    However, if the text can contain other operations like "A+B*C-D/E", then it will become really difficult to do with events. You can use a JS library though, for example this one:

    https://mathjs.org/docs/expressions/parsing.html

    Thanks, what if I want to use the newline expression in a large text?

  • I want to say thanks to dop2000

    Helped solve the problem using the replace expression

    If anyone will be interested write an example:

    In the array we write:

    text1 <br> text2

    After receiving the text from the array, use replace for the <br> tag:

    replace (localizationfamily.Text, "<br>", newline)

    We get:

    text1

    text2

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