Manual for Tidycode T-Sql Formatter version 1.1.1


Contents

Manual for Tidycode T-Sql Formatter version 1.1.1
Contents
Description
How to use it
How to use it in an editor
About the use of switches
List of switches
Switches and examples
-h
-i[r] filename input file
-o filename output file (tidied up)
-io[r] filename same input and output file
--oe ext extension of output if -o is not specified
-od[r] output directory if -i is specified
-ef[r] exclude filename
-sl lineno tidy lines from this lineno on
-el lineno tidy lines up to that lineno
-t s1[,s2..] tab is equal to s1,s2.. columns
-ut[+-] use only tabs for indenting
-uts[+-] use tabs and spaces if necessary for indenting
-is size indent size in spaces (generally)
-in[+-] size indent size in spaces (generally)
-il[Level] size indent size at Level(specific)
-sit[+-] set indent sizes to tab sizes
-ctis[+-] convert tabs into spaces
-mcs mcssize maximum column width allowed
-amso[+-] allow moving statements only
-asc[+-] allow shortening comments
-amc[+-] allow moving comments
-abusc[+-] allow broken up standalone comments
-abuc[+-] allow broken up comments
-acoslc[+-] allow conversion of single line comments
-acs[+-] allow changing space
-aci[+-] allow changing indentation
-uk[+-] uppercase keywords yes/no
-ck[+-] capital keywords yes/no
-lk[+-] lowercase keywords yes/no
-ui[+-] uppercase identifiers yes/no
-ci[+-] capital identifiers yes/no
-li[+-] lowercase identifiers yes/no
-ugv[+-] uppercase global variables yes/no
-cgv[+-] capital global variables yes/no
-lgv[+-] lowercase global variables yes/no
-ulv[+-] uppercase local variables yes/no
-clv[+-] capital local variables yes/no
-llv[+-] lowercase local variables yes/no
-ul[+-] uppercase labels yes/no
-cl[+-] capital labels yes/no
-ll[+-] lowercase labels yes/no
-clb[+-] column like lists inside brackets
-c[+-] compactify, remove redundant spaces/keep
-co[+-] remove spaces around operations (+,- etcdo /nothing)
-sao[+-] add space around operations/do nothing
-rsaob[+-] remove spaces after opening brackets/keep
-rsbcb[+-] remove spaces before closing brackets/keep
-ncb[+-] don't remove spaces around brackets/do nothing
-rs[+-] keep the relative indentation of a sql/do nothing
-id[+-] indent after declarations yes/no
-iacw[+-] indent after when in case statement yes/no
-iac[+-] indent after cursor yes/no
-isc[+-] indent standalone comments
-isc2[+-] indent standalone comments in special cases too
-iic[+-] indent inside comments/do nothing
-iibe[+-] indent inside begin/end block
-ibe[+-] indent begin/end keyword in if/while
-ni[+-] nice indents
-iiie[+-] indent if in else
-actv[+-] align consecutive types in declarations vertically
-ps size padding size, number of spaces between variables and types
-actvct[+-] align consecutive types in create table-s vertically
-acav[+-] align consecutive assignments (=) vertically
-acev[+-] align consecutive equalities (=) vertically
-acarv[+-] align consecutive arrows (=>) vertically
-aav[+-] align aliases vertically
-pcr[+-] put commas right
-as[+-] align selects
-au[+-] align updates
-aaw[+-] align after where clauses
-ac[+-] align conditions
-aroa[+-] align right of assignments
-aak keyword
-kpit[+-] keep (procedure)/(as) together
-kwtt[+-] keep when/then together
-tblas[+-] treat blank lines as separators
-cif[+-] comments in front
-sbi[+-] show block information after the end of blocks
-sbi.ml lines show it for blocks that have at least minimum lines
-sbi.m string marker string to use to denote end of block information
-sbi.max chars maximum characters to show from the start of the block
-rbi+
-pius[+-] put 'into' under select
-bus[+-] break up sql statements
-bbj[+-] break before joins
-isis size indentation size (in spaces) in Sql clauses,-ins+,iu+ and iaw+
-rask[+-] right-align sql keywords
-buml[+-] break up multistatement lines
-plouwh[+-] put logical operations under where/having
-si identifier/keyword set identifier to look like identifier
-milipl no minimum list items per line
-mlipl no maximum list items per line
-rael remove all empty lines
-mlacd[+-] maintain a linebreak after cursor declarations
-mlai[+-] maintain a linebreak after each if
-mlaw[+-] maintain a linebreak after each while loop
-mlafu[+-] maintain a linebreak after function names
-mlapr[+-] maintain a linebreak after procedure
-rlacd[+-] remove linebreaks after each cursor declaration
-rlai[+-] remove linebreaks after each if
-rlaw[+-] remove linebreaks after each while loop
-rlapr[+-] remove linebreaks after procedure
-dbvn[+-] declaration based variable names
-cmk[+-] check for missing keywords
-x
-b maxvers number of backup versions to keep
-bdir directory
-v
-sf[+-] show filenames in block stack
-rl[+-] reverse listing of block stack
-sr[+-] show the result of formatting
-ss[+-] show the summary of multiple file formatting
-ls filename load settings/switches from a file
-ae ext accept files with ext only
-sw[+-] show switches
-sdw show default switches
-swc show switches compactly
-0 sets all switches to off
-alll+ set all formatting switches on and left-aligned sql
-allr+ set all formatting switches on and right-aligned sql
-lsql[+-] left-aligned sql
-rsql[+-] left-aligned sql
-alol[+-] at least one linebreak after blocks and elsewhere
-ol+-] one linebreak after blocks and elsewhere
-html[+-] set the format of output to html
-ht html template filename
-tag\[token type\] tag sequence :sets what tags to use for each token.
-pl[+-] prepend logo
-plo[+-] prepend logo only
-mte[+-] multithreaded execution for multiple files
-gsfif[+-] get switches from input file
-soe[+-] stop on errors
-w[+-] show warnings
-rla.. remove linebreaks after ... type of switches
Changing default options
Line endings
Backing up
Syntax checking
Return code of the software
Safety measures
License
Credits

Description

This software allows you to tidy/beautify/format your T-Sql code in a batch file or Dos prompt.
This is a command line tool that gives you the freedom to build it in your programming environment. You can use it in your favorite editor easily.

How to use it

Goto to the installation directory and enter in dos:
ttsf -h
for the options and help,

How to use it in an editor

In a regular editor, there are user definable tools. Set a tool to execute ttsf.
Make sure that the working directory is the same as the installation directory. Otherwise, it won't work.

E.g. Ultraedit
Command line : ttsf -io %F
Working directory: d:\ttsf

E.g. Microsoft Sql Server Management Studio
Use menu tools/external tools.
Title: Tidycode T-Sql Formatter
Command: <install dir>\ttsf.exe
Arguments: -io $(ItemPath)
Check Use Output Window.


About the use of switches

Incorrect switches are simply ignored. You are informed about that.
Incompatible switches are allowed. The switches that come later will override earlier ones.

There are 3 types of switches:
-with no value (-h,-v)
-with 2 possible values (-rs+,-rs-)
-with many possible values (-i,-o..)

Many switches are already "on" by default. Therefore the software may not work out as you expect.
Take these into account when using switches.

Here is the list:
-in+ -uk+ -c+ -rsaob+ -co+ -ncb+ -rs+  -iacw+ -iac+ -clb+ -iibe+  -ibe+ -soe+ -sf+ -rl+ -sr+

There are switches that set a number of switches. They are categorized as styles. 
See them here

List of switches

Switch/option

Meaning

-i[r] inpsrc input source can be:a filename,stdin,globbing [recursively]
-o outdest output destination can be:a filename,stdout
-io[r] filename same input and output file [recursively]
-oe ext extension of output if -(i)o is not specified
-od[r] dir output directory [recursive mode]
-ef[r] filename exclude filenames from formatting [recursively]
-sl lineno read input from this line (don't use lines before)
-el lineno don't use input after this line
-t s1[,s2..] tab is equal to s1,s2.. columns
-ut[+-] use only tabs for indenting
-uts[+-] use tabs and spaces if necessary for indenting
-is size(t) indent size in spaces or in tabs (generally)
-in[+-] indent lines yes/no
-il[Le] size(t) indent size in spaces or in tabs at (Le)vel(specific)
-sit[+-] set indent sizes to tab sizes
-ctis[+-] convert tabs into spaces
-uk[+-] uppercase keywords yes/no
-ck[+-] capital keywords yes/no
-lk[+-] lowercase keywords yes/no
-li[+-] lowercase identifiers
-ui[+-] uppercase identifiers
-ci[+-] capitalised identifiers
-lgv[+-] lowercase global variables
-ugv[+-] uppercase global variables
-cgv[+-] capitalised global variables
-llv[+-] lowercase local variables
-ulv[+-] uppercase local variables
-clv[+-] capitalised local variables
-ll[+-] lowercase labels
-ul[+-] uppercase labels
-cl[+-] capitalised labels
-si ident set identifiers to look like ident
-mcs size maximum allowed size of columns
-amso[+-] allow moving statements only
-asc[+-] allow shortening comments
-amc[+-] allow moving comments
-abusc[+-] allow broken up standalone comments
-abuc[+-] allow broken up comments
-acoslc[+-] allow conversion of single line comments
-aci[+-] allow changing indentation
-acs[+-] allow changing space
-c[+-] compactify, remove redundant spaces/keep
-co[+-] remove spaces around operations (+,- etcdo nothing/)
-sao[+-] add space around operations/do nothing
-rsaob[+-] remove spaces after opening brackets/keep
-rsbcb[+-] remove spaces before closing brackets/keep
-ncb[+-] don't remove spaces around brackets/do nothing
-rs[+-] keep the relative identation of an allowed sql/do nothing
-id[+-] extra indentation for declarations yes/no
-iacw[+-] extra indentation after case when yes/no
-iac[+-] extra indentation after cursor yes/no
-isc[+-] indent standalone comments
-isc2[+-] indent standalone comments in some special cases too
-iic[+-] indent inside comments/do nothing
-iibe[+-] indent inside begin/end block
-ibe[+-] indent begin/end keyword in if/while
-ni[+-] nice indents
-iiie[+-] indent or do not indent if in else
-clb[+-] column like lists inside brackets
-actv[+-] align consecutive types in declarations vertically
-ps size padding size, number of spaces between variables and types
-acav[+-] align consecutive assignments (=) vertically
-acev[+-] align consecutive equalities (=) vertically
-acarv[+-] align consecutive arrows (=>) vertically
-pcr[+-] put commas right
-as[+-] align selects
-au[+-] align updates
-aaw[+-] align after where clauses
-ac[+-] align conditions in IF/WHILE
-aroa[+-] align right of assignments
-aak keyword align after keyword
-pius[+-] put 'into' under select
-plouwh[+-] put logical operations under where/having
-bus[+-] break up sql statements
-rask[+-] right align sql keywords
-actvct[+-] align consecutive types in create table-s vertically
-aav[+-] align aliases vertically
-bbj[+-] (line)break before joins
-isis size indentation size (in spaces) in Sql clauses
-ins[+-] extra indentation after selects
-iu[+-] extra indentation after updates
-iaw[+-] extra indentation after where clauses
-milipl no minimum list items per line
-mlipl no maximum list items per line
-buml[+-] break up multistatement lines
-rael[+-] remove all empty lines
-mlapcd[+-] maintain a linebreak after cursor declarations
-rlapcd[+-] remove linebreaks after cursor declarations
-mlai[+-] maintain a linebreak after each if
-rlai[+-] remove linebreaks after each if
-mlaw[+-] maintain a linebreak after each while loop
-mlafu[+-] maintain a linebreak after function names
-mlapr[+-] maintain a linebreak after each procedure
-rlapr[+-] remove linebreaks after procedure
-dbvn[+-] declaration based variable names
-kpit[+-] keep procedure and as together
-kwtt[+-] keep when/then together
-tblas[+-] treat blank lines as separators
-cif[+-] comments in front,belong to statements following them
-sbi[+-] show block information after the end of blocks
-sbi.ml lines show it for blocks that have at least minimum lines
-sbi.m string marker string to use to denote end of block information
-sbi.max chars maximum characters to show from the start of the block
-rbi[+-] remove block information after the end of blocks
-cmk[+-] check for missing keyword [then]
-x print the configuration and does not format
-v verbose , same as -x but it will tidy
-sf[+-] show filenames in block stack
-rl[+-] reverse listing of block stack
-sr[+-] show the result of formatting
-ss[+-] show the summary of multiple formatting
-b maxvers number of backup versions to keep
-bdir dir location of the backup directory
-ls filename load settings/switches from a file
-gsfif[+-] get switches from input file
-ae ext accept files with ext only
-sw[+-] show switches in effect
-sdw show default switches
-swc show switches compactly
-0 sets all switches to off
-pl[+-] prepend logo and formatting info to the output file
-plo[+-] prepend logo only
-mte[+-] multithreaded execution for multiple files
-w[+-] show warnings/potential problems in code
-al[+-] set all formatting switches on and left-aligned sql
-ar[+-] set all formatting switches on and right-aligned sql
-ai[+-] set all formatting switches on and indent in sql
-lsql[+-] left-aligned sql
-rsql[+-] right-aligned sql
-isql[+-] indent in sql
-alol[+-] at least one linebreak after blocks and elsewhere
-ol[+-] one linebreak after blocks and elsewhere
-html[+-] format of output is html
-ht filename filename of html template
-tag\\[type\\] tags use html tags for token type
-h this help

Switches and examples

-h

lists you all possible switches you can use.

-i[r] filename input file

This is the filename of scripts to tidy.
If the filename is stdin, the program uses the standard input as a source.
If the filename is clipboard, the clipboard is used as a source.
It is possible to use globbing instead of exact filenames.
This switch can be repeated multiple times. In that case, multiple files will be formatted.
-ir causes the formatter to look for files recursively in the subdirectories of filename that match the globbing.

E.g. ttsf -ir=*.sql

E.g. ttsf -i=h.sql
E.g ttsf -i stdin
ttsf -i *.sql -i exception.srt

-o filename output file (tidied up)

This is the resultant file of the formatting.

If the filename is stdout, the program uses the standard output as a destination.
If the filename is clipboard, the program puts the output in the clipboard.
E.g. ttsf -i=h.sql -o=h2.sql
E.g ttsf -i stdin -o stdout

-io[r] filename same input and output file

This is a shortcut for -i and -o.

-ior causes the formatter to look for files recursively in the subdirectories of filename as well.
E.g. ttsf -io=h.sql
ttsf -ior=*.bdy

--oe ext  extension of output if -o is not specified


E.g. ttsf -i=h.sql -oe .bdy
It will produce a file h.bdy.

Using + appends the extension to the name of the generated file instead of replacing it.

E.g. ttsf -i=h.sql -oe +.bdy
It will produce a file h.sql.bdy

-od[r] output directory if -i is specified

By default, the output directory is the same is as the input directory given by -i switch.
-od sets the output directory. 

If -ir is used, -od will not follow or create the corresponding subdirectories ,nor will it copy the files recursively. Instead, all files will go to the output directory. The directory structure will be "flattened".  However, -odr will follow and create corresponding subdirectories that exist in the source. -odr is natural pair of -ir.

-od[r] can be used once effectively. If it is repeated in the command line, its previous instances will be ignored, only the last one will be used.

E.g. ttsf -i=c:\source\h.sql -od d:\temp
It will produce a file d:\temp\h.bdy.  Temp directory needs to exist.

-ef[r] exclude filename

It will remove the list of files given by -i,-io switches matching filename.
This switch works only if all filenames have the same path format when using -i,-io or -ef.
The path format should be full path or no path or the same relative path format.
-efr causes the formatter to look for files recursively in the subdirectories of filename too.

E.g. ttsf -i=c:\source\*.sql -ef c:\source\d*.sql

It will format all files in the c:\source directory excluding those which match d*.sql

E.g. ttsf -i=*.sql -ef d*.sql -ef test.sql
ttsf -ir=*.sql -efr d*.sql

-sl lineno tidy lines from this lineno on

The resultant file will not contain lines before line lineno of the original file.

E.g. ttsf -i=h.sql -sl 4

-el lineno tidy lines up to that lineno

The resultant file will not contain lines after the line lineno of the original file.

E.g. ttsf -i=h.sql -sl 2000


-t s1[,s2..] tab is equal to s1,s2.. columns

Specify the column sizes of tab character.

E.g. ttsf -io=h.sql -t 4

-ut[+-] use only tabs for indenting

At the beginning of each line only tab character (9 in ascii) will be used to position code approximately as defined by  -t.-is,-il switches.

-uts[+-] use tabs and spaces if necessary for indenting

At the beginning of each line tab character (9 in ascii) and spaces will be used to position code accurately as defined by  -t.-is,-il switches.
Spaces are used only if necessary.
So any line can look like : <tab> anytimes (0..) <space> anytimes (0..)

-is size indent size in spaces (generally)

Probably it is one of the most important switches.

E.g. ttsf -io=h.sql -is 3

-in[+-] size indent size in spaces (generally)

It affects if the beginning of each line is indented according to block level.

E.g. ttsf -io=h.sql -is 3

-il[Level] size indent size at Level(specific)

Level refers to how many spaces of indentation precedes a given line of code. The code inside a loop is more indented than the code before the loop.
Statements that make the level of code higher/more indented :
packages, functions, procedures,loops, if , begin, when(optional), cursor (optional),
The size is in spaces. Use more of this switch, if you want to set more than 1 level.

E.g. ttsf -io=h.sql -is 3 -il1 2 -il2 4

-sit[+-] set indent sizes to tab sizes

Indent size and tab column size don't need to be the same but it is often desirable if they are the same.

This switch sets indent size (which they would be specified by -is, il) to tab column sizes.

E.g. ttsf -io=h.sql -t 3 -sit

-ctis[+-] convert tabs into spaces

It converts non-leading tabs into spaces with the exception of multiline comments.

For them, leading tabs may be converted too if they span multiple lines.

-mcs mcssize maximum column width allowed

If a line is longer than mcssize columns,  it will be shortened using different methods.

The methods:

-splitting the line by tokens(-ams-) or statements (-ams+), so it becomes shorter
-removing redundant * or - in case of /*****/ and --------- line if -asc is on.
-comments can be moved into next line if -amc is on.
-standalone comments are broken up on words if -abusc is on
-comments are broken up on words if -abuc is on 

E.g. ttsf -io=h.sql -mcs 80

Original

/*********/
/**unit  start***/
------------
/*one two*/
begin/***/
set @a=5+2;
end
Tidied
-mcs 5
/***/
/**unit start*/
-----
/*one
two*/
begin
/***/
set @a
=5+2;
end

-amso[+-] allow moving statements only

It influences the effect of -mcs.  If it is on, the splitting of lines is only allowed at statement boundaries.
In other words, it turns on "statement-wrapping". Otherwise, there/default is "token-wrapping".
This switch has no effect on wrapping of some basic sql statements. They are always token-wrapped.
This switch will not move comments in itself unless -amc is on.

Original

set @a=4 set @b=5;
Tidied
-mcs 7
-amso+
set @a:=4
set @b:=5;

-asc[+-] allow shortening comments

It influences the effect of -mcs.  If it is on, *-s or - can be removed from a comment to make it shorter.

Original

set @a=4; /******/
Tidied
-mcs 13
-asc+
set @a=4;/**/

-amc[+-] allow moving comments

It influences the effect of -mcs.  If it is on, a comment can be moved into next line to make a line shorter.

Original

set @a:=4;/******/
Tidied
-mcs 9
-amc+
set @a=4
/******/

-abusc[+-] allow broken up standalone comments

It modifies the effect of -mcs.   If it is on, a standalone comment can be broken up on words to make a line shorter.
In other words, it turns on word-wrapping for standalone comments.

Original

/* my long comment*/
Tidied
-mcs 5
-abusc+
/* my
long
comment*/

-abuc[+-] allow broken up comments

It modifies the effect of -mcs.   If it is on, a comment can be broken up on words to make a line shorter.
In other words, it turns on word-wrapping for comments.

Original

set @e=@e*4;/* my long comment*/
Tidied
-mcs 18
-abux+
set @e=@e*4; /* my
long
comment*/

-acoslc[+-] allow conversion of single line comments

It modifies the effect of -mcs.   If this and-abuc/-abusc are on, a single line comment can be converted into a multiline comment. In this way, single line comments can be also word-wrapped.

Original

--my long comment too long
Tidied
-mcs 5
-acoslc+
-abusc+
/* my
long
comment
too
long*/

-acs[+-] allow changing space

It modifies the effect of -mcs.   If -acs is on, the number of spaces before an item that causes a line to be too long can be reduced in order to make a line shorter. It can affect indentation too beside not indenting spaces.


Original

begin
   set @f=5
end
Tidied
-mcs 8
-acs+
begin
set @f=5
end

-aci[+-] allow changing indentation

It modifies the effect of -mcs.   If -acs is on, indentation can be reduced  in order to make a line shorter.

Original

begin
   set @f=5
end
Tidied
-mcs 8
-aco+
begin
set @f=5
end

-uk[+-] uppercase keywords yes/no

All keywords will be converted into uppercase letters. (BEGIN IF VARCHAR)

E.g. ttsf -io=h.sql -uk+

-ck[+-] capital keywords yes/no

All keywords will be capitalized. (Begin If Varchar)

E.g. ttsf -io=h.sql -ck+

-lk[+-] lowercase keywords yes/no

All keywords will be converted into uppercase letters (begin if varchar) 

-ui[+-] uppercase identifiers yes/no

Default state:off.
All identifiers will be converted into uppercase letters. (open TERRA5)
Identifiers are defined as those identifiers which are not keywords,labels or variables.

E.g. ttsf -io=h.sql -ui+

-ci[+-] capital identifiers yes/no

Default state:off.
All identifiers will be capitalized. (open Terra5)
Identifiers are defined as those identifiers which are not keywords,labels or variables.

E.g. ttsf -io=h.sql -ci+

-li[+-] lowercase identifiers yes/no

Default state:off.
All keywords will be converted into lowercase letters. (open terra5)
Identifiers are defined as those identifiers which are not keywords,labels or variables.

E.g. ttsf -io=h.sql -li+


-ugv[+-] uppercase global variables yes/no

Default state:off.
All global variables will be converted into uppercase letters. (@@IDENTITY)

E.g. ttsf -io=h.sql -ugv+

-cgv[+-] capital global variables yes/no

Default state:off.
All global variables will be capitalized. (@@Identity)

E.g. ttsf -io=h.sql -ccgv+

-lgv[+-] lowercase global variables yes/no

Default state:off.
All global variables will be converted into lowercase letters. (@@identity)

E.g. ttsf -io=h.sql -lgv+


-ulv[+-] uppercase local variables yes/no

Default state:off.
All local variables will be converted into uppercase letters. (@TERRA5)

E.g. ttsf -io=h.sql -ulv+

-clv[+-] capital local variables yes/no

Default state:off.
All local variables will be capitalized. (open Terra5)

E.g. ttsf -io=h.sql -clv+

-llv[+-] lowercase local variables yes/no

Default state:off.
All local variables will be converted into lowercase letters. (@terra5)

E.g. ttsf -io=h.sql -llv+


-ul[+-] uppercase labels yes/no

Default state:off.
All labels will be converted into uppercase letters. (TERRA5:)

E.g. ttsf -io=h.sql -ul+

-cl[+-] capital labels yes/no

Default state:off.
All labels will be capitalized. (Terra5:)

E.g. ttsf -io=h.sql -cl+

-ll[+-] lowercase labels yes/no

Default state:off.
All labels will be converted into lowercase letters. (terra5:)

E.g. ttsf -io=h.sql -ll+


-clb[+-] column like lists inside brackets

E.g. ttsf -io=h.sql -clb+

this:

set @a = (a + 1
+ 4
+ 5
+ 8);
will become that:
set @a = (a + 1
+ 4
+ 5
+ 8);

-c[+-] compactify, remove redundant spaces/keep

E.g. ttsf -io=h.sql -c+

Original

procedure h     as

Tidied

procedure h as

-co[+-] remove spaces around operations (+,- etcdo /nothing)

E.g. ttsf -io=h.sql -co+

Original

set @d= 5 + 7;

Tidied

set @d=5+7;


-sao[+-] add space around operations/do nothing

E.g. ttsf -io=h.sql -co- -sao+

Original

set @d=5+7;

Tidied

set @d = 5 + 7;


-rsaob[+-] remove spaces after opening brackets/keep

Original

ttsf -io=h.sql -rsaob-

( SELECT g,quality FROM duality
WHERE g =5)

Tidied

ttsf -io=h.sql -rsaob+

(SELECT g,quality FROM duality
WHERE g = 5)


-rsbcb[+-] remove spaces before closing brackets/keep

Original

tpsf -io=h.sql -rsbcb-l

FOR rec IN (SELECT g,quality FROM duality
WHERE g =5    )

Tidied

tpsf -io=h.sql -rsbcb+

FOR rec IN (SELECT g,quality FROM duality
WHERE g = 5)

-ncb[+-] don't remove spaces around brackets/do nothing


Original  ttsf -io=h.sql -ncb-

set @res=(SELECT * FROM duality
WHERE g =5)

Tidied ttsf -io=h.sql -ncb+ set @res=(SELECT * FROM duality
WHERE g = 5)


-rs[+-] keep the relative indentation of a sql/do nothing

If it is on, the indentation (relative to the start of sql) of each line of a select statement will be kept as much as possible.

Original
ttsf -io=h.sql -rs+

select *
from memory
where year>1786


Tidied
ttsf -io=h.sql -rs-

select *
from memory
where year>1786

-id[+-] indent after declarations yes/no


Original
ttsf -io=h.sql -id-

declare
@b float=5,
@d456 float=456;

Tidied
ttsf -io=h.sql -id+

declare
   @b float:=5;
   @d456 float:=456;



-iacw[+-] indent after when in case statement yes/no


Original
ttsf -io=h.sql -iacw-

CASE opinion
  WHEN '9' THEN
  dbms_output.put_line('Excellent');
  WHEN '5' THEN dbms_output.put_line('Poor');
  ELSE dbms_output.put_line('cannot decide');
END CASE;   


Tidied
ttsf -io=h.sql -iacw+

CASE opinion
  WHEN '9' THEN      

    dbms_output.put_line('Excellent');
  WHEN '5' THEN dbms_output.put_line('Poor');
  ELSE dbms_output.put_line('cannot decide');
END CASE;

-iac[+-] indent after cursor yes/no

 Cursor statements (except their first line) will have an extra indent level/extra indentation.

Original
ttsf -io=h.sql -iac-

DECLARE B CURSOR FOR
SELECT * FROM taxpayers;

Tidied
ttsf -io=h.sql -iac+

DECLARE B CURSOR FOR
  SELECT * FROM taxpayers;


-isc[+-] indent standalone comments

If it is on, single line comments that start a line are indented as everything else.
If it is off, they are not touched.
Original
ttsf -io=h.sql -isc-
begin
/*hello  Sql*/
  set @low=4+4
-- end of little block
end;
Tidied
ttsf -io=h.sql -isc+
begin
  /*hello  Sql*/
  set@low=4+4
  -- end of little block
end;

-isc2[+-] indent standalone comments in special cases too

These are the special cases: sql statements,lists,alignments and other.

Original
ttsf -io=h.sql -isc2-
begin
insert into l16 (C,L,L,L) values (
         /*added by me*/@cl);
end
Tidied
ttsf -io=h.sql -isc2+
begin
  insert into l16 (C,L,L,L) values (
                                                  /*added by me*/@cl);
end

-iic[+-] indent inside comments/do nothing

If it is on, it will indent text inside /*..*/

-iibe[+-]      indent inside begin/end block

It is on by default.  BEGIN/END blocks will have an extra indent level/extra indentation.

Original
ttsf -io=h.sql -iibe-

BEGIN
set @s=select star from sky
where star=(select star
from catalogue
where r>3
and brightness>5
);

END

Tidied
ttsf -io=h.sql -iibe+
BEGIN
   
set @s=select star from sky
    where star=(select star
    from catalogue
    where r>3
    and brightness>5
    );
END

-ibe[+-]     indent begin/end keyword in if/while

It is on by default.  BEGIN/END keyword will have the same amount of indentation as the body of if or while.

Original
ttsf -io=h.sql -ibe-

IF @res=0
BEGIN
  set @s=select star from sky
  where star=(select star
  from catalogue
  where r>3
  and brightness>5
  );
END

Tidied
ttsf -io=h.sql -ibe+
IF @res=0
  BEGIN
   
set @s=select star from sky
    where star=(select star
    from catalogue
    where r>3
    and brightness>5
    );
  END

-ni[+-] nice indents

Without this option, the first "end" in the following example would be located more to the left side of the second "if" producing a less nice code. In this case, "end" is located under "if".


Original
ttsf -io=h.sql -nl-

if s=1 IF (record_exists = yes_flag)
            THEN
            set @a=3;
end            
end
         

Tidied
ttsf -io=h.sql -nl+

IF s=1 IF (record_exists = yes_flag)
         a:=3;
       END
END

-iiie[+-] indent if in else

It will indent if statement in else part of an if.


Original
ttsf -io=h.sql -iiie-


if a
 null;
else
if b
 null;
 

Tidied
ttsf -io=h.sql -iiie+

if a
 null;
else
  if b
   null;
 

-actv[+-] align consecutive types in declarations vertically

In declarations, spaces are put in between a variable and its type so that types will form a column.

Original
ttsf -io=h.sql -actv-

@d int=5,
@ertr varchar='5'

Tidied
ttsf -io=h.sql -actv+

@d    int=5,
@ertr varchar='5';

-ps size padding size, number of spaces between variables and types

It is meaningful only if -actv+ or -aav+ are used too. 


Original
ttsf -io=h.sql -actv-

declare

@d int=5,
@ertr varchar(4)='5'

Tidied
ttsf -io=h.sql -actv+ -ps 2

declare

@d     int:=5;
@ertr  varchar(4)='5';

-actvct[+-] align consecutive types in create table-s vertically

In CREATE TABLE statements, spaces are put in between a field and its type so that types will form a column.

Original
ttsf -io=h.sql -actvct-

create table listofjobs
(
name varchar(70),
location
varchar(411)

);

Tidied
ttsf -io=h.sql -actvct+

create table listofjobs
(
name     varchar(70),
location
varchar(411)

);

-acav[+-] align consecutive assignments (=) vertically

If assignments follow each other in each line,  they will be aligned vertically.
It does not have any effect on lines containing more than one assignments.

Original
ttsf -io=h.sql -acav-

set @derival=0;
set @d=1;

SET @derival=0;
SET @d        =1;

-acev[+-] align consecutive equalities (=) vertically

If  equality operators follow each other in each line,  they will be aligned vertically.
It does not have any effect on lines containing more than one equality.

Original
ttsf -io=h.sql -acev-

where myownname = 'richard' and
      tabname = 'nt';

Tidied
ttsf -io=h.sql -acev+

where myownname = 'richard' and
      tabname   = 'nt';

-acarv[+-] align consecutive arrows (=>) vertically

If arrows follow each other in each line,  they will be aligned vertically.
It does not have any effect on lines containing more than one arrow.

Original
ttsf -io=h.sql -acarv-

call_now(myownname => USER,
         tabname => 'nt');

Tidied
ttsf -io=h.sql -acarv+

call_now(myownname => USER,
         tabname   => 'nt');


-aav[+-] align aliases vertically

If aliases follow each other in consecutive lines,  they will be aligned vertically.
Aliases may be detected after select and from keyword.
It does not have any effect on lines containing more than one alias.
In itself it may produce strange results. It shows its value if it is used with -as+ at least.

Original
ttsf -io=h.sql -aav-

select name dubbed,
emot emotion,
c "alias",
e2  "alias2",
ffff,
gg 4
from table122 a,
table2 b 

Tidied
ttsf -io=h.sql -as+ -aav+

SELECT name dubbed,
               emot  emotion,
               c       "alias",
               e2     "alias2",
               ffff,
               gg 4
FROM table122 a,
            table2     b  

-pcr[+-] put commas right

It moves commas to the right side if they are at the beginning of a line.

Original
ttsf -io=h.sql -pcr-

create PROCEDURE myerr(
   /* arguments*/
--msg ..
--msg2 ..
                ,msg VARCHAR
                ,msg2 VARCHAR)

Tidied
ttsf -io=h.sql -pcr+

create PROCEDURE myerr(
   /* arguments*/
--msg ..
--msg2 ..
                msg VARCHAR,
                msg2 VARCHAR)

-as[+-] align selects

As variables are declared, so they will look elsewhere. This option is not compatible with
uppercase,lowercase,capitalized identifier switch. Those will override this option.
It also affects the naming of cursors. They are included as if they were variables.

Original
ttsf -io=h.sql 

select e,j
from tablea,
tableb
where f1>f2
and f4=9;

Tidied
ttsf -io=h.sql -as+

select e,j
from tablea,
     tableb
where f1>f2
      and f4=9;

-au[+-] align updates

Within updates, non-keywords are left-aligned.

Original
ttsf -io=h.sql 

update t
set g=56,
i=3;

Tidied
ttsf -io=h.sql -au+

update t
set g=56,
    i=3; 

-aaw[+-] align after where clauses

It also aligns after having clauses.

Original
ttsf -io=h.sql 

where f1>f2
and f4=9;

Tidied
ttsf -io=h.sql -aaw+

where f1>f2
      and f4=9;

-ac[+-] align conditions

It affects if/while/elsif/when conditions. Conditions will be left-aligned after a starting keyword.

Original
ttsf -io=h.sql 

if u>2
and b!=4
  print 9;
 
  

Tidied
ttsf -io=h.sql -ac+

if u>2
   and b!=4
  print 9;

-aroa[+-] align right of assignments

Everything after an assignment = will be left- aligned until the end of statement .

Original
ttsf -io=h.sql 

set @a=@b
+@c;   

Tidied
ttsf -io=h.sql -aroa+

set @a=@b
       +@c; 

-aak keyword

Everything after the keyword will be left- aligned until the end of statement .

E.g. ttsf -io=h.sql -aak set -aak exec

Original
ttsf -io=h.sql 

set @a=@b
+@c;   

Tidied
ttsf -io=h.sql -aak set

set @a=@b
    +@c; 

-kpit[+-] keep (procedure)/(as) together

Redundant whitespace are removed between the last ) of a procedure header and is.
E.g. ttsf -io=h.sql -kpit+

