This is an entirely new section on basic scripting in nuke script editor for personal reference only. There are couple of things to understand in scripting, which is Scripting Language.

 

“A scripting language or script language is a programming language that supports scripts, programs written for a special run-time environment that can interpret (rather than compile) and automate the execution of tasks that could alternatively be executed one-by-one by a human operator. – wikipedia”

 

Data types

 

variables = A variable in a shell script/script editor means of referencing a numeric or character value. Qoute – http://lowfatlinux.com/linux-script-variables.html

However, programming is not limited only to printing simple texts on the screen. In order to go a little further on and to become able to write programs that perform useful tasks that really save us work, we need to introduce the concept of variable. Qoute – http://www.cplusplus.com/doc/tutorial/variables/

 

string = An example of compound type is the string class. Variables of this type are able to store sequences of characters, such as words or sentences. A very useful feature!

A first difference with fundamental data types is that in order to declare and use objects (variables) of this type, the program needs to include the header where the type is defined within the standard library (header <string>) Qoute = http://www.cplusplus.com/doc/tutorial/variables/

To recognize a string, there is always an open hyphen. There are also various hyphen and brackets in script that are like ” ” , (  ) , [   ] , {  }

On the above case, python cant recognize dog as a variable because there isnt an open close hyphen on it.

With the open close hyphen, python can recognize its a variable and will print – this is dog

For example “apple” , “doctor” , “dog” , “this is a string”

 

integer = integers are numbers,whole numbers that are not 11.5 , 5.5. They are  ( 56 , 23 , 5 ,11 ) In script editor it will be typed as int

 

float      = floating numbers. For example ( 1.0 , 5.1 , 88.5 )

 

print = to execute commands. For example: print(“Today is a good day”)

 

*The reason why there are data types in green or red is that python has reserved them for certain functions.

*There are times when script has an error that says – TypeError: cannot concatenate ‘str’ and ‘int’ objects

concatenate means combine, in this case it means a string cant be combined with an integer (number)

In order to solve this, we should tell python that the integer is a string in order to print out the result. By adding str + (  ) it should work, put the integer into the bracket.


Below are a couple of examples on how does these data types works with each other.

Python is able to add both same data type together. For example on the above case, it is able to combine two variables together without the open close hyphen.

 

On above example, because all variables are integers, python can add all of them.

 

python can also recognize integer and float together.

 

You can also create a variable to add two integers together.  Above is an example.

By printing the result of the variable it will add the integers.

 

As for this, we will need to tell python theres string and integer to be executed. So we have to put str(  ) for the integer in order to combine both info together.

Will continue with more information on the next post 🙂