How do I separate the year from the day, month and time?

0 favourites
From the Asset Store
Action packed 2 track pack for use in your projects
  • Hey everybody. I read this tutorial, and now I'm wondering... How do I separate the year from the day, month and time?

    https://www.scirra.com/tutorials/940/ho ... -a-project

    Thanks,

    <img src="{SMILIES_PATH}/icon_cool.gif" alt="8-)" title="Cool">

  • like the author of the tutorial says using system expressions left, right, and mid

    https://www.scirra.com/manual/126/system-expressions

    example

    mid("thu apr 03",4,3) would give the text "apr"

  • Sorry I guess I should have asked instead, where exactly would I put the left, right, or mid in this: Browser.ExecJS("Date()")

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bump...

  • In this case I would set a text-variable to: Browser.ExecJS("Date()")

    Then use mid(text-variable,4,3) to get the desired part..

  • Hey LittleStain, I still don't get where you actually insert "mid(text-variable,4,3)" into Browser.ExecJS("Date()"). Sorry, I know it seems simple, but I still don't get it (I'm a visual learner). Can you please show me with a tiny capx example? It would be greatly appreciated.

  • If you don't want to use a variable..

    text set text = mid(Browser.ExecJS("Date()"),4,3)

    Browser.ExecJS("Date()") is a string..

    You manipulate the string with the expression..

    mid(text,index,count)

    Mid() - is the expression

    text - is the text you want to manipulate

    index - is the number of the letter you want to start with

    count - is the amount of letters you want to show

  • Okay, I'll try that.

  • Hey LittleStain, mid(Browser.ExecJS("Date()"),4,3) works... It shows that it's Oct. But, when I changed mid to right or left, it comes up with an error saying "Wrong number of parameters ('right' does not take 3 parameters, should have 2) ". How do I get around that?

  • From the manual, there is a link to it at the top of this page:

    left(text, count)

    Return the first count characters of text.

    mid(text, index, count)

    Return the count characters starting from index in text.

    right(text, count)

    Return the last count characters of text.

  • Hey LittleStain, again. I guess what I mean to ask is... What exactly does the 4,3 values represent in mid(Browser.ExecJS("Date()"),4,3)?

  • mid(text,index,count)

    Mid() - is the expression

    text - is the text you want to manipulate

    index - is the number of the letter you want to start with

    count - is the amount of letters you want to show

  • Hey LittleStain, lol okay, so, I'v coded in, right(Browser.ExecJS("Date()"),4,4). But, it says I need only 2 parameters, not 3. Which parameter should I remove for it to work correctly?

  • Did you read this post?

    From the manual, there is a link to it at the top of this page:

    left(text, count)

    Return the first count characters of text.

    mid(text, index, count)

    Return the count characters starting from index in text.

    right(text, count)

    Return the last count characters of text.

    as you can see in the expression right(), the index is missing, which is logical, because it is counting from the last letter of the text..

  • (Yes, I did read the post, I just don't get what I'm doing wrong.) Hey Okay, so I took out the index number (like so... right(Browser.ExecJS("Date()"),4)), but it still isn't working. It shows letters, instead of numbers. Can you pleeeaase show me how do it with a small capx example? I'm starting to feel like an idiot over here lol.

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