Ability to create local and global variables (scope)

In typical programming languages (Java, C++, JS, some PLC sw) we can define a scope of a variable. Ie define what part of the app has access to that variable.
here is a link for JS scoping in W3 schools.

In Tulip every step in the app can access a given variable, so in terms of scope these are “global” variables. Typically in the OOP world global variables are frowned upon as it causes many bugs and an indication of bad sw planning.

My suggestion is to have “local” variables where a given variable can only be accessed by a single step where it was declared in.
The benefit is we can create reusable steps and easily copy paste, not having 100s of variables in drop downs, less bugs, easy diagnostics. etc

Perhaps something like this:

Actually if this is implemented… then my next request will be “input var” and “output var” … lol

Hey @Rakitha -

This is a feature we think about on occasion internally and go back and forth on it. There are kinda 2 sides to this:

  1. Unquestionably it would make it easier to manage apps with tons of variables and make steps more reusable, this would make it easier to scale Tulip apps across an orginization.
  2. The concept of variables in the first place is one that needs to be learned/understood by new users who have never programmed before, adding a layer of complexity where a user has just created their line variable on step 1, but now on step 2 then can’t tie an imput to it, that could drive a lot of confusion.

We are constantly trying to strike the balance of allow the way you would normally handle this in software and a non programmer can quickly understand this concept. We are adding features to better support power users who have some software background (see custom widgets), but we are always hyper-aware of the impact of changes on new users.

Can you provide a little more context on your input var vs output var concept? Not something I have thought about in the past as it relates to variable scope.

Pete

1 Like

Hi @Pete_Hartnett ,
I totally agree with point #2 and I commend Tulip’s approach and effort in keeping the platform very user friendly. I have seen that Tulip does somethings in 30 seconds and in 1 drop down where as in the past I would spend half a day writing 100 lines of code. So I’m very happy with Tulip.
I come from a PLC programming background (Beckhoff TwinCAT , Rockwell CCW) just to give you a bit of context.
The input and output var I speak of are inline with Function blocks in PLCs or Classes/objects in C++.

Actually I did some reading… What I’m asking for is -“PROPS” in custom widgets. My project is in life sciences. So I don’t have access to custom widgets yet.

1 Like