Scripts in Programming

Introduction

In this arti­cle we are going to see what a script is in pro­gram­ming, we are going to write a sim­ple script in the notepad that does a cer­tain task and give sev­er­al exam­ples of application.

CHECK OUT THIS CRAZY EXPERIMENT

Script in programming

In sim­ple terms a pro­gram­ming script is a text doc­u­ment where we place instruc­tions or com­mands that will then be exe­cut­ed by an intel­li­gent device.

These instruc­tions will be writ­ten in some pro­gram­ming lan­guage in which their syn­tax must be respect­ed so that each instruc­tion can be trans­lat­ed into machine lan­guage. In addi­tion, each script will be a file with a for­mat that will depend on the lan­guage in which it is written.

All the scripts of our pro­gram make up the source code.

Let's write a Script right now!

The field of appli­ca­tion of pro­gram­ming is very wide, we can write pro­grams for a num­ber of pur­pos­es. I invite you to per­form the fol­low­ing exper­i­ment for the Win­dows platform:

Let's open Notepad, that appli­ca­tion that has always been in Windows.

Let's write the fol¬≠low¬≠ing two lines:

time­out /t 6000 /nobreak

shut¬≠down ‚ÄĎh

It should look like this:

Fig. 1: Script made in Notepad. When run­ning, the com­put­er waits 6000 sec­onds and then goes into hibernation.

We click on "file-save file as" and make sure to choose the option "All Files (.)", as shown in Fig­ure 2. We give it a name and end it with the exten­sion ".bat" which is the Batch exten­sion or batch­es. Let's save it on the desk­top to find it quickly.

Fig. 2: Save How win­dow of Notepad. Put the exten­sion ".bat".

We are gen¬≠er¬≠at¬≠ed a Batch file that we can exe¬≠cute by dou¬≠ble click¬≠ing, fig¬≠ure 3.

Fig. 3: File gen­er­at­ed when sav­ing with the extension.

When exe­cut­ing it, the win­dows ter­mi­nal opens indi­cat­ing that it is wait­ing for a cer­tain amount of time that we have indi­cat­ed in our Script.

Fig. 4: Exe­cu­tion of the "hibernar.bat" script.

When the 6000 sec¬≠onds indi¬≠cat¬≠ed in the script are reached, the sec¬≠ond instruc¬≠tion will be exe¬≠cut¬≠ed: "shut¬≠down /h" that will put our equip¬≠ment in hiber¬≠na¬≠tion state.

That's how easy it is to write a script that ful¬≠fills a cer¬≠tain function! 

This script is very use¬≠ful to me to put the com¬≠put¬≠er to hiber¬≠nate auto¬≠mat¬≠i¬≠cal¬≠ly after a cer¬≠tain time, avoid¬≠ing that it remains on all night.

Other examples of Scripts

Next I'm going to show a series of exam­ples of Scripts that we can find when start­ing a project that involves programming.

Games made with Unity

If we want to devel­op a game in Uni­ty, we are going to find the Scripts in C# lan­guage. If we want we can write these scripts in Notepad as long as we save them with the exten­sion ".cs", but that would be unnec­es­sar­i­ly com­pli­cat­ed. We have Edi­tors that allow us to check the syn­tax, auto com­plete and make the job easier.

examples of scripts in programming, unity game development
Fig. 5: Script in c# belong¬≠ing to the devel¬≠op¬≠ment of the series "Fun¬≠da¬≠men¬≠tals of Unity".

If you're inter­est­ed in learn­ing how to make games at Uni­ty, I invite you to watch the My First Game series at Uni­ty and the new Uni­ty Fun­da­men­tals series I'm cur­rent­ly work­ing on. There are videos, arti­cles and files to download.

Android Applications

Maybe you are inter­est­ed in mak­ing an App for Android, in that case an option is to use the Android Stu­dio software.

XML Scripts are used to define the design of our appli­ca­tion and log­ic using Java Scripts. Fig­ures 6 and 7 respectively.

examples of scripts in programming, xml scripts for android applications in android studio
Fig. 6: XML script for the design of an appli­ca­tion in Android Studio.

examples of scripts in programming, java scripts for android applications in android studio
Fig. 7: Java script for the design of an appli­ca­tion in Android Studio.

To study pro¬≠gram¬≠ming I have used devel¬≠op¬≠ment envi¬≠ron¬≠ments such as Eclipse or Net¬≠Beans, in which I have writ¬≠ten Scripts in Java that I could then sim¬≠u¬≠late in the con¬≠sole and ana¬≠lyze the results. Here is an exam¬≠ple of a Java script using the Net¬≠Beans IDE:

Integrated Development Environments (IDE)

examples of scripts in programming, java scripts in eclipse
Fig. 8: Java script using Net­Beans IDE. The Script is for the study of con­cur­rent programming.

Arduino Projects

Maybe we're inter­est­ed in elec­tron­ics and want to pro­gram an Arduino. In that case we are going to write scripts in ".ino" for­mat using the Arduino IDE.

examples of scripts in programming, c scripts for arduino programming
Fig. 9: Arduino default script.

Speak¬≠ing of Arduino, I leave a video that I uploaded to my chan¬≠nel some time ago about a project in which I used Arduino Mega and sent the infor¬≠ma¬≠tion to a sim¬≠u¬≠la¬≠tion made in Uni¬≠ty. The mod¬≠els are made in Uni¬≠ty. I think it would be nice to make a series of videos with a project to com¬≠bine elec¬≠tron¬≠ics and game devel¬≠op¬≠ment, just for fun.

Simulación de proceso industrial hecha en Unity
 ūüüĘ

Oth­er exam­ples can be Scripts for Mat­Lab or SciLab, plu­g­ins for Blender, Scripts to process data in Excel tables, scripts to run macros and many oth­er examples.

Conclusion

Scripts in pro¬≠gram¬≠ming are sets of instruc¬≠tions writ¬≠ten in some lan¬≠guage and that lat¬≠er will be exe¬≠cut¬≠ed by an intel¬≠li¬≠gent device, be it a com¬≠put¬≠er, a mobile phone, and so on.

The field of appli¬≠ca¬≠tion of pro¬≠gram¬≠ming is very wide. Depend¬≠ing on what we want to do we will have dif¬≠fer¬≠ent tools to write Scripts and these will be in dif¬≠fer¬≠ent formats. 

YouTube
Scroll to Top
Secured By miniOrange