📄 cclassparser.prg
字号:
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: GetClassMethods()
*-------------------------------------------------------
*) Description: Returns an array of class methods
*) for a class
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Numeric
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE GetClassMethods(tcClassID, raClassMethods)
LOCAL lnRetVal
lnRetVal = 0
SELECT cn_methods
SET ORDER TO methname
SCAN FOR cn_methods.classid = tcClassID
lnRetVal = lnRetVal + 1
DIMENSION raClassMethods[lnRetVal,6]
raClassMethods[lnRetVal,1] = cn_methods.id
raClassMethods[lnRetVal,2] = ALLTRIM(cn_methods.methname)
raClassMethods[lnRetVal,3] = cn_methods.protected
raClassMethods[lnRetVal,4] = cn_methods.hidden
raClassMethods[lnRetVal,5] = cn_methods.parameters
raClassMethods[lnRetVal,6] = cn_methods.startchar
ENDSCAN
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: ZapClassCursors()
*-------------------------------------------------------
*) Description: Cleans out all class cursors
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE ZapClassCursors()
LOCAL lnSelected
lnSelected = SELECT(0)
IF !USED('cn_classes')
SELECT cn_classes
ZAP
ENDIF
IF !USED('cn_properties')
SELECT cn_properties
ZAP
ENDIF
IF !USED('cn_methods')
SELECT cn_methods
ZAP
ENDIF
SELECT (lnSelected)
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: WordsToArray()
*-------------------------------------------------------
*) Description: Accepts a string and converts the string
*) into a one dimensional array. Each word in the string
*) will be in its own element in the array.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Numeric
*$ Notes: When converting a string of words to an array
*$ the following rules need to be observed:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROTECTED PROCEDURE WordsToArray(tcWordString, raWordArray)
LOCAL lnRetVal, lcWordString, lnBrackets, ;
llInQuotes, lnCount, lcLetter, lcNewList
DIMENSION raWordArray[1]
lcWordString = ALLTRIM(tcWordString)
*-- In its simplest form, STRTRAN() could be used
*-- to convert each space in the string into a
*-- carriage return and then use ALINES() to
*-- convert into an array. However if this was done
*-- functions and array would be broken up for.
*-- For example SUBSTR(lcSring, 1, 10) would become
*-- 3 different words. Also, there are some
*-- special words that may not have spaces between
*-- them for example lcName="CSession" should be
*-- three words, not one. Finally, everything in
*-- a string whould be a single word so
*-- lcTitle = "Class Navigator" should also be
*-- three words. Iterate through the string
*-- placing the CRs manually.
lnBrackets = 0
llInQuotes = .F.
lcNewList = ""
FOR lnCount = 1 TO LEN(lcWordString)
lcLetter = SUBSTR(lcWordString, lnCount, 1)
DO CASE
CASE lcLetter = "(" OR lcLetter = "[" AND NOT llInQuotes
lnBrackets = lnBrackets + 1
lcNewList = lcNewList + lcLetter
CASE lcLetter = ")" OR lcLetter = "]" AND NOT llInQuotes
lnBrackets = lnBrackets - 1
lcNewList = lcNewList + lcLetter
CASE lcLetter = '"' OR lcLetter = "'"
llInQuotes = NOT llInQuotes
lcNewList = lcNewList + lcLetter
CASE lcLetter = " " AND lnBrackets = 0 AND NOT llInQuotes AND RIGHT(lcNewList,1) # CHR(13)
lcNewList = lcNewList + CHR(13)
CASE lcLetter = " " AND lnBrackets = 0 AND NOT llInQuotes AND RIGHT(lcNewList,1) = CHR(13)
*-- Do nothing. Adding a CR here would create
*-- an empty word.
CASE lcLetter = "=" AND NOT llInQuotes
lcNewList = lcNewList + IIF(RIGHT(lcNewList,1) # CHR(13), CHR(13), SPACE(0)) + lcLetter + CHR(13)
OTHERWISE
lcNewList = lcNewList + lcLetter
ENDCASE
ENDFOR
*-- Now, use ALINES() to do all the work
lnRetVal = ALINES(raWordArray, lcNewList)
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: ListToArray()
*-------------------------------------------------------
*) Description: Accepts a comma delimited list and
*) converts each item in the list into an element in
*) an array.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Numeric
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROTECTED PROCEDURE ListToArray(tcWordList, raWordArray)
LOCAL lnRetVal, lcWordList, lnCount, ;
lnWords, lcLetter, lnBrackets, ;
lcNewList
lnBrackets = 0
lcNewList = ""
lcWordList = ALLTRIM(tcWordList)
*-- This one is a bit tricky because a comma can
*-- appear either between two words or in an
*-- array definition. Argh. So, loop through each
*-- letter in the string changing commas to
*-- carriage returns unless the comma appears
*-- between either () or [].
FOR lnCount = 1 TO LEN(lcWordList)
lcLetter = SUBSTR(lcWordList, lnCount, 1)
DO CASE
CASE lcLetter = "(" OR lcLetter = "["
lnBrackets = lnBrackets + 1
lcNewList = lcNewList + lcLetter
CASE lcLetter = ")" OR lcLetter = "]"
lnBrackets = lnBrackets - 1
lcNewList = lcNewList + lcLetter
CASE lcLetter = "," AND lnBrackets = 0
lcNewList = lcNewList + CHR(13)
CASE lcLetter = " "
*-- Don't do anything.
OTHERWISE
lcNewList = lcNewList + lcLetter
ENDCASE
ENDFOR
*-- We should now have a string with the
*-- CHR(13)'s in place.
*-- Now, use ALINES() to do all the work
lnRetVal = ALINES(raWordArray, lcNewList)
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: GetWordInString()
*-------------------------------------------------------
*) Description: Returns a word from a string of words
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Character
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE GetWordInString(tcWordString, tnGetWord)
LOCAL lcRetVal, lcWordString, laWordArray[1], ;
lnWords
lcRetVal = ""
lnWords = THIS.WordsToArray(tcWordString, @laWordArray)
IF lnWords >= tnGetWord
lcRetVal = ALLTRIM(laWordArray[tnGetWord])
ENDIF
RETURN lcRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: LineNumberToCharNumber()
*-------------------------------------------------------
*) Description: Accepts a line number and determines
*) which character number in the aClassFile array that
*) line represents. This is used primarily because
*) MODIFY COMMAND has an option to set the starting
*) position of the cursor. This starting position is
*) based on the character number, not the line number.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Numeric
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE LineNumberToCharNumber(tnLine)
LOCAL lnRetVal, lnCount
lnRetVal = 0
FOR lnCount = 1 TO tnLine - 1
*-- Get the length of the line and add +2 to account
*-- for the CR + LF
lnRetVal = lnRetVal + LEN(THIS.aClassFile[lnCount]) + 2
ENDFOR
*-- The current value of lnRetVal will place the cursor
*-- at the very end of the line before tnLine. To make
*-- it appear at the beginning of the next line add
*-- one more to it.
lnRetVal = lnRetVal + 1
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CCLASSPARSER.PRG
*} Class: CProgrammaticClassParser
*} Method: GetErrorString()
*-------------------------------------------------------
*) Description: Returns true if there is text in
*) the cErrorString property, copies the string
*) to the parameter and clears the string.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE GetErrorString(rcErrorString)
LOCAL llRetVal
llRetVal = !EMPTY(THIS.cErrorString)
rcErrorString = THIS.cErrorString
THIS.cErrorString = ""
RETURN llRetVal
ENDPROC
*///////////////////////////////////////////////////////
ENDDEFINE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -