"menu to" under windows NT 
Author Message
 "menu to" under windows NT

Hallo guys,

I've never been on this forum before as I switched to VO some 5 years ago.
But some of my Clipper-work lives on and the users have drawn my attention
to the problem of Clipper programs eating away all CPU time in wait states.

Thanks to the work of some people on this forum I have already covered all
inkey() situations but I have failed to do the same for "menu to".  This
command also pushes the CPU utilisation to 100 %.

Is there anyone here who has solved this problem ?

TIA

Jean-Pierre Maertens
Brugge
Belgium



Sun, 27 Jun 2004 21:32:06 GMT  
 "menu to" under windows NT

Quote:
> Thanks to the work of some people on this forum I have already covered all
> inkey() situations but I have failed to do the same for "menu to". This
> command also pushes the CPU utilisation to 100 %.

Perhaps <URL:http://www.davep.org/clipper/OSLib/OL_AutoYield.html> might
offer an idea or two?

Also, I think PhilB's MULTI offers a MENU TO replacement that plays better.
The VFAQ <URL:http://www.davep.org/clipper/VFAQ/> (posted weekly to this
news group), as well as offering the above pointer, also has a pointer to
MULTI.

--
Dave Pearson                        |  OSLib - Timeslice release functions.
http://www.davep.org/               |     eg - Norton Guide reader for Linux.
http://www.davep.org/clipper/       |    weg - Norton Guide reader for Windows.
http://www.davep.org/norton-guides/ | dgscan - DGROUP scanner for Clipper.



Sun, 27 Jun 2004 22:25:19 GMT  
 "menu to" under windows NT
Dave,

Thank you very much, Phil Barnett's work has saved me a lot of time !

Thank you Phil Barnett

JP Maertens
Brugge
Belgium



Quote:

> > Thanks to the work of some people on this forum I have already covered
all
> > inkey() situations but I have failed to do the same for "menu to". This
> > command also pushes the CPU utilisation to 100 %.

> Perhaps <URL:http://www.davep.org/clipper/OSLib/OL_AutoYield.html> might
> offer an idea or two?

> Also, I think PhilB's MULTI offers a MENU TO replacement that plays
better.
> The VFAQ <URL:http://www.davep.org/clipper/VFAQ/> (posted weekly to this
> news group), as well as offering the above pointer, also has a pointer to
> MULTI.

> --
> Dave Pearson                        |  OSLib - Timeslice release
functions.
> http://www.davep.org/               |     eg - Norton Guide reader for
Linux.
> http://www.davep.org/clipper/       |    weg - Norton Guide reader for
Windows.
> http://www.davep.org/norton-guides/ | dgscan - DGROUP scanner for Clipper.



Mon, 28 Jun 2004 00:53:27 GMT  
 "menu to" under windows NT

says...

Quote:
> Hallo guys,

> I've never been on this forum before as I switched to VO some 5 years ago.
> But some of my Clipper-work lives on and the users have drawn my attention
> to the problem of Clipper programs eating away all CPU time in wait states.

> Thanks to the work of some people on this forum I have already covered all
> inkey() situations but I have failed to do the same for "menu to".  This
> command also pushes the CPU utilisation to 100 %.

Decompiling reveals that the AT PROMPT... MENU TO subsystem is actually
coded in Clipper. Here's the source for the module __ATPROM.OBJ which can
be found in clipper.lib. This kind of thing can be expanded to also be
used with getsys and tbrowse. Achoice will remain a problem unless you
rewrite it using a tbrowse. (Memoedit is also problematic.)

As you can see, the problem is that __menuto calls inkey(0). By
substituting your own inkey function like the sample below, you can break
this up into repeated calls to inkey(); you could set his hook by
overriding std.ch to call your own function (__myMenuTo)

Neil

