Multiple lines for long device state text string?

Posted on
Fri Sep 06, 2013 9:33 am
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

Multiple lines for long device state text string?

Trying to include the "Worded Forecast" statements from the NOAA WeatherPlus plugin into a control page. These can be very long. Reducing the font size to fit into a single line makes it illegible to our eyes when reading on an iPad, even when the line stretches across the entire screen width.

Have checked forum and docs, but just can't seem to find the way to make device state text windows occupy multiple lines on a control page instead of just a single, long line.

Thanks,
mjc

Posted on
Fri Sep 06, 2013 7:29 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Multiple lines for long device state text string?

It's not currently possible to have a multi-line text area on a control page though it's on the request list.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Sep 06, 2013 9:06 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Multiple lines for long device state text string?

There are some AppleScripts posted somewhere that helps break down variables onto multiple lines

Computer says no.

Posted on
Sat Sep 28, 2013 1:04 am
gtreece offline
Posts: 171
Joined: Sep 26, 2011

Re: Multiple lines for long device state text string?

I had to do this for my weather control page for my iPad. I took the full forecast text, and used applescript to split it into separate variables for each line of display, and then placed the line variables on the control page. I just have a schedule that runs to get the latest forecast, and split it into variables.

The script will create up to 5 line variables, based on how long the forecast text is. It's long and repetitive, but makes sure that each line variable doesn't have more than 45 characters in it, and doesn't end in the middle of a word (always splits at a space character).
Attachments
ipadweather.png
ipadweather.png (326.82 KiB) Viewed 1940 times

Posted on
Sat Sep 28, 2013 10:19 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Multiple lines for long device state text string?

This is the script I use:

viewtopic.php?f=4&t=6822

Posted on
Sat Sep 28, 2013 11:03 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Multiple lines for long device state text string?

Nice looking Control Page, greece.

Image

Posted on
Sat Sep 28, 2013 8:36 pm
gtreece offline
Posts: 171
Joined: Sep 26, 2011

Re: Multiple lines for long device state text string?

Thanks, Matt. I'm getting there. :)

hamw, I started with that script, and added logic to make sure it only split at spaces, and not in the middle of a word.

Posted on
Sun Sep 29, 2013 8:39 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Multiple lines for long device state text string?

Any chance of posting your modified script? I tried something but it didn't work, and gave up in a fit of disgust ;)

Computer says no.

Posted on
Sun Sep 29, 2013 1:34 pm
gtreece offline
Posts: 171
Joined: Sep 26, 2011

Re: Multiple lines for long device state text string?

durosity, this is the script I have running right now. Most of it is repetitive work, so it could be simplified a lot with a couple routines. I just haven't had time to revisit it. I run this as an external script file.

In my case, I didn't want a line longer than 45 characters, so it's all hard-coded to that. It splits both period1 and period2, So that I can utilize both on the control page.

