The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How insert a time out in a loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gilles wat

France
20 Posts

Posted - 09/24/2003 :  12:25:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Does anybody know how insert a time out in a loop.
thank you
gilles

Mike Buess

USA
3037 Posts

Posted - 09/24/2003 :  2:16:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi gilles,

I'm not sure what kind of time out you need, but this LabTalk command

sec -p n;

pauses script execution for n seconds. In Origin C you can use

Sleep(N);

where N is in milliseconds.

Mike Buess
Origin WebRing Member
Go to Top of Page

gilles wat

France
20 Posts

Posted - 09/25/2003 :  08:30:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike
I wait a change on a status line during a data acquisition. If no change occures the loop does not finish. In C++ the function TIME() allows solving this problem with a test on time. This function is not in Origin C.
Thank you
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/25/2003 :  08:59:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi gilles,

Can't you use Sleep in a do or while loop and require a status change to exit the loop? Something like this...

do
{
Sleep(100);
} while (//-no status change-);

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/25/2003 09:01:44 AM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 09/25/2003 :  8:01:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can test time by using GetTickCount, and use either

Sleep(N);// Origin will wait, nothing can be done in Origin

or

LT_execute("set -p 0.5"); // you can still do other things in Origin while waiting


CP


Go to Top of Page

gilles wat

France
20 Posts

Posted - 09/29/2003 :  11:20:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for all.
I am added the function time to Origin C with the header:

#include <common.h>
#pragma dll(c:\WINNT\SYSTEM32\Msvcrt)
typedef long time_t;
typedef long* ptime;

int __cdecl _inp(unsigned short port);
int __cdecl _outp(unsigned short port, int value);
time_t __cdecl time(ptime temps);
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 10/20/2003 :  05:38:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It is better to write

#pragma dll(msvcrt, system)

to avoid hard coded path to your msvcrt dll.

CP


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000