As one who likes to automate most small tasks without OverDrive, one of them has stumped me. We're building election results templates, and I would like the fonts to change based on certain factors.
First, if a candidate is republican, the text object for their name should be red instead of white, blue for demos, yellow for I's, etc...
If a race has a declared winner, a "winner tag" is given to a candidate via our xml DataLinq. That already enables a checkmark image, but I would like to to change their percentage image to green. I.E., they win with 55% of the votes, the visual "55%" changes from white to green.
I haven't found a "SetFont" function yet in the SDK help file, and I'm not sure one exists. I see it playing out one of two ways. One, the "if R, then SetFont.CandidateR." The other, "if R, then SetFontMaterial(0, Red Material)." Not sure which way would be more feasible, but I have all of the fonts made for color, as well as materials that can be set. I just don't know the script.
Here's how I see it in my head:
dim Name as xpTextObject
dim Party as xpTextObject
dim WinTag as xpTextObject
dim Perc as xpTextObject
dim RFont as xpFont
dim BFont as xpFont
dim YFont as xpFont
dim GFont as xpFont
dim WFont as xpFont
dim i as Integer
for i = 1 to 5
Self.GetObjectByName("Candidate " & i, Name)
Self.GetObjectByName("Party " & i, Party)
Self.GetObjectByName("Winner " & i, WinTag)
Self.GetOBjectByName("Perc Total " & i, Perc)
Self.GetFontByName("Red Font", RFont)
Self.GetFontByName("Blue Font", BFont)
Self.GetFontByName("Yellow Font", YFont)
Self.GetFontByName("Green Font," GFont)
Self.GetFontByName("White Font," WFont)
If InStr(Party.Text, "R") = 1 then
Candidate.SetFont(RFont)
End If
'etc for the other party colors
If Len(WinTag.Text) > 0 then
Perc.SetFont(GFont)
else
Perc.SetFont(WFont)
End If
next i
Thoughts on how this script (which compiles perfectly in my head ;) ) would work in the real world?