Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Emulating Visual Foxpro Command Window
Message
 
 
To
03/08/2000 14:14:22
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00399066
Message ID:
00401042
Views:
18
>Nadya,
>
>>Your emulator works fine, but it's not a complete replacement of command window. It has couple of limitations. For instance, I can not select multiple lines and execute them by hitting Enter, as I can in VFP Command window. In VFP Command window I see reserved words in blue, but not in your Emulator. Also, Error Message, wcich comes with VFP, uses _Screen.Title. Yours shows 'Microsoft Visual FoxPro' instead.
>
>Of course there are differences. This VFP command window, never could replace the original one: There are things that cannot (or difficult) be done in a VFP form. For instance displaying the reserved words in blue would be quite a problem.
>
>But if you feel that there are things that can be of added value to this command window, feel free to adress it. I'll gather them and i'll consider to implement them next time....
>
>Thanks,
>
>Walter,

Walter,

This program can help you (it still doesn't format strings correctly, for my deepest regret, but I just became tired...)
********************************************************************
*  Description.......: nnHTMLCode
*  Calling Samples...: on key label F9 _cliptext=nnHTMLCode(_cliptext)
*  Parameter List....: lcCode, lcPath, lcBeatify
*  Created by........: Mike Helland
*  Modified by.......: Nadya Nosonovsky 04/18/2000 04:45:16 PM
********************************************************************
lparameters lcCode, lcPath, lcBeatify

if empty(lcCode) or vartype(lcCode)<>'C' && Check if first parameter exists
     return .f.
endif

local lnSec, lcOldExact, llNotUsedWords
lnSec=seconds()
lcOldExact=set('exact')

set exact off && in order to compare part of strings

if vartype(lcBeatify)<>'C'
     rele lcBeatify && test partial words
     lcBeatify='M' && Mixed
endif

if vartype(lcBeatify)='C' and not inlist(left(upper(lcBeatify),1),'U','L')
     lcBeatify='M' && Mixed
endif

#define FONTBLUE   [<font color=blue>]
#define FONTGREEN  [<font color=green>]
#define FONTEND    [</font>]
#define SYMBOLS    ':~!#$%^&*(@)-+=|{}[]:;,./\<>'

local SINGLEQUOTE, DOUBLEQUOTE, LEFTPAR, RIGHTPAR, CRLF

SINGLEQUOTE = chr(39)
DOUBLEQUOTE = chr(34)
LEFTPAR = chr(91)
RIGHTPAR = chr(93)
CRLF  = chr(13)+chr(10)

private CR
CR= chr(13) && should be seen in aparser

*Setup two simple variables for speed
local LF, leTab
LF      = chr(10)
leTab     = chr(9)

*Do some basic HTML intializing
lcCode = strtran(lcCode, leTab, space(5))
lcCode = strtran(lcCode, '&', '&')
lcCode = strtran(lcCode, '<', '<')
lcCode = strtran(lcCode, '>', '>')

lcCode = strtran(lcCode, CR, CR + CR) && to proper handle blank line

*Create an array ouf of our strings.
local laLines[1], lcReturn, lnLines, lnI, lcLine, lnWA

local lcComment, lcBeforeComment, lnWords, lcResult

local lcDoubleAmp, lnStartComment, k, lcLeft, lcRight, lcSymb, llStartString, lcRightPrev

private chr254, space1 && in order to be seen in aparser

chr254=chr(254)
space1=space(1)

lnLines=alines(laLines, lcCode)

lcReturn = '<pre>'

lnWA=select()

if !used('words')
    llNotUsedWords=.t.
     use (iif(empty(lcPath), '', lcPath) + 'words') in 0 order tag revword
endif

*Proccess each line
for lnI = 1 to lnLines

     lcLine = laLines[lnI]

*Don't even bother the blank ones
     if empty(alltrim(lcLine))
          lcReturn = lcReturn +CRLF
          loop
     endif

*Full Line Comments, first
     if left(alltrim(lcLine),1) = '*'
          lcLine = FONTGREEN + lcLine + FONTEND

*Print line here
          lcReturn = lcReturn + CRLF + lcLine
          loop
     endi && to test partial words

     lcComment=''
     lcBeforeComment=lcLine

*Now end of the line comments

     lcDoubleAmp = '&&' && This is to test our function

     lnStartComment = at(lcDoubleAmp, lcLine)

     if lnStartComment > 0
          lcComment = FONTGREEN+substr(lcLine, lnStartComment) + FONTEND && Insert comment tag
          lcBeforeComment=substr(lcLine, 1,lnStartComment-1)
     endif

*!* Devide string into words
     dimension laWords[1]

     lnWords = aparser(@laWords, lcBeforeComment,SYMBOLS)

     lcResult=''

     local lcWord, lnWordLen

     for k=1 to lnWords

* First check if we're in a string
          if !empty(laWords[k])

               laWords[k]=chrtran(laWords[k],chr254,space1)

               lcLeft=left(laWords[k],1)

               llStartString=.f.

               if inlist(lcLeft,DOUBLEQUOTE,SINGLEQUOTE,LEFTPAR) && String starts
                    llStartString=.t.
                    if lcLeft=LEFTPAR
                         lcLeft=RIGHTPAR
                    endif
                    lcSymb=lcLeft
               endif

               do while llStartString && Check if we're still in string

                    if k<lnWords
                         lcLeft=left(laWords[k+1],1)
                         lcRight=right(alltrim(laWords[k+1]),1)
                         lcRightPrev=right(alltrim(laWords[k]),1)

                         laWords[k]=chrtran(laWords[k],chr254,space1)
                         lnWordLen=len(laWords[k]) && Word length

                         if lcSymb==lcLeft or lcSymb==lcRight or ;
                                   (lnWordLen>1 and lcSymb==lcRightPrev)

                              lcSymb=''
                              lcResult=lcResult+laWords[k]
                              k=k+1
                              llStartString=.f. && String ends
                              exit
                         endif

                         lcResult=lcResult+laWords[k]

                         k=k+1 && Increment count

                    else
                         laWords[k]=chrtran(laWords[k],chr254,space1)
                         lcSymb=''
                         llStartString=.f. && String ends
                         exit
                    endif
               enddo

               laWords[k]=chrtran(laWords[k],chr254,space1)
               lnWordLen=len(alltrim(laWords[k]))
               lcWord=upper(alltrim(laWords[k]))

               if lnWordLen<4
                    lcWord=padr(lcWord,4) && short word
               endif

               if not empty(laWords[k]) and seek(lcWord,'words','revword') && Word found
                    do case
                    case left(upper(lcBeatify),1)='U' && Upper case
                         laWords[k]=upper(laWords[k])
                    case left(upper(lcBeatify),1)='L' && Lower case
                         laWords[k]=lower(laWords[k])
                    endcase
                    laWords[k]=FONTBLUE+laWords[k]+FONTEND
               endif
               lcResult=lcResult+laWords[k]
          endif
     next

     if not empty(lcBeforeComment) and not empty(lcResult)
          lcBeforeComment=lcResult
     endif

*Submit the process line
     lcReturn = lcReturn  + CRLF + lcBeforeComment+lcComment && Another In Line Test to use
endfor

lcReturn = lcReturn  + '</pre>'

if llNotUsedWords && was not used before
     use in words
endif     

select (lnWA) && Return to prev. area
set exact &lcOldExact && Restore exact settings

wait window nowait 'Transformed  '+alltrim(str(lnLines))+'# lines in '+alltrim(str(seconds()-lnSec,10,6))+' sec'
return lcReturn

**********************************************************************
function aparser
*  Description.......: Function parses a text string into an array.
*                    : Each element of the array contains one word...
*  Calling Samples...: dimension laWords[1]
*                    : lcWordString = "Some text string"
*                    : lnWords = aparser(@laWords, lcWordString)
*  Parameter List....: paWords, pcWordString, pcDelimiter
********************************************************************
lparameter paWords, pcWordString, pcDelimiter
local lnWords, i, lcSymbol

external array paWords

if vartype(pcDelimiter)<>'C'
     pcDelimiter=space1
endif

pcWordString=strtran(pcWordString, space1, space1+chr254) && Replace space(1) with rare symbol chr(254)

for i=1 to len(pcDelimiter)
     lcSymbol=substr(pcDelimiter,i,1)
     pcWordString=strtran(pcWordString,lcSymbol,space1+lcSymbol+space1)  && Larry Miller suggested
next

*!* Replace the delimiter with CHR(13) using STRTRAN.
pcWordString = strtran(pcWordString, space1, CR)

*!* Now put each element in an array.
lnWords=alines(paWords, pcWordString)

return lnWords
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform