ioan
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
10:50 AM
[SOLVED] Cannot share functions between brs files in source folder
I created yesterday a new .brs files in my /source folder and it seems that the functions defined in this file cannot be seen by other .brs files from that same folder.
function sendRTSPCommand(socket, commandArray, mtop) is defined in rtsp.brs and is located in /source folder, but when I try to call the function in stream.brs (which is in the same folder), I get the following error:
This doesn't happen with other files that I have there, is just with this, the last one. Also, I checked and the file is in the zip archive that is uploaded to roku.
Any ideas what could be wrong?
function sendRTSPCommand(socket, commandArray, mtop) is defined in rtsp.brs and is located in /source folder, but when I try to call the function in stream.brs (which is in the same folder), I get the following error:
039:* sendRTSPCommand(socket, commandArray, mtop)
040: end sub
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in pkg:/source/stream.brs(39)
This doesn't happen with other files that I have there, is just with this, the last one. Also, I checked and the file is in the zip archive that is uploaded to roku.
Any ideas what could be wrong?
https://github.com/e1ioan/
http://rokucam.com
http://rokucam.com
11 REPLIES 11
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
11:02 AM
Re: Cannot share functions between brs files in source folder
Assuming you're working in RSG, you probably need to include the new file in the XML of any other files where you intend to use its functions;
https://sdkdocs.roku.com/display/sdkdoc/script
<script type = "text/brightscript" uri = "pkg:/components/VideoTheater.brs" />
https://sdkdocs.roku.com/display/sdkdoc/script
aspiring
ioan
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
11:12 AM
Re: Cannot share functions between brs files in source folder
"joetesta" wrote:
Assuming you're working in RSG, you probably need to include the new file in the XML of any other files where you intend to use its functions;<script type = "text/brightscript" uri = "pkg:/components/VideoTheater.brs" />
https://sdkdocs.roku.com/display/sdkdoc/script
The files that I'm trying to share the functions between are just brs files with utility functions with no xml equivalent and they are all in the /source folder. The old ones can share the functions fine between them, just the last one that I created cannot be seen by the other files from the same folder.
https://github.com/e1ioan/
http://rokucam.com
http://rokucam.com
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
01:24 PM
Re: Cannot share functions between brs files in source folder
"ioan" wrote:
[The files that I'm trying to share the functions between are just brs files with utility functions with no xml equivalent and they are all in the /source folder. The old ones can share the functions fine between them, just the last one that I created cannot be seen by the other files from the same folder.
i would venture a guess the .brs file was not included in the build.
to troubleshoot, just check in console when the error happens what's in sendRTSPCommand (? sendRTSPCommand); if it's a function, try calling it with params and so on... you'll figure out what's happening soon enough
ioan
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
01:59 PM
Re: Cannot share functions between brs files in source folder
"RokuNB" wrote:
i would venture a guess the .brs file was not included in the build.
to troubleshoot, just check in console when the error happens what's in sendRTSPCommand (? sendRTSPCommand); if it's a function, try calling it with params and so on... you'll figure out what's happening soon enough
The file IS in the build. I checked and the file, is just like the other ones in the zip archive in the /source directory (I unzipped to make sure is there). After uploading the zip file to Roku device, I get the error above. If I move all the functions from this file to another one that already works, the functions are found. If I copy the functions to another file AND I leave the original file in there, I get the error that the functions are redefined... so the brs is in there, just cannot share it's functions...
------ Compiling dev 'IP Camera Viewer Pro' ------
*** ERROR compiling /pkg:/source/rtsputils.brs:
SUB or FUNCTION defined twice. (compile error &had) in pkg:/source/rtsputils.brs(2) 'sendRTSPCommand'
https://github.com/e1ioan/
http://rokucam.com
http://rokucam.com
ioan
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
02:09 PM
Re: [SOLVED] Cannot share functions between brs files in source folder
joetesta was right... all those libraries of functions end up used in a task, even if I don't call them directly in the task, so I had to include the .brs file in the XML file that belongs to the task
https://github.com/e1ioan/
http://rokucam.com
http://rokucam.com
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2018
04:52 PM
Re: [SOLVED] Cannot share functions between brs files in source folder
There two different models of inclusion:
- main() thread execution sees all functions defined in source/.../*.brs (implicit inclusion)
- component threads only see the functions from explicitly <script/> included files
mco_dolo
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018
03:47 PM
Can't call functions in source folder other than in main.brs
Project structure:
/source - A.brs, B.brs. main.brs
I can call functions from A.brs and B.brs in main.brs, but I can't call functions from B.brs in A.brs and vice versa. Is it suppose to be like that? Thanks.
/source - A.brs, B.brs. main.brs
I can call functions from A.brs and B.brs in main.brs, but I can't call functions from B.brs in A.brs and vice versa. Is it suppose to be like that? Thanks.
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2018
12:28 AM
Re: Can't call functions in source folder other than in main.brs
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2018
10:05 AM
Re: [SOLVED] Cannot share functions between brs files in source folder
Merged the two. Thank you for the pointer @joetesta !