Page 1 of 2 12>
Topic Options
#174916 - 2007-03-23 04:16 PM Postprep 2 command-line
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
WARNING - the PostPrep.zip attached to this post does not work with Kix32 version 4.63. An update is being tested and will be uploaded when validated.

For those of you that don't know - PostPrep is the Kix script that colorizes kix code, generating HTML that can be pasted directly into a message as you see below, without using Code tags. You must select HTML or HTML/UBB as the message type when posting a message with PostPrep content.

This postprep release runs from a command line -
Kix32 ppcl.kix -s:myscript.kix -c
The postprepped code is placed on the clipboard, ready to paste into a KORG message. The default (without -c) writes a .HTM file with the same name as the source file. Run without args for usage info.

The PostPrep.INI file will be posted in the next message. The script expects this file to be in the path defined by %S_CONFIG%, or - if not there - in @SCRIPTDIR.

This version is quick & easy to use, and is capable of postprepping an entire folder of Kix files automatically. The zip file contains both the GUI and command-line versions of PostPrep, and both share a common configuration file.

Due to the size of this post, it is presented in 3 parts. Parts 1 & 2 are the core script, part 3 is the config file. The code presented here is primarily to illustrate the concept and code structure. You are strongly encouraged to download the entire code set - PostPrep.kxw, PostPrep.ini, PPCL.Kix, and the ReadMe.txt file from the attached zip file. Only the zip file will be updated as versions change!!

Enjoy!

Glenn


;; KixGenerated: 2007/10/13 21:46:19 
; UBB PostPrep 2.0.0 
; ---------------------------------------------------------------------------------------------- 
; MINIMUM REQUIREMENTS 
; 
;	KIXTART		4.53 (KiX32.exe) 
; ---------------------------------------------------------------------------------------------- 
; AUTHORs 
;       Glenn Barnas    - This development tree 
; ---------------------------------------------------------------------------------------------- 
; ACKNOWLEDGEMENTS 
;	Jochen Polster	- Form, Controls, original design 
;	Jooel Nieminen	- original conversion Engine ! 
; ---------------------------------------------------------------------------------------------- 
; VERSION HISTORY 
; 
;       2.0.0.0         - 12/30/2006 Glenn Barnas - New development tree based on PostPrep 1.0.3.4 
;                         requires Kix 4.53 
;                         COMMAND-LINE version, HTML only (no UBB output) 
;       2.0.0.1         - 03/24/2007 Changes to Kix2Htm UDF 
;       2.0.2.0		- 10/15/2007 Change to WC function to allow WORDWRAP=0 setting 
;			  Added support to Kix2Htm() to support Block Comments 
; ---------------------------------------------------------------------------------------------- 
 
Break On
 
Dim $ShowStats			; Display conversion time stats if true 
Dim $Version			; Current version string 
Dim $				; general purpose "throwaway" var 
Dim $ConfigFile			; Filespec for PPCL configuration file 
Dim $SourceFile			; Source file to process 
Dim $DestFile			; Output file  
Dim $FileContent		; Content of file as a single string 
Dim $CommandLine		; Command Line Args 
Dim $I				; Index pointer 
Dim $Clip			; Boolean - copy generated output to clipboard if true 
Dim $Wrap			; Boolean - wrap long lines when true 
Dim $Commands			; Array of Commands 
Dim $Functions			; Array of Functions 
Dim $Border			; Border / background specification 
Dim $TimerS			; Start time of conversion 
Dim $TimerE			; End time of conversino 
Dim $Body			; Body text specifier 
Dim $Sections[7]		; Types of formatting 
Dim $ColorTable[7]		; Table of format colors for various types 
Dim $BoldTable[7]		; Table of format bolding for various types 
 
$Sections = 'Comments','Strings','Numbers','Commands','Functions','Macros','Operators','Variables'
 
 
$ = SetAscii('On')
$ = SetOption('Explicit', 'On')
$ = SetOption('WrapAtEOL', 'On')
$ = SetOption('NoVarsInStrings', 'On')
$ = SetOption('NoMacrosInStrings', 'On')
 
$Version = '2.0'
 
; Exit if not at KiX V4.53 
$ = KixVer('4.53')
 
; initialization 
 
$ConfigFile = ''
$SourceFile = ''
$DestFile   = ''
 
; check for a Config file in the standard system configuration folder 
If Exist(%S_CONFIG% + '\PostPrep.ini')
  $ConfigFile = %S_CONFIG% + '\PostPrep.ini'
EndIF
 
; If we didn't find it in the standard location, look in the folder where the script was launched 
If Exist(@SCRIPTDIR + '\PostPrep.ini') And Not $ConfigFile
  $ConfigFile = @SCRIPTDIR + '\PostPrep.ini'
EndIf
 
 
; Parse the command line 
$CommandLine = GetCommandLine(1)
 
; Complain and exit if no arguments were specified. 
If UBound($CommandLine) = 1
  'No input arguments were specified.' ?
  ' Usage: ppcl -s:SrcFileSpec [-o:DestFileSpec] [-p:AltConfigFile] [-c]' ?
  '        -c copies the resulting HTM output to the clipboard INSTEAD OF' ?
  '        generating the .HTM file.' ?
  Quit 1
EndIF
 
; Have arguments - figure out what to do 
For $I = 2 to UBound($CommandLine)
  Select
 
    Case Left($CommandLine[$I], 3) = '-s:'
      $SourceFile = SubStr($CommandLine[$I], 4)
 
    Case Left($CommandLine[$I], 3) = '-o:'
      $DestFile = SubStr($CommandLine[$I], 4)
 
    Case Left($CommandLine[$I], 3) = '-p:'
      $ConfigFile = SubStr($CommandLine[$I], 4)
 
    Case $CommandLine[$I] = '-c'
      $Clip = 1
 
    Case 1
      'Warning: Argument ' $CommandLine[$I] ' was not understood! Ignored!' ?
 
  EndSelect
 
Next
 
 
; Verify that the source file exists 
If Not $SourceFile
  ? 'A source file was not specified - aborting!' ? ?
  Quit 1
EndIF
 
If Not Exist($SourceFile)
  ? 'The defined source file "' $SourceFile '" was not found - aborting!' ? ?
  Quit 1
EndIf
 
 
; If the destination file wasn't specified, use the SourceFileSpec and change the extension to ".htm" 
If Not $DestFile
  $DestFile = Left($SourceFile, InStrRev($SourceFile, '.')) + 'htm'
EndIf
 
