1

In a Livecode script I have

   put "CREATE TABLE containers ( `id` INTEGER NOT NULL, `name` TEXT NOT NULL, `description`    TEXT, `location`    TEXT,  `kind`   TEXT NOT NULL,    `capacity`    INTEGER NOT NULL,  PRIMARY KEY(id)    )" into tSQL

It would read much better if I could use line continuation as in

put "CREATE TABLE containers (\
    `id`    INTEGER NOT NULL,\
    `name`  TEXT NOT NULL,\
    `description`   TEXT,\
    `location`  TEXT,\
    `kind`  TEXT NOT NULL,\
    `capacity`  INTEGER NOT NULL,\
    PRIMARY KEY(id)\
)" into tSQL

but the \ does not seem to work when the line contains double quotes. Is there any other way to accomplist his?

tgunr
  • 1,540
  • 17
  • 31

1 Answers1

1

Unfortunately you can't use a line continuation character inside a quoted string, since it is treated as a literal value. You have to close the string and concatenate, like this:

put "CREATE TABLE containers (" & \
  "`id`    INTEGER NOT NULL," & \
  "`name`  TEXT NOT NULL," & \
  "`description`   TEXT," & \
  "`location`  TEXT," & \
  "`kind`  TEXT NOT NULL," & \
  "`capacity`  INTEGER NOT NULL," & \
  "PRIMARY KEY(id)" & \
")" into tSQL
Devin
  • 593
  • 1
  • 3
  • 8
  • Agreed, but you wanted to know how to put it together in a variable in a script. If you're saving queries anyway, you could build the query in a field or store it in a custom property, using whatever multiline formatting you wanted, with no continuation characters, then just say: `put field "querystr" into tSQL ` ,or `put the savedQuery of this card into tSQL`. – Devin Aug 22 '16 at 23:12