Pascal – Program Structures ”; Previous Next Before we study basic building blocks of the Pascal programming language, let us look a bare minimum Pascal program structure so that we can take it as a reference in upcoming chapters. Pascal Program Structure A Pascal program basically consists of the following parts − Program name Uses command Type declarations Constant declarations Variables declarations Functions declarations Procedures declarations Main program block Statements and Expressions within each block Comments Every pascal program generally has a heading statement, a declaration and an execution part strictly in that order. Following format shows the basic syntax for a Pascal program − program {name of the program} uses {comma delimited names of libraries you use} const {global constant declaration block} var {global variable declaration block} function {function declarations, if any} { local variables } begin … end; procedure { procedure declarations, if any} { local variables } begin … end; begin { main program block starts} … end. { the end of main program block } Pascal Hello World Example Following is a simple pascal code that would print the words “Hello, World!” − Live Demo program HelloWorld; uses crt; (* Here the main program block starts *) begin writeln(”Hello, World!”); readkey; end. This will produce following result − Hello, World! Let us look various parts of the above program − The first line of the program program HelloWorld; indicates the name of the program. The second line of the program uses crt; is a preprocessor command, which tells the compiler to include the crt unit before going to actual compilation. The next lines enclosed within begin and end statements are the main program block. Every block in Pascal is enclosed within a begin statement and an end statement. However, the end statement indicating the end of the main program is followed by a full stop (.) instead of semicolon (;). The begin statement of the main program block is where the program execution begins. The lines within (*…*) will be ignored by the compiler and it has been put to add a comment in the program. The statement writeln(”Hello, World!”); uses the writeln function available in Pascal which causes the message “Hello, World!” to be displayed on the screen. The statement readkey; allows the display to pause until the user presses a key. It is part of the crt unit. A unit is like a library in Pascal. The last statement end. ends your program. Compile and Execute Pascal Program Open a text editor and add the above-mentioned code. Save the file as hello.pas Open a command prompt and go to the directory, where you saved the file. Type fpc hello.pas at command prompt and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line and would generate hello executable file and hello.o object file. Now, type hello at command prompt to execute your program. You will be able to see “Hello World” printed on the screen and program waits till you press any key. $ fpc hello.pas Free Pascal Compiler version 2.6.0 [2011/12/23] for x86_64 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling hello.pas Linking hello 8 lines compiled, 0.1 sec $ ./hello Hello, World! Make sure that free pascal compiler fpc is in your path and that you are running it in the directory containing source file hello.pas. Print Page Previous Next Advertisements ”;
Category: Computer Programming
Pascal – Discussion
Discuss Pascal ”; Previous Next Pascal is a procedural programming language, designed in 1968 and published in 1970 by Niklaus Wirth and named in honour of the French mathematician and philosopher Blaise Pascal. Pascal runs on a variety of platforms, such as Windows, Mac OS, and various versions of UNIX/Linux. This tutorial will give you great understanding of Pascal to proceed with Delphi and other related frameworks etc. Print Page Previous Next Advertisements ”;
Pascal – Overview
Pascal – Overview ”; Previous Next Pascal is a general-purpose, high-level language that was originally developed by Niklaus Wirth in the early 1970s. It was developed for teaching programming as a systematic discipline and to develop reliable and efficient programs. Pascal is Algol-based language and includes many constructs of Algol. Algol 60 is a subset of Pascal. Pascal offers several data types and programming structures. It is easy to understand and maintain the Pascal programs. Pascal has grown in popularity in the teaching and academics arena for various reasons: Easy to learn. Structured language. It produces transparent, efficient and reliable programs. It can be compiled on a variety of computer platforms. Features of the Pascal Language Pascal has the following features − Pascal is a strongly typed language. It offers extensive error checking. It offers several data types like arrays, records, files and sets. It offers a variety of programming structures. It supports structured programming through functions and procedures. It supports object oriented programming. Facts about Pascal The Pascal language was named for Blaise Pascal, French mathematician and pioneer in computer development. Niklaus Wirth completed development of the original Pascal programming language in 1970. Pascal is based on the block structured style of the Algol programming language. Pascal was developed as a language suitable for teaching programming as a systematic discipline, whose implementations could be both reliable and efficient. The ISO 7185 Pascal Standard was originally published in 1983. Pascal was the primary high-level language used for development in the Apple Lisa, and in the early years of the Mac. In 1986, Apple Computer released the first Object Pascal implementation, and in 1993, the Pascal Standards Committee published an Object-Oriented Extension to Pascal. Why to use Pascal? Pascal allows the programmers to define complex structured data types and build dynamic and recursive data structures, such as lists, trees and graphs. Pascal offers features like records, enumerations, subranges, dynamically allocated variables with associated pointers and sets. Pascal allows nested procedure definitions to any level of depth. This truly provides a great programming environment for learning programming as a systematic discipline based on the fundamental concepts. Among the most amazing implementations of Pascal are − Skype Total Commander TeX Macromedia Captivate Apple Lisa Various PC Games Embedded Systems Print Page Previous Next Advertisements ”;
OAuth 2.0 – Architecture
OAuth 2.0 – Architecture ”; Previous Next In this chapter, we will discuss the architectural style of OAuth 2.0. Step 1 − First, the user accesses resources using the client application such as Google, Facebook, Twitter, etc. Step 2 − Next, the client application will be provided with the client id and client password during registering the redirect URI (Uniform Resource Identifier). Step 3 − The user logs in using the authenticating application. The client ID and client password is unique to the client application on the authorization server. Step 4 − The authenticating server redirects the user to a redirect Uniform Resource Identifier (URI) using authorization code. Step 5 − The user accesses the page located at redirect URI in the client application. Step 6 − The client application will be provided with the authentication code, client id and client password, and send them to the authorization server. Step 7 − The authenticating application returns an access token to the client application. Step 8 − Once the client application gets an access token, the user starts accessing the resources of the resource owner using the client application. OAuth 2.0 has various concepts, which are briefly explained in the following table. Sr.No. Concept & Description 1 Terminology OAuth provides some additional terms to understand the concepts of authorization. 2 Web Server Web server delivers the web pages and uses HTTP to serve the files that forms the web pages to the users. 3 User-Agent The user agent application is used by client applications in the user”s device, which acts as the scripting language instance. 4 Native Application Native application can be used as an instance of desktop or mobile phone application, which uses the resource owner password credentials. Print Page Previous Next Advertisements ”;
OAuth 2.0 – Overview
OAuth 2.0 – Overview ”; Previous Next What is OAuth 2.0? OAuth is an open authorization protocol, which allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as Facebook, GitHub, etc. It allows sharing of resources stored on one site to another site without using their credentials. It uses username and password tokens instead. OAuth 2.0 is developed by the IETF OAuth Working Group, published in October 2012. Why Use OAuth 2.0? You can use OAuth 2.0 to read data of a user from another application. It supplies the authorization workflow for web, desktop applications, and mobile devices. It is a server side web app that uses authorization code and does not interact with user credentials. Features of OAuth 2.0 OAuth 2.0 is a simple protocol that allows to access resources of the user without sharing passwords. It provides user agent flows for running clients application using a scripting language, such as JavaScript. Typically, a browser is a user agent. It accesses the data using tokens instead of using their credentials and stores data in online file system of the user such as Google Docs or Dropbox account. Advantages of OAuth 2.0 OAuth 2.0 is a very flexible protocol that relies on SSL (Secure Sockets Layer that ensures data between the web server and browsers remain private) to save user access token. OAuth 2.0 relies on SSL which is used to ensure cryptography industry protocols and are being used to keep the data safe. It allows limited access to the user”s data and allows accessing when authorization tokens expire. It has ability to share data for users without having to release personal information. It is easier to implement and provides stronger authentication. Disadvantages of OAuth 2.0 If you are adding more extension at the ends in the specification, it will produce a wide range of non-interoperable implementations, which means you have to write separate pieces of code for Facebook, Google, etc. If your favorite sites are connected to the central hub and the central account is hacked, then it will lead to serious effects across several sites instead of just one. Print Page Previous Next Advertisements ”;
Obtaining an Access Token
OAuth 2.0 – Obtaining an Access Token ”; Previous Next An access token is a string that identifies a user, an application, or a page. The token includes information such as when the token will expire and which app created that token. First, it is necessary to acquire OAuth 2.0 client credentials from API console. Then, the access token is requested from the authorization server by the client. It gets an access token from the response and sends the token to the API that you wish to access. You must send the user to the authorization endpoint at the beginning. Following is an example of a dummy request https://publicapi.example.com/oauth2/authorize?client_id=your_client_id&redirect_uri=your_url &response_type=code Following are the parameters and their descriptions. client_id − It should be set to the client id of your application. redirect_uri − It should be set to the URL. After the request is authorized, the user will be redirected back. response_type − It can either be a code or a token. The code must be used for server side applications, whereas the token must be used for client side applications. In server side applications, you can make sure that the secrets are saved safely. Following table lists the concepts of Client Credentials. Sr.No. Concept & Description 1 Authorization Code The authorization code allows accessing the authorization request and grants access to the client application to fetch the owner resources. 2 Resource Owner Password Credentials The resource owner password credentials include only one request and one response, and is useful where the resource owner has a good relationship with the client. 3 Assertion Assertion is a package of information that makes the sharing of identity and security information across various security domains possible. 4 Refresh Token The refresh tokens are used to acquire a new access tokens, which carries the information necessary to get a new access token. 5 Access Token Response Access token is a type of token that is assigned by the authorization server. 6 Access Token Error Response Codes If the token access request, which is issued by the authorization server is invalid or unauthorized, then the authorization server returns an error response. Print Page Previous Next Advertisements ”;
OAuth 2.0 – Useful Resources
OAuth 2.0 – Useful Resources ”; Previous Next The following resources contain additional information on OAuth 2.0. Please use them to get more in-depth knowledge on this. Useful Links on OAuth 2.0 OAuth 2.0 Wiki − Wikipedia Reference for OAuth 2.0. Useful Books on OAuth 2.0 To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;
Objective-C – Useful Resources ”; Previous Next The following resources contain additional information on Objective C. Please use them to get more in-depth knowledge on this topic. Useful Video Courses Understanding S.M.A.R.T. Objectives 19 Lectures 1 hours PARTHA MAJUMDAR More Detail Econometrics For Dummies: Learn The Basic 20 Lectures 51 mins Pedro Planas More Detail Master Creating Well-Defined Marketing Objectives in 30 mins 6 Lectures 25 mins Ken Burke More Detail Build Landing Page Design for Higher Sales & Lead Generation 20 Lectures 1.5 hours Being Commerce More Detail Build Landing Page Optimization for higher conversion rate 20 Lectures 1.5 hours Being Commerce More Detail RECRUITMENT: IT basics for IT Recruiters Featured 61 Lectures 5 hours Valeria Frisch More Detail Print Page Previous Next Advertisements ”;
Pascal – Objects
Pascal – Object Oriented ”; Previous Next We can imagine our universe made of different objects like sun, earth, moon, etc. Similarly, we can imagine our car made of different objects like wheel, steering, gear, etc. Same way, there are object-oriented programming concepts, which assume everything as an object and implement a software using different objects. In Pascal, there are two structural data types used to implement a real world object − Object types Class types Object-Oriented Concepts Before we go in detail, let”s define important Pascal terms related to Object-Oriented Pascal. Object − An Object is a special kind of record that contains fields like a record; however, unlike records, objects contain procedures and functions as part of the object. These procedures and functions are held as pointers to the methods associated with the object”s type. Class − A Class is defined in almost the same way as an Object, but there is a difference in way they are created. The Class is allocated on the Heap of a program, whereas the Object is allocated on the Stack. It is a pointer to the object, not the object itself. Instantiation of a class − Instantiation means creating a variable of that class type. Since a class is just a pointer, when a variable of a class type is declared, there is memory allocated only for the pointer, not for the entire object. Only when it is instantiated using one of its constructors, memory is allocated for the object. Instances of a class are also called ”objects”, but do not confuse them with Object Pascal Objects. In this tutorial, we will write ”Object” for Pascal Objects and ”object” for the conceptual object or class instance. Member Variables − These are the variables defined inside a Class or an Object. Member Functions − These are the functions or procedures defined inside a Class or an Object and are used to access object data. Visibility of Members − The members of an Object or Class are also called the fields. These fields have different visibilities. Visibility refers to accessibility of the members, i.e., exactly where these members will be accessible. Objects have three visibility levels: public, private and protected. Classes have five visibility types: public, private, strictly private, protected and published. We will discuss visibility in details. Inheritance − When a Class is defined by inheriting existing functionalities of a parent Class, then it is said to be inherited. Here child class will inherit all or few member functions and variables of a parent class. Objects can also be inherited. Parent Class − A Class that is inherited by another Class. This is also called a base class or super class. Child Class − A class that inherits from another class. This is also called a subclass or derived class. Polymorphism − This is an object-oriented concept where same function can be used for different purposes. For example, function name will remain same but it may take different number of arguments and can do different tasks. Pascal classes implement polymorphism. Objects do not implement polymorphism. Overloading − It is a type of polymorphism in which some or all of operators have different implementations depending on the types of their arguments. Similarly functions can also be overloaded with different implementation. Pascal classes implement overloading, but the Objects do not. Data Abstraction − Any representation of data in which the implementation details are hidden (abstracted). Encapsulation − Refers to a concept where we encapsulate all the data and member functions together to form an object. Constructor − Refers to a special type of function which will be called automatically whenever there is an object formation from a class or an Object. Destructor − Refers to a special type of function which will be called automatically whenever an Object or Class is deleted or goes out of scope. Defining Pascal Objects An object is declared using the type declaration. The general form of an object declaration is as follows − type object-identifier = object private field1 : field-type; field2 : field-type; … public procedure proc1; function f1(): function-type; end; var objectvar : object-identifier; Let us define a Rectangle Object that has two integer type data members – length and width and some member functions to manipulate these data members and a procedure to draw the rectangle. type Rectangle = object private length, width: integer; public constructor init; destructor done; procedure setlength(l: inteter); function getlength(): integer; procedure setwidth(w: integer); function getwidth(): integer; procedure draw; end; var r1: Rectangle; pr1: ^Rectangle; After creating your objects, you will be able to call member functions related to that object. One member function will be able to process member variable of related object only. Following example shows how to set lengths and widths for two rectangle objects and draw them by calling the member functions. r1.setlength(3); r1.setwidth(7); writeln(” Draw a rectangle: ”, r1.getlength(), ” by ” , r1.getwidth()); r1.draw; new(pr1); pr1^.setlength(5); pr1^.setwidth(4); writeln(” Draw a rectangle: ”, pr1^.getlength(), ” by ” ,pr1^.getwidth()); pr1^.draw; dispose(pr1); Following is a complete example to show how to use objects in Pascal − Live Demo program exObjects; type Rectangle = object private length, width: integer; public procedure setlength(l: integer); function getlength(): integer; procedure setwidth(w: integer); function getwidth(): integer; procedure draw; end; var r1: Rectangle; pr1: ^Rectangle; procedure Rectangle.setlength(l: integer); begin length := l; end; procedure Rectangle.setwidth(w: integer); begin width :=w; end; function Rectangle.getlength(): integer; begin getlength := length; end; function Rectangle.getwidth(): integer; begin getwidth := width; end; procedure Rectangle.draw; var i, j: integer; begin for i:= 1 to length do begin for j:= 1 to width do write(” * ”); writeln; end; end; begin r1.setlength(3); r1.setwidth(7); writeln(”Draw a rectangle:”, r1.getlength(), ” by ” , r1.getwidth()); r1.draw; new(pr1); pr1^.setlength(5); pr1^.setwidth(4); writeln(”Draw a rectangle:”, pr1^.getlength(), ” by ” ,pr1^.getwidth()); pr1^.draw; dispose(pr1); end. When the above code is compiled and executed, it produces the following result − Draw a rectangle: 3 by 7 * * * * * * * * * * *
OAuth 2.0 – Home
OAuth 2.0 Tutorial PDF Version Quick Guide Resources Job Search Discussion OAuth2.0 is an open authorization protocol, which allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as Facebook, GitHub, etc. It allows sharing of resources stored on one site to another site without using their credentials. It uses username and password tokens instead. Audience This tutorial is designed for software programmers who would like to understand the concepts of OAuth. This tutorial will give you enough understanding on OAuth from where you can take yourself to higher levels of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of authorization and authentication of a basic client server application model. Print Page Previous Next Advertisements ”;