Original

create procedure  printtable
AS
begin

Tidied

package printtabe AS
begin

-kwtt[+-] keep when/then together

This affects when/then in exceptions,insert statements and in case statements.

E.g. ttsf -io=h.sql -kwtt+


Original

CASE
                 WHEN v IS NULL
        THEN NULL

Tidied

CASE
           WHEN FAC_ORDER.CORE_COMPLETED_DATE IS NULL THEN NULL

-tblas[+-] treat blank lines as separators

Blank lines will act as statement separators. Note : similar effect can be achieved by using semicolon instead.
It can be useful to prevent indentation of comment that may be indented as the statement before them.
There are three way of solving that problem. Using this switch, using semicolon or -cif switch.

E.g. ttsf -io=h.sql -tblas+

-cif[+-] comments in front

Comments in front will be indented as the statements that come after them.

E.g. ttsf -io=h.sql -cif+


Tidied
-cif-
begin
  if @u<16
    set @c=4
    -- end
end


Tidied
-cif+
begin
  if @u<16
    set @c=4
-- end
end

-sbi[+-] show block information after the end of blocks

-sbi.ml lines  show it for blocks that have at least minimum lines

-sbi.m string  marker string to use to denote end of block information

-sbi.max chars maximum characters to show from the start of the block

The 4 headings above have this one description.
sbi switch inserts a comment/description after each end of block statement that describes the block. The description identifies the block. It has 3 subswitches that help refine when the description appears and how long it can be. -sbi.ml sets the size of block in lines below which no description is generated. -sbl.m sets what marker to put before the description in the multiline comment. It is "of block:" by default.  -sbi.max sets the maximum length of the description in characters.

