xsharp.eu • text endtext in Core dialect
Page 1 of 1

text endtext in Core dialect

Posted: Sat Mar 19, 2022 2:01 pm
by wriedmann
Hi Robert,
specially when combining SQL, JSON or XML statements, something like the TEXT ... ENDTEXT functionality in VFP dialect would help to make code clearer. The text I need includes newlines and " character.
Is there something I can use in Core dialect?
Thank you very much!
Wolfgang

text endtext in Core dialect

Posted: Sat Mar 19, 2022 4:39 pm
by robert
Wolfgang,
At this moment TEXT .. ENDTEXT is only available in the FoxPro dialect.
But we actually already have a request to add support for it to other dialects.
https://github.com/X-Sharp/XSharpPublic/issues/977
And in that case the most obvious location would either be the core dialect or in all non core dialects.
I will see what I can do here.

Robert

text endtext in Core dialect

Posted: Sat Mar 19, 2022 4:44 pm
by wriedmann
Hi Robert,
thank you very much, that would help a lot!
I could use that feature not only constructing SQL, XML and Json, but also for XAML.
Such a piece of code is not very easy to write and to read:

Code: Select all

oSB := System.Text.StringBuilder{}
oSB:AppendLine( e"<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">" )
oSB:AppendLine( e"<Grid  VerticalAlignment="Center" HorizontalAlignment="Left" Background="#ececec">" )
oSB:AppendLine( e"<Grid.RowDefinitions>" )
oSB:AppendLine( e"<RowDefinition Height="Auto"/>" )
oSB:AppendLine( e"</Grid.RowDefinitions>" )
oSB:AppendLine( e"<Grid.ColumnDefinitions>" )
oSB:AppendLine( e"<ColumnDefinition Width="Auto"/>" )
oSB:AppendLine( e"<ColumnDefinition Width="Auto"/>" )
oSB:AppendLine( e"</Grid.ColumnDefinitions>" )
oSB:AppendLine( e"<TextBlock Margin="20,5,5,1" " + cFontProperties + e" Text="Auftrag : " Grid.Row="0" Grid.Column="0" />" )
oSB:AppendLine( e"<TextBlock Margin="1,5,5,10" " + cFontProperties + e" Text="{Binding DraggingRecords[0].DraggingBeschreibung}" Grid.Row="0" Grid.Column="1"/>" )
oSB:AppendLine( e"<TextBlock Text="Ziel : " Grid.Row="1" Grid.Column="0"/>" )
oSB:AppendLine( e"<TextBlock Text="{Binding DragStatus}" Grid.Row="1" Grid.Column="1"/>" )
oSB:AppendLine( e"</Grid>" )
oSB:AppendLine( e"</DataTemplate>" )
oStringReader := System.IO.StringReader{ oSB:ToString() }
oXmlReader := System.XML.XmlReader.Create( oStringReader )
oDataTemplate := ( DataTemplate ) System.Windows.Markup.XamlReader.Load( oXmlReader )
_oPlanungGrid:RowDragDropTemplate	:= oDataTemplate
Wolfgang

text endtext in Core dialect

Posted: Sat Mar 19, 2022 6:37 pm
by robert
Wolfgang,
Here is the reference to the TEXT .. ENDTEXT command
https://www.xsharp.eu/help/command_text.html
In the core dialect we can create the string and evaluate the expressions (between << and >>) when the TEXTMERGE keyword is used.
These expressions work like interpolated strings. The FoxPro TEXT command also outputs to a file (when set alternate is on). We can't do that in the core dialect.

Robert

text endtext in Core dialect

Posted: Sun Mar 20, 2022 6:08 am
by wriedmann
Hi Robert,
yes, I had looked at the help before writing.
IMHO it would be enough to have a possibility to write such long expressions to a string variable - variable substitution can be done later, it is really an easy thing.
When output to a file is needed, it is IMHO better to use later one of the relative functions in the System.IO namespace. They give much more control.
It is really important that things like newlines, apostrophes and parentheses can be used inside this string without too much masking needed (masking makes the expressions hard to write and, more important, hard to write).
I'm writing so much code everyday that is really important to be able to read and understand it later very fast.
Wolfgang