; Abort if no config file was found, otherwise load the configuration settings 
If Not $ConfigFile
 
  'This Script requires a PostPrep.ini configuration - aborting!' ?
  Quit 1
 
Else
 
  ; OK to proceed - read the configuration data 
 
  For $I = 0 to UBound($Sections)
    $ColorTable[$I] = ReadProfileString($ConfigFile, 'FormatTable', $Sections[$I] + 'Color')
    $BoldTable[$I] = Bool(ReadProfileString($ConfigFile, 'FormatTable', $Sections[$I] + 'Bold'))
  Next
 
 
  $Commands       = EnumIni($ConfigFile, 'Commands')
  $Functions      = EnumIni($ConfigFile, 'Functions')
 
  ; verify the config file contains valid information 
  If  Not UBound($Commands)
   Or Not UBound($Functions)
   Or Not UBound($ColorTable)
   Or Not UBound($BoldTable)
    ? 'This Script requires a consistent configuration file - aborting!' ? ?
    Quit 1
  EndIf
 
  $ShowStats = Bool(ReadProfileString($ConfigFile, 'Global', 'ShowStats'))
  $Wrap      = ReadProfileString($ConfigFile,      'Global', 'WordWrap')
  $Border    = Bool(ReadProfileString($ConfigFile, 'Global', 'Border'))
 
  ; Set the Border directive based on the flag value 
  If $Border
    ; read from PostPrep.ini - can be one of none,hidden,dotted,dashed,solid,double,groove,ridge,inset, or outset 
    $I = ReadProfileString($ConfigFile, 'FieldSet', 'Background-Color')
    $Border = 'background:' + IIf($I, $I, 'white')
    $I = ReadProfileString($ConfigFile, 'FieldSet', 'Border-Style')
    $Border = $Border + ';border-style:' + IIf($I, $I, 'none')
    $I = ReadProfileString($ConfigFile, 'FieldSet', 'Border-Width')
    $Border = $Border + ';border-width:' + IIf($I, $I, '0')
  Else
   $Border = 'background:white;border-style:none;border-width:0'
  EndIf
 
  ; Define the body settings 
  $Body = '<font face="'
  $I = ReadProfileString($ConfigFile, 'FieldSet', 'TypeFace')
  $Body = $Body + IIf($I, $I, 'Courier New')
  $I = ReadProfileString($ConfigFile, 'FieldSet', 'FontSize')
  $Body = $Body + '" size="' + IIf($I, $I, '2')
  $Body = $Body + '" color="#000000">'
 
EndIf
 
;=================================================================== 
; Load the file contents into a string 
If Open(1,$SourceFile,2) = 0
 
  $I = ReadLine(1) + @CRLF
  While @ERROR = 0
    $FileContent = $FileContent + $I
    $I = ReadLine(1) + @CRLF
  Loop
  $ = Close(1)
 
Else
 
  ? 'Error opening ' $SourceFile ' - aborting!' ?
  @SERROR ? ?
  Quit 1
 
EndIf
 
 
;=================================================================== 
 
$TimerS = @TICKS
$FileContent = Kix2HTM($FileContent,$ColorTable,$BoldTable,$Functions,$Commands,$Border, $Body, $Wrap)
$TimerE = @TICKS - $TimerS
 
 
; Copy to clipboard if the -c option was specified. 
If $Clip
  $ = CopyToClipboard($FileContent)
Else
  Del $DestFile
  $ = RedirectOutput($DestFile)
  $FileContent
  $ = RedirectOutput('')
EndIf
 
; Display time statistics if requested 
If $ShowStats
  ? 'PostPrep completed processing in ' 
  If Val($TimerE) < 1000
    $TimerE ' milliseconds.' ?
  Else
    ($TimerE / 1000) '.' CStr($TimerE Mod 1000) ' seconds.' ?
  EndIf
EndIf
 
 
Function CopyToClipboard($strCopy)
  Dim $objIE
  $objIE = CreateObject("InternetExplorer.Application")
  $objIE.Navigate("about:blank")
  $CopyToClipboard = $objIE.document.parentwindow.clipboardData.SetData("Text",$strCopy)
  $objIE.Quit
  Exit @ERROR
EndFunction
 
 
 
;; 
;;====================================================================== 
;; 
;;FUNCTION       Bool() 
;; 
;;ACTION         return True if Flag is "non-zero", "T", "Y", or "ON" 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;SYNTAX         Bool(flag [,other_true] [,default]) 
;; 
;;PARAMETERS     Flag    - REQUIRED, a text string - can be null 
;; 
;;               Extra   - OPTIONAL, a string of other "true" matches, comma-delimited. 
;;                         "En*" will match the leftmost 2 chars 
;; 
;;               Default - OPTIONAL, a default value to use if Flag is null 
;; 
;;REMARKS        Returns TRUE if any of the following condidions are met: 
;;			First char of flag is "Y"  (yes) 
;;			First char of flag is "T"  (true) 
;;			First char of flag is a non-zero digit 
;;			Flag text is "ON" 
;;			Flag text matches optional Extra value 
;; 
;;RETURNS        1 if the flag evaluates to a "true" boolean, 0 otherwise 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    W2K, WXP, W2K3 
;; 
;;EXAMPLES       If Bool(ReadProfileString('config.ini', 'sect', 'setting') 
;;                 'Setting is on!' ? 
;;               EndIf 
;; 
;;               ; In this configuration, the default is T, and the config.ini value is 
;;               ; used to turn it off. If the setting in the ini file is not defined,  
;;               ; the default value is used. 
;;               $Default = 'T' 
;;               If Bool(ReadProfileString('config.ini', 'sect2', 'setting'), '', $Default) 
;;                 'Setting is on!' ? 
;;               EndIf 
;  
Function Bool($_Flag, OPTIONAL $_Extra, OPTIONAL $_Default)
 
  ; Handle embedded ReadLine errors passed to this wrapper func 
  If @ERROR Exit @ERROR EndIf
 
  Dim $_XV, $_aXV, $bT, $bF
 
  $bT = Not 0				; TRUE value 
  $bF = Not $bT				; FALSE value 
 
  ; set default value if defined and test value (Flag) is not defined 
  If $_Flag = '' And $_Default <> ''
    $_Flag = $_Default
  EndIf  
 
  $_Flag = UCase($_Flag)		; force uppercase chars 
 
  $Bool = $bF				; default to FALSE 
 
  If $_Extra
    $_Extra = 'ON,TRUE,T,YES,Y,' + $_Extra
  Else
    $_Extra = 'ON,TRUE,T,YES,Y'		; default test values 
  EndIf
 
  ; Handle the numeric test 
  If Val($_Flag) <> 0			; flag is non-zero 
    $Bool = $bT
  EndIf
 
 
  ; process string comparisons 
  If Not $Bool
    $_aXV = Split($_Extra, ',')		; get array of string match values 
    For Each $_XV in $_aXV		; then compare each one 
      If InStr($_XV, '*')		; is it a substring compare? 
        If UCase(Left($_XV, InStr($_XV, '*') - 1)) = Left($_Flag, InStr($_XV, '*') - 1)
          $Bool = $bT
        EndIf
      Else				; or a direct compare 
        If UCase($_XV) = $_Flag
          $Bool = $bT
        EndIf
      EndIf
    Next
  EndIf
 
  Exit 0				; always successful ;\) 
 
