RobotStudio event

GetTime with S4

2»

Comments

  • DenisFR
    DenisFR ✭✭✭
    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


  • lemster68
    lemster68 ✭✭✭
    I think that is pretty smart Denis.
    Lee Justice
  • Hi.

    I suppose I should supplement with...

    VAR num nTime;
  • DenisFR
    DenisFR ✭✭✭
    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?
  • lemster68
    lemster68 ✭✭✭
    What part of the date are you trying to examine?
    Lee Justice
  • Oh.

    Is it possible to have both day and month in same?
  • lemster68
    lemster68 ✭✭✭
    Look up both CDate and Strpart functions in manual.
    Lee Justice
  • 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);

  • 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);

    FUNC string sToday()
            VAR string sTextYear;
            VAR string sTextMonth;
            VAR string sTextDay;
            VAR string sTextHour;
            VAR string sTextMinute;
            VAR string sTextSecond;
            VAR num nTextHour;
            VAR num nTextMinute;
            VAR num nTextSecond;
            sReadDateToday:=CDate();
            sReadTimeToday:=CTime();
            sTextYear:=StrPart(sReadDateToday,1,4);
            sTextMonth:=StrPart(sReadDateToday,6,2);
            sTextDay:=StrPart(sReadDateToday,9,2);
            nTextHour:=GetTime(\Hour);
            nTextMinute:=GetTime(\Min);
            nTextSecond:=GetTime(\Sec);
            sTextHour:=NumToStr(nTextHour,0);
            sTextMinute:=NumToStr(nTextMinute,0);
            sTextSecond:=NumToStr(nTextSecond,0);
            RETURN "Today is "+sTextYear;
            !RETURN "Today is "+sTextYear+"/"+sTextMonth+"/"+sTextDay+sGap+"Time "+sTextHour+":"+sTextMinute+":"+sTextSecond;
        ENDFUNC
    Have a look at this maybe this will give you some better understanding.  :)