Manual Visual Studio - 2020
Manual Visual Studio - 2020
Visual Studio
ISBN 978-1727581539
Preface
i
ii
For these purposes, the chapter 1 deals with the installation of Visual
Studio in a Windows OS and some essential tools associated to the IDE. It
also treats how to configure the environment in order to start using some
really powerful functions.
Finally, the chapter 6 covers the use of Git and GitHub, a Version Con-
trol Systems (VCS) compatible with Visual Studio, and once again, a pow-
erful tool when managing codes.
Preface i
1 Introduction 1
1.1 Development Environments . . . . . . . . . . . . . . . . . . . 1
1.2 Configuration and Project Files/Folders . . . . . . . . . . . . 4
1.3 Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2 Visual Studio 15
2.1 Installing Visual Studio . . . . . . . . . . . . . . . . . . . . . 15
2.2 Configuring Visual Studio features . . . . . . . . . . . . . . . 22
2.3 Importing the environment configuration . . . . . . . . . . . . 33
2.4 Modifying shortcut icons . . . . . . . . . . . . . . . . . . . . . 34
2.5 Enterprise distribution of Visual Studio . . . . . . . . . . . . 40
3 Python Projects 47
3.1 Installing Python Interpreter . . . . . . . . . . . . . . . . . . 47
3.2 Create a Python project . . . . . . . . . . . . . . . . . . . . . 49
3.3 Execute the “Hello World” example . . . . . . . . . . . . . . 50
3.4 Installing and removing Python Packages . . . . . . . . . . . 50
3.5 Include modules & packages from other Projects . . . . . . . 52
4 Arduino Projects 57
4.1 Install Visual Micro plug–in . . . . . . . . . . . . . . . . . . . 57
4.2 Create an Arduino Project . . . . . . . . . . . . . . . . . . . . 58
4.3 Execute the “Hello world” with Arduino . . . . . . . . . . . . 58
4.4 Configuring complex projects . . . . . . . . . . . . . . . . . . 59
iii
iv CONTENTS
5 Fortran Projects 69
5.1 Installing Fortran Compiler . . . . . . . . . . . . . . . . . . . 69
5.2 Create a Fortran project . . . . . . . . . . . . . . . . . . . . . 75
5.3 Compile, link and execute the “Hello world” example . . . . . 75
5.4 Include new projects and new files . . . . . . . . . . . . . . . 76
5.5 Configuring compilation options . . . . . . . . . . . . . . . . . 79
5.6 Configuring a graphic library: DISLIN . . . . . . . . . . . . . 86
5.7 Fortran FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6 Web Projects 99
6.1 Installing tools . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.2 Create Website HTML/CSS/JS project . . . . . . . . . . . . 100
6.3 Execute the “Hello world” example . . . . . . . . . . . . . . . 104
6.4 Web Application: Fundamentals . . . . . . . . . . . . . . . . 111
6.4.1 HTML Structure . . . . . . . . . . . . . . . . . . . . . 113
6.4.2 CSS Concepts . . . . . . . . . . . . . . . . . . . . . . . 115
6.4.3 JavaScript Concepts . . . . . . . . . . . . . . . . . . . 116
6.5 Installing Node.js tools . . . . . . . . . . . . . . . . . . . . . . 117
6.6 Create a Node.js project . . . . . . . . . . . . . . . . . . . . . 118
6.7 Execute the “Hello world” example (Node.js) . . . . . . . . . 119
6.8 Debugging a web page . . . . . . . . . . . . . . . . . . . . . . 120
6.9 Cordova project . . . . . . . . . . . . . . . . . . . . . . . . . . 121
References 131
Chapter 1
Introduction
The aim of this manual is to guide the user in the first steps of Python, C++,
Fortran and Web (HTML/CSS/JavaScript) programming with Visual Stu-
dio. When starting to code in any language there are a number of essential
concepts that should be perfectly understood and they are not always clear
for beginners. We cover some of those concepts in this introduction.
1
2 CHAPTER 1. INTRODUCTION
the interpreter takes all the code line by line and performs the compilation
and execution simultaneously. On the contrary, when a compiler is used,
the execution comes after the compilation. Compilers are generally faster
than interpreters but the detection and removal of errors are more diffi-
cult since the interpreter allows resuming the translation when the error is
fixed. In addition, it is said that the interpretation or compilation of the
code are a property of the implementation and not the language. Hence,
some programming languages like C, C++ or Fortran are implemented with
a compiler while Python make use of an interpreter in one stage of the im-
plementation.
On the other hand we find IDEs (like Visual Studio). They are a soft-
ware application that offers some facilities for software development. Some
of the functionalities that the IDE provides are a source code editor (sim-
ilar to a text editor), build automation tools, version management tools,
a debugger, intelligent code completion and a long etcetera. It is possi-
ble to write programs without an IDE but it is less comfortable specially
when too many source codes are involved in the program. This guide ex-
plains how to install and start using Microsoft Visual Studio (which
accepts 36 different programming languages) and all the necessary tools
associated to the mentioned programming languages. Some of these tools
are for example the Intel® Fortran Compiler (Parallel Studio XE 2018)
or the compiler for C++ (Intel® C++ Compiler or similar) which allow
compiling programs. In addition, a Python interpreter, the Visual Micro ex-
tension (Arduino projects) and some web tools will be included in the IDE.
Please notice that the first thing to install in your computer is the IDE,
Visual Studio. Then all the compilers, interpreters and extensions needed
are added to the environment so it can recognise the different languages.
It has been mentioned before that working with an IDE is not manda-
tory for programming, it is just an useful tool that can make easier the
software development. The process of coding can be developed by means
of a code editor or a simple text editor, later with the use of the command
prompt we can call the compiler/interpreter of our programming language
and build any project. Hence, one question that may appear is: What are
the differences and advantages of using an IDE instead of a Code Editor?
of Visual Studio), etc. The IDE is where we write the code and convert it
into a product, a compiled program, a web app, etc., using a lot of tools
and everything in one single program.
On the contrary, we find Code Editors which are more than text edi-
tors since they have enhanced features. When they are optimized for source
code editing, they provide syntax highlighting, navigation tools, search pos-
sibilities and they are often easily customized. The bottom line is that they
are limited to the edition of plain text, they do not compile and debug the
code in their nature, however, they accept plug-ins and extensions to imi-
tate the use of an IDE. Finally, a third option would be programming with
command-line tools.
In the IDE, we have access to all the essential tools related to software
development just learning how to use one program and we do not need to
check the compatibility between the tools used since they are all imple-
mented in the same environment. While the potential of Visual Studio is
more remarkable when developing a big software project, it is a really com-
fortable tool to use even with little projects. It is sometimes said that a
Code Editor is going to be very useful with languages that does not need to
be compiled (like JavaScript or a static HTML page for example) since they
are lighter. On the contrary, languages like Fortran that are being compiled
and executed constantly are going to be easily used with an IDE, which of-
fers quickly (and with no need of external plug-ins) these capabilities. This
is specially important when our project needs from the pre-process, compi-
lation and linked of a big amount of codes (with an Editor we should do it
manually).
In addition, IDE’s often use the Make tool, this is a build automation
tool in charge of building the libraries and executable files of our program
4 CHAPTER 1. INTRODUCTION
starting with the source code. It makes use of files called Makefiles where
a set of directives are stored specifying how to generate the target program.
This tool decides automatically the order of compilation for all the source
codes involved in the project by reading the dependencies between them.
Furthermore, if we change the source code of a file and rebuild the whole
project, the Make tool will update the project by compiling and rebuilding
only one file, with no need of building the whole project again. This can
be done by reading the modification date of all the files and as a result the
process is much faster, specially when the project has a large number of
source codes.
Figure 1.1: Scheme of the main folders that we should have in a solution containing
different projects.
library file to the logical folder called “libraries” while the real file is stored
in our Desktop. The Fortran project will store the information about the
location of the library. In addition, if we create a new file in that folder
(using Visual Studio), it is by default stored in the project folder in the
hard drive, but not necessarily in a folder called with the same name. The
folders that organize all the necessary content for the program are different
and we must manage not only the order used in the solution (seen in the
solution explorer in Visual Studio) but also the real location of the files.
It is not the same for languages like Python or JavaScript. Once the
project is started, if we create a folder or a code file using Visual Studio, the
same folder or file is created in our hard drive in the same location where our
project and solution are (both projects and solutions are explained later). In
this case we do not have to take an strict control of files since the structure
is repeated and consistent.
Let’s think about a code file that we use in many different projects
(stored in our desktop, outside our project folder, for example). If we are
using Fortran, we can add that file to our project with no need of copying
the file to the project folder. Different projects will have the path associated
to the file and if we make a modification to the file, all the projects benefit
from that update in the next compilation. Once again, this is different for
languages like JavaScript. If we add the file to the project, a copy is auto-
matically made in the project folder and a modification in the code stored in
the desktop will be totally useless. If the file is used in 3 different projects,
a modification in the code can become a mess. We strongly recommend to
delete all files that has been previously copied to a project in order to avoid
unnecessary duplications (there cannot be two files with the same name). If
the code is going to be used in different projects we will build a library with
that code (treated in each language) and include it in the different works.
1.2. CONFIGURATION AND PROJECT FILES/FOLDERS 7
Important Notice
For all these reasons, we are going to follow the same files/folders
scheme in our projects from now on. Whether it is automatically
created or not, we have to store all the source codes in a folder called
“sources” inside our folder project (see Figure 1.1). If the folder is
not created by default in both the real and the logical folder scheme,
we have to do it manually. In addition, a list of files and folders are
created together with the source files in order to make the project
work properly. These additional elements depend on the program-
ming language we are using and they would be treated in the specific
chapter. As a practical implementation of this topic, take a look at
the example 1.4.
Nevertheless, our programs are not only comprised by code files. Visual
Studio works with the concepts of projects and solutions, each of them with
their configuration files and extensions associated. It is important to
clarify the nomenclature that the program gives to the project and solution
files since we are going to live together with them from now on. Simplifying,
it could be said that a project is a specific program written in a programming
language while a solution is a set of different programs. In the official
Microsoft Visual Studio documentation a project is defined as:
(https://msdn.microsoft.com/en-
us/library/b142f8e7.aspx)
8 CHAPTER 1. INTRODUCTION
(https://msdn.microsoft.com/en-
us/library/b142f8e7.aspx)
Both the solution and the project have files associated. The file where
the solution is stored has .sln extension and contains information that the
environment uses to load it, load the projects within the solution and other
information attached. As an example, we can find there the file format
version, the newest version of Visual Studio that saved the file, the older
version of VS that can open the solution and a list of parameters needed
for loading the project files. In the case of the project, the extension of
the file depends on the programming language used. If an Intel Fortran
project has been created, the extension is .vfproj while in the case of a C++
compiler, .icproj would be the extension. This file stores information about
the configuration of the project in the different building modes; Release,
Debug and those created by us. It also stores the name and relative path of
all the files needed for opening and building the project and the admitted
extensions that can be opened.
The solution and project files are XML files (Extensible Markup Lan-
guage), this means that the data structure is machine-readable and human-
readable at the same time. Although both kind of files are automatically
generated by Visual Studio and they are not made for being modified by
hand, we can do it if required. We could open the file with a text editor,
read the information and change parameters directly with no need of using
VS. The solution settings for each user are stored in the .suo file that Visual
Studio automatically creates when the solutions is saved. Unlike the men-
1.3. EXAMPLE 1 9
All the configuration files mentioned are physically stored in our hard
drive, in the folder reserved for the solution and the projects.
1.3 Example 1
In order to help the reader in the first steps with Visual Studio, a repository
has been created in GitHub with the solutions and projects explained here.
Apart from the examples created in the guide, some extra content can be
found, specially in the fields of Applied Maths, Simulation software with
Fortran, Energy efficiency in buildings or Embedded software (C++). The
repository is located in the url: https://github.com/jahrWork (Figure
1.2).
1.4 Example 2
Open now the path where your new solution has been created and open
your solution folder. You find a .sln file with the name “Semester1” and
a folder Milestone1 containing the project data. Right now in this project
folder you have a file Milestone1.vfproj with the configuration of the project,
this configuration data is read by VS when the solution is opened. In
addition, the first source code file .f90 (with the same name of the project)
has been created.
Figure 1.4: Initial folders and files structure in the File Explorer of Windows and
the Solution Explorer of Visual Studio.
1.4. EXAMPLE 2 13
However, our first project is going to grow and some files and folders
will be created. The following steps show how to imitate the structure seen
in the Figure 1.1 in order to maintain a strict folder order.
Finally, all the projects to be created during the rest of the semester
(Milestone2, Milestone3, etc.) can be stored in the same solution. The
section 5.4 tells how to include new projects and files in a solution already
created. At the end of the semester you will have something like the Figure
1.6.
14 CHAPTER 1. INTRODUCTION
Figure 1.5: Folders and files structure in the File Explorer of Windows after orga-
nizing the Fortran project.
Figure 1.6: Folders and files structure in the Solution Explorer of Visual Studio
after creating three projects in the same solution.
Chapter 2
Visual Studio
The first thing we are going to do is to install the latest version of Visual
Studio, the IDE, in our computer. We have to download the installer
of the program in the tab “Downloads” of the official website (https://
visualstudio.microsoft.com/es/downloads/). There, Microsoft offers
the installers for the Community, Professional and Enterprise versions1 .
Please notice that Professional and Enterprise releases have to be paid in
case no license is obtained. However, the Community version is free and it
is enough in most of the cases for the use we are going to make. If you are
interested in the VS Enterprise distribution see how to install it with
an academic license in the section 2.5.
1
In the same webpage Microsoft give us the possibility of downloading another tool:
Visual Studio Code. In the introduction of this guide we explain why we use Visual Studio
instead of this editor.
15
16 CHAPTER 2. VISUAL STUDIO
Important Notice
• The examples of this book are created using Visual Studio 2017
and 2019. Typically, the Microsoft webpage offers the latest
version of the IDE, however, you will find a previous distribu-
tion to download in case your computer is running an older
Windows version (like Windows 8 for example).
When opening the url we quickly find the section reserved for the last
release of Visual Studio (see Figure 2.1). In case the Visual Studio down-
loads are not shown, we can look for it by scrolling down the webpage or
writing “Microsoft Visual Studio” in the space reserved for the search of
downloads. We can obtain the installer of the Community version by click-
ing on “Free Download” in that distribution. A file is downloaded on our
computer, the name should be something similar to vs_yyyyyyyy_xxxxx.exe
where the distribution appears instead of “y” and a number of version ap-
pears in the place of the “x”. We have chosen the Community version so we
obtain a file similar to vs_community__2074385403.1558468341.exe. In
case a more complete IDE version is needed, later it is explained how to
obtain a student license and download the Enterprise distribution of the
tool.
2.1. INSTALLING VISUAL STUDIO 17
Figure 2.1: Downloads tab of Microsoft Visual Studio webpage where the different
installers for the distributions available can be downloaded.
1. Execute the installer you have obtained. Accept first that the execu-
tion is done as an administrator and later accept the privacy conditions
and the terms of the license of the software by clicking on Continue.
Wait for the program to download and start installing (see Figures
2.2 and 2.3).
2. When finished, some options will appear in a window. There are four
different tabs: Workloads, Individual Components, Language Pack-
ages and Installation folder. This tool called Visual Installer is es-
sential for obtaining compilers and other tools used with different
programming languages. In Workloads we choose Desarrollo para el
escritorio con C++ and in Language Packages we choose: English or
both Spanish and English (see figure 2.4).
5. Execute Visual Studio. The first time some welcome windows appear
(see figure 2.5), first we are going to Start Session. Although Commu-
nity distribution is free for the people we first obtain a license for 30
days and we have to initiate session in order to activate the product.
Click on Initiate Session and in the new window that appears use your
18 CHAPTER 2. VISUAL STUDIO
Figure 2.2: First window that appears when executing the Visual Studio installer.
2
If you use the institutional email of the UPM (finished with @alumnos.upm.es), you
will be redirected to the organization’s sign-in page of the UPM. There you have to write
again the same email and the password for that account and confirm the process. A
webpage with the header “Servicio de Identidad de RedIRIS” may appear.
2.1. INSTALLING VISUAL STUDIO 19
Figure 2.3: Download and installation process of the Visual Studio environment.
Figure 2.5: Start window that appears after the installation, we have to start
session now in order to use the options of Community version with no limit.
Figure 2.6: Account Configuration inside the IDE, here we can activate the license
and manage our accounts. You can use an institutional email or the Microsoft
account.
2.1. INSTALLING VISUAL STUDIO 21
Figure 2.7: Account Configuration menu, click on “Search for an updated license”
if your product is not already activated.
Together with the environment itself, the Visual Studio Installer has
been included in our computer, we can check it in the Start menu of Win-
dows. We have seen this tool before during the process (Figure 2.4) and
we are going to open it a few more times if we install all the programming
languages and tools explained in this guide. For example, all the necessary
tools needed for writing Cordova projects (smartphone applications) or the
minimum templates used in a basic webpage can be installed using this
installer.
Important Notice
Now we are going to look through a list of useful functions and general
common features that Visual Studio offers. All of them, when controlled,
make the process of programming simpler:
1. Language
2. Line numbers
3. Navigation through files
4. Look for references
5. Open the definition of source functions and variables
6. Show description of intrinsic and new functions
7. Executing the program: Start without Debugging
8. Outlining blocks
9. Additional requirements
10. Common IDE configuration
11. Windows inside the IDE
12. Find in Files, Find and Replace
2.2. CONFIGURING VISUAL STUDIO FEATURES 23
Figure 2.8: Example of the line numbers that leads all the code lines of a program.
1. Language
This manual has been written assuming that the IDE is configured
in English, if you have used Spanish as default language, it can be
changed in Tools/Options/International Settings. There are options
and commands with no intuitive translation to Spanish so we recom-
mend getting used to the English version of the IDE and the English
name of the programming concepts.
2. Line numbers
The line numbers are unique assignments for each of the code lines of
your program (see Figure 2.8). This essential tool is used in all the
programming languages mentioned in this guide, they are specially
helpful when a list of errors appears in the compilation and each error
must be found (in a specific file and line) in order to fix them. It is
a good idea to change the configuration of the IDE to show them by
default, independently of the language. Go to Tools/Options... and in
the menu Text Editor/All Languages/General select the option Line
numbers. These numbers are also an easy way of referencing your code
in case of writing documentation about it.
24 CHAPTER 2. VISUAL STUDIO
Important Notice
Notice that Visual Studio has a very useful search engine that
can be accessed with toolbars. The command needed is Find in
files or just Find and it can also be minimised and put every-
where in the screen, ready to be used whenever. It is treated
later in the item 12.
2.2. CONFIGURING VISUAL STUDIO FEATURES 25
Figure 2.10: Enable Find All References and Enable Go To Definition options to
activate in the Visual Studio configuration.
Figure 2.11: Enable Intrinsic Parameter Info and Enable Intrinsic Quick Info are
both really useful when our codes become long and they are spread in multiple
source files.
of your toolbars. If you cannot see the mentioned icon in your toolbars
take a look at the section 2.4.
Notice that Visual Studio will launch your application without at-
taching the Debugger, you won’t be able to pause the execution by
breakpoints or use default debugging tools of the IDE. However, this is
by far the most common method for executing programs in this guide.
The behaviour of the command depends on the specific language used.
For example, in Fortran it saves the modified files, compiles, links
and executes all the project selected in the Solution Explorer. By
contrast, in Python this command invokes the interpreter and the
code is read and interpreted so the results can be shown in a com-
mand window.
8. Outlining blocks
Outlining the source code is one of the most common code folding
patterns that IDEs and code editors offer. This feature allows to
collapse a code block to a single line normally based on the syntax
of the specific language used (other mechanisms appear depending on
the indentation, the tokens or the preferences of the user). In general,
the user can hide and show pieces of code that define a structure e.g.
functions, subroutines, loops, if statements, etc. Then the code can
be easily managed (specially if there is a large amount of text in the
program) since only the headers of the hidden block are seen. Getting
an overview of code and navigating through is now easier without
being distracted by other code. The Figure 2.14 shows an example.
Depending on the language you are configuring the way to activate
these features can vary, as an example we can go to TOOLS/Op-
tions.../Text Editor and deploy the Fortran options. There click on
30 CHAPTER 2. VISUAL STUDIO
Figure 2.14: Example of two pieces of code hidden by the user, one is a loop and
the other a subroutine. By clicking on + or - we can deploy or hide the code.
Advanced and in the menu called Outlining mark True in the options
Enable Outlining (which is actually activated by default) and Out-
line Statement Blocks in case you also want to outline statements like
loops. Notice that this options could be in a different menu for each
programming language.
9. Additional requirements
There are some tools that are common for a lot of Microsoft programs
and in the case of the software development can be really useful. First
of all, the different extensions of the files created in a software
project are essential and the whole guide is full of references to some
kind of files. Make sure that you have already activated in your Win-
dows OS the option that shows the extensions of the files. If it is not
activated, open any folder in your computer, click on View and mark
the option File name extensions. From now on, you will see when a
file is a C++ source code, a library or maybe a Fortran module.
Part of the Visual Studio potential can be accessed using the right
button of the mouse, exactly like the context menu of Windows OS.
The options shown depend on the element where we deploy the pop-up
menu and it is desirable to become familiarised with some commonly
2.2. CONFIGURING VISUAL STUDIO FEATURES 31
https://github.com/jahrWork/Visual-Studio-projects
We can import this configuration and then all the options treated will
be automatically applied. Go to Tools/Import and Export Settings/Import
selected environment settings and click on Next, in the next window decide
if creating or not a backup of your actual configuration, depending on your
needs. Click on Next again and then in Browse, look for the file downloaded
from the Git repository and open it. Finally click on Next and Finish.
Important Notice
The Figure 2.16 shows some commands that are going to be highly used
when programming so we recommend to enable the quick access in the tool-
bars. The first two of them comment and uncomment the code selected and
next two decrease and increase the indentation. The fifth one is the Start
without Debugging button (already explained) and the last active buttons
are in charge of compiling and building our program. While the first com-
piles the current file, the second builds the project or library selected and
the last builds the whole solution (which we know can contain more than
one project). These functionalities will be explained in the chapters of the
different programming languages.
We can personalise all the toolbars and commands that the IDE shows
and it can be done in two ways. Firstly, by clicking on the right part of
each toolbar we see the option Add or Remove Buttons which deploys a
list of default options for that bar (Figure 2.17). Secondly, we can click on
Tools/Customize and we access two tabs: Toolbars (Figure 2.18), which can
show and hide a big list of toolbars and Commands where we can select any
of them, add and delete commands and also add new buttons that are not
in the bar by default (figures 2.19, 2.20 and 2.21).
In these mentioned figures we can see that the Text Editor, Standard,
Build and Micro toolbars are shown. The Figure 2.19 shows that Standard
bar includes new commands like Find in Files, Solution Explorer and Prop-
erties Window while Build bar (figure 2.20) includes Compile command
and the most important; Start without debugging. It is necessary to
have quick access to this command because most of the times we won’t use
the default debugger and we just want to run the code directly without de-
bugging. Finally, the toolbar Text Editor (figure 2.21) is really useful while
writing code because of the Comment and Uncomment commands or the
new ones added, Line Indent and Line Unindent. We should take the time
to organize buttons and include those we use more.
36 CHAPTER 2. VISUAL STUDIO
Figure 2.17: Add and Remove options for the buttons that appear in the toolbars.
2.4. MODIFYING SHORTCUT ICONS 37
Figure 2.18: Toolbars tab in the menu Tools/Customize, it allows to show and hide
toolbars for the IDE.
38 CHAPTER 2. VISUAL STUDIO
Obtaining an academic license and the installer for Visual Studio En-
terprise.
2. Click on the blue button Sign In and Initiate session using your insti-
tutional email (finished with @alumnos.upm.es, Figure 2.23).
5. There, you may see the last release of Visual Studio in the right part
of the window. However, you can also click on “Software”, look for
“Visual Studio Enterprise” in the list or write it in the search bar.
6. Click on the name of the tool and you will have access to the download
of the installer and the Key for activating the product (Figure 2.26).
7. Download the installer for the Enterprise distribution and keep safe
the Key, you are going to use it later.
Figure 2.22: Main webpage of Microsoft Azure Dev Tools for Teaching where we
have to click on Sign In.
Figure 2.23: Start session window, the institutional email must be used here (fin-
ished with @alumnos.upm.es).
42 CHAPTER 2. VISUAL STUDIO
Figure 2.24: Authentication service of the UPM, you must use your institutional
email and the same password used in the email account.
Figure 2.25: Start window of Microsoft Azure, Visual Studio Enterprise is already
shown but we could look for it in the Software space if needed.
2.5. ENTERPRISE DISTRIBUTION OF VISUAL STUDIO 43
Figure 2.26: Menu where we can download the installer of Visual Studio Enterprise
and consult the key used to activate the tool.
44 CHAPTER 2. VISUAL STUDIO
of the Community version, executing this time the installer of the Enter-
prise version. The name now is similar to vs_enterprise_xxxxx.exe. As a
difference, in the step 7 you have to activate the product using your Key:
7. Notice that in the top right part of the IDE it is shown that you
have already started session. If you click on the letter of your name
and “Account Configuration” (see figure 2.6) you will see that your
credentials are activated. In the right part of that window it may say
that you are using a 30 days license, click on “Unlock with a Product
Key” (see figure 2.27) and it will show a window waiting for the Key
obtained (see figure 2.28). Click on Apply and the message “Product
Key applied” should appear.
Figure 2.27: License information in the Account Configuration window in the IDE,
before activating the product you will have a 30 days license.
Figure 2.28: Activation window, copy here the key obtained with Azure Dev Tools
for Teaching and click on Apply.
46 CHAPTER 2. VISUAL STUDIO
Chapter 3
Python Projects
47
48 CHAPTER 3. PYTHON PROJECTS
Figure 3.1: Main window of the Visual Studio Installer with the release Enterprise
2017 shown.
Figure 3.2: Workloads ready to be installed using the Visual Studio Installer. The
Python development is already selected and the needed characteristics chosen.
3.2. CREATE A PYTHON PROJECT 49
We will see during this guide that the process for creating a new project is
similar for all the programming languages, in the case of a Python project:
2. Click on File/New/Project...
7. Choose the name of the solution, it does not have to be the same as
the name of the project.
8. Click on OK.
This first example ensures that the installation has finished correctly. Like
in the rest of the programming languages, it writes a “Hello World” message
on the console. In this case, there is not a template already written with
this example so we will write it from scratch. Open the project created
in the previous section, you will find a .py file with the same name as the
project, open it and write the following code:
Important Notice
Python can download projects developed by other people and include them
in our own solutions. These projects or packages have been tested by
experts to ensure a proper performance and can help us while coding with
no need of developing the code from scratch. In order to install a package
follow the next steps:
3.4. INSTALLING AND REMOVING PYTHON PACKAGES 51
Figure 3.4: First step to install new Python packages on the Python environment.
52 CHAPTER 3. PYTHON PROJECTS
Figure 3.5: Second step to install new Python packages on the python environment.
Write here the name of the package to be installed.
Python Projects can “import” modules and packages from other projects
on separated directories. With this way we can have the latest updates of
an actively developed module or package without duplicating code. There
are two ways for including external modules and packages:
3.5. INCLUDE MODULES & PACKAGES FROM OTHER PROJECTS 53
Figure 3.7: Option reserved for removing those Python packages not needed from
the Python environment.
Figure 3.8: Available Python Projects for importing packages. Each project con-
tains a package with the same name on its root directory.
3.5. INCLUDE MODULES & PACKAGES FROM OTHER PROJECTS 55
Figure 3.9: In this window we can look for the path of the package to be used by
the Python Project.
56 CHAPTER 3. PYTHON PROJECTS
Chapter 4
Arduino Projects
Visual Micro is a plug–in for Microsoft Visual Studio with C++ installed.
It allows to create Arduino IDE compatible projects to develop embedded
software using the power of the Visual Studio IDE.
57
58 CHAPTER 4. ARDUINO PROJECTS
8. Click OK.
Visual Studio will create a folder in the Desktop with the name “Ar-
duinoProjects” to hold the complete solution. Inside this folder another
folder named “HelloWorld” will contain the project HelloWorld.ino. In this
case this project contains only one file. In order to be compatible with the
Arduino IDE this folder and the Arduino .ino file should have the same
name.
1. Download the latest version of the Arduino IDE and unzip its content
to same folder.
2. Open the visual studio solution that we have created in the last sec-
tion.
4.3. EXECUTE THE “HELLO WORLD” WITH ARDUINO 59
3. Select the location of the Arduino IDE from the VMICRO tab of the
Visual Studio window.
6. Select the Serial port in which the Arduino board is discovered: COM1,
COM2, ...
9. After the output windows shows: “The upload process has finished”,
click on the serial monitor for the selected port (Figure 4.1). It will
open a serial COM17 window showing the results of the program.
Every 5 seconds, the message : “Hello World” will appear on the
serial terminal.
Important Notice
Figure 4.1: Icon to open the Serial monitor close to the selected port: COM17
Visual Studio is useful when we are dealing with very complex projects in
which many libraries of different codes files are involved.
Besides of the internal libraries of the Arduino IDE, Visual Studio can
share external libraries with the Arduino project as any other programming
language. To specifically configure some project, we propose to start from
a simple project to increase gradually the complexity by adding different
external libraries.
6. Create two files: LedClass.h and LedClass.cpp inside this share item.
public :
int pin;
void on();
void off ();
};
If you have installed Visual Studio following this guide you do not have to
install anything else since the C++ compiler was included in the first steps.
In case you do not have the necessary tools already included in the IDE
open the Visual Studio Installer as an administrator and click on Modify.
We have to select in the Workloads (in the tab reserved for Windows) the
default tools related to “Development for Desktop with C++” (see Figure
2.4). We click on Modify and wait for the process to finish the download
and installation.
3. Deploy the field Language and select C++, then click on Empty Project
(see Figure 4.2).
4. Change the Project Name, for example “HelloWorld” in this case (see
Figure 4.3).
7. Click on Create.
4.6. CREATE A C++ PROJECT 63
Figure 4.2: Window for creating a project in Visual Studio 2019 Community ver-
sion. We have filtered by C++ and chosen Empty Project.
64 CHAPTER 4. ARDUINO PROJECTS
Figure 4.3: In this window we can create a new Project, a new Solution and specify
the names for both and the location for the folders.
4.7. EXECUTE THE “HELLO WORLD” EXAMPLE WITH C++ 65
Now we are going to execute our first example in C++, the Hello World
program. Firstly, include a new source file to the project by clicking with
the right button in the folder “Source Files” and on Add/New Item... (see
Figure 4.4). Secondly, choose C++ File (.cpp) in the tab Installed/Visual
C++, change the name of the file to “HelloWorld.cpp” and click on Add
(Figure 4.5). You will find a blank file where copying the following code:
int main ()
{
cout << "Hello , World !";
return 0;
}
To compile, link and execute the program follow the next steps (the box
in Figure 4.6 shows the icons for building and executing the project):
Important Notice
Figure 4.4: Menu where adding new or existing files to our project.
4.7. EXECUTE THE “HELLO WORLD” EXAMPLE WITH C++ 67
Figure 4.5: Window where choosing the C++ File. Name it “HelloWorld” and add
it to the project. The .cpp file stores the source code for a C++ program.
Figure 4.6: Final aspect of the project, click on Build the project and execute it
without debugging to see the result.
68 CHAPTER 4. ARDUINO PROJECTS
Chapter 5
Fortran Projects
As it has been said before, we need now the compiler of the programming
language we are interested in. Hence, Intel® Fortran Compiler must be
installed in the computer and it should be recognized by the Visual Studio
environment (previously installed). We are going to use an academic license,
follow the steps below:
Important Notice
• The package used for the examples of this book is the version
2018 Update 3 of Intel® Parallel Studio Cluster Edition. How-
ever, you should install the latest version of the compiler offered
by Intel® in order to ensure the compatibility with the latest
version of Visual Studio.
69
70 CHAPTER 5. FORTRAN PROJECTS
Figure 5.1: Different available options for the installation, choose Windows version.
After the installation has finished we can start creating our Fortran
projects and executing programs.
72 CHAPTER 5. FORTRAN PROJECTS
Figure 5.4: Register an Account form in Intel Developer Zone, after filling in all
the information click on Register an Account.
Figure 5.5: Downloading page of Intel Parallel Studio, here, choose Intel Parallel
Studio Cluster Edition for Windows* (all tools) and version 2018 Update 3.
74 CHAPTER 5. FORTRAN PROJECTS
Figure 5.6: These options are shown before installation. Select those marked here
and click on Next.
5.2. CREATE A FORTRAN PROJECT 75
6. Choose the name of the solution, it does not have to be the same as
the name of the project.
8. Click on OK.
To compile, link and execute the program follow the next steps:
Important Notice
Before learning how to include files in our project (whether new or existing
ones), it is interesting to understand the difference between the logical order
that is generated in our solution and the real order of the files stored in the
hard drive. This concept has been introduced at the beginning of this guide
and it is specially important for the case of Fortran. When our project
grows, we include files and folders in the solution explorer in order to have
all the source codes, images, libraries, etc. organized. However, each file
can be stored anywhere in our hard drive, maybe in the folder of a different
project/solution, in the desktop, in the cloud, etc.
Think for example in a library that we use for different projects, it can
be stored in a generic folder that is not related to the projects at all. It
is responsibility of the programmer to have also the files organized in the
computer in order to avoid problems when linking the project (e.g avoiding
changes of files location). As an example see the Figure 2.17, we see in the
Solution explorer a large number of folders but if we open the project we
find that all the source codes are stored in the same folder (including also
the libraries and modules of dislin).
other two are empty. Create the most appropriate structure inside Source
folder (by creating new folders for example) and organize the project. The
libraries and modules can also be included there.
On the other hand, in the hard drive the structure is different, choose the
most comfortable for your purposes. Apart from the .sln and the .suo files
in the solution folder and the .vfproj file in the project folder (all essential
for the project), we find the folders associated to the results of the build and
compilation processes. If we build the project in the Release configuration,
a Release folder appears with the .obj and .mod files, the executable, etc.
If it is built in Debug mode, the same happens with a Debug folder. We
suggest to create a sources folder inside the project path and store there all
the .f90 real files with the source code.
We can check in the solution location that after creating the solution
and project, a .sln file, a folder with the name of the project and a .vfproj
file inside have appeared. If the Solution is already created and we just want
to open it we can double click on the .sln file or click on File/Open/Projec-
t/Solution... in the IDE and look for our .sln file.
1. Click on File/New/Project....
2. In the Intel(R) Visual Fortran menu select Console Application and
then click on Empty Project.
3. Write the name of the new project.
4. In Solution select the option Add to solution.
5. Click on OK.
6. Before closing Visual Studio do not forget to click on Save All.
1. Right click on the name of the project (in the solution explorer).
2. Click on Add.
3. Click on New Item... if you are going to start from scratch (or click
in Existing Item... if you add it from an existing one).
4. Click on Fortran Free-form File (.f90).
5. Write the name of the file.
6. Click on Add.
78 CHAPTER 5. FORTRAN PROJECTS
Figure 5.7: First step in order to create a solution with a Fortran project.
Important Notice
Figure 5.8: Second step in order to create a solution with a Fortran project.
In the section 2.2 we have seen how to configure general VS settings, how-
ever, notice that those options are not related to the Fortran project
configuration. For each project inside our solution (or any project we cre-
ate from now on) we have to define some compilation properties. Actually,
it is possible to define some properties for every individual source code
file (by clinking right button on the name of the file and clicking on prop-
erties) but we are going to treat here some of the properties that involve
the whole project.
With the project opened and selected in the solution explorer we have
to click on Project/Properties, the changes we make now will only affect to
80 CHAPTER 5. FORTRAN PROJECTS
the chosen project. First of all check in this window that the Configuration
selected is the Active one, which means, if you are running the application
in Release mode, then change the properties of the Release mode (and the
same if you are running the program in a different configuration). A change
applied only to the Debug mode won’t affect to the rest of configurations.
The configuration (or mode) that you are modifying in the window opened
can be checked in the top-left part of the window itself.
Important Notice
Now let’s take a look at some important compiler options that can be
found in the window Project/Properties:
program ExampleManual1
implicit none
real(kind=4) :: x
real :: y
Important Notice
2. Stack Overflow can occur in our software for many reasons, it hap-
pens when the “call stack” pointer exceeds the stack bound [7] (con-
cepts like call stack can be found in [8]). One of the causes of stack
overflow is to allocate more memory on the stack than the maximum
that fits there (too large local array variables for example). Hence, in
order to extend the size of the stack in these cases we change the con-
figuration by clicking on Linker/Command Line/Additional Options:
and writing “/STACK:100000000”.
(https://software.intel.com/en-
us/node/678222)
Now our dislin example should work, take note of the subroutines used in
the plotting example below in order to use it in future codes. The example
5.6. CONFIGURING A GRAPHIC LIBRARY: DISLIN 87
program Graph
use dislin
implicit none
call sine_graph
contains
subroutine sine_graph
a = 0
b = 2 * PI
x = [ (a + (b-a) * i / N, i=0, N) ]
y = sin(x)
end subroutine
end program
Important Notice
In case that you comment the “use dislin” statement that enables
the use of DISLIN libraries (because you are not going to use it
for example) do not forget to reverse last two steps of the DISLIN
configuration. A list of errors could appear while building the code
if you do not change the configuration.
88 CHAPTER 5. FORTRAN PROJECTS
Figure 5.9: Necessary configuration for the Project Properties in order to make the
program work with DISLIN, the fields to change are Runtime Library and Ignore
Specific Library.
5.6. CONFIGURING A GRAPHIC LIBRARY: DISLIN 89
Figure 5.10: Solution explorer for the project Graph showing the inclusion of dislin
libraries and dislin_d.f90 interfaces.
90 CHAPTER 5. FORTRAN PROJECTS
In this section some general concepts and good practices are going to be
explained through Frequently Asked Questions.
Build: With this command Visual Studio will compile and link the
source files of your program. You can build only the project that you
have opened or you have selected in the Solution Explorer with the
option BUILD/Build “Name of the project” or clicking in the symbol
You can also build the whole solution, with all the projects involved,
by clicking in BUILD/Build Solution or clicking in the symbol
In this case it does not matter which project you have selected since
the whole solution is going to be compiled and linked.
1
If you can not see the symbol go to the section 2.4 and modify the aspect of your IDE
to show all the interesting shortcuts.
92 CHAPTER 5. FORTRAN PROJECTS
Important Notice
created, compiled and linked in a different way. Let’s see how to create
a static library and a full program that uses the library through an
example:
(a) Create a new solution (or recycle one of the previous sections).
Then, in this solution, create a new project as it is explained
previously in this chapter. This project will contain the call to
the subroutines stored in the library. Do not forget to choose a
proper name for the project.
(b) Include an empty file called ExampleManual2.f90 in the project
and copy the following code:
program ExampleManual2
use ModuleExample
implicit none
call HelloWorld
call WritePI
read(* ,*)
end program
(d) Add to this Library project an empty source file called Module-
Example1.f90 and paste the next example code, this will be the
module code stored in our library:
module ModuleExample
implicit none
contains
subroutine HelloWorld
end subroutine
subroutine WritePI
real :: PI
PI = 4 * atan(1.)
end subroutine
end module
(e) Then save all and set the library project as startup project (click
with the right button on its name in the solution explorer and
click on Set as StartUp Project). Compile the file ModuleExam-
ple.f90 and build the whole library project in the Release mode.
Check that ModuleExample.lib and ModuleExample.mod appear
in the Release folder of the project.
(f) Add to the main project both library files with the Solution
Explorer in the Source folder using right click in the project
name/Add/Existing Item.../ and looking for the files (see sec-
tion 5.4).
There are two options: in the first one you can copy both files
96 CHAPTER 5. FORTRAN PROJECTS
in the folder of the main project and then include them using the
solution explorer. In this case if you make a change and rebuild
the library, you will have to copy again the files in the folder of
the main project.
The second option could be including the files directly in the
solution explorer and linking them to the original folder (the
folder of the library). Just Add them in the same way, but this
time look for the files in the folder of the library project, in
Release. This last option lets you rebuild the library whenever
you want and the main project will be accessing always the latest
version of the library. However, you must remember that the
location of the library cannot change since the main project could
not find the files.
(g) Set the main project as startup project, build it and execute it
without debugging.
Important Notice
Figure 5.11: List with common file extensions used in Intel Fortran projects.
Chapter 6
Web Projects
In order to obtain the essential tools for creating website projects with Vi-
sual Studio, we have to open the Visual Studio Installer as an administrator
and click on Modify. We must select in the Workloads (in the tab reserved
for Web and Cloud) the tools related to “ASP.NET and web” with the pre-
defined optional installations selected (see Figure 6.1). After that, we click
on Modify and wait for the process to finish the download and installation.
99
100 CHAPTER 6. WEB PROJECTS
Figure 6.1: Main window of Visual Studio Installer with the Workload related to
the web programming tools selected.
In this section the basic tools for creating web projects with Visual Studio
are treated (HTML/CSS/JS). First of all, we have to open Visual Studio and
create a solution with a similar template to the one we want, an “ASP.NET
Empty Web Site”.
Figure 6.2: ”New Project” window of Visual Studio with the project template
selected, the name of both the project and the solution are already written.
8. Click on OK.
The project is created with the default files and folders (see Figure 6.3)
but we prefer to use the structure explained in this guide: index.html, CSS
folder, JS folder and images folder if needed:
1. Firstly, click with the right button on the name of the project (in the
Solution Explorer/myWebSite) and go to Add/Add New Item....
3. Then, click on Add and a basic template will be created in your project
(Figure 6.5).
102 CHAPTER 6. WEB PROJECTS
Figure 6.3: Initial aspect of the Solution and Project created for the Website.
Figure 6.4: Adding index.html to our website using the “Add New Item” window
of Visual Studio.
6.2. CREATE WEBSITE HTML/CSS/JS PROJECT 103
Figure 6.5: Template of the index.html file (created by default), here the website
is going to be built.
Now we are going to create the desired folder structure, right click on
the name of the project once again and go to Add/New Folder, give it the
name “css”. Repeat the process twice with the names “js” and “img”, the
final aspect of your project should be like the seen in Figure 6.6.
104 CHAPTER 6. WEB PROJECTS
Figure 6.6: Final folder structure of the project, the files “css”, “js” and “img” are
not included by default.
The Figure 6.8 shows the toolbar “Build” where the Build and Start
commands are. We have to click first on Build and later in Start and Visual
Studio will automatically show the output. In addition, a Chrome window
(or the default browser) will be opened with our result. If we do not have
the mentioned toolbar shown in the environment (highly recommended) we
can also click on BUILD/Build Web Site and later on DEBUG/Start without
Debugging. The result of our webpage is shown in the Figure 6.9.
6.3. EXECUTE THE “HELLO WORLD” EXAMPLE 105
Figure 6.7: First example of website, the index.html file has been modified.
Figure 6.8: The window Output shows results of the execution. The “Build”
toolbar appears remarked in the upper part of the IDE.
106 CHAPTER 6. WEB PROJECTS
The next step is to include some style to the page. It can be done
in the main HTML file (including <style>...<\style> tags and defining
inside properties) or using external style sheets, which is preferable. In
order to include the mandatory reference to the external file, it is used the
<link> element in the head section.
First of all, include the file in the project by clicking with the right
button in the css folder (in the Solution explorer) and going to Add/Add
New Item.... There, in Installed/Visual C#, select Style Sheet and name it
Style.css. Finally, add the new sheet to the project.
Now, include in the head of the html file the line seen in the Code 6.1.
While the “rel” attribute specifies the relation between the main document
and the linked one, the “type” command is used to specify the media type
of the external file. The “href” command at the end of the line defines the
location and name of the file.
Listing 6.1: Line of code included in the HTML file in order to link the css style
sheets.
The code is now ready to accept some style in our dedicated file. In
order to complete this basic example, we are going to change three things:
the body background, the colour of the header in the text and the colour
of the paragraphs. Open the sheet “Style.css” in Visual Studio and copy
there the code seen in 6.2. As can be checked, there are different colours
6.3. EXECUTE THE “HELLO WORLD” EXAMPLE 107
Figure 6.10: Result of myWebSite project, main files opened and structure of the
project seen in the Solution Explorer.
to choose (you can even define them with the RGB code). In this example
we are changing first the background colour, later the colour and alignment
of the header (called h1, included in the HTML file) and finally the same
parameters for the “Hello world!” paragraph. When finished, press on Build
and later in Start, Visual will show the result. It should be like the Figure
6.10 and the final webpage like the Figure 6.11.
body {
background -color: lightblue ;
}
h1 {
color: navy;
margin -left: 20px;
}
p {
color: Tomato ;
margin -left: 10px;
}
Listing 6.2: Code to include in the Style.css created in the project in order to give
style to the webpage.
108 CHAPTER 6. WEB PROJECTS
Figure 6.11: Result of myWebSite project after including style, using Google
Chrome browser.
Include at the end of the body of the html file the line seen in the Code
6.3. It makes use of the same tags but in this case the “src” attribute tells
the browser where to find the script. External scripts are practical when
the same code is used in many different web pages. Notice that the style is
charged at the beginning of the html file in order to have the style orders
defined before the content appears. For a similar reason, the modification
of the contents (js file) is not uploaded until the content is already charged
in the website, and that is why the code is located at the end of the body.
We have to write the JavaScript file and some elements to modify in the
content of the webpage. In this example, we include a button with the text
“I’m a button” written, and in the HTML file a function programmed for
6.3. EXECUTE THE “HELLO WORLD” EXAMPLE 109
that button. At the same time, we include an identifier for the element to
be modified when clicking in the button, let’s say for example the paragraph
“Hello world!”. This identifier (HWid) is used to specify (in the function)
the element that has to change. Hence, the HTML file should be changed
to be like the seen in the Code 6.4. Notice how the button has the attribute
type and the function (called in this case “myFunction”) has the order to
make when clicking (onclick).
<head>
</head>
<body>
<h1>This i s myWebSite</h1>
<p id=”HWid”>H e l l o World !</p>
<button type=” button ” onclick=” myFunction ( ) ”>I ’m a button</
button>
</body>
</html>
Listing 6.4: HTML file with a new button included, an identifier in the paragraph
element and the link to the .js file.
Finally, open in Visual Studio the file “JavaScript.js” and copy there
the code seen in 6.5 in order to define the function. When finished, press on
Build and later in Start and Visual will show the result. It should be like
the Figure 6.12 and the webpage, after pushing the button created, should
be like the Figure 6.13.
110 CHAPTER 6. WEB PROJECTS
Figure 6.12: Result of myWebSite project, index and script opened and the struc-
ture of the project seen in the Solution Explorer.
f u n c t i o n myFunction ( ) {
document . getElementById ( ”HWid” ) . innerHTML=” H e l l o U n i v e r s e ! ”
}
Listing 6.5: myFunction code defined in the JavaScript file, it changes the text
found with the identifier “HWid”.
6.4. WEB APPLICATION: FUNDAMENTALS 111
Figure 6.13: Result of myWebSite project after including style and a script, using
Google Chrome browser.
A website usually consists of many files: text content, code, style sheets,
media content, etc. When building a website, it is necessary to assemble
these files into structure on your local computer, make sure they can talk
to one another, and get all the content looking right before it is uploaded
to a server. A common distribution of folders and files (extracted from
https://developer.mozilla.org) in a web project involves:
CSS and JS files are linked to the main HTML file using a file path so
one file (main HTML file) knows where another one is. For example, the
header of the index.html contains different routes to the style files (CSS), in
addition, the body of the main HTML file also contains routes to images,
videos and rest of the material that the webpage has.
CSS (Cascading Style Sheets) is the code used to provide style to the
content referred in the HTML file, this means that here we are going to
decide whether the words are black or red, the decoration around the images
or the aspect of the different elements mentioned in the HTML file. CSS is
a style sheet language, we can select individually elements in the main file
and change the style. In addition, we can apply the same configuration to
a specific group of elements that share the same aspect.
Once the different files are written in our computer and the project has
been finished, all the information is uploaded to the server, a hardware and
software tool that is activated at all times (in the case of a public website
for example) waiting for the clients. If this server is accessible through
the internet, it will be waiting for a client all over the world. When a
user writes the specific IP address in its browser (or the URL assigned to
6.4. WEB APPLICATION: FUNDAMENTALS 113
our server and port), then the software part of the server will receive the
request and answer. If the access is permitted, then the server will send over
the internet the webpage to the computer of the client, where the browser
will interpret all the information and show the website. This is a general
description since there are many different ways of receiving the webpage
or the web application depending on the amount of information that is
processed in the client’s computer or in the server. In addition, there are
many protocols and applications involved in this operation.
HTML uses predefined tags and elements, both are read by the browser
and define the properties of the content that is displayed, all the tags used
have to be closed when the effect must finish. Otherwise, the property of
the specific effect will continue until the end of the page. In a general case,
the extent of an element is indicated by a pair of tags: the ”start tag”
(<p>) and the ”end tag” (</p>), an example is shown in Code 6.6. The
text content of the element is placed between these tags. The start tag may
also include attributes or specific routes (in the case of including images for
example) within the tag.
Listing 6.6: Tags used in HTML with the predefined function of including
paragrahps in the webpage.
One of the simplest examples of HTML can be seen in the Code 6.7. It
contains elements (head, title or body in this case) which are used to build
the blocks of webpages, there are a lot more elements and tags that can
114 CHAPTER 6. WEB PROJECTS
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
We could write now the Code 6.7 in the notepad, save it with the name
index.html and open the file with the browser of our computer. The browser
would interpret it and show the result as a common internet webpage. The
browser also takes into account the HTML version written at the start of the
code since not all the browser support all the versions, it must be remarked
that creating webpages involves that we always depend on the browser used
by the user.
6.4. WEB APPLICATION: FUNDAMENTALS 115
The CSS syntax consist in rules that the browser interprets and then
applies to the specific element in the document that is affected by the style
change. In every rule-set there are a selector and a declaration block; the
selector points to the specific element that is going to show the style and
the declaration block contains the style. It uses the name of the property
to be changed and the value, both separated by semicolons. Finally, a
CSS declaration always ends with a semicolon and declaration blocks are
surrounded by curly braces.
There are a lot of properties and values to apply to the design of the
web, some examples are: colour, text-align, opacity, font size or font-weight.
Depending on the element selected there are different options available to
modify. An essential part of CSS code is the selector of the element to
change, there are Selectors used to “find” (or select) HTML elements based
on their element name, id, class, attribute, and more. The Universal
selector simply matches the name of any element type so we will define
the colour (for example) of every element in the document. On the contrary,
we can choose that the property only affects to the elements with an specific
Name like for example the paragraphs called <p>... </p> in the example
of the previous section. The id selector uses the id attribute of an HTML
element (we can add it to the different elements used) to select a specific
element. The id of the elements should be unique so we would be selecting
one unique element. It uses a hash (#) character followed by the id in order
to select the element. The class selector selects elements with a specific
class attribute (we can also add the class to the elements of our webpage).
In this case it uses a (.) character, followed by the name of the class. The
Code 6.8 shows some examples of the notions explained.
116 CHAPTER 6. WEB PROJECTS
p {
color: red;
text -align: center ;
}
# para1 {
text -align: center ;
color: red;
}
. center {
text -align: center ;
color: red;
}
Listing 6.8: Code to include in the css file created in order to give style to the
webpage.
In the beginning, JavaScript was only used in the client side (in the browser),
but node js have made possible to run also JavaScript on the server side.
Today, JavaScript is everywhere (Desktop/Server/Mobile) and, as it has
been said, it is used to program the behaviour of the webpages. JavaScript
can change content of the HTML, change attribute values, styles, show or
hide elements and more.
Listing 6.9: Example of the inclusion of JavaScript files in our main HTML.
6.5. INSTALLING NODE.JS TOOLS 117
var person = {
firstName : "John",
lastName : "Doe",
id : 5566 ,
fullName : function () {
return this. firstName + " " + this. lastName ;
}
};
In order to use Node.js with Visual Studio we need the specific workload for
the IDE and the JavaScript runtime environment installed in the computer.
To install the workload we have to open as usually the Visual Studio Installer
(as an administrator) and click on Modify. We must select in the Workloads
(in the tab reserved for Web and Cloud) the package Node.js Development
with the predefined optional tools selected (see Figure 6.14). Then, we click
on Modify and wait for the process to finish the download and installation.
Now, we are going to install the LTS version of the runtime (long-term
support, stable release of software that is maintained by the owners for long
periods of time).
118 CHAPTER 6. WEB PROJECTS
Figure 6.14: Main window of Visual Studio Installer with the Workload to install
chosen.
2. Choose the “recommended version for most users” installer for your
computer (typically Windows 64-bit) and download the installer.
5. Maintain the same location for the installation and click twice in Next.
2. Click on File/New/Project....
6.7. EXECUTE THE “HELLO WORLD” EXAMPLE (NODE.JS) 119
3. In the TypeScript menu of the Installed tab select Node.js and then
click on Blank Node.js Console Application.
6. Choose the name of the solution, it does not have to be the same as
the one of the project.
8. Click on OK.
You can check in the solution directory chosen that a folder with the project
has been created, inside, the project is represented by a .njsproj file. In the
solution explorer you will find a npm node which shows the already installed
npm packages (NPM is a package manager for Node.js with thousands of
free packages (or modules) to download and use).
After building and starting the project this program opens the console
and shows ”Hello World” written. Follow the next steps:
Important Notice
1. Install node.js.
2. Install a http server by the following command:
>npm install http-server -g
3. Execute the commnad:
>http-server
4. In chrome browser type:
//http://localhost:8080/index.html
and press F12.
Cordova allows us to create Phone Apps starting with our previously created
Web project. In order to obtain the essential tools for creating Cordova
projects with Visual Studio follow these steps:
2. Select in the Workloads (in the tab reserved for smartphones and
games) the tools related to “Development for Mobile Phones Devices
with JavaScript” with the predefined optional installations selected
(GIT for Windows is not needed) (see Figure 6.15).
3. In this case we also need from the Individual Components tab the
“Google Android Emulator (API level 27)” and the “Installation of
Android SDK (API level 27)” (Figures 6.16 and 6.17).
4. Click on Modify and wait for the process to finish downloading and
installing.
Important Notice
This process has been tested with Visual Studio 2017, in the newer
versions of the IDE we do not know if Microsoft will continue offering
the Cordova tools.
122 CHAPTER 6. WEB PROJECTS
Figure 6.15: Main window of Visual Studio Installer with the Workload to install
chosen, it installs Cordova programming tools.
Figure 6.16: Main window of Visual Studio Installer with the Individual Compo-
nents to install chosen. The right version for Android applications is selected.
6.9. CORDOVA PROJECT 123
Figure 6.17: Main window of Visual Studio Installer with more Individual Compo-
nents to install in order to obtain Cordova programming tools. The right version
for Android applications is selected.
The next step is to create a project with Cordova, follow these steps:
3. Click on OK.
Now we can simulate and execute the HelloWorld example starting with
the webpage created in the previous section:
1. Select all the files inside the “www” folder and delete them.
2. Click with the right button of your mouse on the folder “www” and
click on Add/Existing Item..., navigate to the location of the files
created in the section 6.3 (HTML/CSS/JS) and add to the project all
the files and folders. The final aspect of the project opened is shown
in the Figure 6.21.
6. If the results of the simulation are correct, the .apk file can be gener-
ated in order to install the App in your Android phone.
7. In the same place where the simulation is chosen, now choose “Device”
(Figure 6.24). Execute the project and a .apk file will appear in the
folder of the project, in the path
platforms\android\build\outputs\apk.
Important Notice
When building and executing the project, the first time, an error
like the next one could appear:
Error: Failed to run “javac -version”, make sure that you have a
JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/-
javase /downloads.
Figure 6.19: Empty Cordova project, do not forget to choose a Name for the project
(name of the app), a Solution Name and the location to store the folders and files.
6.9. CORDOVA PROJECT 127
Figure 6.20: Initial aspect of the project, the folder “www” is where all the files of
the HTML/CSS/JS project will be stored.
128 CHAPTER 6. WEB PROJECTS
Figure 6.21: Solution explorer with our files already included, the “index.html”
that we created in the previous sections is displayed.
Figure 6.22: Configuration Manager of the solution, here we deselect the Deploy
option that allows to transfer the .apk file to the smartphone automatically when
it is connected.
6.9. CORDOVA PROJECT 129
Figure 6.23: Simulation of the App in the browser, in this case simulating a LG
G5 smartphone. The result has the same aspect ratio as the smartphone screen.
Figure 6.24: Configuration to choose in order to generate the .apk file that will be
installed in the Android smartphone.
130 CHAPTER 6. WEB PROJECTS
Figure 6.25: Phone Application installed in the smartphone through the .apk file.
References
[2] Intel Software Development Tools. Intel® Fortran Compiler User and Reference
Guides-Document Number: 304970-006US. Intel.
[5] Oracle. Sun studio 12: Fortran user’s guide-4.9 module files. https://docs.oracle.
com/cd/E19205-01/819-5263/aevog/index.html. [Online; accessed 28-April-2018].
[6] B. B. C. Society. What are the differences between .mod, .obj, .lib, .exp, .exe, .dll and
.def? http://www.fortran.bcs.org/2003/porting/part_3/slide_06.html. [On-
line; accessed 27-April-2018].
[9] I. D. Zone. Understanding files associated with intel® fortran applications (win-
dows*). https://software.intel.com/en-us/node/680056, . [Online; accessed 27-
April-2018].
131