Page 1 of 1

Insert Spaces in Variable?

PostPosted: Tue Sep 11, 2012 9:56 pm
by ckeyes888
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

Re: Insert Spaces in Variable?

PostPosted: Tue Sep 11, 2012 10:10 pm
by nsheldon
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" & "     "

Re: Insert Spaces in Variable?

PostPosted: Tue Sep 11, 2012 10:33 pm
by ckeyes888
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.

Re: Insert Spaces in Variable?

PostPosted: Tue Sep 11, 2012 10:44 pm
by nsheldon
Cool! Glad it worked.

Re: Insert Spaces in Variable?

PostPosted: Wed Sep 12, 2012 9:34 am
by ckeyes888
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

Re: Insert Spaces in Variable?

PostPosted: Wed Sep 12, 2012 9:44 am
by nsheldon
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.

Re: Insert Spaces in Variable?

PostPosted: Wed Sep 12, 2012 10:00 am
by berkinet
You can try   that should work in a browser, but probably not the iTouch client

Re: Insert Spaces in Variable?

PostPosted: Wed Sep 12, 2012 10:21 am
by ckeyes888
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

Re: Insert Spaces in Variable?

PostPosted: Wed Sep 12, 2012 11:38 am
by berkinet
Looks good. Nice touch with the High/Low gradient from Red to Blue.