EndFunction
 
 
;; 
;;====================================================================== 
;; 
;;FUNCTION       EnumIni() 
;; 
;;ACTION         Enumerates sections or keys of an INI file 
;; 
;;AUTHOR         Glenn Barnas  
;; 
;;VERSION        2.0 
;; 
;;DATE CREATED   2003/11/17 
;; 
;;DATE MODIFIED  2004/10/16 
;; 
;;SYNTAX         EnumIni(File [, Section]) 
;; 
;;PARAMETERS     File - 	REQUIRED, path/name of INI file to examine 
;; 
;;               Section -	OPTIONAL, Section name to parse 
;; 
;;REMARKS        Returns an array containing the sections in an INI file, or 
;;               an array of key names in a specified section. Errors are returned 
;;               for non-existant files or INI file reads. If the specified file 
;;               contains no sections, or the specified section contains no keys, 
;;               the UDF exits with error 13 and returns a null array. Thus, a For-Each loop 
;;               will properly perform no iterations if no data is returned. 
;; 
;;               CAUTION - Error 13 is returned for empty files, or nonexistant sections. 
;;                         This is not necessarily a "failure". 
;; 
;;RETURNS        Array of sections or keys in a section 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    Kix 4.2+, NT4, W2K, WXP, W2K3 
;; 
;;EXAMPLES       $Sections = EnumIni('.\config.ini') 
;;               $Keys = EnumIni('.\config.ini', 'Common') 
; 
Function EnumIni($_fSrcFile, OPTIONAL $_fSectName)
 
  Dim $_fSectList
 
  ; die if the file doesn't exist 
  If Exist($_fSrcFile) = 0
    Exit 2
  EndIf
 
  ; Get the list of sections or keys 
  $_fSectList = ReadProfileString($_fSrcFile, $_fSectName, '')
  ; Return if error occurred 
  If @ERROR
    Exit @ERROR
  EndIf
 
  ; If len is >0, return an array of sections 
  ; If len is 0, either no sections or keys exist, or an invalid section name was specified. Return nothing. 
  If Len($_fSectList) > 0
    $EnumIni = Split(Left($_fSectList,len($_fSectList)-1), Chr(10))
    Exit 0
  EndIF
 
  ; return an error here for value not found (no sections or no keys in section) 
  Exit 13
 
EndFunction
  
 


Attachments
PostPrep.zip (1406 downloads)
Description:


_________________________
Actually I am a Rocket Scientist! \:D

Top
#174917 - 2007-03-23 04:25 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Part 2

