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 06-08-2009, 09:33 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Question About CreateArray

Is there a way to define the number of elements in CreateArray() without having to call them out say by the size of a file collection?

In other words instead of
CreateArrary(0,1,2,3,4,5)

use

CreateArray(num) with number being the total number of elements I want in the array

Also

Is there a way to search an array once made for only elements with a matching string?

I found FindElement but that only searches for the first match correct?

cheers
Reply With Quote
  #2  
Old 06-08-2009, 09:42 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
You can create a variable using the Java Array class. I am pretty sure I have seen examples of it in SageMC and the default STV.

I believe for the search you can use the filterbymethod, etc.. calls to search an array for a certain value..

Thanks,
Jeff
Reply With Quote
  #3  
Old 06-08-2009, 10:33 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by jphipps View Post
You can create a variable using the Java Array class. I am pretty sure I have seen examples of it in SageMC and the default STV.

Jeff

come again
Reply With Quote
  #4  
Old 06-08-2009, 10:50 AM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
SageMC uses ArrayLists quite a bit. You call the constructor once and then append items to the ArrayList as necessary, usually in a loop. In Studio the code would like something like:

Code:
MyArrayList = new_java_util_ArrayList()
java_util_ArrayList_add( MyArrayList , NewItem )
The advantage is that you do not have to pre-determine the size of the ArrayList, but you can otherwise treat it as an array.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)

Last edited by MeInMaui; 06-08-2009 at 10:57 AM.
Reply With Quote
  #5  
Old 06-08-2009, 10:57 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Quote:
Originally Posted by PLUCKYHD View Post
come again
What Mike said....
Reply With Quote
  #6  
Old 06-08-2009, 11:16 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by MeInMaui View Post
SageMC uses ArrayLists quite a bit. You call the constructor once and then append items to the ArrayList as necessary, usually in a loop. In Studio the code would like something like:

Code:
MyArrayList = new_java_util_ArrayList()
java_util_ArrayList_add( MyArrayList , NewItem )
The advantage is that you do not have to pre-determine the size of the ArrayList, but you can otherwise treat it as an array.

Aloha,
Mike
that makes sense thanks for the great explanation
Reply With Quote
  #7  
Old 06-09-2009, 07:50 AM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by MeInMaui View Post
SageMC uses ArrayLists quite a bit. You call the constructor once and then append items to the ArrayList as necessary, usually in a loop. In Studio the code would like something like:

Code:
MyArrayList = new_java_util_ArrayList()
java_util_ArrayList_add( MyArrayList , NewItem )
The advantage is that you do not have to pre-determine the size of the ArrayList, but you can otherwise treat it as an array.

Aloha,
Mike
Thank you, thank you... I don't know java that well and that's exactly what i needed
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #8  
Old 06-09-2009, 08:37 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
FYI... But Sun has some good resources and tutorials on Java. If you are not that familiar with java, then I'd look at the "Trails Covering the Basics" section, specifically the first 4 "Trails".

One of the Trails specifically deals with "Collections" which is term to refer to Lists, Sets, Queues, and Maps. Knowing what each of those are, and why you'd use them, can help you a lot. For example, if you are dynamically building a list of items, but you don't want to have duplicates, then you may be tempted to use a List (ArrayList), but then you'd have to track duplicates before you insert them. Using a Set (HashSet) will do that for you and save you a bunch of effort.

Also, understanding the Java implementations for various Collections will be a bonus. For example, using a HashMap will not retain the insertion order of the items, but if that is important, then can use a LinkedHashMap.
Reply With Quote
  #9  
Old 06-09-2009, 09:23 AM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by stuckless View Post
FYI... But Sun has some good resources and tutorials on Java. If you are not that familiar with java, then I'd look at the "Trails Covering the Basics" section, specifically the first 4 "Trails".
Thanks for that link. I will definitely take a look. Some tutorials are exactly what i need
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #10  
Old 06-09-2009, 01:55 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Yeah me too thanks I have bought a couple of books and started reading them as well. It is just easier for me to learn by doing but I know sometimes you have to read
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
Picture quality question, also question on delays andrew1810 SageTV Software 5 03-08-2006 04:51 PM


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


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