#61376 - 2001-12-16 03:36 AM
There is no spoon
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
; KIXTART 4.01 break on cls color w/n srnd(@msecs) $t=5
$greenies = 15 $greenie = marray("$greenies,2") for $i=0 to $greenies $greenie[$i][0] = rnd(24) $greenie[$i][1] = rnd(78) next
$blankies = 15 $blankie = marray("$blankies,2") for $i=0 to ubound($blankie) $blankie[$i][0] = rnd(24) $blankie[$i][1] = rnd(78) next
$=setoption("hidecursor","on")
while not kbhit() for $i = 0 to $greenies color g/n $c=rnd(100)+100 if $c=7 or $c=149 $c=150 endif if $greenie[$i][0] at($greenie[$i][0],$greenie[$i][1]) chr($c) endif if $greenie[$i][0] < 23 $greenie[$i][0] = $greenie[$i][0] + 1 color g+/n at($greenie[$i][0],$greenie[$i][1]) chr($c) else $greenie[$i][0] = rnd(5) $greenie[$i][1] = rnd(78) endif delay($t) next for $i = 0 to $blankies color w/n at($blankie[$i][0],$blankie[$i][1]) " " $blankie[$i][0]=$blankie[$i][0]+1 if $blankie[$i][0] = 24 $blankie[$i][0]=0 $blankie[$i][1]=rnd(78) endif delay($t) next color w/n delay($t) loop get$
cls exit 1 function delay($n) $ticks = @ticks +$n while @ticks < $ticks loop endfunction
function marray($ind, optional $ptr) if ubound($ind) else $ind = split($ind,",") endif redim $marray[$ind[$ptr]] if $ptr < ubound($ind) $marray[0] = marray($ind,$ptr+1) dim $L for $l = 1 to ubound($marray) $marray[$L]=$marray[0] next endif endfunction
; KIXTART 4.01 break on cls
color w/n
srnd(@msecs)
$t=15
while not kbhit() $row = rnd(23) $col = rnd(78) if rnd(4) = 2 for $i = 0 to 24 at($i,$col) " " delay($t) next else for $i = 0 to $row $c = rnd(100)+100 if $c<>7 and $c<>149 color g+/n at($i,$col) chr($c) if $i color g/n at($i-1,$col) chr($c) endif color w/n delay($t) endif next endif delay($t) loop get$
cls exit 1 function delay($n) $ticks = @ticks +$n while @ticks < $ticks loop endfunction
[ 17 December 2001: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#61377 - 2001-12-16 04:03 AM
Re: There is no spoon
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
|
|
Top
|
|
|
|
#61378 - 2001-12-16 05:38 PM
Re: There is no spoon
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Shawn,sometimes I wonder how it comes that there are similar thoughts at the same time ... the following was planned to be posted as an addition to my request for a msec delay/sleep/wait command on monday I referred to your sample 'spinner' in kixlib32.dll sample code to 'force' Ruud to implement that thing intrinsic, as a udf delay() will grab all processor time it can get !!! code:
;FUNCTION delay() ; ;AUTHOR Jochen Polster (jochen.polster@gmx.net) ; ;ACTION halts script execution for specified amount of milliseconds ; ;SYNTAX Delay(milliseconds) ; ;PARAMETERS milliseconds (Required) ; - integer amount of milliseconds ; ;REMARKS if passed parameter is divisible by 1000, ; better use sleep instead ... ; Found no way yet to prevent the function being leaky ; regarding CPU time ! ; ;RETURNS Nothing ; ;DEPENDENCIES None ; ;EXAMPLES call "path\Delay.udf" break on $ = setoption("HideCursor","on") at(5,10) "Spinner" at(7,10) "'S' - slow" at(8,10) "'M' - medium" at(9,10) "'F' - fast" at(10,10)"'Q' - quit" $wait = 100 while $k <> "q" $c = $c + 1 select case $c = 1 at(5,19)'\' case $c = 2 at(5,19)'|' case $c = 3 at(5,19)'/' case 1 at(5,19)'-' $c = 0 endselect if kbhit() get $k select case $k = 's' $wait = 180 case $k = 'm' $wait = 100 case $k = 'f' $wait = 50 endselect endif delay($wait) loop ; ;SOURCEfunction delay($ms) if vartype($ms) = 3 dim $t $t = @ticks + $ms do ;whatever to prevent grabbing 99% of proc time !!! until $t <= @ticks endif endfunction
If anybody, I bet you are the one able to tell if there is any way around this problematic (at least you have the delay implemented non-leaky in your dll's ..) I deny posting this on the library side unless there's a solution for it ... I mean that is not what one would expect if one tries to send his script to sleep  J.
_________________________
|
|
Top
|
|
|
|
#61380 - 2001-12-16 06:08 PM
Re: There is no spoon
|
Anonymous
Anonymous
Unregistered
|
Where can I find more info about the "setoption" function? I can find nothing about it in the manuel... And what about kbhit??? Do I look wrong in the manuel or are there hidden functions?  [ 16 December 2001: Message edited by: awinkel ]
|
|
Top
|
|
|
|
#61381 - 2001-12-16 06:37 PM
Re: There is no spoon
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
JStart MSN ? I would post your delay() function if I were you ... there's no way I can think of to yield the CPU other than shelling out to sleep.exe or something like that ... an msec delay() function in the next release would be very cool ... or an msec sleep() - but I guess its probably too late for that (for compatibilty reasons) ... unless Ruud adds a new setoption("sleep","msec") or the like. I'll take three stars on that.  p.s. If you do post delay() - watch-out for that negative @ticks thingy (after 25 days of uptime) ... make sure the udf works with a negative msec's --Shawn [ 16 December 2001: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#61383 - 2001-12-16 07:53 PM
Re: There is no spoon
|
Anonymous
Anonymous
Unregistered
|
I will be very happy if you can let me know where I can find it in the .chm file. I have download the latest version from the download section of this site but can't find anything about it.
|
|
Top
|
|
|
|
#61385 - 2001-12-16 10:35 PM
Re: There is no spoon
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
|
|
Top
|
|
|
|
#61386 - 2001-12-16 10:40 PM
Re: There is no spoon
|
Anonymous
Anonymous
Unregistered
|
Thankyou LLigetfa, I thought I became crazy but I have found it yet. Ofcourse I have to use it in my next script.  [ 16 December 2001: Message edited by: awinkel ]
|
|
Top
|
|
|
|
#61388 - 2001-12-17 12:45 AM
Re: There is no spoon
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
A small variation of the above ... "Unfortunately no one can be told what the matrix is, you have to see it for yourself." -Morpheus
; KIXTART 4.01 break on cls color w/n srnd(@msecs) $t=5
$greenies = 15 $greenie = marray("$greenies,2") for $i=0 to $greenies $greenie[$i][0] = rnd(24) $greenie[$i][1] = rnd(78) next
$blankies = 15 $blankie = marray("$blankies,2") for $i=0 to ubound($blankie) $blankie[$i][0] = rnd(24) $blankie[$i][1] = rnd(78) next
$=setoption("hidecursor","on")
while not kbhit() for $i = 0 to $greenies color g/n $c=rnd(100)+100 if $c=7 or $c=149 $c=150 endif if $greenie[$i][0] at($greenie[$i][0],$greenie[$i][1]) chr($c) endif if $greenie[$i][0] < 23 $greenie[$i][0] = $greenie[$i][0] + 1 color g+/n at($greenie[$i][0],$greenie[$i][1]) chr($c) else $greenie[$i][0] = rnd(5) $greenie[$i][1] = rnd(78) endif delay($t) next for $i = 0 to $blankies color w/n at($blankie[$i][0],$blankie[$i][1]) " " $blankie[$i][0]=$blankie[$i][0]+1 if $blankie[$i][0] = 24 $blankie[$i][0]=0 $blankie[$i][1]=rnd(78) endif delay($t) next color w/n delay($t) loop get$
cls exit 1 function delay($n) $ticks = @ticks +$n while @ticks < $ticks loop endfunction
function marray($ind, optional $ptr) if ubound($ind) else $ind = split($ind,",") endif redim $marray[$ind[$ptr]] if $ptr < ubound($ind) $marray[0] = marray($ind,$ptr+1) dim $L for $l = 1 to ubound($marray) $marray[$L]=$marray[0] next endif endfunction
|
|
Top
|
|
|
|
#61392 - 2001-12-17 01:29 PM
Re: There is no spoon
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Microsoft Agents are one thing... but their lawyers are a lot toughter
|
|
Top
|
|
|
|
#61395 - 2002-08-06 02:13 PM
Re: There is no spoon
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Shawn...
Your code gives me an error with KiX v4.10a
code:
Script error: expected ']'! redim $marray[$ind[$ptr]]
I'll try to check it myself if I get a chance... but since you wrote it, maybe you can see right off the bat what may be different since v4.01 of KiX.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1003 anonymous users online.
|
|
|