;; 
;;====================================================================== 
;; 
;;FUNCTION       Kix2Htm() 
;; 
;;ACTION          
;; 
;;AUTHOR         Glenn Barnas 
;;		 Rewrite of original postprep code by Jochen Polster & Jooel Nieminen 
;; 
;;VERSION        1.0 / 2006/12/15 
;; 
;;SYNTAX         Kix2HTM(SrcTxt, C_Table, B_Table, F_Table, C_Table, Border, Body, LLW) 
;; 
;;PARAMETERS     ALL PARAMETERS ARE REQUIRED! 
;; 		 SrcTxt	  String  - all text from source file 
;;		 C_Table  Array   - color values for each text class 
;;		 B_Table  Array   - if element is true, replace with 2 element array of "<b>" and "</b>" 
;;		 funcs 	  Array   - List of Kix Functions 
;;		 cmds     Array   - List of Kix Commands 
;;		 Border   String  - HTML markup to define the Border / background 
;;		 Body	  String  - HTML markup to define the body style 
;;		 LLW      Number  - column # if Long Line Wrapping is enabled 
;; 
;;REMARKS        Text Classes (for B_Table and C_Table) are 
;;		  'Comments', 'Strings', 'Numbers', 'Commands', 'Functions', 'Macros',  
;;		  'Operators', & 'Variables' 
;; 
;;		 This UDF requires significant preparation prior to calling! 
;; 
;;RETURNS        String - source text formatted as HTML 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    W2K, WXP, W2K3 
;; 
;;EXAMPLES       See the documentation! 
;; 
Function Kix2HTM($SrcTxt, $C_Table, $B_Table, $Fn_Table, $Cm_Table, $Border, $Body, $LLW)
 
  Dim $1,$2,$3,$4,$5				; special tag characters 
  Dim $I					; Index var 
  Dim $LineCt					; count of lines in source text 
  Dim $Lp					; LinePointer - index of SrcTxt array 
  Dim $Line					; current working line text 
  Dim $Ll					; Current working line length 
  Dim $Cp					; character position in current working line 
  Dim $Wp					; Wrap pointer 
  Dim $OBuf					; output buffer 
  Dim $TBuf					; Temp buffer for checking words 
  Dim $T1, $T2, $N				; list of terminating chars, numbers 
  Dim $C					; current character 
  Dim $Indent					; Long-Line Breaker indent value 
  Dim $Spaces					; string of 60 spaces 
  Dim $OutBuffer				; Output Buffer for the function 
  Dim $Fs_Co,$Fe_Co				; Format string for Comments 
  Dim $Fs_St,$Fe_St				; Format string for Strings 
  Dim $Fs_No,$Fe_No				; Format string for Numbers 
  Dim $Fs_CM,$Fe_CM				; Format string for Commands 
  Dim $Fs_Fn,$Fe_Fn				; Format string for Functions 
  Dim $Fs_Ma,$Fe_Ma				; Format string for Macros 
  Dim $Fs_Op,$Fe_Op				; Format string for Operators 
  Dim $Fs_Va,$Fe_Va				; Format string for Variables 
 
  ; special character definitions 
  $1 = chr(1) $2 = chr(2) $3 = chr(3) $4 = chr(4) $5 = chr(5)
  For $I = 1 to 60
    $Spaces = $Spaces + Chr(32)
  Next
 
  ; Define special characters and number strings 
  ; $n defines numeric characters 
  ; $m defines characters not allowed in a variable name (denoting the end of a var!) 
  $T1 = "-+,.'?&=@()[]" + Chr(32) + Chr(34) + Chr(36) + Chr(9) + $1 + $2 + $3
  $T2 = "-+,'?&=@()[]" + Chr(32) + Chr(34) + Chr(36) + Chr(9) + $1 + $2 + $3
  $N  = "0123456789"
 
  ; Define the BOLD tags for each element in the table 
  ; This is an array of 2-element arrays, containing the opening and closing tags 
  for $I = 0 to UBound($B_Table)
    If $B_Table[$I]
      $B_Table[$I] = '<b>','</b>'
    Else
      $B_Table[$I] = '',''
    EndIf
  Next
 
 
  ; Format definition string for COMMENTS - k/ke 
  $Fs_Co = '<font color="' + $C_Table[0] + '">' + $B_Table[0][0]
  $Fe_Co = ' ' + $B_Table[0][1] + '</font>'
 
  ; Font definition string for STRINGS - t/te 
  $Fs_St = '<font color="' + $C_Table[1] + '">' + $B_Table[1][0]
  $Fe_St = $B_Table[1][1] + '</font>'
 
  ; Font definition string for NUMBERS - u/ue 
  $Fs_No = '<font color="' + $C_Table[2] + '">' + $B_Table[2][0]
  $Fe_No = $B_Table[2][1] + '</font>'
 
  ; Font definition string for COMMANDS - q/qe 
  $Fs_Cm = '<font color="' + $C_Table[3] + '">' + $B_Table[3][0]
  $Fe_Cm = $B_Table[3][1] + '</font>'
 
  ; Font definition string for FUNCTIONS - r/re 
  $Fs_Fn = '<font color="' + $C_Table[4] + '">' + $B_Table[4][0]
  $Fe_Fn = $B_Table[4][1] + '</font>'
 
  ; Font definition string for MACROS - p/pe 
  $Fs_Ma = '<font color="' + $C_Table[5] + '">' + $B_Table[5][0]
  $Fe_Ma = $B_Table[5][1] + '</font>'
 
  ; Font definition string for OPERATORS - o/oe 
  $Fs_Op = '<font color="' + $C_Table[6] + '">' + $B_Table[6][0]
  $Fe_Op = $B_Table[6][1] + "</font>"
 
  ; Font definition string for VARIABLES - v/ve 
  $Fs_Va = '<font color="' + $C_Table[7] + '">' + $B_Table[7][0]
  $Fe_Va = $B_Table[7][1] + '</font>'
 
  ; Init the output buffer - wrapping the content in a table preserves the original post format 
  $OutBuffer = '<table width="100%">' + '<tr>' + '<td>' + @CRLF
  $OutBuffer = $OutBuffer + '<fieldset style="' + $Border + '">' + @CRLF
  $OutBuffer = $OutBuffer + '<pre>' + $Body + @CRLF
 
 
  ; $SrcTxt contains all file text as a string.  
  ; Translate "&" to Chr(1) 
  ; Translate "<" to Chr(2) 
  ; Translate ">" to Chr(3) 
  ; Translate "" to Chr(4) 
  ; Translate "" to Chr(5) 
  ; Split into array of Lines 
  ; Hiding the replaced chars prevents treating them during the HTML processing 
  $SrcTxt = Split(Join(Split(Join(Split(Join(Split(Join(Split(Join(Split($SrcTxt,'&'),$1),'<'),$2),'>'),$3),''),$4),''),$5),@CRLF)
 
  ; determine the number of lines in the fileset data 
  $LineCt = UBound($SrcTxt)
 
 
  For $Lp = 0 to $LineCt			; process each line 
    $Line = $SrcTxt[$Lp]			; the working line 
    If $Line = '' $Line = ' ' EndIf		; Preserve blank lines 
    $Ll = len($Line)				; $Ll is the working line length 
    $Cp = 0 $Wp = 0				; initialize the pointers 
    $OBuf = '' $TBuf = ''			; Clear the buffers 
 
    Do
      $Cp = $Cp + 1 $Wp = $Wp + 1
      $C = SubStr($Line, $Cp ,1)		; get a character from the working line 
      $Tbuf = ""				; Clear the TEMP buffer 
 
      Select
 
	;====================================================================== 
        ; This process wraps formatting around DOUBLE-QUOTED STRINGS 
        Case $C = '"'				; Found a leading double-quote 
          $OBuf = $OBuf + $Fs_St + $C		; Add the STRING format code and char to Output buffer 
          Do
            If $Cp >= $Ll			; If current pointer > working line length 
              $SrcTxt[$Lp] = $OBuf		; write output string to file text array 
              $Lp = $Lp + 1			; Increment the line pointer 
              $Line = $SrcTxt[$Lp]		; get the next line 
              $OBuf = ''			; init the output buffer 
              $Cp = 0 $Wp = 0			; init the Line character pointer 
              $Ll = Len($Line)			; set the new line length 
            EndIf
            Do					; read input Line and copy to Output buffer until 
              $Cp = $Cp + 1 $Wp = $Wp + 1	; trailing quote OR end of input line is reached 
              $C = SubStr($Line, $Cp, 1)
              $OBuf = $OBuf + $C
              $Indent = WC($C, $Wp, $Line, $LLW)
              If $Indent			; Long line! Break here & indent next 
                $Wp = $Indent			; Account for the indent to setup next wrap pointer 
                $OBuf = $OBuf + @CRLF + Left($Spaces, $Indent)
              EndIf
            Until $C = '"' or $Cp >= $Ll
          Until $C = '"' or $Lp = $LineCt	; continue until trailing quote OR end of data 
          $OBuf = $OBuf + $Fe_St		; Add STRING end format code to output buffer 
 
	;====================================================================== 
        ; This process wraps formatting around SINGLE-QUOTED STRINGS 
        Case $C = "'"				; Found a leading double-quote 
          $OBuf = $OBuf + $Fs_St + $C		; Add the STRING format code and char to Output buffer 
          Do
            If $Cp >= $Ll			; If current pointer > working line length 
              $SrcTxt[$Lp] = $OBuf		; write output string to file text array 
              $Lp = $Lp + 1			; Increment the line pointer 
              $Line = $SrcTxt[$Lp]		; get the next line 
              $OBuf = ''			; init the output buffer 
              $Cp = 0 $Wp = 0			; init the Line character pointer 
              $Ll = Len($Line)			; set the new line length 
            EndIf
            Do					; read input Line and copy to Output buffer until trailing quote OR 
              $Cp = $Cp + 1 $Wp = $Wp + 1	; end of input line is reached 
              $C = SubStr($Line, $Cp, 1)
              $OBuf = $OBuf + $C
              $Indent = WC($C, $Wp, $Line, $LLW)
              If $Indent			; Long line! Break here & indent next 
                $Wp = $Indent			; Account for the indent to setup next wrap pointer 
                $OBuf = $OBuf + @CRLF + Left($Spaces, $Indent)
              EndIf
            Until $C = "'" or $Cp >= $Ll
          Until $C = "'" or $Lp = $LineCt	; continue until trailing quote OR end of data 
          $OBuf = $OBuf + $Fe_St		; Add STRING end format code to output buffer 
 
	;====================================================================== 
        ; This process wraps formatting around BLOCK COMMENTS 
        Case $C = Chr(4)			; Found an initial block comment tag 
          $OBuf = $OBuf + $Fs_co + ''		; Add the COMMENT format code and "" to Output buffer 
          Do
            If $Cp >= $Ll			; If current pointer > working line length 
              $SrcTxt[$Lp] = $OBuf		; write output string to file text array 
              $Lp = $Lp + 1			; Increment the line pointer 
              $Line = $SrcTxt[$Lp]		; get the next line 
              $OBuf = ''			; init the output buffer 
              $Cp = 0 $Wp = 0			; init the Line character pointer 
              $Ll = Len($Line)			; set the new line length 
            EndIf
            Do					; read input Line and copy to Output buffer until trailing quote OR 
              $Cp = $Cp + 1 $Wp = $Wp + 1	; end of input line is reached 
              $C = SubStr($Line, $Cp, 1)
              If $C = Chr(5)
                $OBuf = $OBuf + ''
              Else
                $OBuf = $OBuf + $C
              EndIf
              $Indent = WC($C, $Wp, $Line, $LLW)
              If $Indent			; Long line! Break here & indent next 
                $Wp = $Indent			; Account for the indent to setup next wrap pointer 
                $OBuf = $OBuf + @CRLF + Left($Spaces, $Indent)
              EndIf
            Until $C = Chr(5) or $Cp >= $Ll
          Until $C = Chr(5) or $Lp = $LineCt	; continue until trailing quote OR end of data 
          $OBuf = $OBuf + $Fe_St		; Add STRING end format code to output buffer 
 
	;====================================================================== 
        ; Wrap format codes around a COMMENT 
        Case $C = ";"				; found a comment char 
          $OBuf = $OBuf + $Fs_Co + $C		; Add the COMMENT format code and char to Output buffer 
          Do					; read input Line and copy to Output buffer until  
            $Cp = $Cp + 1 $Wp = $Wp + 1		; end of input line is reached 
            $C = SubStr($Line, $Cp, 1)
            $OBuf = $OBuf + $C
            $Indent = WC($C, $Wp, $Line, $LLW)
            If $Indent				; Long line! Break here & indent next 
              $Wp = $Indent			; Account for the indent to setup next wrap pointer 
              $OBuf = $OBuf + @CRLF + Left($Spaces, $Indent - 2) + '; '
            EndIf
          Until $Cp >= $Ll			; continue until end of line 
        $OBuf = $OBuf + $Fe_Co			; Add COMMENT end format code to output buffer 
 
	;====================================================================== 
        ; Wrap format codes around a VARIABLE 
        Case $C = Chr(36)
          Do
            $TBuf = $TBuf + $C			; add next char to TEMP buffer 
            $Cp = $Cp + 1 $Wp = $Wp + 1		; increment line pointer 
            $C = SubStr($Line, $Cp ,1)		; Get next char from input Line 
          Until InStr($T1, $C)			; until VarName terminating char is found 
          $OBuf = $OBuf + $Fs_Va + $TBuf + $Fe_Va	; add String and format codes to output buffer 
          $Cp = $Cp - 1 $Wp = $Wp - 1		; reset (decrement) line pointer 
          $TBuf = ''
 
          ; handle KForms $var.x.y type declarations 
          ; If the terminating character was a ".", read the remaining chars until another 
          ; non="." terminating char is found 
          If $C = '.'
            $Cp = $Cp + 1 $Wp = $Wp + 1		; reset (decrement) line pointer 
            Do
              $TBuf = $TBuf + $C		; add next char to TEMP buffer 
              $Cp = $Cp + 1 $Wp = $Wp + 1	; increment line pointer 
              $C = SubStr($Line, $Cp ,1)	; Get next char from input Line 
            Until InStr($T2, $C)		; until terminating char is found 
            $OBuf = $OBuf + $TBuf		; add String to output buffer 
            $Cp = $Cp - 1 $Wp = $Wp - 1		; reset (decrement) line pointer 
          $TBuf = ''
 
          EndIF
 
	;====================================================================== 
        ; Wrap format codes around a MACRO 
        ; Same process as above, except for Macros - inserts Macro format tags 
        Case $C = '@'
          Do
            $TBuf = $TBuf + $C			; add next char to TEMP buffer 
            $Cp = $Cp + 1			; increment line pointer 
            $C = SubStr($Line, $Cp ,1)		; Get next char from input Line 
          Until InStr($T1, $C)			; until VarName terminating char is found 
          $OBuf = $OBuf + $Fs_Ma + $TBuf + $Fe_Ma	; add String and format codes to output buffer 
          $Cp = $Cp - 1				; reset (decrement) line pointer 
          $TBuf = ''
 
	;====================================================================== 
        ; Wrap format codes around a NUMBER 
        Case InStr($N, $C)			; current char found in number string ($n) 
          Do
            $TBuf = $TBuf + $C			; add next char to TEMP buffer 
            $Cp = $Cp + 1			; increment line pointer 
            $C = SubStr($Line, $Cp ,1)		; Get next char from input Line 
          Until InStr($T2, $C)			; until terminating char is found (no ".") 
          $OBuf = $OBuf + $Fs_No + $TBuf + $Fe_No	; add String and format codes to output buffer 
          $Cp = $Cp - 1				; reset (decrement) line pointer 
          $TBuf = ''
 
	;====================================================================== 
        ; Terminating character found - just add to output buffer and check for long line break 
        Case InStr($N + $T1, $C)			; current char found in number string ($n) 
          $OBuf = $OBuf + $C
          $Indent = WC($C, $Wp, $Line, $LLW)
          If $Indent				; Long line! Break here & indent next 
            $Wp = $Indent			; Account for the indent to setup next wrap pointer 
            $OBuf = $OBuf + @CRLF + Left($Spaces, $Indent)
          EndIf
 
 
	;====================================================================== 
        ; Not a comment, string, macro, or variable - might be a command or function 
        Case 1
          Do
            $TBuf = $TBuf + $C			; Add char to TEMP buffer 
            $Cp = $Cp + 1 $Wp = $Wp + 1		; Increment line pointer 
            $C = SubStr($Line, $Cp ,1)		; Get next char 
          Until InStr($T1, $C)			; until number-terminating char is found 
          $Cp = $Cp - 1 $Wp = $Wp - 1		; reset (decrement) character pointer 
 
          ; Examine the TEMP buffer and apply formatting for FUNCTION or COMMAND 
          Select
 
            ; Found in list of commands - apply COMMAND format tags to output buffer 
            Case Ascan($Cm_Table, $TBuf) > -1
              $OBuf = $OBuf + $Fs_Cm + $TBuf + $Fe_Cm
 
            ; Found in list of functions - apply FUNCTION format tags to output buffer 
            Case Ascan($Fn_Table, $TBuf) > -1
              $OBuf = $OBuf + $Fs_Fn + $TBuf + $Fe_Fn
 
            ; conjunction - simply output the text 
            case $TBuf = "not" or $TBuf = "and" or $TBuf = "or" or $TBuf = "mod"
            $OBuf = $OBuf + $TBuf
 
            ; catch all - just add to output  
            case 1
              $OBuf = $OBuf + $TBuf
 
          EndSelect
 
      EndSelect
 
    Until $Cp >= $Ll				; keep processing until end of line 
 
    $SrcTxt[$Lp] = $OBuf			; write output buffer back to array 
 
  Next ; Lp 
 
 
  ; $SrcTxt is array of all file text.  
  ; Join into a single string 
  ; Translate Chr(1) to "&" 
  ; Translate Chr(2) to "&lt;" 
  ; Translate Chr(3) to "&gt;" 
  ; Hiding the replaced chars prevents treating them during the HTML processing 
  $OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&amp;'),$2),'&lt;'),$3),'&gt;')
  $OutBuffer = $OutBuffer + '</pre>' + '</fieldset>' + @CRLF
  $OutBuffer = $OutBuffer + '</td>' + '</tr>' + '</table>' + @CRLF
  $Kix2HTM = $OutBuffer
 
