SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Documentation for the Code Formatter?

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Documentation for the Code Formatter?
Author Message
risotto



Joined: 21 May 2007
Posts: 5

Post Documentation for the Code Formatter? Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
In the existing templates move commas from the end of line to the following line.
For example,

Before
Code:
DECLARE ...,
         ...


After
Code:
DECLARE ...
         ,...

Mon May 21, 2007 5:45 pm View user's profile Send private message
risotto



Joined: 21 May 2007
Posts: 5

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
Thanks for your comments.

Quote:
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

Code:
... AND
...


vs.

Code:
...
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 View user's profile Send private message
risotto



Joined: 21 May 2007
Posts: 5

Post Reply with quote
Here's another one:


How do I get from

-------------------------
Code:
alter procedure TestProc @p1 int,@p2 int,@p3 int
as select @p1,@p2,@p3

-------------------------

to this

-------------------------
Code:
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).

Code:
ALTER PROCEDURE ...
    ...,
    ...


and here is the result:

Code:
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
That's a very interesting question. I have to consulting with developers before I can answer this.
Fri May 25, 2007 8:55 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
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

Code:
CREATE TABLE ...
(
    ...
    ,...
)

Fri May 25, 2007 9:08 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
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 View user's profile Send private message
risotto



Joined: 21 May 2007
Posts: 5

Post Reply with quote
Uh, where is this CREATE PROCEDURE formatting rule?
Mon May 28, 2007 11:45 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6498

Post Reply with quote
Try

Code:
CREATE PROCEDURE ...
(
     ...
     ,...
)

Mon May 28, 2007 3:43 pm View user's profile Send private message
risotto



Joined: 21 May 2007
Posts: 5

Post Reply with quote
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:


Code:
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 View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.