tgunr
tgunr

Reputation: 1548

How to do line continuation with quotes in Livecode?

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?

Upvotes: 1

Views: 505

Answers (1)

Devin
Devin

Reputation: 603

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

Upvotes: 1

Related Questions