Is GPScript similar to an existing scripting language?

I’m looking to get into scripting for Gig Performer. While the documentation on GPScript is very useful, I’m still feeling lost in many regards as I have absolutely no scripting background or experience. I was hoping that GPScript might be based in or at least similar to an existing scripting language, like python or something similar. If that’s the case, I can go through the beginner tutorials of the more widely used language and get familiar with the basics enought to feel confident tackling GPScript.

So, what’s the best language to familiarize myself with before getting into the logic/syntax of GPScript? Similarly, if anyone has any tips on the best way to learn coming in with almost no knowledge (outside of basic HTML almost a decade ago) I would love to hear em.

Also, if either of the devs happen across this thread, it might be useful to scripting newbies like myself to include a note or something in the documentation on which language GPScript most closely mirrors so they can seek out some beginner basics. Understandably, the info in the manual isn’t meant to hold your hand through script basics, as I can imagine most people who get into this stuff are already familiar with scripting in other contexts. If it is already mentioned in the documentation, then I apologize in advance. I searched through most of the manual/GPScript documentation and wasn’t able to find it myself. Thanks!

1 Like

GPScript is not based on any particular language - it was developed from scratch specifically to integrate seamlessly with Gig Performer. It was however heavily influenced by languages like Pascal.

If you have no programming background, then a google search for something like “basic programming concepts” that introduces you to things like

  • variables
  • variable types
  • loops
  • functions

that should get you started

3 Likes

Ok great, thanks! Would you recommend learning some Pascal ahead of time or just getting a basic understanding of these programming concepts before diving into GPScript directly?

I’ve been trying to learn scripting with specific uses in mind and jumping around the documentation but maybe it would be more useful to just go through the manual front to back and once I feel I understand it all, then trying to write my own use cases.

My advice is that you first check this explanation: How to control multiple parameters with a single widget?

Afterwards, think of your use case and search the community - perhaps that use case is already covered in some community thread(s).

I’m not a great scripter, but luckily, in this Community are people that do wonders with GPScript.

3 Likes

The most important thing to learn (and it’s IMHO also the most diffficult), is to get used to think through the single logical steps which are neccessary to solve a problem - and this “mindset” is completely independent from any programming language.
You should be able to think in a flow chart manner - this will enable you to best define the solution for a problem and form it into code (whatever language you may want to use).

You have to get familiar with the concepts of variables (and their diffrent types), loops, decisions, operations… this also doesn’t depend on a particular programming language!
So, no matter of which language you start to learn, these basic structures will stay the same, but their “look” might vary with diffrent languages.

Then, if you got there and have finally decided which language to use, that’s the point, when it comes to get used to the particular “vocabulary” of that language… and from that point on, you also will be able to understand how use the documentary as it is.

Solving problems in a programming language is nothing that can only be done in one single way, there are many ways, and none of those (which work) is wrong!

I guess, that’s why it is so difficult to learn programming “from scratch” and why there can’t be a “one-size-fits-all” solution for it. But do dare to enter this Rabbit Hole! …and take your time and start with small steps…

5 Likes

That’s always my first go to, and has given me some great solutions. I’m definitely guilty of searching the forums before even checking the manual just because there are so many knowledgeable and helpful users here. Also seen some ingenius workarounds/alternate methods. e.g. a couple weeks ago I was searching how to get a midi cc input from a sustain pedal to be treated as a midi note. I found an old thread asking the same question. Someone had written a great script to answer OP’s question but another user replied you could do the same thing without scripting by just mapping the midi cc to a widget which is then linked to a midi in block and sends the note. Pretty clever.

Also thank you for the link! I’ve actually skimmed that page in the past but I’ll definitely start there. Looks like a quick way to get acquainted with the relationship between scripts and widgets/blocks.

I think the one thing I have going for me is that I usually have a pretty good idea of the general logic and order of arguments that I could use to get the job done. Understanding operators, variables, etc. and using the proper syntax is where things start to get tripped up. Nothing like compiling a script and seeing an error returned on line 1!

This is one of the appealing things about scripting to me from what little I understand of it. It’s kind of like music even; a soloist has countless ways to arrange and place notes, as long as they fall in the scale. I’m sure once I get past the initial frustration of learning this stuff I can start to enjoy the problem solving aspects. Thanks for the advice!

2 Likes

Why not start a thread here in this sub forum, where you first describe your actual intention, means “tell us what you like to do with scripting”… maybe nothing too complex for the beginning.
And then we (or just me) will try to help you get there… step by step. And maybe there might be some other users who want to join this “course” too (mabye as “students” or maybe as “teachers”)?
I can’t promise that this will be a success, but we could just try… :beers:

3 Likes

Pascal is pretty obsolete, but pretty much all programming languages use the same concepts (as David mentioned) and it comes down to semantics and syntax. Why learn some other language before diving into GP script if GP script is the tool you need? Just study the many examples in the forums and you will soon see many patterns that you can begin to shape into the tools you need or want.

2 Likes

Are you kidding? Go play with the FPC (Free Pascal Compiler) along with the Lazarus IDE — runs on Mac, Windows, Linux and numerous other platforms. FPC is a really good optimizing compiler and support modern OO techniques, exception handling, etc really well. It’s still supported and under development

If it hadn’t been for the need to use some existing C++ libraries, we would have developed Gig Performer in Pascal…it’s a great language, seriously underappreciated.

1 Like

While it may not be necessary to learn another language, it is still useful to read up on basic concepts as mentioned earlier — otherwise even such simple things as

x = x + 1

can be confusing until you understand what’s going on (after which point it’s simple :slight_smile: )

1 Like

I may just do that, as long as it wouldn’t be received poorly. I try to be careful about asking for too much from communities like this where everyone is extremely eager to help as to not take advantage of their kindness and knowledge. But I’ll start keeping track of the script use cases I think of and once I have a few that aren’t extremely specific to my needs or overly intricate I’ll make a thread. Hopefully it can help others too, like you said.

Well I tried getting into it one night using the documentation and index reference guide but it didn’t really click for me. It felt like the explanations and examples were moving quickly through concepts and examples without fully explaining them for a complete coding novice like me. That’s why I thought if it closely mirrored a popular language I could go through some of the beginner learning resources for that language to fully grasp the logic, arguments, variables, etc. before getting familiar with how they’re expressed in GPScript.
I will say that when I tried getting familiar with it, I was trying to script to accomplish a specific task I already had in mind so maybe that’s why it didn’t click. Could’ve been that I wasn’t fully digesting the information since I was seeking out specific sections that I felt like applied to my task. After about 10 or 15 errors when trying to write a functional script, I gave up. Once I do a quick read up on the basic concepts of scripts, though, I’ll take your advice and look at more examples here in the forums.

@dhj does x = infinity?

In the example of @dhj, x is a variable, x + 1 means “add 1 to the value of x”, while the result of this operation is stored in the variable again, that’s what “x = …” means.

Could you give us an example of a GPScript which results in compilation errors ?

2 Likes

I didn’t save my previous attempt at a script, since I didn’t think I was anywhere close to a working script. So unfortunately I don’t have it available.
The script I was unsuccessfully experimenting with was one that would send multiple midi notes through a midi in block when a certain midi note was sent to that block. But to have this function “inside” of another parent function that would change the “trigger other midi notes” note number based on what midi note was being played in the bass. This would allow me to to play bass notes and chord extensions with only one hand.

It’s been several weeks since I looked at the documentation so apologies if this is confusing or completely off-base, but I believe the rough logic behind it went something like this (not meant to be actual script, obviously):

 Receive midi note input from controller
     If note is F#1 then f#m7function:
           when midi note is A1  
           send midi notes A3, C#4, E4, and A4 to midi in block
     If note is B1 then end f#m7function and 
     If note is B1 then b13function:
           when midi note is D#2, send midi notes 
           A3, C#4, D#4, and G#4 to midi in block
     If note is Ab1 end b13function and 
etc. etc. etc. 

Ok I wrongly assumed he was was providing a metaphor of how x=x+1 is a seemingly paradoxical math equation that seems nonsensical until you understand that x is the limitless “number” infinity aka ∞ (since adding a number to infinity still results in infinity). I thought he was comparing this type of seemingly confusing equation with how scripting/code seems very confusing to many newbies like me until you understand the simple explanation behind it. Clearly I was way off the mark there haha.

Now I understand the statement is just redefining the value of x by adding a number to its previously stored value. Thanks for clearing that up. Obviously I’m not quite thinking like a coder yet.

And that was precisely my point…. it’s necessary to understand some basic concepts before you get started. None of them are hard but they can be a little confusing.

Pascal (and some other related languages) used a different symbol for assignment, i.e.

   x := x + 1

to make it clear that the operation was not stating any kind of equality but rather was setting a variable to the value of an expression that could include the previous value of that same variable. In fact, GP Script supports that assignment symbol as well. I considered requiring that symbol and not allowing ‘=’ but so many people are used to using the latter that I felt it should be allowed.

1 Like

LOL, somehow I knew I would get some blowback on that. I even Googled to see if anyone was actually using some form of Pascal, didn’t find much. Last Pascal I remember using was from Borland probably in the late '80s early '90s. Back when I was also coding 6502 and 8088 assembly language. Yeah, those were the days.

Pascal, Object Pascal (and its “dialects”) are pretty much still not dated.

1 Like

It’s kinda related to the split in how programming languages were taught in the US vs in Europe.

In the former, CS was mostly part of engineering whereas in Europe it was mostly coming from Math and so there was a more formal approach than “let’s get the job done”

Just my theory having been exposed to both sides.

Turbo Pascal was awesome as were early versions of Delphi which were essentially similar to Visual Basic except with a decent underlying language.

But if I have write tools and other auxiliary stuff, I’ll often turn to the FPC and Lazarus….it’s just more fun!