E.g. ttsf -i h.sql -sbi+


Original

set @i=1
while @i<=100
 print @i

Tidied

set @i=1
while @i<=100
 print @i  /*of block: while @i<=100*/

-rbi+

It removes the comment after each end of block statement that describes the block that was placed there by -sbi+. 

E.g. ttsf -io h.sql -rbi+

-pius[+-]  put 'into' under select

Into keywords are "moved" so that they appear under select keyword.
E.g. ttsf -io=h.sql -pius+

Original

select amount into amountv from budget
where id=4

Tidied

select amount
   into amountv from budget
where id=4

-bus[+-] break up sql statements

Select statements that occupy one line will span several lines if this is on.
Generally, it makes the sql statements more "vertical" in appearance.
Original

select amount into amountv from budget where id=4

Tidied

select amount
into amountv
from budget
where id=4

-bbj[+-] break before joins

It inserts a linebreak before join and like keywords if there is no any.

Original

SELECT name, title+' '+job
FROM names natural JOIN employees;

Tidied

select name, title + ' ' + job
from names
natural JOIN employees;
     

-isis size  indentation size (in spaces) in Sql clauses,-ins+,iu+ and iaw+

These switches are not compatible with -au+,as+,aaw+.
It is possible to put additional indentation in Sql statements. -isis specifies the indentation size relative to the start of an Sql statement.
This switch requires that at least one of these switches should be on too:
-ins[+-]   extra indentation after selects
 -iu[+-]  extra indentation after updates
 -iaw[+-]  extra indentation after where clauses
