Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
if Somefunction anotherfunction endifwould become:
If SomeFunction AnotherFunction EndIf
Here is some sample code. It needs the xCAM array extender to run.
Note: When using this utility in WinBatch Studio, the array extender and the CAM array will never be unloaded while WBStudio is up.
You might make some enhancements to the proposal. For example, load the CAM array from ready made dump file, so that it must not created each time when it is first time invoked. Or let it loop to make pretty a complete line or whatever else.
Overall it is a good demonstration for the usage of the xCAM lookup array mechanism.
;========================================================================================================================================== ; MakePretty.wbt ;------------------------------------------------------------------------------------------------------------------------------------------ ; This script tries to replace the word under the cursor with the same word, ; accordingly good looking and proper cased, as it is defined in the WIL.CLR file. ; Use this script only in WinBatch Studio Editor. ; ; Insert following two lines into your personal WSP-USER.MNU file at appropriate place. ; This will let you invoke the script by pressing [Ctrl+F6]. ; ; MakePrettyKeyword \ ^{F6} ; Call("G:\TEMP\WBT\MakePretty.wbt","") ; <== Change path to your needs. ; ;------------------------------------------------------------------------------------------------------------------------------------------ ; Detlev Dalitz.20031023 ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ sFileExtCAM = "D:\Programme\WinBatch\System\XCAM34I.DLL" ; <== Change path to your needs. sFileCLR = "D:\Programme\WinBatch\System\WIL.CLR" ; <== Change path to your needs. ;------------------------------------------------------------------------------------------------------------------------------------------ If !IsDefined(aCAMKeyword) Display(2,"WSP-USER.MNU","Loading MakePrettyKeyword ...") ; This message is displayed only once when creating the CAM. AddExtender(sFileExtCAM) ; This implements a fast read routine for reading large section from an inifile. ; All lines of inifile must be terminated by @CRLF sequence. ; Read the CLR file completely into a string. ; Insert one helper @LF at the beginning of the stream, and one helper @CR at end of stream. sIni = StrCat(@LF,FileGet(sFileCLR),@CR) ; Remove empty lines. sSearch = StrCat(@LF,@CR) sReplace = "" While (StrIndex(sIni,sSearch,1,@FWDSCAN)) sIni = StrReplace(sIni,sSearch,sReplace) EndWhile ; For sure, remove leading blanks. sSearch = StrCat(@LF," ") sReplace = @LF While (StrIndex(sIni,sSearch,1,@FWDSCAN)) sIni = StrReplace(sIni,sSearch,sReplace) EndWhile ; Find the proper section and skip over section header line. iScan = StrIndexNC(sIni,"[keywords]",1,@FWDSCAN) If !iScan sTermTitle = "Error" sTermText = StrCat("Inifile is damaged:",@LF,"{1}") sTermText = StrReplace (sTermText,"{1}",sFileWilClr) Terminate(iTermBool,sTermTitle,sTermText) EndIf iScan = StrIndex(sIni,@LF,iScan,@FWDSCAN) If !iScan sTermTitle = "Error" sTermText = StrCat("Inifile is damaged:",@LF,"{1}") sTermText = StrReplace (sTermText,"{1}",sFileWilClr) Terminate(iTermBool,sTermTitle,sTermText) EndIf iSection = iScan ; Find end of section. iScan = StrIndex(sIni,StrCat(@LF,"["),iScan,@FWDSCAN) If iScan sIni = StrSub(sIni,iSection,iScan-iStart+1) Else sIni = StrSub(sIni,iSection,-1) EndIf ; Delete comment lines. sSearch = StrCat(@LF,";") sSearchWild = StrCat(@LF,";*",@CR) iScan = 0 While @TRUE iScan = StrIndex(sIni,sSearch,iScan,@FWDSCAN) If !iScan Then Break sWild = StrSubWild(sIni,sSearchWild,iScan) sIni = StrReplace(sIni,sWild,"") EndWhile ; Remove all @CR. sIni = StrReplace(sIni,@CR,"") ; Remove leading blanks. sSearch = "= " sReplace = "=" While (StrIndex(sIni,sSearch,1,@FWDSCAN)) sIni = StrReplace(sIni,sSearch,sReplace) EndWhile ;Create CAM array. aCAMKeyword = camCAMFromArray(camArrayFromList(StrSub(sIni,2,-1),StrCat(@LF,"="),0),0,0) EndIf Drop(iScan,iSection,sFileCAM,sFileCLR,sFileExtCAM,sIni,sReplace,sSearch,sSearchWild,sTermText,sTermTitle,sWild) ;------------------------------------------------------------------------------------------------------------------------------------------ sUgly = wGetWord() sPretty = camGet(aCAMKeyword,sUgly) If (sPretty !="*EOF*CAM*") wWordLeft() iStrLen = StrLen(sUgly) For ii=1 To iStrLen wDelete() Next wInsString(sPretty) EndIf Drop(ii,iStrLen,sPretty,sUgly) Exit ;==========================================================================================================================================
Article ID: W16265
File Created: 2004:03:30:15:43:40
Last Updated: 2004:03:30:15:43:40