Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kernfamily4
Visitor

Global String Functions in SG App

I am trying to use the global string functions in my app and I am receiving compile error messages. Do I need to include something for these functions to work? I noticed the SG example files do not have Makefiles. Do I need one with some reference to the global functions?

Here is some test code that is in my Init function of my main scene component:

   '** Trim off "List" from the FilterName and add "ID"
   FilterName = "CategoryList"
   Pos = Instr(FilterName, 1, "List")
   Key = Left (FilterName, Pos - 1) + "ID"

Here are the errors I am receiving:

--- Syntax Error. Builtin function call expected. (compile error &h9d) in pkg:/components/TestScene.xml(15)
--- Syntax Error. Builtin function call expected. (compile error &h9d) in pkg:/components/TestScene.xml(16)

I am unable to find any explanations for error messages in the documentation.

I also tried this code and received the same error messages:

   '** Trim off "List" from the FilterName and add "ID"

   FilterName = CreateObject ("roString")
   FilterName = "CategoryList"
   Pos = FilterName.Instr(1, "List")
   Key = FilterName.Left (Pos) + "ID"

Any help would be appreciated. Thanks.
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: Global String Functions in SG App

POS is a reserved word in BrightScript, see https://sdkdocs.roku.com/display/sdkdoc/Reserved+Words

You should never, ever - never ever - use one of the reserved words as variable name, it won't work. 
I agree, the diagnostic does not help. In its defense, pos(0) is an obscure function (related to PRINT).
0 Kudos
kernfamily4
Visitor

Re: Global String Functions in SG App

Thank you,

I never thought to check the reserved word list. In my defense, the message did not mention reserved words. On the other hand, POS is a function in many languages, so I should have known better.

Have a great day
0 Kudos