Introduction
In this article we are going to see what a script is in programming, we are going to write a simple script in the notepad that does a certain task and give several examples of application.
Script in programming
In simple terms a programming script is a text document where we place instructions or commands that will then be executed by an intelligent device.
These instructions will be written in some programming language in which their syntax must be respected so that each instruction can be translated into machine language. In addition, each script will be a file with a format that will depend on the language in which it is written.
All the scripts of our program make up the source code.
Let’s write a Script right now!
The field of application of programming is very wide, we can write programs for a number of purposes. I invite you to perform the following experiment for the Windows platform:
Let’s open Notepad, that application that has always been in Windows.
Let’s write the following two lines:
timeout /t 6000 /nobreak
shutdown -h
It should look like this:
We click on “file-save file as” and make sure to choose the option “All Files (.)”, as shown in Figure 2. We give it a name and end it with the extension “.bat” which is the Batch extension or batches. Let’s save it on the desktop to find it quickly.
We are generated a Batch file that we can execute by double clicking, figure 3.
When executing it, the windows terminal opens indicating that it is waiting for a certain amount of time that we have indicated in our Script.
When the 6000 seconds indicated in the script are reached, the second instruction will be executed: “shutdown /h” that will put our equipment in hibernation state.
That’s how easy it is to write a script that fulfills a certain function!
This script is very useful to me to put the computer to hibernate automatically after a certain time, avoiding that it remains on all night.
Other examples of Scripts
Next I’m going to show a series of examples of Scripts that we can find when starting a project that involves programming.
Games made with Unity
If we want to develop a game in Unity, we are going to find the Scripts in C# language. If we want we can write these scripts in Notepad as long as we save them with the extension “.cs”, but that would be unnecessarily complicated. We have Editors that allow us to check the syntax, auto complete and make the job easier.
If you’re interested in learning how to make games at Unity, I invite you to watch the My First Game series at Unity and the new Unity Fundamentals series I’m currently working on. There are videos, articles and files to download.
Android Applications
Maybe you are interested in making an App for Android, in that case an option is to use the Android Studio software.
XML Scripts are used to define the design of our application and logic using Java Scripts. Figures 6 and 7 respectively.
To study programming I have used development environments such as Eclipse or NetBeans, in which I have written Scripts in Java that I could then simulate in the console and analyze the results. Here is an example of a Java script using the NetBeans IDE:
Integrated Development Environments (IDE)
Arduino Projects
Maybe we’re interested in electronics and want to program an Arduino. In that case we are going to write scripts in “.ino” format using the Arduino IDE.
Speaking of Arduino, I leave a video that I uploaded to my channel some time ago about a project in which I used Arduino Mega and sent the information to a simulation made in Unity. The models are made in Unity. I think it would be nice to make a series of videos with a project to combine electronics and game development, just for fun.
Other examples can be Scripts for MatLab or SciLab, plugins for Blender, Scripts to process data in Excel tables, scripts to run macros and many other examples.
Conclusion
Scripts in programming are sets of instructions written in some language and that later will be executed by an intelligent device, be it a computer, a mobile phone, and so on.
The field of application of programming is very wide. Depending on what we want to do we will have different tools to write Scripts and these will be in different formats.