1. questions from a newbie
First of all Happy New Year one and all.
I downloaded euphoria about a week ago and am greatly impressed
however I have a few questions:
1:
does any one know a routine for a wait command that could be invoked
in say milliseconds like:
wait(500) or delay(500) ???
presently I am using:
integer i
i = 1
while i < 5000000
do
i = i + 1
end while
of course this routine is dependant upon the processor speed, and not
entirely accurate. On mine it gives roughly a 1 second delay.
any bright ideas????
2:
in text mode any ideas how to print a character to row 25 column 80
without scrolling the screen????
3:
I'm writing a menu program and have run into a setback:
a: using "system" to run programs out of the menu I tried to use:
system("c:\\mydir\\subdir\\my.exe",0)
however this consistently fails to work
I must use:
system("c:",0) system(" cd \\mydir\\subdir",0) system("my.exe",0)
this causes an extensive amount of flashing.
anyone know a better idea????
b:
some programs when run out of the menu defy all my attempts to have
it return to the menu upon exitting the program ( i.e. Word Perfect 6
for dos)
this not only happens on my own menu program but also one that I
downloaded from archives.
anyone know a way to fix this???
thanks for your help.
Thys de Jong
2. Re: questions from a newbie
Hi!,
-----Original Message-----
From: Thys de Jong <thys at SCSINTERNET.COM>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Friday, January 01, 1999 1:32 PM
Subject: questions from a newbie
>First of all Happy New Year one and all.
And you too..
>does any one know a routine for a wait command that could be invoked
>in say milliseconds like:
>wait(500) or delay(500) ???
Try:
procedure Delay(atom t)
t = time() + t
while time() < t do
end while
end procedure
This is roughly accurate to approx .05 seconds
To delay half a second for example:
Delay(.5)
Hope this helps..
Greg Harris
3. Re: questions from a newbie
- Posted by JJProg at CYBERBURY.NET
Jan 01, 1999
EU>1:
EU>does any one know a routine for a wait command that could be invoked
EU>in say milliseconds like:
EU>wait(500) or delay(500) ???
procedure wait(atom tm)
atom start
start = time()
tm = tm * 1000
while time() - start < tm do
end while
end procedure
EU>2:
EU>in text mode any ideas how to print a character to row 25 column 80
EU>without scrolling the screen????
include image.e
procedure DisplayAt(integer row, integer col, integer fore, integer back,
object c)
sequence s
integer n
if integer(c) then
s = {{c,fore + (back * 16)}}
else
s = {repeat(fore+(back*16),length(c)*2)}
for i = 1 to length(c) do
s[1][(i*2)-1] = c[i]
end for
end if
display_text_image({row,col},s)
end procedure
Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/
4. Re: questions from a newbie
here is a simpler way to print a character on the screen
procedure DisplayXY(integer row, integer col, integer fore, integer back,
integer character)
poke(#B8000 + ((row - 1) * 2) + ((col - 1) * 160), {character, fore +(16 *
back)})
end procedure
5. Re: questions from a newbie
Thys de Jong writes:
> does any one know a routine for a wait command that could be
> invoked in say milliseconds like:
You can improve the resolution of time() by setting
tick_rate(), but this only works up to about 1000 ticks/second.
Another solution can be found in Language War - sched.e.
Basically, you see how many for-loop iterations you can do in
(say) 1 second. Then, when you want to wait for a few milliseconds,
you loop for some fraction of that. Here's the code I used.
constant sample_interval = 1.0
atom sample_count
global procedure init_delay()
-- since time() does not have fine enough
-- resolution for small delays, we see how many for-loop iterations
-- we can complete over a small sample period
atom t
t = time() + sample_interval
for i = 1 to 999999999 do
if time() < t then
else
sample_count = i
exit
end if
end for
end procedure
global procedure delay(atom t)
-- delay for t seconds
atom stop
if t > sample_interval then
-- time() should be precise enough
stop = time() + t
while time() < stop do
end while
else
-- loop a certain number of times
stop = time() + sample_interval
for i = 1 to floor(t / sample_interval * sample_count) do
if time() < stop then
else
end if
end for
end if
end procedure
> in text mode any ideas how to print a character to
> row 25 column 80 without scrolling the screen????
Try wrap(0):
include graphics.e
clear_screen()
wrap(0) -- turn off line-wrap
position(25, 80)
puts(1, 'x')
if getc(0) then
end if
Regards,
Rob Craig
Rapid Deployment Software
http://members.aol.com/FilesEu/
6. Re: questions from a newbie
>does anyone know a routine for a wait command that could be
>invoked in say milliseconds like:
>wait(500) or delay(500) ???
If you use the Windows95/98 API you can use the C function:
DWORD GetTickCount(VOID)
which returns the number of milliseconds since Windows started.
Then set up a differencing routine to determine the milliseconds
that have past since a given point in the program.
After loading Win's kernal32.dll and
linking GetTickCount (or GetTickCountA) as a function:
--declare and initialize variables:
atom t001,t002,milliseconds,MilliTime
t001=0
--function setup:
function GetTicks()
t002=c_func(GetTickCount,{})
milliseconds=t002-t001
t001=t002
return milliseconds
end function
MilliTime=GetTicks()
--now every call to 'GetTicks()' returns the time in milliseconds
--since the last call to 'GetTicks()'.
--example:
MilliTime=GetTicks()
CallTestRoutine()
MilliTime=GetTicks()
--now MilliTime is the number of milliseconds between calls.
--end example.
One thing should be pointed out here though:
With any of the timing methods there could be a wide variance
in the time it takes to execute the entire "TestRoutine" as
Windows has a lot to keep up with sometimes and not other
times depending on all the activities going on at the time
the test routine is executed. Remember it's a multitasking
environment. Expect as much as 100% change or more depending
on tasks. Of course this implies there is no way any critical
timing loops can be constructed with any timing method except
in assembly language. You might also try using the timer
functions present in the API which are all called quite easily
from Euphoria but again the accuracy can't be mistaken for
perfect.
One last note is that some of the timing routines in
Windows are rumored to start over around the year 2037.
Instead of returning the number of seconds since a given
year in the past it will start returning the number of
seconds since 2037. This is because of the max integer count
capability using 4 bytes.
Hey good luck with all your programs!!
I'll be looking forward to seeing some great software from
you in the future.
Xaxo at AOL.COM
7. Re: questions from a newbie
>One thing should be pointed out here though:
>With any of the timing methods there could be a wide variance
>in the time it takes to execute the entire "TestRoutine" as
>Windows has a lot to keep up with sometimes and not other
>times depending on all the activities going on at the time
>the test routine is executed. Remember it's a multitasking
>environment. Expect as much as 100% change or more depending
>on tasks. Of course this implies there is no way any critical
>timing loops can be constructed with any timing method except
>in assembly language. You might also try using the timer
>functions present in the API which are all called quite easily
>from Euphoria but again the accuracy can't be mistaken for
>perfect.
You can tell windows your program is critical, by turning its priority to
Thread Control -- Good.... or to RealTime-Control -- Better.
You could use interrupts, but you need machine code for that indeed.
However, then you can really bog the system.. if even real-time priority is
not enough, an interrupt will give you almost all of the system's speed,
however, windows will not be able to operate anymore..
Ralf
8. Re: questions from a newbie
Halo Euphoria Programming for MS-DOS, a reply for you!
> If you use the Windows95/98 API you can use the C function:
> DWORD GetTickCount(VOID)
Why don't use Sleep(ms) anyway?
Don't forget to reply, Euphoria,
Pak Hendy * http://ceefour.indoglobal.com
Real Programmers' programs never work right the first time. But if you throw
them on the machine they can be patched into working in "only a few" 30-hour
debugging sessions.
It is rumored that the World Wide Web will be a great embarrassment to the
Information Super Highway.
Gotta try this: Ceefour Software: Useful software you just can't miss!
http://ceefour.indoglobal.com