 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
Applying formatting rules |
|
How are the formatting rules applied to the code in the editor? Do they have any order or priority? What about overlapping rules?
|
|
Thu Sep 14, 2017 10:20 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
The order is important, that's why there are controls in the Options dialog allowing to move rules up and down. when you refer to overlapping rules, I guess you mean rules to contain formatting pattern which is also referenced somehow in another rules. Rules are matched in the order they are specified, the processing doesn't stop after the first found rule, it continues after the rule is applied, that's why overlapping isn't really an issue
|
|
Fri Sep 15, 2017 9:34 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Are you saying it is possible to have a rule for SELECT that would be overridden by another rule lower on the list in case the code has eg. an additional INTO keyword that the rule higher on the list would not touch when formatting the statement?
|
|
Fri Sep 15, 2017 9:47 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
That might produce unexpected side effect, I would say it's a grey area, but you may have SELECT ... INTO... FROM... WHERE rule, and a separate ...FROM..., and ...WHERE ... rules.
|
|
Fri Sep 15, 2017 10:01 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
I've read in help (and also recall you stating somewhere) that:
 |
 |
Keywords included in the pattern that do not appear in the statement are ignored during code processing and do not affect the results.
|
But that doesn't always seem to be true. I have the following rule for SELECT:
 |
 |
SELECT
... AS ...
,... = ...
INTO ...
FROM
... AS ...
,...
JOIN
...
ON ... = ...
AND ...
OR ...
WHERE ... = ...
AND ...
OR ...
GROUP BY
...
,...
HAVING
...
,...
ORDER BY
...
,...
;
|
That formats a piece of code so that the result is like below:
 |
 |
SELECT
opm.CI
,opm.KI AS KI_most
,ope.KI AS KI_elotte
INTO ##keses_sietes_elteresek
FROM
#online_plusz_most AS opm
INNER JOIN
##online_plusz_elozo AS ope
ON ope.CI = opm.CI
AND ope.jarat_id = opm.jarat_id
AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;
|
which is more or less what I want (notice that the alias for table #online_plusz_most was not properly aligned).
However, removing the line with the keyword INTO will result in ruining the rest of the code:
 |
 |
SELECT
opm.CI
,opm.KI AS KI_most
,ope.KI AS KI_elotte
FROM
#online_plusz_most AS opm
INNER JOIN
##online_plusz_elozo AS ope
ON ope.CI = opm.CI
AND ope.jarat_id = opm.jarat_id
AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
|
Removing the INTO part from the rule will restore order, with the formatting result of:
 |
 |
SELECT
opm.CI
,opm.KI AS KI_most
,ope.KI AS KI_elotte
FROM
#online_plusz_most AS opm
INNER JOIN
##online_plusz_elozo AS ope
ON ope.CI = opm.CI
AND ope.jarat_id = opm.jarat_id
AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;
|
But that in turn makes malformatting INTO in the original code, in case it is present:
 |
 |
SELECT
opm.CI
,opm.KI AS KI_most
,ope.KI AS KI_elotte
INTO ##keses_sietes_elteresek
FROM
#online_plusz_most AS opm
INNER JOIN
##online_plusz_elozo AS ope
ON ope.CI = opm.CI
AND ope.jarat_id = opm.jarat_id
AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;
|
By the way, I tried to reorder the rules. The rule sets can be reordered using the controls there
, yet the modifications done to them do not persist (closing and reopening the SA - Options window will restore the original order, see post here).
The individual rules themselves lack that control. Though there are items for Move Up/Down in their context menu
those do not work (or at least not as I'd expect). Move down only moves selection down one item, not the item itself. Move up does not even do that. It seems the rules are always ordered alphabetically. I've tried moving by renaming them so that they would swap their order but I ended up not fixing anything doing that.
|
|
Fri Sep 22, 2017 5:43 am |
|
 |
|
|
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
|
|
|