Author |
Message |
risotto
Joined: 21 May 2007 Posts: 5
|
|
Documentation for the Code Formatter? |
|
Is there any documentation for the Code Formatter templates. I was unable to make even a simple modification to put the commas in front in a T-SQL select. Any sample would be welcome as well as a definition of the available tokens and what they're supposed to do. Thanks.
|
|
Mon May 21, 2007 4:24 pm |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
In the existing templates move commas from the end of line to the following line.
For example,
Before
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE ...,
... |
After
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE ...
,... |
|
|
Mon May 21, 2007 5:45 pm |
|
![](templates/GreenTech/images/spacer.gif) |
risotto
Joined: 21 May 2007 Posts: 5
|
|
|
|
Thanks, that did the trick! I would still like to see a little more attention paid to explaining this in the documentation however. If you look at the PDF it refers to an example of how to do exactly this but then neglects to actually put the example in!
It looks to me like you basically create each line as a potential matching expression and the parser goes through each one and formats based on the first match - so you would normally list your lines with any keywords you want to be matched and have a specially formatted and probably finish with a catch-all line with just the ... token to match anything left over. Only keywords are matched and other stuff seems to be ignored. Is this correct? The commas are a little less clear. I'm guessing that the parser looks for a comma as the first character or last character of a line and uses that to decide where to put commas in a repeating sequence. Warm???
PS: I will be buying the product - you seem committed to making it a good one and it is more versatile than anything else out there - in my case T-SQL, some MySQL, and my favorite editor, UltraEdit - all supported!
|
|
Mon May 21, 2007 7:51 pm |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
Thanks for your comments.
![](templates/GreenTech/images/quote_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
If you look at the PDF it refers to an example of how to do exactly this but then neglects to actually put the example in! |
This piece has been missed unintentionally. The documentation will be updated with the next build. Because v 2.5 is already on the horizon, I don't know if an intermediate build will be released in between. In the worst case it will be updated by the end of June, beginning of July when v2.5 becomes available.
Commas, spaces and tabs are considered to be syntax word separators as well some other symbols. 3 dots "…" represent a syntax token that could be a single keyword or multiple syntax words representing a lexeme. Note that the same rule applies to logical keywords like AND and OR, here is what I mean
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
... AND
... |
vs.
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
...
AND ... |
This flexible method of provided customization interface is very unique to SQL Assistant. Yet, while it provides maximum possible flexibility it can be tricky to use.
|
|
Mon May 21, 2007 9:36 pm |
|
![](templates/GreenTech/images/spacer.gif) |
risotto
Joined: 21 May 2007 Posts: 5
|
|
|
|
Here's another one:
How do I get from
-------------------------
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
alter procedure TestProc @p1 int,@p2 int,@p3 int
as select @p1,@p2,@p3 |
-------------------------
to this
-------------------------
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
ALTER PROCEDURE TestProc
@p1 int
,@p2 int
,@p3 int
AS
SELECT @p1
,@p2
,@p3 |
--------------------------
The default SELECT template is doing the job on the select statement but nothing I try can get the ALTER PROCEDURE to behave. Here is what I think should work but I've tried many variations as well (this is T-SQL).
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
ALTER PROCEDURE ...
...,
... |
and here is the result:
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
ALTER
procedure TestProc @p1 int,@p2 int,@p3 int
as
SELECT @p1,
@p2,
@p3 |
Thanks for you advice...
|
|
Fri May 25, 2007 12:23 am |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
That's a very interesting question. I have to consulting with developers before I can answer this.
|
|
Fri May 25, 2007 8:55 am |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
For both ALTER TABLE and CREATE TABLE you should use the template for "CREATE TABLE." In your case you want to change it as the following
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
CREATE TABLE ...
(
...
,...
) |
|
|
Fri May 25, 2007 9:08 am |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
Just to clarify this, as I got this question asked again..
For ALTER TABLE and CREATE TABLE formatting you should use the "CREATE TABLE rule. For ALTER PROCEDURE and CREATE PROCEDURE you should use the "CREATE PROCEDURE" formatting rule.
Hope this helps.
|
|
Mon May 28, 2007 9:30 am |
|
![](templates/GreenTech/images/spacer.gif) |
risotto
Joined: 21 May 2007 Posts: 5
|
|
|
|
Uh, where is this CREATE PROCEDURE formatting rule?
|
|
Mon May 28, 2007 11:45 am |
|
![](templates/GreenTech/images/spacer.gif) |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7849
|
|
|
|
Try
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
CREATE PROCEDURE ...
(
...
,...
) |
|
|
Mon May 28, 2007 3:43 pm |
|
![](templates/GreenTech/images/spacer.gif) |
risotto
Joined: 21 May 2007 Posts: 5
|
|
|
|
But this brings us back to the original problem...
Using a CREATE PROCEDURE template like the one above, based on the CREATE TABLE which works fine, I get this result:
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
alter procedure TestProc @p1 int,@p2 int,@p3 int
as select @p1,@p2,@p3
--produces
CREATE
procedure TestProc @p1 int,@p2 int,@p3 int
as
SELECT @p1,
@p2,
@p3 |
The SELECT formats correctly but the create (or alter) doesn't...
|
|
Tue May 29, 2007 3:34 am |
|
![](templates/GreenTech/images/spacer.gif) |
|