MANY, MANY thanks to you!!!
I’ll test that next week.
I want to divide the day into 3 parts, if its possible?
00:00 to 07:00,
7:00 to 15:30,
15:30 to 24:00.
MANY, MANY thanks to you!!!
I’ll test that next week.
I want to divide the day into 3 parts, if its possible?
00:00 to 07:00,
7:00 to 15:30,
15:30 to 24:00.
Yes. IF (nHour > 0) AND (nHour < 7) THEN
Do something
ELSEIF (nHour > 7) AND (nHour < 15) THEN
Do something else
ELSEIF more of the same…
Do something else
ENDIF
But for the 30 minutes part you will need to read in the minutes and add that too.
YOU have helped me so, so much.
I have no robot to test now but, is this right?
VAR string time;
VAR string stHour;
VAR num nHour;
VAR num nMinute;
VAR bool bOk;
time := CTime();
stHour:=StrPart(time,1,2);
stMinute:=StrPart(time,1,2);
bOk:=StrToVal(stHour,nHour);
bOk:=StrToVal(stHour,nMinute);
IF (nHour > 0) AND (nHour < 7) THEN
Do something
ELSEIF (nHour > 7) AND (nHour >15,nMinute<30) THEN
Do something else
ELSEIF more of the same…
Do something else
ENDIF
stMinute:=StrPart(time,1,2);
Change to:
stMinute:=StrPart(time,4,2);
bOk:=StrToVal(stHour,nMinute);
Change to:
bOk:=StrToVal(stMinute,nMinute);
ELSEIF (nHour > 7) AND (nHour >15,nMinute<30) THEN
Change to:
ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
I go on vacation next week, so even you get free from me ![]()
But I will test this, week 9 and will tell you how it is going.
Hi again.
This line may not be OK.
ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
No error message, but nothing happens.
When I only white with whole hours it works.
ELSEIF (nHour > 7) AND (nHour >15) THEN
I see now that this logic is a bit funny:
ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
If nHour > 15 then of course it is greater than 7. Might just simplify to:
IF (nHour = 15) AND (nMinute < 30) THEN
Hi.
Now it works just as I had imagined.
(except weekdays).
But I am more than satisfied.
Thank you so much again !!!
You are welcome. ![]()
Hi.
Thanks for all help I got from you in "GetTime with S4".
Now it works and the robot doesn't stop (good), so I've tested many different times, etc., but can't find the solution
The times I want is:
0:24 -> 6:48
TPWrite "1";
6:48 -> 15:42
TPWrite "2";
15:42 -> 0:24
TPWrite "3";
```
Know that there are several errors, but can not find the right one.
Please, can you find a solution for me, below?
```
```
IF (nHour >= 0) AND (nMinute > 24) AND (nHour = 6) AND (nMinute < 48) THEN
TPWrite "1";
ELSEIF (nHour >= 6) AND (nMinute >= 48) AND (nHour < 16) AND (nMinute < 42) THEN
TPWrite "2";
ELSE
TPWrite "3";
ENDIF
```
Kindly.
Hello,
Is it not more simple to transform all in one variable in minute unit?
nTime:=nHour*60+nMinute;
IF (nTime > 24) AND (nTime < 408) THEN
TPWrite “1”;
ELSEIF (nTime >= 408) AND (nTime < 1002) THEN
TPWrite “2”;
ELSE
TPWrite “3”;
ENDIF
I think that is pretty smart Denis.
Hi.
I suppose I should supplement with…
VAR num nTime;
Yes.
Your If statement is looping around.
IF (nHour >= 0) AND (nMinute > 24) AND (nHour = 6) AND (nMinute < 48) THEN
TPWrite "1";
ELSEIF (nHour > 6) AND (nMinute > 48) AND (nHour < 16) AND (nMinute < 42) THEN
TPWrite "2";
ELSE
TPWrite "3";
ENDIF
Hi.
Now its working with time (all in minutes).
Less is more… ![]()
Now I (we) continues with date.
VAR string date;
VAR num nDate;
date := CDate();
TPWrite "Current date is: "+date;
That’s OK
But when I have test IF… I got problem
Maybe is below?
stDate:=StrPart(date,1,2);
bOk:=StrToVal(stDate,nDate);
Any idea?
What part of the date are you trying to examine?
Oh.
Is it possible to have both day and month in same?
Look up both CDate and Strpart functions in manual.
Hi.
“Look up both CDate and Strpart functions in manual.”
I cant find it in the manual.
I’ve also tested some, but the program pointer always stop on
ex.:
stDate:=StrPart(date,1,2);
stDate:=StrPart(date,2,2);
stDate:=StrPart(date,3,2);
stDate:=StrPart(date,4,2);
stDate:=StrPart(date,8,2);