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:
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.
“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;
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.
“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
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'
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
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.
Hmm, I didn’t understand the solution,
In /source I have A.brs, B.brs, and main.brs. For A.brs to call function from B.brs, I have to create A.xml and import B.brs?
I don’t think A.xml will get initialized unless you call CreateObject(“A”) right??
If main.brs can already statically call methodFromA() so I don’t really know why you would need to call CreateObject(“A”).
Sorry, kinda new to this.