---------------------------------------------------------------------- --- Knud van Eeden --- 06 July 2008 - 01:06 pm ----------------------- Computer: Editor: TSE: Syntax: Highlight: How to possibly convert automatically a .txt file to .syn file? [<How to>] [<Technical>] [<Published>] --- Steps: Overview: 1. -Create e.g. the following macro --- cut here: begin -------------------------------------------------- FORWARD INTEGER PROC FNFileChangeConvertSyntaxHighlightTextToSynB( STRING s1, STRING s2, STRING s3 ) FORWARD PROC Main() // --- MAIN --- // PROC Main() STRING s1[255] = "c:\WORDPROC\tse32_v44041\mac\syncfg2.mac" // change this STRING s2[255] = "c:\WORDPROC\tse32_v44041\synhi\java3.txt" // change this STRING s3[255] = "c:\WORDPROC\tse32_v44041\synhi\java3.syn" // change this // IF ( NOT Ask( "full path to syncfg2.mac = ", s1 ) ) RETURN() ENDIF // IF ( NOT Ask( "full path to text file syntax highlight definitions = ", s2 ) ) RETURN() ENDIF // IF ( NOT Ask( "full path to generated .syn file = ", s3 ) ) RETURN() ENDIF // Message( FNFileChangeConvertSyntaxHighlightTextToSynB( s1, s2, s3 ) ) // gives TRUE when no apparent errors END <F12> Main() // --- LIBRARY --- // // library: file: change: syntax: highlight: text: to: syn (filenamemacro=chanfits.s) [kn, ri, su, 06-07-2008 12:24:11] INTEGER PROC FNFileChangeConvertSyntaxHighlightTextToSynB( STRING fileNameMacroS, STRING fileNameTextS, STRING fileNameSynS ) // e.g. PROC Main() // e.g. STRING s1[255] = "c:\WORDPROC\tse32_v44041\mac\syncfg2.mac" // change this // e.g. STRING s2[255] = "c:\WORDPROC\tse32_v44041\synhi\java3.txt" // change this // e.g. STRING s3[255] = "c:\WORDPROC\tse32_v44041\synhi\java3.syn" // change this // e.g. // // e.g. IF ( NOT Ask( "full path to syncfg2.mac = ", s1 ) ) // e.g. RETURN() // e.g. ENDIF // e.g. // // e.g. IF ( NOT Ask( "full path to text file syntax highlight definitions = ", s2 ) ) // e.g. RETURN() // e.g. ENDIF // e.g. // // e.g. IF ( NOT Ask( "full path to generated .syn file = ", s3 ) ) // e.g. RETURN() // e.g. ENDIF // e.g. // // e.g. Message( FNFileChangeConvertSyntaxHighlightTextToSynB( s1, s2, s3 ) ) // gives TRUE when no apparent errors // e.g. END // e.g. // e.g. <F12> Main() // // Steps: Overview // // 1. -Supply the input: // // 1. Your full path to your Semware syncfg2.mac file // // E.g. // // "c:\WORDPROC\tse32_v44041\mac\syncfg2.mac" // // 2. Your full path to your .txt text file containing your syntax highlight definitions // (if you generate this text file e.g. from another program, e.g. concatenate a header // and lines like [KeyWords1], [KeyWords2], ... there where you want to get that colors // and save it, then that becomes the (new) input for your syntaxhighlight) // // E.g. // // "c:\WORDPROC\tse32_v44041\synhi\java3.txt" // // 3. A full path to where you want to store the resulting output .syn file // // E.g. // // "c:\WORDPROC\tse32_v44041\synhi\java3.syn" // // 2. -Run this macro // // 3. -It should output the .syn in // // edit the given text file containing the syntax highlight definitions IF ( NOT ( EditFile( fileNameTextS ) ) ) Warn( Format( "could not find input .txt file:", " ", fileNameTextS ) ) RETURN( FALSE ) ENDIF // // run the standard Semware syncfg2 macro IF ( NOT ( ExecMacro( fileNameMacroS ) ) ) Warn( Format( "could not find the syncfg2 macro:", " ", fileNameMacroS ) ) RETURN( FALSE ) ENDIF // // the resulting .syn file will be saved with a name of your choice IF ( NOT( SaveAs( fileNameSynS, _DONT_PROMPT_ | _OVERWRITE_ ) ) ) Warn( Format( "Could not save the generated .syn buffer to filename:", " ", fileNameSynS, " - e.g. check the .txt file for syntax" ) ) RETURN( FALSE ) ENDIF // // remove that .syn file from the current buffer IF ( NOT ( AbandonFile() ) ) Warn( Format( "could not remove the generated .syn buffer", " ", fileNameSynS ) ) RETURN( FALSE ) ENDIF // // remove that .txt file also IF ( NOT ( EditFile( fileNameTextS ) ) ) Warn( Format( "could not find input .txt file:", " ", fileNameTextS ) ) RETURN( FALSE ) ENDIF // IF ( NOT ( AbandonFile() ) ) Warn( Format( "could not remove the input .txt file", " ", fileNameTextS ) ) RETURN( FALSE ) ENDIF // // <source>Carlo Hogeveen</source> LinkSynFile( fileNameSynS, -1 ) // // <source>Carlo Hogeveen</source> UpDateDisplay( _ALL_WINDOWS_REFRESH_ ) // RETURN( TRUE ) END --- cut here: end ---------------------------------------------------- === Book: see also: === Diagram: see also: === File: see also: === Help: see also: === Image: see also:![]()
![]()
![]()
![]()
![]()
![]()
=== Internet: see also: === Podcast: see also: === Screencast: see also: 01.htm === Table: see also: === Video: see also: --- ----------------------------------------------------------------------