Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a timer value

Status
Not open for further replies.

PuzzleLogic

Technical User
Mar 22, 2004
8
GB
I am looking for a way to create an event timer (from sending data on the line to receiving a response for instance) by using some sort of system timer.

All I can find is $ltime which only has one second granularity - I need to get to millisecond granularity.

Anyone help?
 
Does this have to happen at a specific time? If you want to pause something I know that mspause will pause something in millisecond time frames.

proc main
integer Count = 0 ; Integer used for counting.

while (Count++) < 3 ; Loop 3 times.
transmit "^M" ; Transmit a carriage return.
mspause 250 ; Pause script for 250 ms.
endwhile
endproc
 
There is not a direct way in ASPECT to get times more precise than a second.

What I tried to do was redirect the output of the DOS time command to a text file that a script could then read (and perform a second time to get the final time, then computer the elapsed time with those two values). However, the script needs to send a return to the DOS window to terminate the time command when it is asking for a new time and I have not been able to come up with a way to do that as of yet.


aspect@aspectscripting.com
 
Thanks Volkmanian and knob,

I am writing a script to simulate an application and need to send data out with the original timings and then measure the time taken to get a response - this will be used over a number of different systems to benchmark the transport system.



Maybe I need to find some sample com port code for VB and write this in VB?
 
VB would probably be a good option.

Another would be to find an executable (I imagine there might be a couple likely candidates on a freeware site) that, when run, would output the time to a text file or environment variable that ASPECT could then access.


aspect@aspectscripting.com
 
Ok. Tried all this and got it to work by writingthe timer to a file and then reading this in procomm once the called task has exited.

This works well but is really slow (time taked for the dos app to createthe file, wrtite the time, close the file, close the app, aspect to open the file, read the time and close the file again..)

Wanted to try and use environment variables to do the same thing but don't seem to be able to set a variable and then read it with getenv in aspect...

Another way I though of was to read the memory location of the system time value with an aspect peek but I can't find where windows stores the timer...

Anyone got any other ideas?
 
What operating system are you running? If I'm remembering correctly, it seemed like I had some problems on Win95 or Win98 with environment variables, but don't recall much more detail than that.


aspect@aspectscripting.com
 
Running Win 2000 at the moment.

Problem with environment variables is that they seem to be dedicated to the particular instance of the environment.

When I set a variable using a compiled quickbasic exe it does not change in any other shell other than the one it was set in - ie. Procomm only sees the default setting from when it was initiated. This is my first foray into env vars so I am not sure what I'm doing here.

Another way I thought of was to constantly poke the basic timer value into a memory area that I have allocated from procomm using memalloc (I can pass the memaddress to the exe as a argument) but I cant seem to get the address given by procomm to match any addressing scheme in quck basic - any ideas on that one?
 
I don't have a Win2K machine handy at the moment to test this theory, but what if you create just a dummy environment variable in Control Panel (under System, Advanced, Environment Variables I think) for the value you want to pass? If that environment variable is present before the QB app is run, maybe the change will be propagated globally.

All of Procomm's memory operations just target a memory block that is allocated by Windows. There is no way to correlate a Procomm memory block and an actual physical memory address that I am aware of, so this approach won't work.


aspect@aspectscripting.com
 
I have tried creating a new variable but the change still doesnt propogate between the apps.

The 'write it to a file' idea works but the time it takes is too long. I have to start the app with a run statement and thengo into a while loop waiting for taskexit to tell me that it finished before I can open the file and read the value. Often, this takes longer than the delay I am trying to measure.

I have tried to open the file in the QB app, leave it open and constantly write to the beginning of the file, then open the file in Procomm, leave it open and rewind it and re-read from the beginning of the file when I need to get a value - this should cut out the file open and close times and the time it takes to wait for the app to finish. The problem here is that Procomm seems to cache the file and, unless you close it and open it again it doesnt get the new data.

Maybe I will try constantly wriring the file and then opening and closeing it for reading in procomm - at least this will cut out the app running time??
 
One other thing you might try (if QB supports it) is using DDE to transfer the value between the QB app and Procomm. This would eliminate the need for an environment variable or text file completely.


aspect@aspectscripting.com
 
Thanks - I will give that a go later...

For now though I needed to get it working quickly so I re-wrote it all in QB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top