Insert Spaces in Variable?

Posted on
Tue Sep 11, 2012 9:56 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Insert Spaces in Variable?

Hey,

I'm constructing some variables using AppleScript that I need to have six spaces
inserted into, e.g. "abcde______ abcde", where the underscores here would be actual spaces. I've tried a number of things like, & " " & " " to add them but it only works to add just one space.

Not having much luck finding an answer anywhere how best to add them.

Any ideas?

Thanks,

Carl

Posted on
Tue Sep 11, 2012 10:10 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Insert Spaces in Variable?

Hi Carl.

Are you trying to use spaces in variable names or variable values? Variable names cannot have spaces in them. To add 5 spaces to the end of a variable value, the following AppleScript should work.
Code: Select all
set value of variable "MyVariable" to value of variable "MyVariable" & "     "

Posted on
Tue Sep 11, 2012 10:33 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Insert Spaces in Variable?

I'd tried that but I only get one space. The spaces, in the variable value, need to be in the
middle, not at the beginning or end if that makes a difference.

Thanks,

Carl

Edit: Tried it again and it did work...go figure. Thanks a bunch.

Posted on
Tue Sep 11, 2012 10:44 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Insert Spaces in Variable?

Cool! Glad it worked.

Posted on
Wed Sep 12, 2012 9:34 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Insert Spaces in Variable?

Oops...spoke too soon. The extra spaces show correctly in Touch control pages but
not in any browsers. Any idea what character I could insert into the variable to
get the spaces to show on web pages?

Thanks,

Carl

Posted on
Wed Sep 12, 2012 9:44 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Insert Spaces in Variable?

ckeyes888 wrote:
Oops...spoke too soon. The extra spaces show correctly in Touch control pages but
not in any browsers. Any idea what character I could insert into the variable to
get the spaces to show on web pages?


Ha! That's a very different question. :-) The short answer is "no". I've seen this as well in my own control pages. The spaces do exist in the variable value, but either the web browsers ignore the extra white space (which makes sense, as that's how HTML, XML, and many other languages are), or Indigo Web Server interprets the control page contents slightly differently for web browsers compared to Indigo Touch, or both.

Posted on
Wed Sep 12, 2012 10:00 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Insert Spaces in Variable?

You can try   that should work in a browser, but probably not the iTouch client

Posted on
Wed Sep 12, 2012 10:21 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Insert Spaces in Variable?

Thanks a bunch. Well I ended up just using some characters to fill it up.
It shows the high and low temps for the week here at the house and the NOAA reporting
station at the airport here.

Carl
Attachments
Past Temps.jpg
Past Temps.jpg (154.1 KiB) Viewed 2256 times

Posted on
Wed Sep 12, 2012 11:38 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Insert Spaces in Variable?

Looks good. Nice touch with the High/Low gradient from Red to Blue.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests

cron