Code: Select all
using terms from application "IndigoServer"
   tell application "IndigoServer"
      set day1Period1Forecast to value of variable "Wunderground_Day1Period1TextForecast" as string
      set day1Period2Forecast to value of variable "Wunderground_Day1Period2TextForecast" as string
      
      if length of day1Period1Forecast is less than 46 then
         set the value of variable "day1Period1Line1" to day1Period1Forecast as string
         set value of variable "day1Period1Line2" to ""
         set value of variable "day1Period1Line3" to ""
         set value of variable "day1Period1Line4" to ""
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      if ((length of day1Period1Forecast is less than 91) and (length of day1Period1Forecast is greater than 45)) then
         set splitChar2 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period1Forecast
            set splitChar to splitChar - 1
         end repeat
         if ((length of day1Period1Forecast) - (splitChar + 2)) is greater than 45 then
            set splitChar2 to splitChar + 45
            set lastChar2 to "-"
            repeat until lastChar2 is equal to " "
               set lastChar2 to character splitChar2 of day1Period1Forecast
               set splitChar2 to splitChar2 - 1
            end repeat
         end if
         set value of variable "day1Period1Line1" to (characters 1 through splitChar of day1Period1Forecast) as string
         if splitChar2 is equal to 0 then
            set value of variable "day1Period1Line2" to (characters (splitChar + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line3" to ""
            set value of variable "day1Period1Line4" to ""
            set value of variable "day1Period1Line5" to ""
            set value of variable "day1Period1Line6" to ""
         else
            set value of variable "day1Period1Line2" to (characters (splitChar + 2) through splitChar2 of day1Period1Forecast) as string
            set value of variable "day1Period1Line3" to (characters (splitChar2 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line4" to ""
            set value of variable "day1Period1Line5" to ""
            set value of variable "day1Period1Line6" to ""
         end if
      end if
      
      if ((length of day1Period1Forecast is greater than 90) and (length of day1Period1Forecast is less than 136)) then
         set splitChar3 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period1Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period1Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         if ((length of day1Period1Forecast) - (splitChar2 + 2)) is greater than 45 then
            set splitChar3 to splitChar2 + 45
            set lastChar3 to "-"
            repeat until lastChar3 is equal to " "
               set lastChar3 to character splitChar3 of day1Period1Forecast
               set splitChar3 to splitChar3 - 1
            end repeat
         end if
         set value of variable "day1Period1Line1" to (characters 1 through splitChar of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters (splitChar + 2) through splitChar2 of day1Period1Forecast) as string
         if splitChar3 is equal to 0 then
            set value of variable "day1Period1Line3" to (characters (splitChar2 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line4" to ""
            set value of variable "day1Period1Line5" to ""
            set value of variable "day1Period1Line6" to ""
         else
            set value of variable "day1Period1Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period1Forecast) as string
            set value of variable "day1Period1Line4" to (characters (splitChar3 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line5" to ""
            set value of variable "day1Period1Line6" to ""
         end if
      end if
      
      
      if ((length of day1Period1Forecast is greater than 135) and (length of day1Period1Forecast is less than 181)) then
         set splitChar4 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period1Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period1Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         set splitChar3 to splitChar2 + 45
         set lastChar3 to "-"
         repeat until lastChar3 is equal to " "
            set lastChar3 to character splitChar3 of day1Period1Forecast
            set splitChar3 to splitChar3 - 1
         end repeat
         if ((length of day1Period1Forecast) - (splitChar3 + 2)) is greater than 45 then
            set splitChar4 to splitChar3 + 45
            set lastChar4 to "-"
            repeat until lastChar4 is equal to " "
               set lastChar4 to character splitChar4 of day1Period1Forecast
               set splitChar4 to splitChar4 - 1
            end repeat
         end if
         set value of variable "day1Period1Line1" to (characters 1 through splitChar of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters (splitChar + 2) through splitChar2 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period1Forecast) as string
         if splitChar4 is equal to 0 then
            set value of variable "day1Period1Line4" to (characters (splitChar3 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line5" to ""
            set value of variable "day1Period1Line6" to ""
         else
            set value of variable "day1Period1Line4" to (characters (splitChar3 + 2) through splitChar4 of day1Period1Forecast) as string
            set value of variable "day1Period1Line5" to (characters (splitChar4 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line6" to ""
         end if
      end if
      
      if ((length of day1Period1Forecast is greater than 180) and (length of day1Period1Forecast is less than 226)) then
         set splitChar5 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period1Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period1Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         set splitChar3 to splitChar2 + 45
         set lastChar3 to "-"
         repeat until lastChar3 is equal to " "
            set lastChar3 to character splitChar3 of day1Period1Forecast
            set splitChar3 to splitChar3 - 1
         end repeat
         set splitChar4 to splitChar3 + 45
         set lastChar4 to "-"
         repeat until lastChar4 is equal to " "
            set lastChar4 to character splitChar4 of day1Period1Forecast
            set splitChar4 to splitChar4 - 1
         end repeat
         if ((length of day1Period1Forecast) - (splitChar4 + 2)) is greater than 45 then
            set splitChar5 to splitChar4 + 45
            set lastChar5 to "-"
            repeat until lastChar5 is equal to " "
               set lastChar5 to character splitChar5 of day1Period1Forecast
               set splitChar5 to splitChar5 - 1
            end repeat
         end if
         set value of variable "day1Period1Line1" to (characters 1 through splitChar of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters (splitChar + 2) through splitChar2 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters (splitChar3 + 2) through splitChar4 of day1Period1Forecast) as string
         if splitChar5 is equal to 0 then
            set value of variable "day1Period1Line5" to (characters (splitChar4 + 2) through -1 of day1Period1Forecast) as string
            set value of variable "day1Period1Line6" to ""
         else
            set value of variable "day1Period1Line5" to (characters (splitChar4 + 2) through splitChar5 of day1Period1Forecast) as string
            set value of variable "day1Period1Line6" to (characters (splitChar5 + 2) through -1 of day1Period1Forecast) as string
         end if
      end if
      
      if length of day1Period1Forecast is greater than 225 then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through 180 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to (characters 181 through 225 of day1Period1Forecast) as string
         set value of variable "day1Period1Line6" to (characters 226 through -1 of day1Period1Forecast) as string
      end if
      
      
      --These are for period 2
      
      if length of day1Period2Forecast is less than 46 then
         set the value of variable "day1Period2Line1" to day1Period2Forecast as string
         set value of variable "day1Period2Line2" to ""
         set value of variable "day1Period2Line3" to ""
         set value of variable "day1Period2Line4" to ""
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is less than 91) and (length of day1Period2Forecast is greater than 45)) then
         set splitChar2 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period2Forecast
            set splitChar to splitChar - 1
         end repeat
         if ((length of day1Period2Forecast) - (splitChar + 2)) is greater than 45 then
            set splitChar2 to splitChar + 45
            set lastChar2 to "-"
            repeat until lastChar2 is equal to " "
               set lastChar2 to character splitChar2 of day1Period2Forecast
               set splitChar2 to splitChar2 - 1
            end repeat
         end if
         set value of variable "day1Period2Line1" to (characters 1 through splitChar of day1Period2Forecast) as string
         if splitChar2 is equal to 0 then
            set value of variable "day1Period2Line2" to (characters (splitChar + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line3" to ""
            set value of variable "day1Period2Line4" to ""
            set value of variable "day1Period2Line5" to ""
            set value of variable "day1Period2Line6" to ""
         else
            set value of variable "day1Period2Line2" to (characters (splitChar + 2) through splitChar2 of day1Period2Forecast) as string
            set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line4" to ""
            set value of variable "day1Period2Line5" to ""
            set value of variable "day1Period2Line6" to ""
         end if
      end if
      
      if ((length of day1Period2Forecast is greater than 90) and (length of day1Period2Forecast is less than 136)) then
         set splitChar3 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period2Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period2Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         if ((length of day1Period2Forecast) - (splitChar2 + 2)) is greater than 45 then
            set splitChar3 to splitChar2 + 45
            set lastChar3 to "-"
            repeat until lastChar3 is equal to " "
               set lastChar3 to character splitChar3 of day1Period2Forecast
               set splitChar3 to splitChar3 - 1
            end repeat
         end if
         set value of variable "day1Period2Line1" to (characters 1 through splitChar of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters (splitChar + 2) through splitChar2 of day1Period2Forecast) as string
         if splitChar3 is equal to 0 then
            set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line4" to ""
            set value of variable "day1Period2Line5" to ""
            set value of variable "day1Period2Line6" to ""
         else
            set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period2Forecast) as string
            set value of variable "day1Period2Line4" to (characters (splitChar3 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line5" to ""
            set value of variable "day1Period2Line6" to ""
         end if
      end if
      
      if ((length of day1Period2Forecast is greater than 135) and (length of day1Period2Forecast is less than 181)) then
         set splitChar4 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until ((lastChar is equal to " ") or (lastChar is equal to "."))
            set lastChar to character splitChar of day1Period2Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period2Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         set splitChar3 to splitChar2 + 45
         set lastChar3 to "-"
         repeat until lastChar3 is equal to " "
            set lastChar3 to character splitChar3 of day1Period2Forecast
            set splitChar3 to splitChar3 - 1
         end repeat
         if ((length of day1Period2Forecast) - (splitChar3 + 2)) is greater than 45 then
            set splitChar4 to splitChar3 + 45
            set lastChar4 to "-"
            repeat until lastChar4 is equal to " "
               set lastChar4 to character splitChar4 of day1Period2Forecast
               set splitChar4 to splitChar4 - 1
            end repeat
         end if
         set value of variable "day1Period2Line1" to (characters 1 through splitChar of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters (splitChar + 2) through splitChar2 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period2Forecast) as string
         if splitChar4 is equal to 0 then
            set value of variable "day1Period2Line4" to (characters (splitChar3 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line5" to ""
            set value of variable "day1Period2Line6" to ""
         else
            set value of variable "day1Period2Line4" to (characters (splitChar3 + 2) through splitChar4 of day1Period2Forecast) as string
            set value of variable "day1Period2Line5" to (characters (splitChar4 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line6" to ""
         end if
      end if
      
      if ((length of day1Period2Forecast is greater than 180) and (length of day1Period2Forecast is less than 226)) then
         set splitChar5 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period2Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period2Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         set splitChar3 to splitChar2 + 45
         set lastChar3 to "-"
         repeat until lastChar3 is equal to " "
            set lastChar3 to character splitChar3 of day1Period2Forecast
            set splitChar3 to splitChar3 - 1
         end repeat
         set splitChar4 to splitChar3 + 45
         set lastChar4 to "-"
         repeat until lastChar4 is equal to " "
            set lastChar4 to character splitChar4 of day1Period2Forecast
            set splitChar4 to splitChar4 - 1
         end repeat
         if ((length of day1Period2Forecast) - (splitChar4 + 2)) is greater than 45 then
            set splitChar5 to splitChar4 + 45
            set lastChar5 to "-"
            repeat until lastChar5 is equal to " "
               set lastChar5 to character splitChar6 of day1Period2Forecast
               set splitChar5 to splitChar5 - 1
            end repeat
         end if
         set value of variable "day1Period2Line1" to (characters 1 through splitChar of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters (splitChar + 2) through splitChar2 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters (splitChar3 + 2) through splitChar4 of day1Period2Forecast) as string
         if splitChar5 is equal to 0 then
            set value of variable "day1Period2Line5" to (characters (splitChar4 + 2) through -1 of day1Period2Forecast) as string
            set value of variable "day1Period2Line6" to ""
         else
            set value of variable "day1Period2Line5" to (characters (splitChar4 + 2) through splitChar5 of day1Period2Forecast) as string
            set value of variable "day1Period2Line6" to (characters (splitChar5 + 2) through -1 of day1Period2Forecast) as string
         end if
         
      end if
      
      
      if length of day1Period2Forecast is greater than 225 then
         set splitChar6 to 0
         set splitChar to 45
         set lastChar to "-"
         repeat until lastChar is equal to " "
            set lastChar to character splitChar of day1Period2Forecast
            set splitChar to splitChar - 1
         end repeat
         set splitChar2 to splitChar + 45
         set lastChar2 to "-"
         repeat until lastChar2 is equal to " "
            set lastChar2 to character splitChar2 of day1Period2Forecast
            set splitChar2 to splitChar2 - 1
         end repeat
         set splitChar3 to splitChar2 + 45
         set lastChar3 to "-"
         repeat until lastChar3 is equal to " "
            set lastChar3 to character splitChar3 of day1Period2Forecast
            set splitChar3 to splitChar3 - 1
         end repeat
         set splitChar4 to splitChar3 + 45
         set lastChar4 to "-"
         repeat until lastChar4 is equal to " "
            set lastChar4 to character splitChar4 of day1Period2Forecast
            set splitChar4 to splitChar4 - 1
         end repeat
         set splitChar5 to splitChar4 + 45
         set lastChar5 to "-"
         repeat until lastChar5 is equal to " "
            set lastChar5 to character splitChar4 of day1Period2Forecast
            set splitChar5 to splitChar5 - 1
         end repeat
         if ((length of day1Period2Forecast) - (splitChar5 + 2)) is greater than 45 then
            set splitChar6 to splitChar5 + 45
            set lastChar6 to "-"
            repeat until lastChar6 is equal to " "
               set lastChar6 to character splitChar6 of day1Period2Forecast
               set splitChar6 to splitChar6 - 1
            end repeat
         end if
         set value of variable "day1Period2Line1" to (characters 1 through splitChar of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters (splitChar + 2) through splitChar2 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters (splitChar2 + 2) through splitChar3 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters (splitChar3 + 2) through splitChar4 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to (characters (splitChar4 + 2) through splitChar5 of day1Period2Forecast) as string
         if splitChar6 is equal to 0 then
            set value of variable "day1Period2Line6" to (characters (splitChar5 + 2) through -1 of day1Period2Forecast) as string
         else
            set value of variable "day1Period2Line6" to (characters (splitChar5 + 2) through splitChar6 of day1Period2Forecast) as string
         end if
      end if
      
   end tell
end using terms from

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 17 guests