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

Get help using Construct 2

Post » Wed Oct 07, 2015 1:40 am

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,
8-)
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 2:02 am

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"
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 2:30 am

Sorry @LittleStain. I guess I should have asked instead, where exactly would I put the left, right, or mid in this: Browser.ExecJS("Date()")
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 6:38 am

Bump...
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 7:37 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 3:52 pm

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.
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 4:01 pm

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
Last edited by LittleStain on Wed Oct 07, 2015 4:04 pm, edited 1 time in total.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 4:02 pm

Okay, I'll try that.
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 4:13 pm

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?
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Wed Oct 07, 2015 4:17 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: Shenkai the ssj and 27 guests