jlfreund
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2012
10:12 PM
noob questions
Hi, I just got started and have a couple questions I couldn't find answers to in the docs or forum so far...
1) What does "validateParam(variable, "roAssociativeArray", "function") do exactly? I presume it confirms the variable is of type("roAssociativeArray") but I don't know how it uses the "function" argument (it doesn't seem to make a difference what is passed there)
2) Is there a line wrap character to allow you to break the source lines? I prefer to keep my source lines < 80 characters wide, so I was looking for something equivalent to the "\" line break character so I can arbitrarily format the lines.
3) I'd be interested in reading more about the "ro" and "if" relationship. The BrightScriptReferenceManual.pdf talks about "ro" classes implementing multiple "if" classes, but I couldn't find a basic explanation of what "ro" and "if" stand for, and why the app developer needs to be concerned with "if" classes. It seems the ComponentReference only documents "ro" classes, so the discussion of "if" in the former document doesn't seem relevant to the app developer. A deeper discussion or some examples may be helpful here.
I wanted to add that I'm really impressed with the developer support so far. All the hard stuff is already done by the SDK for you, the documentation is good, and the sample code is very good.
Thanks!
Jason
1) What does "validateParam(variable, "roAssociativeArray", "function") do exactly? I presume it confirms the variable is of type("roAssociativeArray") but I don't know how it uses the "function" argument (it doesn't seem to make a difference what is passed there)
2) Is there a line wrap character to allow you to break the source lines? I prefer to keep my source lines < 80 characters wide, so I was looking for something equivalent to the "\" line break character so I can arbitrarily format the lines.
3) I'd be interested in reading more about the "ro" and "if" relationship. The BrightScriptReferenceManual.pdf talks about "ro" classes implementing multiple "if" classes, but I couldn't find a basic explanation of what "ro" and "if" stand for, and why the app developer needs to be concerned with "if" classes. It seems the ComponentReference only documents "ro" classes, so the discussion of "if" in the former document doesn't seem relevant to the app developer. A deeper discussion or some examples may be helpful here.
I wanted to add that I'm really impressed with the developer support so far. All the hard stuff is already done by the SDK for you, the documentation is good, and the sample code is very good.
Thanks!
Jason
3 REPLIES 3
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2012
03:34 AM
Re: noob questions
1) see GeneralUtils.brs
That is what it does exactly.
2) It depends on the screen. If it is an roScreen or roImageCanvas, then no, line breaks don't work - you have to manually split lines. If it is the description area on a springboard or other precreated screen, then yes. Either CHR(10) or CHR(13) does a break/line feed.
'******************************************************
'Validate parameter is the correct type
'******************************************************
Function validateParam(param As Object, paramType As String,functionName As String, allowInvalid = false) As Boolean
if type(param) = paramType then
return true
endif
if allowInvalid = true then
if type(param) = invalid then
return true
endif
endif
print "invalid parameter of type "; type(param); " for "; paramType; " in function "; functionName
return false
End Function
That is what it does exactly.
2) It depends on the screen. If it is an roScreen or roImageCanvas, then no, line breaks don't work - you have to manually split lines. If it is the description area on a springboard or other precreated screen, then yes. Either CHR(10) or CHR(13) does a break/line feed.
jlfreund
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2012
08:07 AM
Re: noob questions
Hi, thanks for the reply. Regarding #2, I was wondering if there is a way to arbitrarily break or insert a new line into the brs source code to improve code readability.
Jason
Jason
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2012
07:29 PM
Re: noob questions
"jlfreund" wrote:
3) I'd be interested in reading more about the "ro" and "if" relationship. The BrightScriptReferenceManual.pdf talks about "ro" classes implementing multiple "if" classes, but I couldn't find a basic explanation of what "ro" and "if" stand for, and why the app developer needs to be concerned with "if" classes. It seems the ComponentReference only documents "ro" classes, so the discussion of "if" in the former document doesn't seem relevant to the app developer. A deeper discussion or some examples may be helpful here.
I also wondered about that and here is my understanding (some months ago i was drawing class diagrams to get an idea of the SDK): what starts with "ro" are classes, what starts with "if" are interfaces/protocols. You can instantiate only classes and a class may implement one or more interfaces. I suspect there is some material implementation of the concept but in practical terms for us those are "traits" in the documentation, i.e. "remember when we described that interface? yeah, this class has all traits from there, we won't repeat it here"