These switches determine where these additional indentation should be placed, after which Sql statements.

E.g.  ttsf -io h.sql -isis 2 -ins+

Original

SELECT name,
 title+' '+job
FROM
names
;

Tidied

select name,
  title + ' ' + job
from
  names
;    

-rask[+-] right-align sql keywords

The sql keywords are right aligned as it can been seen in the next example.

Original

select amount into amountv from budget where id=4

Tidied

select amount
   into amountv
  from budget
where id=4

-buml[+-] break up multistatement lines

Declarations are also broken up.

Original

declare
@u int, @b int;

set @a=  3 ,b@=4;
select * from master_table;  set @t=4;
if 4>0 then set @r=3;  set @r=4;
while g<3
set @g=@g+1;


Tidied

DECLARE
  @u INT, @b INT;

SET @a= 3 ,b@=4;
SELECT * FROM master_table;
SET @t=4;
IF 4>0 THEN
 SET @r=3;
  SET @r=4;
  WHILE g<3
    SET @g=@g+1;  

-plouwh[+-]  put logical operations under where/having

E.g. ttsf -io=h.sql -plouwh+

Original

select * from budget
where money<100
and deadline>'1.1.2007'

Tidied

select * from budget
where money<100
    and deadline>'1.1.2007' 

-si identifier/keyword set identifier to look like identifier