EndFunction
 
 
 
 
; Check for line wrap opportunity 
; $_C = current char, $_Wp = Wrap Pointer, $_LBuf = Line, $_Wf = Wrap Flag/Column # 
Function WC($_C, $_Wp, $_Lbuf, $_Wf)
 
  Dim $_Wc			; wrapping char 
  Dim $_P			; char pointer 
 
  $WC = 0
 
  ; do we have a reason to exit - wrap not enabled? Short line? Not a wrappable character? 
  If $_Wf = 0 Or $_Wp < $_Wf Or Not InStr(Chr(9) + Chr(32) + ',+-', $_C)
    Exit 0
  EndIf
 
  ; long line, wrappable char, wrap enabled! 
  ; need to check the original line and determine how far to indent, +2 
 
  $WC = 2
 
  ; find original line indent 
  $_P = 1
  While $_P < Len($_LBuf)
    $_Wc = SubStr($_Lbuf,$_P,1)
    Select
      Case $_Wc = ' '
        $WC = $WC + 1		; add a space 
      Case $_Wc = Chr(9)
        $WC = $WC + 8		; add 8 spaces 
      Case 1
        $_P = 99999		; done! 
    EndSelect
    $_P = $_P + 1
  Loop
 
  Exit 0
  
 
EndFunction
 
 
;; 
;;====================================================================== 
;; 
;;FUNCTION       KixVer() 
;; 
;;ACTION         Exits if not running minimum Kix or Beta version  
;; 
;;AUTHOR         Glenn Barnas  
;; 
;;SYNTAX         KixVer(ver [,SoftErr [,BRC]]) 
;; 
;;PARAMETERS     Minimum - Value of minimum allowable Kix version 
;;               SoftErr - Return error if non-zero, default is End Program 
;;               BRC     - Allows use of Beta or Release Candidate 
;;                         if defined and non-zero 
;; 
;;REMARKS        This function is used to insure use of proper Kix versions 
;; 
;;RETURNS        Kixtart version string if Return is set, otherwise it terminates  
;;               the script if minimum version requirement is not met. 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    NT4, W2K, WXP, W2K3 
;; 
;;EXAMPLES       KixVer(4.21,0,1)  ; requires ver 4.21, allows Beta version 
;; 
;;UPDATES        01/31/04 - fixed quotes in message 
; 
Function KixVer($_Minimum, OPTIONAL $_SoftErr, OPTIONAL $_BRC)
 
  Dim $_CVer, $_VerOK, $_MSG, $_fPtr, $_fX
  $_fPtr = 0
 
  $_CVer = Split(@KIX,' ')
  For $_fX = 0 to UBound($_CVer)
    If InStr('Kix200', Left($_CVer[$_fX],3))
      $_fPtr = $_fPtr + 1
    EndIf
  Next
 
  $_VerOK = 1              ; assume good version 
 
  If $_CVer[$_fPtr] < $_Minimum
    ; Version running is less than minimum allowed 
    $_VerOK = 0
    $_MSG = "Can't run with Outdated Kix Version!"
  Else
    ; If any commentary exists, it isn't a production version. $BRC true allows it, though. 
    If UBound($_CVer) > 0 And $_BRC = 0
      $_VerOK = 0        ; current, but not production 
      $_MSG = "Can't run with Beta or Release Candidate!"
    EndIf
  EndIf
 
  ; Prepare to return the current kixtart version 
  $KixVer = @KIX
 
  ; Minimum version was not found 
  If $_VerOK = 0
    If $_SoftErr = 0
      ; complain and terminate script if version is not acceptable 
      ; use hard print and not MSG function when terminating! 
      ? 'Version Check! Need ' + $_Minimum + ', running @KIX' ?
      $_MSG ?
      Quit 120
    Else
      Exit 120
    EndIf
  EndIf
 
  Exit 0
 
