SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-04-2009, 06:30 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
OK to put text widget at end to make UI chain complete?

Is it OK to stick a text widget at the end of a widget chain in order to complete a UI chain? In my code I am checking for various error conditions and if they exist I want to write a DebugLog() message. The problem is if a UI chain does not have a UI widget at the end it doesn't get executed. To get around this I've been putting a text widget at the end of the chain. Am I asking for trouble?

Here is mock-up example:

Code:
If expression=x
   Display some image on the UI
else if expression=y
  Display some other image on the UI
else if expression=z
   DebugLog("This should never occur.")
      Text Widget Here
This seems to work with no adverse side-effects but I want to make sure I'm not going to break something down the road.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #2  
Old 08-04-2009, 06:37 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Don't know about any side effects.. I have some debugs in the ui as part of a chain but display pictures and such after it.

I don't understand why you have it part of the ui if you are not drawing anything or displaying anything ??
Reply With Quote
  #3  
Old 08-04-2009, 09:30 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
It's error checking. If I get to one of these places it is because there is nothing to display but there should be. If I had an image to display I would
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #4  
Old 08-04-2009, 12:14 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Using dummy text widgets does work, and I've resorted to it once or twice myself, but I don't like doing it and usually try to look for a better way of structuring the code that makes it unneccesary. The thing is that those unreachable text widgets aren't free; they do get instantiated when the menu is loaded, but never actually get drawn on screen (unless execution reaches there somehow). So if you make a habit of this, you could end up larding up your UI with a lot of invisible junk.

In your example I'd probably be inclined to do the error checking before entering the If:

Code:
DebugLog(If(expression == z, "error", "OK"))
  If expression ...
or perhaps

Code:
mypackage_myclass_Assert(expression != z)
  If expression ...
where the Assert function prints out an error and/or throws an exception if the passed-in argument is false. This is a very common error-checking idiom in software engineering. Asserting pre- and post-conditions on a function or block of code lets you combine runtime error checking with a clear, human-readable statement of the input/output contract of that block.

By the way, you're not obliged to keep writing "else if expression==". An If widget also works like a case statement, which is what you want in your example:

Code:
If expression
  > x
    ...
  > y
    ....
  > else
    error
__________________
-- Greg
Reply With Quote
  #5  
Old 08-04-2009, 12:35 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Thanks Greg. I knew how to create a case statement (my example was a poor choice) but I did not think about error handling in that way. Very slick. I've got to stop thinking like an assembler programmer ans start thinking like a java programmer.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get blank line in text widget? cncb SageTV Studio 2 07-20-2008 05:44 PM
When are Text widget properties refreshed? JREkiwi SageTV Studio 9 05-03-2007 09:35 AM
Scaling Text widget size within image widget area Morgan111 SageTV Studio 2 12-04-2006 02:16 PM
Text input widget, copy from clipboard nathanm SageTV Studio 2 10-27-2006 05:47 AM
Complete noob with low end system comptechltd Hardware Support 2 07-14-2003 10:35 AM


All times are GMT -6. The time now is 02:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.