E.g. ttsf -io=h.sql -si @FirstRow

If an identifier is written as @firstrow, then
 all dbms_output with any case will be converted into @FirstRow.

Original

set @firstrow='invalid'

Tidied

set @FirstRow='invalid'


-milipl no minimum list items per line

It increases the number of list items on each line to the specified minimum value if possible.
It does so by removing an end of line character and merging any given line with next line.
This switch turns on -pcr as well.
If no is zero, lists are not touched.
E.g. ttsf -io=h.sql -milipl3

Original

select 1,
          2,3,4,5,
          6,7,8,9
Tidied

select 1,2,3,4,5,
         6,7,8,
         9

-mlipl no maximum list items per line

It reduces the number of list items on each line to the specified maximum value if possible.
It does so by inserting an end of line character and moving the redundant list item(s) into next line.
If no is zero, lists are not touched.
E.g. ttsf -io=h.sql -mlipl 3

Original

select 1,2,3,4,5,
          6,7,8,9

Tidied

select 1,2,3,
         4,5,
         6,7,8,
         9


-rael remove all empty lines

It removes all empty lines except the ones which are included in strings and comments.
The effect of this switch is modified/overridden by the similar ones (maintain linebreaks..) if they are on.
For example:
E.g. ttsf -io=h.sql -rael+