EndFunction
 
 
 
_________________________
Actually I am a Rocket Scientist! \:D

Top
#174918 - 2007-03-23 04:27 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Part 3 - Config file

#PostPrep.ini - Version 2 format
[Global]
ShowStats=Y
Border=Y
# 0 to disable, otherwise specify column # where line wrapping may occur
Wordwrap=0

[FormatTable]
CommentsColor=#578B2E
CommentsBold=1
StringsColor=#008080
StringsBold=1
NumbersColor=#B48246
NumbersBold=0
CommandsColor=#FF0000
CommandsBold=0
MacrosColor=#000000
MacrosBold=1
OperatorsColor=#CC3299
OperatorsBold=0
VariablesColor=#000000
VariablesBold=0
FunctionsColor=#930000
FunctionsBold=0

[FieldSet]
Border-Style=solid
Border-Width=2
Background-Color=#efffef
TypeFace=Courier New
FontSize=2

# New format introduced in V2.0 - the value is meaningless for postprep, but for add-ons, the
# value defined here will represent the version of KiX where the command was first available. 
# This will permit checking scripts for minimum version compatability.
[Commands]
beep=1
big=1
break=1
call=1
case=1
cd=1
cls=1
color=1
cookie1=1
copy=1
debug=1
del=1
delete=1
dim=1
display=1
do=1
each=1
else=1
endfunction=1
endif=1
endselect=1
exit=1
flushkb=1
for=1
function=1
get=1
gets=1
global=1
go=1
gosub=1
goto=1
if=1
in=1
include=1
list=1
loop=1
md=1
move=1
next=1
off=1
on=1
optional=1
password=1
play=1
preserve=1
quit=1
rd=1
redim=1
return=1
run=1
select=1
set=1
setl=1
setm=1
settime=1
shell=1
sleep=1
small=1
step=1
to=1
until=1
use=1
user=1
while=1

