Page 2 of 2 <12
Topic Options
#204824 - 2012-04-20 06:48 PM Re: Postprep 2 command-line [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4297
Loc: New Jersey
Jooel,

It does say "Rewrite of original postprep code by Jochen Polster & Jooel Nieminen", which implies that it was rewritten from scratch based on your original code. If I recall (almost 5 years ago..), this was some of the code that gave rise to the term "Lonkenized"! \:D I rewrote it because it was hard to maintain in your "tight" style and you had become busy with some other project.

I do have the entire dev tree including versions 1.0, 1.0.3.4, and 1.3 that led to the 2.0 release if you're feeling nostalgic.

G-
_________________________
Actually I am a Rocket Scientist! \:D

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

Registered: 2001-06-05
Posts: 22339
Loc: OK
not that much. I was actually thinking about finally incorporating it to the forums as integral part so the postsize limit wouldn't be an issue no more.
_________________________
!

download KiXnet

Top
#204828 - 2012-04-20 10:59 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
do you (I don't remember did we) care about macro's?
didn't see them in the config.
_________________________
!

download KiXnet

Top
#204843 - 2012-04-21 03:30 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
something like this... I just add [postprep] tag inside code-tags and it will be prepped on the fly:
 Code:
[postprep]

;; 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
_________________________
!

download KiXnet

Top
#204844 - 2012-04-21 03:32 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
oops. didn't think about literal operands.

oh and your config.ini doesn't have mod in it.
_________________________
!

download KiXnet

Top
#204845 - 2012-04-21 03:35 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
fixed. what ya think?
_________________________
!

download KiXnet

Top
#204904 - 2012-04-23 04:48 PM Re: Postprep 2 command-line [Re: Lonkero]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 679
Loc: Maryland, USA
Glenn or Jooel,

I'm not sure if this is a function of postprep or the forum software, but it would be nice to have the "postprepped code window" no longer than x lines. Say 10 or 15. It takes a long time to scroll across all that code in order to see the next post.

Hopefully that was clear. \:\)

Regards,

Brad

Top
#204905 - 2012-04-23 04:54 PM Re: Postprep 2 command-line [Re: BradV]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
might be a feature of both.
I added some func like that into the board software.
the vertical limitation got removed cause having a too small view of the code is counter-beneficial.
horisontal scroll doesn't always work but when it does, I smile cause I know those pesky long lines in a pre-field would have otherwise killed the experience \:\)

let me see what I can do about the vertical.
10 is surely too little, but something from 15-20 should already provide a good compromise.
_________________________
!

download KiXnet

Top
#204906 - 2012-04-23 04:56 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
yea, the styles don't seem work on this one.
lets see...
_________________________
!

download KiXnet

Top
#204907 - 2012-04-23 05:16 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
ok, updated one style.
takes a while to get through them all.
anyways, now if the code is way long it is changed to scrolling.
accepted width, with possible vertical scroll: 800
accepted height, with possible horisontal scroll: 500

glenn, I modified your kix2htm() post above by adding class to the pre-tag and it fired the sizing.
we talked about this earlier, iirc.

if you agree to the sizing, add that class to the postprep, otherwise you can leave it out ;\)
_________________________
!

download KiXnet

Top
#204908 - 2012-04-23 05:22 PM Re: Postprep 2 command-line [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22339
Loc: OK
tested with IE and firefox. works with both.
_________________________
!

download KiXnet

Top
#204910 - 2012-04-23 05:31 PM Re: Postprep 2 command-line [Re: Lonkero]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 679
Loc: Maryland, USA
Ahh, much better! \:\)
Top
Page 2 of 2 <12


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

Who's Online
1 registered (Dr_Rick) and 178 anonymous users online.
Newest Members
PureKoala, 7hjd2, jswizz, Andrewpaul, emmamillathompso
17649 Registered Users

Generated in 0.036 seconds in which 0.013 seconds were spent on a total of 14 queries. Zlib compression enabled.

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