Original

select 1,2,3,4,5,

          6,7,8,9
Tidied

select 1,2,3,4,5,
         6,7,8,9

-mlacd[+-] maintain a linebreak after cursor declarations

If there is no linebreak after a cursor declaration, one linebreak will be inserted.
E.g. ttsf -io=h.sql -mlacd+

Original

declare
cursor simple for
select *
from
list;
-- start
Tidied

DECLARE
CURSOR simple FOR
  SELECT *
  FROM
  list;

--start
  

-mlai[+-] maintain a linebreak after each if

If there is no linebreak after if keyword, one linebreak will be inserted.
E.g. ttsf -io=h.sql -mlai+

Original

if g>8 then
  set @f=@d+3;
--next
Tidied

if g>8 then
  set @f=@d+3;

--next

-mlaw[+-] maintain a linebreak after each while loop

If there is no linebreak after a while loop, one linebreak will be inserted.
E.g. ttsf -io=h.sql -mlaw+

Original

while f<200
set @f=@d+3;
--next
Tidied

while f<200
  set @f=@d+3;

--next


-mlafu[+-] maintain a linebreak after function names

If there is no linebreak after a procedure name in a procedure declaration, one linebreak will be inserted.
E.g. ttsf -io=h.sql -mlafu+

Original

procedure next(b int) as
begin

Tidied

procedure next
(b int) as
begin

-mlapr[+-] maintain a linebreak after procedure

If there is no linebreak after a procedure/trigger, one linebreak will be inserted.
E.g. ttsf -io=h.sql -mlapr+

Original

end;
--next
Tidied

end;

--next

-rlacd[+-] remove linebreaks after each cursor declaration

E.g. ttsf -io=h.sql -rlacd+

Original

declare
simple cursor for
select *
from
account;

begin
Tidied

DECLARE
simple CURSOR FOR
  SELECT *
  FROM
  account;
BEGIN  

-rlai[+-] remove linebreaks after each if

E.g. ttsf -io=h.sql -rlai+

Original

if @g>8
  @f:=@d+3;

--next
Tidied

if @g>8
  set @f:=@d+3;
--next


-rlaw[+-] remove linebreaks after each while loop

If there is no linebreak after a while loop, one linebreak will be inserted.
E.g. ttsf -io=h.sql -rlaw+

Original

while @f<200
  set @f=@d+3;
--next
Tidied

while @f<200
  set @f=@d+3;

--next


-rlapr[+-] remove linebreaks after procedure

E.g. ttsf -io=h.sql -rlapr+

Original

end;

--next
Tidied

end;
--next

-dbvn[+-] declaration based variable names

As variables are declared, so they will look elsewhere. This option is not compatible with
uppercase,lowercase,capitalized identifier switch. Those will override this option.
It also affects the naming of cursors. They are included as if they were variables.

Original
ttsf -io=h.sql 

declare @participant int
set @PARTICIPANT = 4

 

Tidied
ttsf -io=h.sql -dbvn+

declare @participant int
set @
participant = 4

-cmk[+-] check for missing keywords

It performs additional syntax checking. If loop or then is required by a syntax construct, the formatter stops with a syntax error.

-x

It prints out what the formatting would do if it ran completely. It stops without doing anything.

-b maxvers number of backup versions to keep

Number of old backup versions to keep +1 (including the current backup version that is being created)

-bdir directory

Set backup directory

-v

The formatter displays/explains what it will do and runs.

-sf[+-] show filenames in block stack

When a syntax error occurs, it shows the filename of the current file in the block stack.

-rl[+-] reverse listing of block stack

When a syntax error occurs, the displayed block stack shows last lines first.

-sr[+-] show the result of formatting

After the formatting is done, a message is printed which shows if the formatting is successfull or not.

-ss[+-] show the summary of multiple file formatting

It prints a message which is similar to this when all files are processed:
"Formatting summary: all 10, tried 2, done 1, failed 1."

The explanation of the labels are:
all: the number of files to be formatted.
tried: the number of files that the formatter tried to format.
done: the number of files that are formatted.
failed: the number of files that were not formatted because of syntax errors.

-ls filename load settings/switches from a file

It is possible to save the command line switches in a file and load those switches instead of giving them.
For example, use any text file. Save these switches as they are written here(without "): "-rs- -dbvn+" in a file named "sw.txt". Then use this: ttsf -ls sw.txt.

A settings file can contain comments (they must be separated by whitespace) like this :
"-- this is a line comment
-rs- -dbvn+
"

It is allowed to use other switches after -ls which then modify the loaded switches.


There is a default settings/configuration file that is loaded automatically if it exists.
Its name is ttsf.cfg and it should be placed in the installation directory.

An example of -ls : ttsf -ls sw.txt -mcs 100.

This will load the switches in sw.txt, then it will set the maximum colunm size, changing
 the column size set in sw.txt, if it was defined there.

-ae ext accept files with ext only

Only files with ext extension will be accepted for formatting.
If -ae is not used at all, any file with any extension is formatted.
If multiple -ae are used, then multiple extensions are accepted.

E.g ttsf -i h.sql -ae sql -ae ps
This will accept both h.sql and h.ps if used as input.

-sw[+-] show switches

It prints out the state of all switches. It does not run the program.

-sdw show default switches

It prints out the state of all default switches. That is , the state of switches before the command line arguments are processed. What is printed can depend on ttsf.cfg too if it exists. It does not run the program.

-swc show switches compactly

It prints out the state of all switches excluding the switches which values are the same as the default switches. What is printed can depend on ttsf.cfg too if it exists.  It is possible that this does not print anything if no switches differ from the default switches.

-0  sets all switches to off

It affects all switches that precede it in command line.

-alll+ set all formatting switches on and left-aligned sql

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
It turns sql formatting on, the sql statements will be left-aligned. The switches which require a number are not affected. E.g. wrapping and set number of list items. Also, the wrapping/html/syntax related switches are not modified.
Using minus sign after this switch have no effect.

-allr+ set all formatting switches on and right-aligned sql

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
It turns sql formatting on, the sql statements will be right-aligned. The switches which require a number are not affected. E.g. wrapping and set number of list items. Also, the wrapping/html/syntax related switches are not modified.
Using minus sign after this switch have no effect.

-lsql[+-] left-aligned sql

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
It turns sql formatting on, the sql statements will be left-aligned. 
Using minus sign after this switch have no effect.

-rsql[+-] left-aligned sql

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
It turns sql formatting on, the sql statements will be right-aligned. 
Using minus sign after this switch have no effect.

-alol[+-] at least one linebreak after blocks and elsewhere

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
There will be at least one linebreak after each block/cursor and function name.
Using minus sign after this switch have no effect.

-ol+-] one linebreak after blocks and elsewhere