[Functions]
abs=1
addkey=1
addprinterconnection=1
addprogramgroup=1
addprogramitem=1
ascan=1
at=1
backupeventlog=1
box=1
cdbl=1
chr=1
cint=1
cleareventlog=1
close=1
comparefiletimes=1
createobject=1
cstr
dectohex=1
delkey=1
delprinterconnection=1
delprogramgroup=1
delprogramitem=1
deltree=1
delvalue=1
dir=1
enumgroup=1
enumipinfo=1
enumkey=1
enumlocalgroup=1
enumvalue=1
execute=1
exist=1
existkey=1
expandenvironmentvars=1
fix=1
formatnumber=1
freefilehandle=1
getcommandline=1
getdiskspace=1
getfileattr=1
getfilesize=1
getfiletime=1
getfileversion=1
getobject=1
iif=1
ingroup=1
instr=1
instrrev=1
int=1
isdeclared=1
join=1
kbhit=1
keyexist=1
lcase=1
left=1
len=1
loadhive=1
loadkey=1
logevent=1
logoff=1
ltrim=1
memorysize=1
messagebox=1
olecallfunc=1
olecallproc=1
olecreateobject=1
oleenumobject=1
olegetobject=1
olegetproperty=1
olegetsubobject=1
oleputproperty=1
olereleaseobject=1
open=1
readline=1
readprofilestring=1
readtype=1
readvalue=1
redirectoutput=1
right=1
rnd=1
round=1
rtrim=1
savekey=1
sendkeys=1
sendmessage=1
setascii=1
setconsole=1
setdefaultprinter=1
setfileattr=1
setfocus=1
setoption=1
setsystemstate=1
settitle=1
setwallpaper=1
showprogramgroup=1
shutdown=1
sidtoname=1
split=1
srnd=1
substr=1
trim=1
ubound=1
ucase=1
unloadhive=1
val=1
vartype=1
vartypename=1
writeline=1
writeprofilestring=1
writevalue=1



Edited by Glenn Barnas (2007-10-14 01:48 AM)
Edit Reason: Update for Kix 4.60
_________________________
Actually I am a Rocket Scientist! \:D

Top
#174935 - 2007-03-24 11:43 AM Re: Postprep 2 command-line [Re: Glenn Barnas]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
What a nice job !!!

but i had some little problems when I copied and pasted to my text editor (same result if I save as in .txt format).
Applying ppc.kix to itself gives a wrong result.

1) the following comment line has been broken in two lines !!!
; If the destination file wasn't specified, use the SourceFileSpec and change the extension
to ".htm"


2) in "; Set the Border directive based on the flag value", the comment line has been broken in two lines. The second line begins with an extra comma and kixtart considers the begins of the second line has an unknown command.

3) in "; Define the body settings", the correct line should be
$Body = '<font face="'
instead of
$Body = '$I = ReadProfileString($ConfigFile, 'FieldSet', 'TypeFace')

this is because of the < character

4) same as 1) in the enumini function with return nothing.
this function always returned an empty array !!!


5) at the end of Kix2HTML function, the $OutBuffer line has been broken and
there is an extra comma :
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&'),,$2),$Lc),$3),$Tc)

Correct line should be :
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&'),$2),$Lc),$3),$Tc)


With theses changes, I have a result but if I apply the new version of ppc to itself, the result is still wrong.
Point 3 should be solved by replacing < character by a variable.
Point 1, 2, 3 ou 4 seem to come from the same reason.

I continue to investigate !!!
_________________________
Christophe

Top
#174937 - 2007-03-25 10:35 AM Re: Postprep 2 command-line [Re: ChristopheM]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
Hi,

the problem is the following lines :
 Code:
If $Cp > 85 And InStr(Chr(9) + Chr(32) + ',+-/*', $C)
  $Line =  $Indent + SubStr($Line, $Cp)	; reset the line
  $Ll = Len($Line)
  $Cp = 0				; and the pointer
  $OBuf = $OBuf + @CRLF		; break the line here
EndIf


if I comment theses lines, the result is correct.
may be it is not a good thing to break a line after the 85th column !!!

first, if the line is commented (or end of line), new line should be commented.
second, when the line is broken, the last character is repeated at the beginning of the new line. Example :
 Code:
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&'),$2),$Lc),$3),$Tc)
is broken in
 Code:
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&'),
  ,$2),$Lc),$3),$Tc)


may be should replace the line
 Code:
$Line =  $Indent + SubStr($Line, $Cp)	; reset the line
with
 Code:
$Line =  $Indent + SubStr($Line, $Cp+1)	; reset the line


i think that when the line is broken, the last character has already been added to $OBuf so it doesn't need to be added to $line.
_________________________
Christophe

Top
#174940 - 2007-03-25 05:36 PM Re: Postprep 2 command-line [Re: ChristopheM]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Christope

Thanks for the feedback!!

I've updated the post, and changed how the long-line wrapping is done. It now works by checking after most characters are added to the output buffer, which fixes the clipped character. The wrap-check function evaluates the original line to determine the indent, and returns the number of chars to indent (+2) if wrapping is needed. The wrap position is now defined in the PostPrep.ini file - the WordWrap was changed from a boolean to a numeric value, indicating at/after which column wrapping should be considered.

