SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Oct 2011
    Location
    FL
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Adding Code for Date/Time Events

    I was going through the Help manual to better understand the objects related to Date/Time events (TTimeEvent, TEventGroup), and I want to set up my code such that at user-defined time intervals (e.g., every 5 minutes, every 30 seconds, every 2 hours, etc.), the script calls a subroutine.

    However, when defining an Date/Time event in TestPartner, I'm supposed to explicitly specify the exact time interval (number value and units...hours, minutes, or seconds). Is there a way to modify that within the script such that if the user selects "5 minutes" for the interval, and the Date/Time event was originally set for 30-second intervals, can it be done?

    Please advise as I am trying to implement this feature in my script. Thank you.
    V/R,
    John J. Bottiger

  2. #2
    Member
    Join Date
    Oct 2011
    Location
    FL
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Adding Code for Date/Time Events

    I was trying to use the FormatDate function in one of my test scripts, but when I tried to run the script, I received a compile error as shown in the attached image file.

    Please advise as to how I use this function properly within my test script. The goal is to capture the current date and current time, assign them each to a specific date/time variable, AND manipulate the format within these two variables such that the date variable takes the format yyyymmdd and the time variable takes the format HHmmss.
    Attached Images Attached Images
    V/R,
    John J. Bottiger

  3. #3
    Member
    Join Date
    Oct 2011
    Location
    FL
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Adding Code for Date/Time Events

    I believe that according to my research, the FormatDate and FormatTime functions are related to visual tests only. To format dates/times, my colleague informed me to use the Format function and set the format patterns accordingly.

    Thanks everyone for reading and (attempting) to assist.
    V/R,
    John J. Bottiger

  4. #4
    Member
    Join Date
    Oct 2011
    Location
    FL
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Adding Code for Date/Time Events

    Oh, another question: please look at the code and tell me how to increment the counting variable "Sec" every 15 seconds. The code is as follows:

    Dim LogMonitor as TEventGroup, ChkPoint as TTimeEvent
    Dim TimeUnit as String, TimeVal as String
    Dim Sec as Integer
    Set LogMonitor = CreateTEventGroup("Event Monitor")
    Set ChkPoint = TimeEvent("ScanChk")

    TimeUnit = S '(H)ours, (M)inutes or (S)econds
    TimeVal = 15


    Select Case TimeUnit
    Case "H"
    ChkPoint.SetInterval Hours:=CLng(TimeVal), Minutes:=0, Seconds:=0
    Case "M"
    ChkPoint.SetInterval Hours:=0, Minutes:=CLng(TimeVal), Seconds:=0
    Case "S"
    ChkPoint.SetInterval Hours:=0, Minutes:=0, Seconds:=CLng(TimeVal)
    End Select

    LogMonitor.AddCondition ChkPoint

    'Monitor the event continuously
    LogMonitor.ActivateAsWhenever

    TestLog.Comment "Current date and time are " & StartCycleDate & ", " & StartCycleTime

    Sec = 0
    SuspendScript

    End Sub

    Private Sub Script_Whenever(ByVal TheEvent As TPEvents.TEventGroup)

    StartCycleDate = Format(Date, "yyyymmdd")
    StartCycleTime = Format(Time, "HHmmss")
    Sec = Sec + 1
    TestLog.Comment "Current date and time are " & StartCycleDate & ", " & StartCycleTime
    TestLog.Comment "Sec value is " & Sec
    If Sec = 5 Then
    ResumeScript
    End If

    End Sub

    Why is the script not incrementing my counter variable? I looked in the TestPartner documentation (under the ActivateAsWhenever method description), and I structured the code almost exactly as they had it. They claim that it works, but it didn't in my case.

    Please advise. Thanks.
    V/R,
    John J. Bottiger

  5. #5
    Member
    Join Date
    Feb 2007
    Posts
    325
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Adding Code for Date/Time Events

    There is a lot going on there so I'm not sure what questions you still have

    From what I see it looks like you actually have two different sub funcation.

    Unless you have SEC decleared as a global variables, it treats them as two seperate variables.

    I usually use Now which returns a variable of Date time(of that time)

    I then usually use DateDiff Which I think can return difference down to even seconds--- not sure thats as useful for seconds---

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.11%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:08 AM.

Copyright BetaSoft Inc.