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

Get help using Construct 2

Post » Wed Oct 07, 2015 4:20 pm

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)?
B
34
S
9
G
1
Posts: 628
Reputation: 3,904

Post » Wed Oct 07, 2015 4:22 pm

LittleStain wrote: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
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:31 pm

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?
B
34
S
9
G
1
Posts: 628
Reputation: 3,904

Post » Wed Oct 07, 2015 4:38 pm

Did you read this post?

LittleStain wrote: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..
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 5:07 pm

(Yes, I did read the post, I just don't get what I'm doing wrong.) Hey @LittleStain. 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.
B
34
S
9
G
1
Posts: 628
Reputation: 3,904

Post » Wed Oct 07, 2015 5:24 pm

If you just set it to 'Browser.ExecJS("Date()")' you'll then see why the statement is showing text (for me, it shows 'Wed Oct 07 2015 18:25:03 GMT+0100 (GMT Standard Time)' therefore the last 4 characters are 'ime)')

If the format of the returned date is consistant, then you could try:

mid(Browser.ExecJS("Date()"),11,4)

which for me shows just the yesr.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,422
Reputation: 59,530

Post » Wed Oct 07, 2015 5:28 pm

You are not doing anything wrong..

Have you looked at what the whole string is before using the right() expression?
What you are seeing are the last 4 letters of that string..
Everything is working like it should :)
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 5:30 pm

zenox98 wrote:If you just set it to 'Browser.ExecJS("Date()")' you'll then see why the statement is showing text (for me, it shows 'Wed Oct 07 2015 18:25:03 GMT+0100 (GMT Standard Time)' therefore the last 4 characters are 'ime)')

If the format of the returned date is consistant, then you could try:

mid(Browser.ExecJS("Date()"),11,4)

which for me shows just the yesr.


Thanks for this. It helps a lot.
B
34
S
9
G
1
Posts: 628
Reputation: 3,904

Post » Wed Oct 07, 2015 5:31 pm

LittleStain wrote:You are not doing anything wrong..

Have you looked at what the whole string is before using the right() expression?
What you are seeing are the last 4 letters of that string..
Everything is working like it should :)


Thanks for all the help man. I get it now.
B
34
S
9
G
1
Posts: 628
Reputation: 3,904

Previous

Return to How do I....?

Who is online

Users browsing this forum: ametueraspirant, dand, mickclarke and 29 guests