//---MENU TO preprocessor entry, altered to point to __myMenuTo
#command MENU TO <v>                                                    ;
   => <v> := __myMenuTo( {|_1| if(PCount() == 0, <v>, <v> := _1)}, #<v> )

//---very crude sample myInkey0 function to substitute for inkey(0)
function myInkey0
   local nKey
   do while ( ( nKey := inkey() ) == 0 )

   enddo
return nKey

//---recovered code from clipper.lib module __atprom
#include "common.ch"
#include "inkey.ch"

static Static1:= {}

//-----------------------------------
function READVAR( Arg1 )

   local Local1:= Static1
   if ( ISCHARACTER( Arg1 ) )
      Static1:= Arg1
   endif
   return Local1

//-----------------------------------
function __ATPROMPT( Arg1, Arg2, Arg3, Arg4 )

   AAdd(Static1, {Arg1, Arg2, Arg3, Arg4})
   SetPos(Arg1, Arg2)
   dispout(Arg3)
   return .F.

//-----------------------------------
//function __MENUTO( Arg1, Arg2 )
function __myMENUTO( Arg1, Arg2 )

   local Local1, Local2, Local3, Local4, Local5, Local6, Local7, Local8
   local Local9, Local10, Local11, Local12, Local13 := Static1
   local Local14 := Set(36), Local15:= Set(37)
   local Local16 := readvar(Upper(Arg2))
   Static1 := {}
   Local11 := errorblock({ |_1| break( _1 ) })
   begin sequence
      Local2:= eval(Arg1)
      Local12:= .F.
   recover
      Local12:= .T.
   end sequence
   errorblock(Local11)
   if ( Local12 )
      __qqpub(Arg2)
   endif
   if ( ValType(Local2) != "N" .OR. Local2 < 1 )
      Local2:= 1
   endif
   if ( Local2 > Len(Local13) )
      Local2:= Len(Local13)
   endif
   if ( Set(31) )
      Local8:= setcursor(0)
   endif
   Local7:= .F.
   Local6:= ""
   Local9:= 0
   while ( Local2 != 0 )
      Local5:= 0
      Local1:= Local13[ Local2 ]
      if ( Set(31) )
         colorselec(1)
      endif
      SetPos(Local1[ 1 ], Local1[ 2 ])
      dispout(Local1[ 3 ])
      if ( Set(31) )
         colorselec(0)
      endif
      if ( Local14 != 0 )
         if ( !Empty(Local6) )
            SetPos(Local14, Local9)
            dispout(Space(Len(Local6)))
         endif
         Local6:= Local1[ 4 ]
         if ( ISBLOCK( Local6 ) )
            Local6:= eval(Local6)
         elseif ( ValType(Local6) == "U" )
            Local6:= ""
         endif
         if ( Local15 )
            Local9:= Int(( MaxCol() - Len(Local6) ) / 2)
         endif
         SetPos(Local14, Local9)
         dispout(Local6)
         SetPos(Local1[ 1 ], Local1[ 2 ])
      endif
      if ( Local7 )
         exit
      endif
      while ( Local5 == 0 )

          //********************************************************
         //  change InKey(0) to call your inkey replacement instead
         //  Local5:= InKey(0)
         Local5:= myInkey0()

         if ( ( Local10:= SetKey(Local5) ) != Nil )
            eval(Arg1, Local2)
            eval(Local10, procname(1), procline(1), Upper(Arg2))
            Local2:= eval(Arg1)
            Local5:= 0
         endif
      end
      if ( Local2 > Len(Local13) )
         Local2:= Len(Local13)
      endif
      do case
      case Local5 == 5 .OR. Local5 == 19
         if ( --Local2 < 1 )
            Local2:= iif( Set(35), Len(Local13), 1 )
         endif
      case Local5 == 24 .OR. Local5 == 4
         if ( ++Local2 > Len(Local13) )
            Local2:= iif( Set(35), 1, Len(Local13) )
         endif
      case Local5 == 1
         Local2:= 1
      case Local5 == 6
         Local2:= Len(Local13)
      case Local5 == 18
         Local7:= .T.
      case Local5 == 3
         Local7:= .T.
      case Local5 == 13
         Local7:= .T.
      case Local5 == 27
         Local2:= 0
      otherwise
         Local4:= Upper(Chr(Local5))
         Local3:= ascan(Local13, ;
                 { |_1| Local4 == Left(Upper(LTrim(_1[ 3 ])), 1) })
         if ( Local3 != 0 )
            Local2:= Local3
            Local7:= .T.
         endif
      endcase
      if ( Local2 != 0 )
         SetPos(Local1[ 1 ], Local1[ 2 ])
         dispout(Local1[ 3 ])
      endif
   end
   setcursor(Local8)
   eval(Arg1, Local2)
   if ( Local12 )
      __MXRelease(Arg2)
   endif
   if ( !Empty(Local16) )
      readvar(Local16)
   endif
   SetPos(MaxRow() - 1, 0)
   return Local2

//---eof
(warning/disclaimer: untested code. Use at your own risk...)



Mon, 28 Jun 2004 01:48:50 GMT  
 "menu to" under windows NT
Jean-Pierre,

Quote:
>... the problem of Clipper programs eating away all CPU time in
>wait states.

FT_IAmIdle() from the Nanforum Toolkit takes care of all the wait
states and can reduce processor hogging all the way down to zero. All
you need to do is add one line to the top of your application and add
the library to your link script. No need to change your code.

You do need a patch, howerver. Instructions, the latest patch and
download links for the whole lib are available here:
http://home.swipnet.se/engw/clipper/nfpat1a.htm

HTH,
Klas

-------
klas dot engwall at engwall dot com




Mon, 28 Jun 2004 07:27:10 GMT  
 "menu to" under windows NT

Quote:

> Dave,

> Thank you very much, Phil Barnett's work has saved me a lot of time !

> Thank you Phil Barnett

You are most welcome!

--


        Oasis WWW  http://www.the-oasis.net
         FTP Site  ftp://ftp.the-oasis.net
      Clipper FAQ  http://www.the-oasis.net/clipper.html
  Harbour Project  http://www.Harbour-Project.org



Mon, 28 Jun 2004 15:32:51 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. "Out Port.vi": passing from Windows NT 4.0 to Windows 2000

2. "Standard" Windows Mac OS X Menu

3. In the "Menu" window (funny)

4. Windows NT "AT" command

5. "Not a Windows NT program"?

6. Windows NT systems "locking up" randomly

7. "open" on Windows NT

8. Windows NT "allways on top"

9. "send" on Windows NT

10. Using "exec" under Windows 95/NT

11. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

12. "Advanced" Shortcuts menu items

 

 
Powered by phpBB® Forum Software