Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stopped working in VFP 7
Message
 
À
30/10/2001 20:37:21
Spencer Redfield
Managed Healthcare Northwest, Inc.
Portland, Oregon, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00575331
Message ID:
00575442
Vues:
25
Spencer,

Here's the code that works for me. For my purpose, I needed to remove the line feed characters and leave in the carriage returns -- feel free to comment out and/or rip out that part of the code if that doesn't meet your needs.

To implement this code:
1) Be certain that FOXTOOLS.FLL is either in the LIBRARY string or available in the VFP home directory.
2) Pass it the window name of your editor window (usually the name in the window's title bar of the PRG you're editing). If it's a method window, use the method name in the window's title bar.
*== GETEDSRC
*-- This method returns a character string
*-- containing the contents of an open editing window
LPARAMETERS tcWindowName
LOCAL lcRetVal, ;
      lcFilNm, ;
      lcOldLib, ;
      lnWHandle, ;
      lnResult, ;
      lnStopPos, ;			
      laEnvironment

*-- Define local variables
lcRetVal   = ""
lcFilNm    = IIF( PCOUNT() > 0 AND TYPE( "tcWindowName" ) = "C", ;
                  ALLTRIM( tcWindowName ), ;
                  "" ;
                  )
lcOldLib   = set( "library" )
lnWHandle  = 0
lnResult   = 0
lnStopPos  = 0

DECLARE laEnvironment[ 25 ]

*-- If we don't have the FOXTOOLS library,
*-- load it now
IF !( "FOXTOOLS" $ lcOldLib )
  SET LIBRARY TO ( HOME() + "FOXTOOLS.FLL" ) ADDITIVE

ENDIF && !( "FOXTOOLS" $ lcOldLib )

*-- If a window name was passed,
*-- get the 'whandle' of the window
IF !EMPTY( lcFilNm )
  *-- Get the 'whandle' of the window
  lnWHandle = _WFindTitl( lcFilNm )

  *-- Populate the array with the editor environment
  lnResult  = _EdGetEnv( lnWHandle, @laEnvironment )

  *-- Get the size of the contents of the window
  lnStopPos = IIF( lnResult = 1, ;
                   laEnvironment[ 2 ], ;
                   1 ;
                   )

  *-- Place the code from the window
  *-- into our working variable
  lcRetVal = IIF( lnStopPos # 1, ;
                  _EdGetStr( lnWHandle, ;
                             0, ;
                             lnStopPos ;
                             ), ;
                  "" ;
                  )

  *-- Strip all the line feeds ( CHR( 10 ) )
  lcRetVal = STRTRAN( lcRetVal, ;
                      CHR( 10 ), ;
                      "" ;
                      )

ENDIF && !EMPTY( lcFilNm )

*-- Restore the LIBRARY string
*-- to its previous contents
SET LIBRARY TO &lcOldLib.

*-- Clean up and return
RETURN ( lcRetVal )
As far as the ignoring of KEYBOARD commands...I'm not sure, since I don't use them often. I find they don't always work the way I expect/want/need, so I usually end up finding another way around the same situation.

Let me know if you have any questions on the above code.

>Hi Evan,
>
>Yes, I'd really appreciate any ideas/code you'd like to pass on.
>
>Also, I'm baffled at what environmental differences might explain why some of us experience the code blowing past and effectively ignoring the expected results of the KEYBOARD commands and why it works for others like you.
>
>Must be the computer that misspelled "pragmatically". Of course couldn't be me!
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform