Samstag, 13. November 2010

SQLPSX Release 2.3 is real tool for SQL-Server

Well it took some time, until Chad Miller published the current version of SQLPSX.
Concerning SQL-Server I dare say, it is a real tool to work with, with some unique features.

You get a lot of options for output format, e.g. list, which showes you the contents of the columns above each other. That helps, if you have varchar fields containing multiple lines. While the usual grid format only displays the first line and the text format looses column alignment, here you get nearly the complete content.
Nearly? Yes using ISE Output window, some wise man desided that truncating the output to current width of the Output window is what users have to want.

OK. With the limitations of the output window you have two options. First you can tweet about this last millenium decision. Second you can pray to Microsoft Connect and send a change Request for an option to programmatically set the witdth of the output pane).
Or you just ignore the two options and write a workaround.

The workaround I invented is the output format isetab. (Yes you find it in SQLPSX 2.3)
The trick is not using the Output pane for displaying the result, but to create a new editor and display it there in its whole witdh.

Working with the new mode, I soon end with lots of ofen editors and nearly as a joke to a coworker I designed the idea of an inline output format. I put the result into the calling editor, just below the calling selection or at the end, if there is none.

First trial was just 4 lines and it just felt good.

You can adjust the princip, if you have a function, which you invoke by ISE menu, which produces some wide output. Instead of sending the output to the output pane, you can use something similar to:


$text = "your code goes here>"            
         $editor = $psise.CurrentFile.Editor            
         $caretLine = $editor.CaretLine            
         $lineCount = $editor.LineCount            
         if (-not $selectedEditor.SelectedText)            
         {            
            $lineend = $editor.GetLineLength($lineCount) + 1            
            # Write-Host "Nothing Selected  Linecount: $lineCount LineEnd: $lineend"            
            if ($lineend -eq 0) {$lineend = 1}            
            # set selection to the end of the editor            
            $editor.Select($lineCount, $lineend, $lineCount, $lineend)            
         }            
         elseif ($caretLine -lt $lineCount)            
         {            
            # Write-Host "Usual case"            
            # set selection to the start of the next line            
            $editor.Select($caretLine + 1, 1, $caretLine + 1, 1)            
         }            
         else            
         {            
            $lineend = $editor.GetLineLength($lineCount) + 1            
            # Write-Host "At end  Linecount: $lineCount LineEnd: $lineend"            
            if ($lineend -eq 0) {$lineend = 1}            
            # set selection to the end of the editor            
            $editor.Select($lineCount, $lineend, $lineCount, $lineend)            
         }            
         $editor.InsertText($text)            



You can load this into an ISE editor and run it using F5. You see the line your code goes here added at the end.

Bernd

Keine Kommentare:

Kommentar veröffentlichen