I also removed the funky "$Lc + 'font..." type definitions by replacing the "<" and ">" chars with their HTML string equivelents.


Give the new version a go and let me know if you find any more issues.

One caveat with line wrapping - it wraps on space, tab, and these characters: ",+-/*". Since "-" is also a dash/heyphen, I'm thinking about removing that as a breakable character.

Also - when strings are broken, the resulting code may insert a CRLF in the output. The code would be more complex, but creating a "diversion" to hold the string text (with quotes" and breaking before and/or after might be better. Maybe the next release.

For now, the user should be aware that text strings may need to be "repaired" back to single lines. I'm also reviewing the HTML guide - maybe the answer is to insert HTML "soft" spaces?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#174941 - 2007-03-25 06:03 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Glenn Barnas
Also - when strings are broken, the resulting code may insert a CRLF in the output. The code would be more complex, but creating a "diversion" to hold the string text (with quotes" and breaking before and/or after might be better. Maybe the next release.
If quoted strings are broken, they should just need to have a closing quote, a concatenation +, and an opening quote on the newline to prevent a multiline embedding.

Easier said than done. :p
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#174942 - 2007-03-25 08:27 PM Re: Postprep 2 command-line [Re: Les]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
OK - that's actually very easy to accomplish - same logic as handling comments. My biggest concern is - just how much modification of the original code is "OK" for the sake of wrapping long lines?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#174946 - 2007-03-25 09:41 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
At one time, Jooel had a version of PP that included a horizontal scrollbar. With that, there was no need to break long lines at all.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#174947 - 2007-03-25 10:18 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
Hi,

one of the last change is worst than the original version.
you replace $Lc+' by '< and '+$Tc by >'.
This is not a good idea because all strings that look like HTML tag now disappear !!!

other changes seem OK.

one suggestion :
i know at least 3 special characters in HTML : <>&
at the beginning of Kix2HTM, special char are replaced with chr(1), chr(2), chr(3)
at the end of Kix2HTM, why not replace these characters with special HTML tag. I have tried to replace
 Code:
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),'&'),$2),'<'),$3),'>')
with
 Code:
$OutBuffer = $OutBuffer + Join(Split(Join(Split(Join(Split(Join($SrcTxt,@CRLF),$1),"&amp;"),$2),"&lt;"),$3),"&gt;")


The result seems better even if you let < and > in place of $Lc and $Tc !!!
_________________________
Christophe

Top
#174950 - 2007-03-26 01:44 AM Re: Postprep 2 command-line [Re: ChristopheM]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
The whole point is to allow and translate htm code. The problem was that I translated the < and > chars, but did not handle the & - this caused the < and > to be interpredted by the BBS, displaying the line as you saw it, even though that's not what the code was.

I did a compare of the .GEN file and the .HTM file and it reports that the two files are identical except for blanks. This is understandable as Kix2Htm adds a space character to every blank line to preserve formatting.

I think we're good now. (although.. I did just realize I need to add a code block to handle Block Comments.)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181589 - 2007-10-14 01:44 AM Re: Postprep 2 command-line [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Updates to the Kix2Htm UDF, as follows:
In Kix2Htm()
Added support for Block Comments

In WC()
If Not $_WF
was changed to:
If $_Wf = 0

This was done to allow the use of 0 (zero) to disable line wrapping via the WordWrap value in PostPrep.ini. The alternative was to use a very large number, such as 9999, which isn't intuitive.

Also updated the PostPrep.ini file with new function references.

Attached a ZIP file with the complete code and INI file.

Glenn


_________________________
Actually I am a Rocket Scientist! \:D

Top
#188804 - 2008-07-17 04:12 AM Re: Postprep 2 command-line [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Updates!
  • Version is now 2.1.0.0 for both GUI and C/L versions
  • GUI and C/L versions share a common code base.
  • New zip file attached to first post - PostPrep.zip - replaces PPCL.ZIP.
  • ZIP file now contains both the GUI and command-line versions, and both share a common configuration file.
  • The command-line version now supports a -W switch, which is designed to generate .HTM files from an entire folder of .KIX, .UDF, or .KXF files. This is how I publish my UDF library on my web site, automatically updated every night.
  • The GUI utilizes separate tabbed windows to display script source, HTML, and colorized preview. Launching IE is no longer required to preview the PostPrepped code.
  • Kix2HTM UDF has been updated (minor) to insert a Global var called $NOTICE, which adds a comment to the HTML indicating the method and version of PostPrep that was used. This will aid in identifying version-specific issues.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188821 - 2008-07-18 06:05 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Minor modification based on UBB post testing. Both versions will display a warning if the generated HTML is larger than 65500 characters - 64K or the current UBB post size limit. It will not affect generation of the HTML, it will only display a warning.

Updated the ZIP file in post #1.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190250 - 2008-10-22 09:14 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
now as the ubb code has been cracked to comply with long line police rules, you should edit the postprep to support it as well.
so, in the code's pre-field <pre> add the class: <pre class="ubbcode-body">
_________________________
!

download KiXnet

Top
#190254 - 2008-10-22 09:34 PM Re: Postprep 2 command-line [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Eh? will this fix the 64K posting limit?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190256 - 2008-10-22 09:38 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it will fix the too-wide-window-so-my-head-start-to-hurt - issue
_________________________
!

download KiXnet

Top
#190258 - 2008-10-23 02:32 AM Re: Postprep 2 command-line [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
The attached zip file has a README.TXT for KGen and does not appear to mention PostPrep.

Why is there a DOS console when running this?

 Code:
C:\WINDOWS\WKIX32.EXE C:\PostPrep2\postprep.kxw

Top
#190337 - 2008-10-27 07:34 PM Re: Postprep 2 command-line [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Updated first post ZIP file to version 2.1.0.2, incorporating the following changes:
  • Added html class definition: pre class="ubbcode-body"
  • Placed correct readme.txt file in the ZIP package.
  • Modification to SetOption definitions to prevent a command window from appearing in the GUI version.
  • Modified the Source window to allow manual entry/modification/pasting of Kix code.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#204822 - 2012-04-20 05:35 PM Re: Postprep 2 command-line [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I just have to say Glenn, you have so many comments in the kix2htm that I can't see any of my handywork in there anymore... not even able to tell if there is any left. makes me sad :P
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1083 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.083 seconds in which 0.058 seconds were spent on a total of 15 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org