> When working with e.g. multiline SQL statements, sometimes I > want to copy them to a string in Lazarus, e.g from something > like: const > SQL = > with this on the clipboard: > SELECT > c.colid as recno, > o.name as TableName, > c.name as FieldName, > c.colorder as FieldPosition, > t.name as FieldType, > c.scale as FieldScale, > c.prec as FieldPrecision, > c.isnullable as FieldNull > FROM sys.syscolumns c > INNER JOIN sys.sysobjects o ON c.id = o.id > INNER JOIN sys.systypes t ON c.xtype = t.xtype and > c.usertype=t.usertype WHERE (o.type='V' or o.type='U') and > o.name='MEDEWERKERS' ORDER BY o.name, c.colorder > > to something like: > Const > SQL = > 'SELECT'+ > 'c.colid as recno,'+ > 'o.name as TableName,'+ > 'c.name as FieldName,'+ > 'c.colorder as FieldPosition,'+ > 't.name as FieldType,'+ > 'c.scale as FieldScale,'+ > 'c.prec as FieldPrecision,'+ > 'c.isnullable as FieldNull'+ > 'FROM sys.syscolumns c'+ > 'INNER JOIN sys.sysobjects o ON c.id = o.id'+ > 'INNER JOIN sys.systypes t ON c.xtype = t.xtype and > c.usertype=t.usertype'+ > 'WHERE (o.type='V' or o.type='U') and o.name=''MEDEWERKERS'''+ > 'ORDER BY o.name, c.colorder'; > > > I.e. indenting, appending quotes and + sign, and escaping > existing quotes. (In this case, it's SQL and having an extra > space at the end of the line before the closing quote would > be even nicer but that's something of a special case) > > Is that possible in Lazarus? >
That is roughly what the 'Editing SQL' window already does with right click/ Create String constant. Your sample string is transformed in: SQL = 'SELECT'+sLineBreak+ 'c.colid as recno,'+sLineBreak+ 'o.name as TableName,'+sLineBreak+ 'c.name as FieldName,'+sLineBreak+ 'c.colorder as FieldPosition,'+sLineBreak+ 't.name as FieldType,'+sLineBreak+ 'c.scale as FieldScale,'+sLineBreak+ 'c.prec as FieldPrecision,'+sLineBreak+ 'c.isnullable as FieldNull'+sLineBreak+ 'FROM sys.syscolumns c'+sLineBreak+ 'INNER JOIN sys.sysobjects o ON c.id = o.id'+sLineBreak+ 'INNER JOIN sys.systypes t ON c.xtype = t.xtype and c.usertype=t.usertype WHERE (o.type=''V'' or o.type=''U'') and o.name=''MEDEWERKERS'' ORDER BY o.name, c.colorder'; Only the indenting is missing. Ludo -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
