Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
button titles and days
#1
I am working on my weather page and want to display buttons that are "todays weather" "tomorrows weather" and then start listing the days so right now the third button would say "Saturdays weather" and then "Sundays Weather" etc. How exactly can a set this up? Variables driver? States?
Reply
#2
You can use the per-day text from the weather channel driver to achieve something similar. It will hold something like "Friday, Oct 16". You could take the first token from that string (at the comma), and then just append to that whatever you want.
Dean Roddey
Explorans limites defectum
Reply
#3
Ahh I didn't realize that was in the weather driver. So how can I remove the date and just get "Friday"
Reply
#4
Get the text into a variable, then there are commands for variables to find the index of the first whatever character. And there's another to cap the text at that index. Then you can append what you want to it.

You'd have to run that OnLoad of the template, and set up the text during the load.
Dean Roddey
Explorans limites defectum
Reply
#5
I am having a brain fart here and cant figure out how to get a variable to be the title of a button.
Reply
#6
At least in the post-3.0 world you should be able to send a SetText command to the button, so:

MyButton::SetText(%(LVar:TheVariable));

Something like that.
Dean Roddey
Explorans limites defectum
Reply
#7
got that part thanks
Reply
#8
Dean,

I assume you would use the GetSubStr command and set the count for "10" - the number of characters in the longest day's name (Wednesday) plus the comma. Or would it be better to use the GetNthToken command? In either case, I guess you'll need to knock off the last character (the comma) of each passed substring.

EDIT - after thinking about this a bit, is it possible to modify these commands to work with a driver field instead of a variable? There are many times that I have to read a driver field into a variable so I can use it with these types of commands. I realize it is more efficient to read the driver field into a variable if you are going to refer to that field more than once, but many times we only need the field value once (for situations like this). Of course it might be better to simply leave it alone. The few times we only need to read the field once probably pale compared to the number of times we read the value several times and to allow a more inefficient method might do more harm than good since people may not realize the difference between the two and always use the driver field method even when it is much less efficient.

As a side note, while checking out the manual to learn how to set this up, I noticed a very minor editing issue. In some commands, you refer to the "Source Variable" as "srcvar" and in other commands you refer to it as the "sourcevar"

Quote:GetNumericRange (srcvar,minvalvar,maxvalvar)
This command assumes that the indicated source variable is of a numeric type. If so, then the min/max values that it can contain (based
on the range limits or lack thereof) will be put into the provided min/max value variables provided.
GetSubStr(sourcevar, first, count, targetvar)
Pulls a substring from the value of the source variable, starting at index first and going for count characters, and puts the resulting
substring into the target variable. The target variable will be created if required. If first plus count goes beyond the end of the source
string, then the substring will go to the end. If first is beyond the end of the source string, then the result will be an empty string.
GetText (srcvar, targetvar)
Puts the value of the source variable into the target variable. It’s basically the same as SetVariable with the value to set being the
source variable.

I would be nice to get it corrected to refer to all of them as "sourcevar". Again, minor point, but something that can clean up the documents.
Brian - a long time user that rarely messes with the system now
Other systems used:
SageTV w/ cablecard tuner & multiple extenders for viewing
BlueIris and IP cameras for CCTV
Incredible PBX for home phone
Reply
#9
You can't do those directly on a field value. You have to get a local copy of the value before you can modify it. And the variable is the local copy.

I'll fix the doc error, thanks.

Quote:I assume you would use the GetSubStr command and set the count for "10" - the number of characters in the longest day's name (Wednesday) plus the comma. Or would it be better to use the GetNthToken command? In either case, I guess you'll need to knock off the last character (the comma) of each passed substring.

I'd just use the scheme above. Search for the first comma (or space if it's space separated, I can't remember), and then cap the value there. That leaves you with the first token value in a pretty efficient way.
Dean Roddey
Explorans limites defectum
Reply
#10
Dean Roddey Wrote:I'd just use the scheme above. Search for the first comma (or space if it's space separated, I can't remember), and then cap the value there. That leaves you with the first token value in a pretty efficient way.

So after looking at the documents again, it seems that the actual command is the "Find" command.
Quote:(!) Find(sourcevar, targetvar, pattern, casesensitive)
Looks for the indicated pattern in the value of the source variable. If found, it returns True and the index at which it was found is placed
in the target variable, else it returns False and the target variable is not affected. If the target value doesn’t exist, it will be created if
required to store the index, else it will not be created. The search can be case sensitive or not, based on the last variable, which should
e True or False.

That returns a variable with a number in it that represents the character number where that pattern (it is probably easiest to use the letter "y" since all days end in that letter) exists. Then use the CapAt command to cap the original variable at the number in the second variable. If you looked for the comma, I think you would have to include an intermediate step to subtrack 1 from the resulting variable in order to get the index number 1 character before the comma.

I'm just trying to get it all straight in my mind.

In my previous post, am I correctly think that the substring is basically all the characters between white spaces? In other words, if I look at the first substring of the weather driver's DayXStamp field, it would return the first word of that field along with any characters (like the comma) until the first white space? Or am I completely misunderstanding the definition of what a substring really is?
Brian - a long time user that rarely messes with the system now
Other systems used:
SageTV w/ cablecard tuner & multiple extenders for viewing
BlueIris and IP cameras for CCTV
Incredible PBX for home phone
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trigger on Russound F1 button xlurkr 6 1,794 06-01-2020, 01:17 PM
Last Post: Dean Roddey
  How to copy/paste command button on template Deane Johnson 1 811 04-17-2020, 02:18 PM
Last Post: Dean Roddey
  Button Generator gReatAutomation 0 809 02-28-2020, 01:33 PM
Last Post: gReatAutomation
  Wireless and attractive CQC "button"/keyfob? IVB 5 3,265 06-22-2015, 06:20 AM
Last Post: jkmonroe
  Field Incr/Decr Button Widget khill 15 7,697 05-17-2015, 01:04 PM
Last Post: dlmorgan999
  Cancelling Blanker causes triggering underlying button Deane Johnson 25 8,439 11-22-2014, 08:50 AM
Last Post: Dean Roddey
  Include Variable in button text? rtarver 3 2,244 09-24-2012, 05:34 PM
Last Post: Dean Roddey
  Easiest way to create a "check box" button that has more than two choices potts.mike 7 3,302 02-10-2010, 09:10 AM
Last Post: potts.mike
  button angles Ron Haley 8 3,760 03-18-2009, 12:18 PM
Last Post: Dean Roddey
  Can a CAB command button overlay the CAB? CalypsoCowboy 1 1,878 11-22-2008, 04:25 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)