How can I auto-indent text to look like a script?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

How can I auto-indent text to look like a script?

Post by MouseUp » Mon Apr 15, 2013 2:12 pm

How can I auto-indent a block of text to look like a script? I have a stack that keeps my favorite scripts in a database for later use. If I have a block of text that needs to be indented as it would appear in the LC script editor, how can I automate this indenting without having to copy and paste into the script editor itself? I tried setting the script of an object then sending a tab key down to it but that didn't work. I want to format an un-indented script to look like an indented script in my card field.
Thanks,

MouseUp

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How can I auto-indent text to look like a script?

Post by Mark » Mon Apr 15, 2013 2:21 pm

Hi,

Send me an e-mail (see my website) and I'll send you a stack. The stack is a bit old, might need some adjustment, but it works well almost all the time.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

Re: How can I auto-indent text to look like a script?

Post by MouseUp » Mon Apr 15, 2013 3:41 pm

This used to work in HyperCard but it not longer works in LiveCode. Any ideas how to get it to work in LC?...

Code: Select all

function formatAsScript CONTAINER
   put script of target into TEMP
   set script of target to CONTAINER
   put script of target into CONTAINER
   set script of target to TEMP
   return CONTAINER
end formatAsScript
Thanks,

MouseUp

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How can I auto-indent text to look like a script?

Post by Mark » Mon Apr 15, 2013 5:32 pm

Hi,

I got your e-mail but I can't send you a reply because my IP address is blocked by Road Runner.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply