Scripting Help w/ Perspective - Passing parameters to a popup window w/ table

Is there anything that you can see that would stop my popup window from opening? The commented rungs are for where a programmer showed me different ways to pass parameters to my table that I’m trying to open. We had the window working, and now it is not.

Also, is there any way to debug these scripts to see where the code is being stopped? I’m used to using an IDE to warn me about errors, and if the program crashes, it tells me where the crashed started.

Nevermind Everyone, I see the simple mistake(s). The tagPathList array that I created in scripting needs to be linked to the array underneath “params” in the view for the table, so I made a new array called tagPathList, and enabled input and output data (it seemed that only allowing data to flow into that array didn’t allow the data to flow into the table, but it did work after I allowed both directions?)

The reason why the window didn’t open was because the for loop had the wrong variable (testPath instead of basePath).

The programmer showed me a bunch of cool functionality, and now I slowly decipher it to figure it all out. Good learning experience for me to solve it on my own, I wonder if he did that on purpose as a learning exercise LOL!

I’m still interested to learn how to debug simple code like this without and IDE, or a way to compile the code. Evidently it will just try to run broken script and not complain but then its harder to debug.

There is no on-board debugger for scripts in Ignition. You can run individual pieces through the Script Console to see how they’re working, but that won’t really work well if you’re passing parameters or receiving values through bindings.

When I’m attempting to discern where a script is breaking down, I always go to my gateway logs for an idea of where the issue is occurring, and then I saturate the troublesome script with

system.util.getLogger('SomeArbitraryNameHere').info('MyValue: {0}'.format(myValue))
# If using Perspective I use the following so that I don't need to go to the Gateway logs
system.perspective.print('MyValue: {0}'.format(myValue))

So if I insert this line of code into the problematic script, where can I expect to see the printed results outside of the gateway, I assume somewhere in the client? How will this help me track down something basic like calling a variable that isn't defined (problem I had above), or a simple syntax error? Again, I'm used to a compiler doing all of that for me, so there is a bit of a learning curve for me here. Thanks a bunch.

In a running session, you'll see the content logged in the browser console (right-click your active browser, select "Inspect" in the context menu). In a Designer, you'll find the content logged in the Designer console (in the Designer menu at the top of the screen select "Tools", then "Console").

Logging won't help with this, however, when you see that the line has not been logged you can then expect to find something like

NameError: name 'myValue' is not defined

in the Gateway logs if the variable was never declared/defined, or a similar Gateway-logged message in the event of a syntax error.

As I said previously, there's no debugger, so this is the only way to check values/types at runtime. Syntax issues and missing declarations are compilation issues, and so a "debugger" would not even start in the strictest sense. An IDE would typically display these errors to you, but the code editors in Ignition are nothing more than glorified text areas and don't have any of the fancy logic an IDE would include (outside of intellihints for system functions).

Alright, thank you very much.

In regards to the popup window, everything is working correcly now, but I’m struggling to find out the most efficient way to pass a new parameter, the title of the table. The title of the table could simply be the last extension of the basePath, so I was trying different variations of view.params.basePath.name, and (or the variable listName that I declared = to basePath …you will see in the screenshot). I’m sure there is a simple way to have the a label above my table that simply displays “Harley Dome”.

Thanks a bunch.

There are, yes, but what you use depends on your expectations for what the basePath will look like. In your instance, basePath is hard-coded, so I don’t understand why you’re not just also hard-coding listName to “Harley Dome”.

If you want something more programmatic, you could use Python splicing:

listName = basePath.split('/')[-1]

In your example, this would return “HARLEY DOME DISCHARGE”, which isn’t quite what you want. if you want to remove the discharge part AND you want the first letters capitalized, you could do :

listName = basePath.split('/')[-1].split(' DISCHARGE')[0].capitalize()

This would get you the desired text of “Harley Dome”, but is dependent on basePath ALWAYS following a pattern of <some_unused_text><known_slash><desired_list_name><potential_discharge>. If " DISCHARGE" is replaced by anything else, then the alternative would be included in the listName.