It modifies the state of a set of switches. Those switches could be set individually but it may be faster to set them in this way.  It is meant as a shortcut.
There will be one linebreak after each block/cursor and function name.
Using minus sign after this switch have no effect.

-html[+-] set the format of output to html

By default, the output format of input Pl/Sql source is not html...
If this option is set, the output will be modified to contain html tags
so that Pl/Sql source can be viewed in a browser.
There are two suboptions that can be used to influence html formatting:
-ht and -tag.
-ht specifies an html file in which a generated converted formatted Pl/Sql source will be inserted.
-tag sets what tags to use for each token.

Original

CREATE PACKAGE BODY
Tidied
-html+
<font color=blue>CREATE</font><font color=blue>&nbsp;</font><font color=blue>PACKAGE</font><font color=blue>&nbsp;</font><font color=blue>BODY</font>


-ht html template filename

This is to be used with -html+.
-ht specifies an html file in which a generated converted formatted Pl/Sql source will be inserted.
The html file should contain the string $formatted.
The insertion point is $formatted. The string $formatted is replaced by the formatted source.
In this way, the generated output will be the html template file up to $formatted plus the formatter source
 plus the html template file after $formatted.
A sample called htmltemplate.html is provided in the installation directory.

E.g. -ht  htmltemplate.html

-tag\[token type\] tag sequence :sets what tags to use for each token.

This is to be used with -html+.
One can specify what html tags each token of the source should be surrounded by.
Multiple tags can be given for each token type.
If no tags are wanted for a token type then <> should be given.
By default, the tokentypes have tags defined.


These token types are accepted : Examples
multilinecomment, /****/
singlelinecomment -- single line comment
other
.,;
whitespace
doublequotes "a string"
singlequotes. 'a string'
identifier Amount
keyword create
globalvariable
@@rowcount
variable
@column
label
nextcase:
number 77 or 77.0 or 0.8e+4


E.g.
-tag[identifier] "<b><i>"
Salary identifier will be formatted like this: <b><i>Salary</i></b>
-tag[number] "<i class=\"number\">"
The number 1.2 will be formatted like that: <i class="number">1.2</i>

-pl[+-] prepend logo

It prepends logo and formatting related information in the formatted files.
The prepended line will look something like this:
/*formatted by Tidycode T-Sql Formatter $vers on: 11:28:26 5/8/2010 options:-is 2 -t 4 -mcs 0 -milipl 0 -mlipl 0 -ps 1 -isis 0 -aav- -aaw- -abuc- -abusc- -ac- -acarv- -acav- ..*/

-plo[+-] prepend logo only

It prepends logo in the formatted files.
The prepended line will look something like this:
/*Tidycode T-Sql Formatter 1.1.1 formatted on:1/7/2008*/

-mte[+-] multithreaded execution for multiple files

Setting this switch will make formatting faster on multicore processors.
It results in a speed-up if there are at least 2 files specified in the command line.
The more cores there are available. the greater the speed-up will be. All available cores will be used automatically. The formatting order of the files -which comes from the command line order- may be out of order because of parallel execution compared to the situation if this switch is off. On the 4 core Q8200 processor 2x speed up was measured.

-gsfif[+-] get switches from input file 

If it is on, the switches will be obtained from the input source file as well if they exist.
The switches should be placed in a multiline comment at the end of the file.
They should be the last multiline comment in the file , otherwise they are not recognised.
The following switches are ignored if they are defined in the input source file:
-tag,-bdir,-b,-ht,-ae
The input file should contain this line at the end :
/*ttsf options: <put here options>*/
To be exact, the options will come from three sources: from the default options file(ttsf.cfg),
the command line options and options embedded in the input file.
The options are evaluated in the order as they were listed in the previous sentence.
In short, it is possible to override all options specified in ttsf.cfg and in the command line in a input file.


E.g. a source file could contain this: /*ttsf options: -in+*/

-soe[+-] stop on errors 

It is taken into account if multiple files are formatted.
If it is on, the formatting stops on at the first file in which there is an error.
That is , the remaining files are not formatted.
The program returns 0 return code when it is off, even there has been errors.

-w[+-] show warnings 

It print one warning at the moment. If there is if/while/etc block starters are not in a block.

-rla.. remove linebreaks after ... type of switches

They can be used together with "maintain a linebreak" switches.
If both are used, first removal of linebreaks are performed, then the addition of linesbreaks.
In short, together they are useful to remove redundant linebreaks (more than 1 linebreaks).


Changing default options

When the formatter is run, it already turns on many options. See here which ones.
It is possible to change what is on by default.
The steps to do this:
1. Create a file ttsf.cfg in the installation directory.
2. Set the switches in ttsf.cfg you want to make default.

Optionally,use -0 switch to turn all options off.



Line endings

The software accepts mac(charcode 13)/dos(charcodes 13,10) and unix(charcode 10) like line endings. It also detects the line ending used and the same type of end of line characters are inserted when a switch requires it.

Backing up

The original source is backed up. Even old backups are backed up.
The backup directory can be specified by -bdir switch. Otherwise, it is
the "tmp" directory.

Syntax checking

Some syntax checking is performed. If the check fails, the code is not tidied.
The followings are checked:
-the balance of brackets ()
-runaway/unclosed '
-runaway/unclosed "
-runaway/unclosed /*
-blocks are closed properly (missing statements, missing end)

Return code of the software

If the executable runs without error, it returns error code 0. 

Otherwise, it returns 2.

Safety measures

-Syntax checking. If it fails, the code is not formatted.
-The formatter checks itself. So it does not produce bad code easily. If self-check fails, it displays the message : Integrity error and the code is not touched. There is an exception. If -pcr switch is used, the check may not be performed as it could fail.
-It backs up the original source in the temp directory. (designated by tmp enviroment variable). By default, 40 versions are backed up. It can be changed by -b flag.
-Unless you specify -io, the output file is the original filename plus .tdy. So the original one is not overwritten.

License

Tidycode T-Sql Formatter
Idea/programmed by Marton Papp ((C)2007-2010 )
See licensetu.txt


Credits




Copyright © 2007-2010 Márton Papp. All Rights Reserved