Delphi Programming - Full Beginner Crash Course

Brief Summary

This comprehensive Delphi tutorial covers everything from setting up the IDE to advanced database manipulation and string handling. Key topics include understanding the Delphi IDE, creating basic applications, working with variables, control flow statements, file I/O, arrays, and database interactions. The course also covers GUI elements like checkboxes and radio buttons, and advanced techniques such as sorting algorithms and text-to-speech functionality.

  • Introduction to Delphi IDE and basic application setup.
  • Core programming concepts: variables, if statements, loops.
  • Advanced topics: file I/O, arrays, database management.
  • GUI design and event handling.

Intro

This is an introductory video for a comprehensive Delphi course, designed for both students and individuals looking to learn Delphi programming. The course covers all the material in the specified book and aims to provide a practical understanding of the language.

The Delphi IDE

This chapter provides a tour of the Delphi IDE, starting with how to create a new VCL forms application. It explains the importance of using "Save All" to save the project and unit files correctly. The video guides the user through creating a new folder for the project and naming the unit and project files with appropriate suffixes (_U for unit, _P for project) for easy identification. It briefly touches on the various menus like File, Edit, View, Project, Run, and Components, highlighting essential options such as compiling, building, and setting application options (like icon and title). The chapter also covers the component palette, object inspector (for changing properties and events), and form designer, explaining how to add components, manage their hierarchy, and modify their attributes. It shows how to switch between the code and design views using the tabs or the F12 key.

Your First Delphi Application

This chapter guides the user through creating a simple application with a label, two buttons, a bit button, and a shape. It starts with creating a new VCL forms application and saving it in a designated directory. The video explains how to adjust the form's height and width using the object inspector and how to add components like labels, buttons, and shapes to the form. It covers customising the label's font and caption, renaming components for better code readability (e.g., btnUp, btnClose, shpCircle), and setting the bit button's "Kind" property to "Close" for automatic closing functionality. The chapter also demonstrates how to disable a button initially and how to change the shape's colour using the "Brush" property. Finally, it introduces the basics of coding button click events to move the shape and enable/disable buttons.

Comments

This chapter explains how to use comments in Delphi code. Single-line comments are created using //, while multi-line comments can be created using (* ... *) or { ... }. Comments are useful for adding notes, explaining code sections, or temporarily disabling code. The video recommends using (* ... *) for multi-line comments due to its ease of use.

Images

This chapter demonstrates how to add images to a Delphi application. It involves placing an TImage component on the form, loading an image file using the "Picture" property in the object inspector, and setting the "Stretch" property to True to ensure the image fits the component's dimensions.

Changing Attributes

This chapter focuses on changing component attributes using event handlers. It uses an example of a form with three edits, three labels, a bit button (for reset), and three buttons (for language selection). The video explains how to clear the contents of the edits on form activation using the Clear method or setting the Text property to an empty string. It also demonstrates how to change the captions of the labels when different language buttons are clicked, providing translations for name, surname, and age in Afrikaans, English, and Spanish. The chapter emphasises the importance of good programming practices, such as consistently using either the Clear method or setting the Text property to an empty string for all edits.

Basic Output

This chapter covers basic output methods in Delphi, including using labels, memos, panels, and show messages. It starts by creating a new VCL forms application and adding a button, a label, a memo, and a panel to the form. The video explains how to clear the default text from the memo component by deleting the lines in the "Lines" property. It then demonstrates how to change the label's caption, add text to the memo using the Add method of the Lines property, and display text on the panel using the Caption property. The chapter also covers using the ShowMessage function to display a pop-up message with text, including how to convert integer values to strings using the IntToStr function for display in the message.

Mathematical Operators

This chapter explains basic mathematical operators in Delphi, including addition, subtraction, multiplication, and division. It uses the ShowMessage function to display the results of these operations. The video demonstrates how to perform addition using the + operator, subtraction using the - operator, multiplication using the * operator, and division using the / operator. It also explains the difference between integer division (div) and real division (/), noting that real division requires converting the result to a string using FloatToStr.

Basic Input

This chapter covers basic input in Delphi, focusing on how to retrieve text from TEdit components and display it in a TLabel. It starts by setting up a form with two labels (FirstName and Surname), two edits (edtName and edtSurname), and an output label (lblOutput). The video explains how to retrieve the text entered in the edits using the Text property and concatenate it to display a greeting in the output label.

Setting Calendar Dates

This chapter explains how to use the TCalendar and TSpinEdit components to set dates in a Delphi application. It involves placing a TCalendar, three TSpinEdit components (for day, month, and year), and a button on the form. The video demonstrates how to limit the input in the spin edits by setting the MaxLength, MaxValue, and MinValue properties. It also explains how to use the OnActivate event of the form to set these properties programmatically. The chapter then covers how to set the Day, Month, and Year properties of the TCalendar component based on the values entered in the spin edits when the button is clicked.

Coding a Traffic Light

This chapter guides the user through creating a traffic light simulation using Delphi. It involves placing three TShape components (for red, yellow, and green lights) and three TButton components on the form. The video explains how to change the shape of the TShape components to circles and how to set the background colour of the form to black. It then demonstrates how to change the colour of the shapes using the Brush.Color property in the OnActivate event of the form, initially setting the green light to green and the others to black. The chapter also covers how to code the button click events to simulate the traffic light sequence, changing the colours of the shapes and ensuring only one light is active at a time.

Variables

This chapter introduces the concept of variables in Delphi. It explains the different types of variables, including string (for text), char (for single characters), integer (for whole numbers), real (for floating-point numbers), and boolean (for true/false values). The video demonstrates how to declare variables in the private section of the form's class and how to assign values to them. It also covers using the IntToStr function to convert integers to strings for display in UI elements. The chapter explains the importance of using descriptive variable names and proper formatting for code readability. It also touches on the concept of variable scope, explaining that variables declared within a procedure are only accessible within that procedure, while variables declared in the private section are accessible throughout the form.

If Statements

This chapter covers the basics of if statements in Delphi. It explains that an if statement allows you to execute a block of code only if a certain condition is true. The video demonstrates how to use if statements with boolean variables and comparison operators (e.g., >, =) to control the flow of execution.

If-Else Statements

This chapter extends the previous lesson on if statements by introducing the else clause. It explains that the else clause allows you to execute a different block of code if the condition in the if statement is false. The video demonstrates how to use if-else statements to provide alternative actions based on different conditions.

Else-If Statements

This chapter introduces else if statements, which allow you to check multiple conditions sequentially. The video explains that else if statements are useful when you have more than two possible outcomes. It demonstrates how to use else if statements to check different values of a string variable and display different messages accordingly.

Logical Operators

This chapter covers logical operators (and, or, not) in Delphi. It explains how to use these operators to combine multiple conditions in if statements. The video demonstrates how to use the and operator to check if two conditions are both true, the or operator to check if at least one condition is true, and the not operator to negate a condition.

Inputbox

This chapter explains how to use the InputBox function in Delphi to prompt the user for input. It demonstrates how to display an input box with a title, a prompt message, and a default value. The video also covers how to retrieve the text entered by the user and display it in a TEdit component.

Constant Variables

This chapter explains how to use constants in Delphi. It demonstrates how to declare a constant using the const keyword and how to assign a value to it. The video also covers the naming conventions for constants (using all uppercase letters) and the importance of using constants for values that should not be changed during program execution.

Input-Process-Output

This chapter explains the Input-Process-Output (IPO) model in programming. It uses a simple example of taking a name as input, processing it by adding "is cool" to it, and displaying the result as output. The video demonstrates how to retrieve text from a TEdit component, concatenate it with a string literal, and display the result in a TLabel.

Building a Voting System

This chapter guides the user through creating a basic voting system using Delphi. It involves placing three TImage components (for movie posters), three TPanel components (to display vote counts), two TButton components (for navigation), and two TBitBtn components (for closing and resetting the system) on the form. The video explains how to load images into the TImage components and how to rename the components for better code readability. It then demonstrates how to code the button click events to increment the vote counts for each movie and display the updated counts in the TPanel components. The chapter also covers how to code the reset button to reset all vote counts to zero and the close button to close the application.

More Logical Operators

This chapter expands on the previous lesson about logical operators by introducing the "not equal to" operator (<>), the "greater than or equal to" operator (>=), and the "less than or equal to" operator (<=). It also reviews the and and or operators. The video demonstrates how to use these operators in if statements to create more complex conditions.

If ... In

This chapter introduces the if ... in statement in Delphi. It explains that this statement allows you to check if a value is present in a set of values. The video demonstrates how to use the if ... in statement to check if a number is within a specific range or if a character is in a set of characters.

Checkboxes

This chapter explains how to use checkboxes in Delphi. It demonstrates how to add a TCheckBox component to a form and how to check its Checked property to determine if it is checked or not. The video uses an example of a form with a checkbox and a button, where the button's action depends on whether the checkbox is checked.

Radio Buttons/Groups

This chapter explains how to use radio buttons and radio groups in Delphi. It highlights the key difference between checkboxes and radio buttons: checkboxes allow multiple selections, while radio buttons allow only one selection within a group. The video demonstrates how to add a TRadioGroup component to a form and how to add radio buttons to the group using the "Items" property. It also covers how to determine which radio button is selected using the ItemIndex property.

Case Statements

This chapter introduces the case statement in Delphi as an alternative to multiple if-else if statements. It explains that the case statement allows you to execute different blocks of code based on the value of a variable. The video demonstrates how to use the case statement with an integer variable and how to specify different actions for different values.

Case Lists

This chapter expands on the previous lesson about case statements by introducing case lists. It explains that case lists allow you to specify multiple values for a single case, making the code more concise. The video demonstrates how to use case lists with integer values and how to specify a range of values using the .. operator.

For Loops

This chapter introduces for loops in Delphi. It explains that a for loop allows you to execute a block of code a specific number of times. The video demonstrates how to use a for loop to iterate over a range of numbers and how to use the downto keyword to iterate in reverse order.

Looping Through a String

This chapter explains how to use a for loop to iterate through the characters of a string in Delphi. It demonstrates how to use the Length function to get the length of a string and how to access individual characters using the [] operator. The video uses an example of counting the number of vowels in a string.

While Loop

This chapter introduces the while loop in Delphi. It explains that a while loop allows you to execute a block of code repeatedly as long as a certain condition is true. The video demonstrates how to use a while loop to iterate over a range of numbers and how to use the Inc function to increment a variable.

Timer

This chapter explains how to use the TTimer component in Delphi to create timed events. It involves placing a TTimer component on the form and setting its Interval property to specify the time interval in milliseconds. The video demonstrates how to use the OnTimer event to execute code at regular intervals, creating a simple animation effect by moving an image across the form.

Using Val

This chapter explains how to use the Val procedure in Delphi to validate and convert strings to numerical values. It demonstrates how to use Val to convert a string entered in a TEdit component to an integer or a real number. The video also covers how to check the value of the Code parameter to determine if the conversion was successful.

Reading From a File - Part 1

This chapter begins the explanation of how to read data from a file in Delphi. It covers the initial steps of creating a new VCL forms application, saving the project, and adding a button and a rich edit component to the form.

Reading From a File - Part 2

This chapter continues the explanation of how to read data from a file in Delphi. It demonstrates how to use the AssignFile, Reset, ReadLn, and CloseFile procedures to read data from a text file line by line. The video also covers how to handle potential exceptions using a try...except block and how to display the contents of the file in a TRichEdit component.

Writing To a File

This chapter explains how to write data to a file in Delphi. It demonstrates how to use the AssignFile, Rewrite, WriteLn, and CloseFile procedures to create a log file and write user login information to it. The video also covers the difference between Rewrite (which overwrites the existing file) and Append (which adds to the end of the existing file).

Custom Columns

This chapter explains how to create custom columns in a Delphi application. It demonstrates how to use the Paragraph.TabCount and Paragraph.Tab properties of a TRichEdit component to create custom tab stops for aligning text in columns.

What is an Array?

This chapter provides a conceptual overview of arrays. It explains that an array is a data structure that can hold multiple values of the same type. The video uses examples of arrays of names and ages to illustrate the concept. It also highlights the difference in array indexing between Delphi (which starts at 1) and other programming languages (which often start at 0).

Creating an Array

This chapter demonstrates how to create and populate an array in Delphi. It involves declaring an array variable with a specific size and data type and then assigning values to individual elements of the array. The video uses an example of an array of monster names to illustrate the process.

Searching an Array

This chapter explains how to search for a specific value in an array. It demonstrates how to use a while loop and an if statement to iterate through the elements of the array and compare them to the search value. The video also covers how to use a boolean variable to indicate whether the search value was found.

Constants

This chapter explains how to use constants in Delphi. It demonstrates how to declare a constant using the const keyword and how to assign a value to it. The video also covers the naming conventions for constants (using all uppercase letters) and the importance of using constants for values that should not be changed during program execution.

Procedures and Functions

This chapter explains the difference between procedures and functions in Delphi. It demonstrates how to create a procedure using the procedure keyword and how to create a function using the function keyword. The video also covers how to pass parameters to procedures and functions and how to return a value from a function using the Result variable.

What is a Database?

This chapter provides a conceptual overview of databases. It explains that a database is a structured collection of data, organised into tables with rows and columns. The video uses a spreadsheet as an analogy to explain the basic concepts of databases.

Connecting to a Database

This chapter demonstrates how to connect a Delphi application to a database. It involves adding a TDataModule, a TADOConnection, and a TADOTable component to the project. The video explains how to configure the TADOConnection component to connect to a Microsoft Access database and how to set the TableName property of the TADOTable component to select a specific table in the database.

DBNavigator

This chapter explains how to use the TDBNavigator component in Delphi to navigate through the records in a database table. It demonstrates how to add a TDBNavigator component to a form and how to connect it to a TDataSource component, which is in turn connected to a TADOTable component. The video shows how to use the buttons on the TDBNavigator to move between records, add new records, delete records, and edit existing records.

Inserting Data Into a Database

This chapter demonstrates how to insert data into a database table using Delphi. It involves adding TEdit components to the form to allow the user to enter data and a button to trigger the insertion process. The video explains how to use the Insert method of the TADOTable component to create a new record, how to assign values to the fields of the new record using the [] operator, and how to use the Post method to save the changes to the database.

Editing Data in a Database

This chapter explains how to edit data in a database table using Delphi. It involves using the Locate method of the TADOTable component to find a specific record based on a key field, and then using the Edit method to put the table in edit mode. The video then demonstrates how to modify the values of the fields in the record and how to use the Post method to save the changes to the database.

Deleting Data in a Database

This chapter demonstrates how to delete data from a database table using Delphi. It involves using the Locate method of the TADOTable component to find a specific record based on a key field, and then using the Delete method to remove the record from the database.

Filtering a Database

This chapter explains how to filter data in a database table using Delphi. It demonstrates how to use the Filtered and Filter properties of the TADOTable component to display only the records that meet certain criteria. The video also covers how to use logical operators (and, or) in the filter expression to create more complex filters.

Calculations With Databases

This chapter demonstrates how to perform calculations with data from a database table using Delphi. It involves using the First and Next methods of the TADOTable component to iterate through the records in the table and accumulate the values of a specific field. The video also covers how to display the calculated result in a TLabel component.

Sorting a Database

This chapter explains how to sort the records in a database table using Delphi. It demonstrates how to use the Sort property of the TADOTable component to specify the field to sort by and the sort order (ascending or descending).

Searching a Database

This chapter demonstrates how to search for a specific record in a database table using Delphi. It involves using the Locate method of the TADOTable component to find a record based on a key field. The video also covers how to use the loPartialKey option to perform a partial search, finding records that contain a specific substring in the key field.

Working with Multiple Forms

This chapter explains how to work with multiple forms in a Delphi project. It demonstrates how to create a new form using "File > New > VCL Form" and how to show the new form from the main form using the Show method. The video also covers how to hide the main form using the Hide method and how to close the secondary form using the Close method. It also explains how to set the main form in the project options to ensure the correct form opens on startup.

Bubble Sort

This chapter explains the bubble sort algorithm and how to implement it in Delphi to sort an array. It starts with a visual explanation of how the bubble sort algorithm works, comparing adjacent elements in the array and swapping them if they are in the wrong order. The video then demonstrates how to implement the bubble sort algorithm using nested for loops in Delphi.

Text to Speech

This chapter demonstrates how to use text-to-speech (TTS) functionality in Delphi. It involves adding the ComObj unit to the uses clause and creating an OLE object to access the SAPI (Speech API) voice. The video then demonstrates how to use the Speak method of the voice object to convert text to speech.

Math Functions

This chapter covers various math functions available in Delphi. It involves adding the Math unit to the uses clause and demonstrating how to use functions like Round, Trunc, Frac, Ceil, Floor, Sqrt, Square, Power, Abs, Pi, Random, and RandomRange. The video explains the purpose of each function and provides examples of how to use them.

String Manipulation Functions

This chapter covers several string manipulation functions in Delphi. It demonstrates how to use functions like Concat, Length, Pos, Copy, and UpperCase. The video explains the purpose of each function and provides examples of how to use them.

String Manipulation Procedures

This chapter covers string manipulation procedures in Delphi, focusing on Delete and Insert. It explains how Delete removes a portion of a string, and Insert adds a substring into a string at a specified position. The video also touches on the Val procedure for validating string input as numerical data.

Message Boxes

This chapter explains how to use message boxes in Delphi, focusing on the MessageDlg function. It demonstrates how to create message boxes with different types of icons (e.g., warning, error, information) and buttons (e.g., Yes, No, Cancel). The video also covers how to check the return value of the MessageDlg function to determine which button was clicked by the user.

More Functions & Procedures

This chapter covers additional functions and procedures in Delphi, including date and time functions (TimeToStr, DateToStr, Now), form colour manipulation, boolean to string conversion (BoolToStr), and character code conversion (Ord, Chr). It explains how to use these functions and procedures to perform various tasks, such as displaying the current date and time, changing the background colour of a form, and converting between characters and their ASCII codes.

Working with RichEdits

This chapter explains how to work with TRichEdit components in Delphi. It demonstrates how to add text to a TRichEdit control, clear its contents, load text from a file, save text to a file, and print the contents of the control. The video also covers how to modify the font size, colour, style, and alignment of the text in the TRichEdit control.

Outro

This is the outro of the Delphi tutorial.

Summarize any YouTube video in seconds

Get summaries like this one for any video, in your language, with the free Summ app.

Download on the App Store
Get it on Google Play

Transcript

YouTube Transcript Generator

0:01 and everyone welcome to your full course thousand tutorials so this beginner's course will if you're following my homework school will cover everything inside of this book this six hour course will teach you to get free great team angular and if you're not doing it because of school this course will help you get up and running with adopted programming language now let's get started and celebrity i'm so glad to see that you're all joining in into the stealthy tutorial so this is our first video and we're not going to do any coding right now i'm just going to show you around

0:48 and show you how everything works and looks at what it does and stuff like that so here you don't have to really worry about anything this is just how the the intro you know what you really got to do is you got to go to file and this is in most cases what you need to do and if you're working with delphi you'd want to say blc forms and vcl forms and applications but if you're working with html stuff you can go here but since you didn't if you didn't follow my html tutorial you'd never actually need to go here but here is the bcl forms and applications you click on that you really need to worry about any of the things that's here just yet you just always started this one all right these will come in later

1:36 now we're just going to show you guys around first off we have files now after you've opened your file you'd want to save it but do not say save we're going to say save is not going to save everything so you have to say save all because it's going to save the project as well as everything else that might have kind of come with it so you can always say shift control s or you can say save all right here for the first few videos i'm going to say right here so you can get it together into your guys heads that you should be using this one now let's click there and then here usually you can keep it like that it's not a problem already first you find your directory

2:22 so you're going to new because i am already where i want to be and now you just say folder and call whatever you want so we're going to go the selfie test we're going to our first folder and then here you can just rename it to whatever you want you can even leave it like that but i suggest you go if or in whatever the name should be so we're going to test and if it's the unit which is usually the first one you go underscore you and you also see here it says you right there for unit and you just put you there now you don't need to do this but it makes it easier to navigate just say save and then you're going to have to save the project now just do the same thing f r m with the name

3:10 underscore and instead of u you go p because p is usually the one you want to open so just that just makes it easier you know otherwise you're going to have to read it the like dot dpr oj and you don't always want to do that so you just go save and you have saved it correctly now that's about all you have to worry about in here the reason really important i never use it you can use it and nothing really important here we don't have to worry about it search nothing really to worry about actually view you never actually use this either but maybe you will find something that will fit to your liking and then you

3:57 will use this but otherwise you don't really have to worry yourself with this either refactor i never use this now probably never will so you can decide if you want to use this i don't know what's going on in here so yeah project here you can find a few cool things for example compiling it building it but you don't need to actually ever use these unless you're creating something specific to like you know actually use for a game right here i've created a game also here's the folders where you can just stack as you can see there's underscore p and stuff so easy to read now what i have done is i've created a game

4:44 now here and basically if you say build you build this exe dot exe you know and you can play the play whatever you used so that's what all this is for then you have the options option which is uh pretty useful as well for you remember this game i just showed you now you might be wondering how do you change how it looks how do you change the icon and stuff here now there's you can change the icon here change the title and go make a help file you can change the version info now this is if you're creating like applications and stuff for actual people

5:31 this could be useful but yeah that's about all i use here you actually bring it you'd actually never have to use this either and then you have to run where you can actually run it or run it without debugging but you don't actually need to click this you know you can just click this which is also wrong run doesn't really do anything right now it just opens it up and shows you this is how it looks it doesn't have why did you do that it doesn't have anything why are you oh wait okay see this is basically the dot exec can you stop doing that why are we doing that the dot exe file so you don't have to click this but you can if you want i just start clicking

6:17 this they have the components which i never use either two with i never use other windows and help i never use any of those then most of these you can find for yourself for example this is save control s you can find it here all of this you can find that here this you can also find here in view like i'm sure you find somewhere here there's nothing special about it saying none won't do anything going undocked it's just making everything it says undocked you just move it around like let's say you have a bunch of things you got to check out you move around mess with it not really important it

7:03 does very confusing things then you get the debug layout which is uh nothing special it's just what you get normally and they also get the default layout which is also nothing really too special but i just go with the default outs because it's the easiest of them all you can see which one you want which one you like you know up to you we'll get to this we'll get to this and here are all your projects now this is just a project you can add another project here for example and i can add this i can put it there but i'm not going to and then you can add a project here oh wait let's do it let's show you what to do so let's say you add a project here so you can like

7:48 so it has anyways been added usually it will have an extra one here but i said close so here it would usually be that you can things and it's both projects you know but this one which usually interfere with this one you can change it here somewhere but i don't do that i'll just say remove remove project this will remove that project and you'll only have your one project there which is mostly useful just for later on yeah because you never know you might accidentally do that then here you can just resize the form the form is nothing reform is actually the whole application i can't say nothing special see if you resize it this suddenly becomes bigger this here is where it will pop up if this is in the middle it will pop up in

8:34 the middle of the screen if it's there there and stuff like that so let's make it pop up right there here so if i run it now it opens up here which i find really annoying usually what i do is i click on it and here at object inspector i go to either windows state and make it maximize or i go to position here and i just say make it into the center desktop sensor there's another one but i just pick whichever one works for me because i don't have two screens or anything so it doesn't bother me so now i can move it around and stop but it'll always stay there why does it do that it's really annoying

9:21 anyways so yeah then you have that so now let's get it to hell now let's get to the two places now here is where you can find things like buttons memos panels which i don't necessarily like using a bunch of things which is pretty cool another thing to notice if you accidentally like put your memo on the panel um let's create an another memo memo if you accidentally put your memo or a button or whatever on the panel you'd see it's quite annoying because

10:06 it's on the panel but you know it makes it looks nice and stuff later on and it does have special effects and stuff but if you do this and you don't want it here it's annoying because it can't go out and stuff let's delete this mirror because this mirror is important you can just go to edit delete then maybe it's gone but see if you want this one to go away all you're going to do is you're going to go here to this the form structure and this is basically how everything is built like see that's with little children and stuff like that like this is a parent this is his children and this is the parent's grandchild but you can make this grandchild the parent's child by dragging it to the parent now as you can see the memo is no longer part of the panel so we can just put it wherever we want

10:53 good thing to note because that can become really annoying if you don't know how to do it now we can go here after we have covered basically all that here we can just change things for example the name which we will get to later when coding usually for button we go btn and then the name like press button press and then to change the caption you go to caption and you remove the button there now just press now this doesn't do anything yet it's just a bunch of components on a form you can do whatever you want isn't going to do anything see this is just so you can edit how everything here looks you can change the

11:39 colors and the size and stuff like that you can all do you can do all of this inside the code um like in this game right here i did a lot of things just inside of the code um especially here when the first version came out the beta version this is all like sit inside of the code like when the game starts all of that is like set to a different place with the code now we're not going to start the code just yet we're going to do that in the next video now i'm just showing you how everything works these three you don't really need to mess with i never mess up them because you know i'm not i never use them so i never mess with them then you have the code which we will get

12:25 to later on and how to edit it and stuff like that because right now you can't do anything really it's just a bunch of pieces of stuff now what you can do is you can either press code or design and it will swap between the two or you can press f12 and it will swap between the two as well now here also on the object inspector it's nice to note that you have events for example on the press button we have like on click event like if they click on it or where's that like in drag but after a dragon they stop something will happen on exit on entry in a bunch of useful things we'll also get to this later inside the code

13:10 okay back to here now here you also have history but i never use it because i never need to now yeah next time we'll get to coding and how to start with the basics for example coding a button and a shape so today we will be creating this it's a basic program which is sends the ball up and down it has a label two buttons and one bit button now i'll be explaining all these later and also has the shape now we'll be trying to create it almost

13:56 exactly like this doesn't need to be exactly but we can kind of create it exactly like this so first create your form new vcl forms application and then the ship button then save it save all you need choose your directory probably want i'm going to call the page i'm explaining to you guys then let's go for in game underscore build a friend the ball game

14:42 you should know what it is when you go in okay underscore you you can copy that if you want and then underscore p and now you have saved it now let's see so it has label two buttons a bit button and a circle so we have a label two buttons one bit button and then one shape okay so let's first do this let's get everything out there

15:28 okay so before we try to everything where it should be let's first try and make this into this because as you can see they're not matching so first off now you can do this but this isn't as accurate let's say you want specifics you know then this isn't going to now first of all you select the form because sometimes you are selected to want these and then it might not work as well so first you select the formula then let's go to the height now the object inspector h should be there we can make this 330

16:15 it will probably be 330 pixels but it doesn't really matter in this context and then you change the word to 30. now that should look pretty much like this a little different but there will probably now let me put the label there there now let's see what else does it have let's see what else does it have here uh so it's font seems to be comic sans so let's go here and then we go to the font now you can change all this in the code but because you're new we'll be using object

17:01 inspector first so then you go to fonts you click on these three buttons right here and you search for comic sense up here select that make the yeah make the size 10 so it's a little bit bigger than that and then you go okay now as you can see everything here changes [Music] then let's see what else would there be now this one has a catch in my first stealthy program now select your form and go to caption my first healthy program yeah my first time program

17:47 now i believe we can go on to the label oh wait wait let's first shake everything how does all this look okay let's first do the label so you change the caption to it says click it button click a button okay so there is the label now here it is around about here so we can reshape this you look bigger this you can change how big you want i would like it to be and we can change about that there now they look basically the same

18:39 all right now this is up to you you can actually make it whatever size you want actually also another thing to note is you can press ctrl and lift right up and down to move it like slightly sideways upwards downwards you know if you can't get it to exactly where you want it for example see you kind of get kind of constantly there but you don't want it control and the society you want to go to and easy as part am i right and then its shape is around here okay so now we can start with the first button now we open it up it says up so first let's let's name all things

19:26 firstly because this makes the whole process easier to first name it so then we go to name btn go to button2 and make this btn close close turn down all right then the bed button we go bit btn and close okay so now we have this and so we can rename this one to shp for shape and then circle

20:12 okay so now we can go to the captions so we can just go there and always there see just go to the object inspector makes everything easy and you can just quickly change whatever you want now of course as i said you could do this in the code but if you don't have to why do that well well i i like to do it like that but since we are new here we gotta stay with now a bit button isn't the same as a button now a button you can code you can create a bit button as well but a bit button you can give a specific thing to do like here they give gave their bed button the specific thing to close

20:59 so if i'm going to click on this it will close no no no need to go reopen it as you can see here so this one should do the same so what with the bit button you select it ending what are you doing okay you select it and you go down to kind you click on this button right here and you go to close now it should look basically the same the reason we i noticed a bit button is because it has this little image here red buttons can have little images i don't know why but it's kind of cute

21:46 you know so yeah so the first button here seems to be enabled as you can see here and this one is disabled so you can't click on it this one you can click and then this one becomes enabled we'll get to the code with this later so first let's disable this one so you click on it and you go to enabled right here and you take it to false now this one should be disabled when we started out then we can go i think we can continue to the shape it should be this now the shape seems to be a circle so you select it

22:31 and you go to shape now this is up to you you can animate it an ellipse or a circle it is truly up to you a circle can only change its radius and the ellipse can only change it's kind of changes height and work if you follow my html tutorials you'll kind of understand this now a circle if you change the height the width will change along with it so if you change the height to 60 the roof will become 60 as well but very much if you change the height to 60 the work will stay the same as what it was so let's go to ellipse you can choose circle if you want it's actually faster but for the sake of the video we're going to choose a lens

23:16 now we're going to change the height of this to 14 which is 40 and then the width will also change to 14. now we have a 40 by 40 ellipse okay now here it's red so to get that you go to brush you click on this plus sign right here and you'll have the option to color it you click on this button right here inside and you choose cl red isn't that beautiful so then

24:01 we can start positioning it so let's make lift around 160 maybe [Music] and we make the two what about 120 the top is 120. we make the top 200 yeah that's better okay so here is what we have here it looks basically exactly the same right but if you're going to run this one you will see they do look exactly the

24:49 same but there's one difference if i click up here and down here the ball moves but if i click up here nothing happens so let's close this now we can start coding so with a button you can either go to the events and click on the on click you can double click here or in the foster way and just double click on that button and it will automatically create on click procedure now here is where we start programming thankfully selfie is in fairly easy language to learn

25:34 um everything is super easy to understand so first off as you can see here the app button since thing since the baller so the first thing you should do is we should save the shape now we called the shape here at the name there shp circle so here we can go this hp circle now uh easy thing to notice you can either do that or you can press ctrl and space

26:20 and then sh and there you pop up account press enter and you have your name now when you press the button up your circle should be going up correct so you say dot and this is where it can become easy so we are still selected at the circle so right now its top is 200 and as we all know changing the top changes where this is so if i change this to 20 it will go up but if i change it to 200 it will go back down so we go shape circle dot top

27:06 and then this is a becomes it is the two dots and an equal sign and then you just go between so it's top becomes string now do you see what i just did there let's do that it was here now if i press ctrl and d it just shifts it upward the alpha has this beautiful thing of impress control and being it makes your code just looks so much better and easier to read i highly suggest you do that because if you don't it will just look unprofessional

27:52 so delphi kind of makes your life easier for you now let's quickly run it and you probably saw here that this changed to green one side this is when i press ctrl s so here i press ctrl d it changes together because it everything is unsaved so ctrl and s saves it and turns it green now let's quickly run this and let's see if i press up you see it changes to 20 so yeah we can close that but you see the problem is when we press up here this one comes enabled and this one becomes

28:38 disabled so what we should do here is we should go btn up dot enabled now as i showed you before you go here and you go to the objectives pane too the name that we chose is yeah beating up now beating up dogs and then here is the enable which is set to true now cp enabled beaten up dot enable then you just make it false now there's just thing in programming where true and false is basically like a one to zero false is where it would be zero and true

29:24 is where it's won now i don't actually need to explain this to you but it's for future reference so if something is enabled then it has a one and the computer reads it as okay so this thing can be used when you create false it gets a zero and then the computer is like huh this is zero it can't be so yeah and then btn down dot enabled becomes true now if you were a bad programmer you would probably do something it would probably look something like this just untidy you don't want that there's controlling d just makes all them beautiful

30:11 now this space here doesn't matter i like to keep mine apart if it's it just looks better you know but there you don't need so also another internet is we can we can do that later okay so now let's quickly try and see what we get so now if we press up it becomes the same and this one becomes enabled but it doesn't work so down is basically the same thing so you go to the down button you double click on it and here you go so shp circle dot top top becomes 200

30:56 then btnr dot enables becomes true and bt in down dot enabled becomes false super positive now the healthiest is nice thing is about where it doesn't care where anything is actually now with any programming language it does sometimes matter where these these are but for those of you that has no experience with programming this doesn't really matter in most cases about where it is or not in these cases in most cases it actually does but this specific case where this is it doesn't matter you can put this one here at the top it doesn't matter

31:42 as long as it's between that begin and end if you don't do it just really doesn't matter okay so now let's try it again down up down and let's quickly see how the other one looks there and there so they look exactly the same to me now right now you might be thinking let's do something what about the coolers don't need to worry this is where the bed button becomes really nice it codes itself basically so close easy as that

32:30 now you might be thinking how do i know if i mean a problem somewhere and it doesn't work and i don't know how to fix it now first thing that would happen is let's remove that this will come up and it will tell you which line it is like around 34 and 20 is how much like where which column not how much character is up just excuse that noise in the background now even if you run this it will give you an error and it will show you exactly where it is and here it will also tell you what's wrong so there fixed so today we'll be covering comments in

33:15 delphi this shouldn't be a long video at all now comments are basically things that remove that you can use like give yourself some tips like um what's that for example slash this is a one line comment it only covers one line so you can be like a sit um shaped position but this won't be red and as you can see there are no problems but if you were to put this without a comment like here then you would immediately get a bunch

34:01 of errors saying hey wait what's this so this really helps you if you just want to cover one line with a comment now you can put a comment anywhere um but these are put above below or after what you wanted to say because if you're going to put this in front of what you wanted to say then this is also going to become a doubt and you don't want that now uh comments are extremely useful correct but if you have like let's say you want to comment out these lines because

34:46 you're not going to use them you want to use something else this is this is lines that you never want to use we can say or let's say you want bt and up to be enabled but always stay enabled or wait wait let's just comment these two out okay then you can already do that and you'll comment out both of them with this but if let's say there's like 50 likes then would you really want to do this 50 times so you can use one of these brackets and close it off with one of those and as you can see these are not comments and they won't be red so b10 update enabled becomes true but it won't become true because

35:34 you see it won't become true because you commented it out now these are the most popular comments to use in healthy but if you really want to you can always use them a bracket with a store and a store and a bracket this does exactly the same thing as this but um yeah but this one is more effort so i suggest you use this one so today we're going to be focusing on the delty images so here in this folder as you can see we have an image along with our project nothing special about it

36:22 now we're going to see how to load it in here now i gotta say images are pretty easy all you gotta do is just say image you add image then you can resize it to whichever size you want you just go like that and then all you got to do is you click on it and you find the picture in the object inspector inspector and you click on the three dots right here at the side you go here and you say load it will open up in the folder and see it's a lot easier than html so then you just click on it you say open and there it is you don't say save or

37:07 clear anything you just say okay now you might be wondering wait what i didn't expect that to happen but all you got to do is just go to go down remember you should still be selected and then here at stretch you should make that true and there you go that will basically stretch itself so it can be shown and that is how you add an image guys okay so today we'll be working through this now um this form is basically just free edits three labels one bit button

37:52 this butt button might say reset but its kind is retry so remember just put a retry and then change the caption to reset and then we have three buttons of records english and spanish now if the person clicks on afrikaans this should change to africans person clicks to english if you change to english or it should stay in english if it is really english and if you click on spanish it should change spanish and if you click reset this should be cleared but when you start up this shouldn't be in it okay so first thing we're going to do is we're going to remove that when we start up the

38:37 whole program because we're starting if we start up now we're going to have a little bit problem with the you know just it's all going to be inside we don't want that so and this doesn't actually work it even if it's a bit button its code doesn't exist just yet so let's get started click on the form go to its advance now you can either choose on activate or on create to be honest i don't know what the difference is i just usually select on activate while everybody else decides to rather select oncreate but to me there's no difference if you start up the application it does everything the same so let's start up

39:23 now we have finally started up or on activate but now what so we want to get rid of the insides now with an edit it's inside or made with text so the inside of that edit is a text now since this shouldn't be doing anything specific we don't need to like assign it to any variables which we haven't done yet but we'll get there so let's press f12 now we know this one is the edt name so edt name dot text becomes i can just do that or if i'm correct we can go dot

40:10 clear so let's see will that clear work yes dot clear works so you can either use that or you can use edt h dot text and make it equal to nothing as you can see it works as well now in i know in some other languages like java you have to use these if you want to create something like this but take note into healthy you don't also in like javascript you can use like

40:57 this this and this it all work the same but in delphi you can only use these so take note of that edt surname dot clear all right so now we should have the first part perfectly done yes now let's do the reset now this is basically a copy and paste literally that that's all this is

41:45 so if you go like that like that and like like that if we say reset it works perfectly because it does exactly the same it clears everything out now it is good to program as and don't do and not doing this because this doesn't look it doesn't look clean we can say now you should either make all of them like this or all of them like this but for the sake of the lesson we did it here like that but here since we have already covered that we can just do what's best don't clear it's automatically in english

42:31 so let's first start with when we press off recons oh well now a label uses a caption but one thing i forgot to add was the label name you don't it's not necessary to add a label name but it is if it is a label then it is just good practice to make it like that right now labels work with captions if i am not mistaken yeah and as you see this one's caption is already perfect this one should be surname

43:19 and this one should be named alright so now when you're pressing afrikaans this should change to afrikaans when you present english this should be changed to english unless it already is which it will not matter then represent spanish it should change to spanish now let's start off with recalls again now lbl name dot caption becomes and enough cons the caption or name in afrikaans is norm there we go could i say something you want to do that okay so

44:04 yeah the lbl surname dot caption becomes fun and then lblh dot caption becomes odor dom if i'm not mistaken can you not now if you run it it should work and shouldn't have any problems so let's select afrikaans norm fun odor door

44:49 yeah i think that's that works now we should of course still do the english because if the changes are considered like i don't actually understand it because they do we should be able to you know they should be able to change it back so i'll be our name dot or we can just be lazy and do this do you give a name yeah it just doesn't look right surname the age [Music]

45:35 all right and then we just have spanish now i don't know any spanish so i'm going to go here and name nombre or i just copy that okay oh wait we want to do it faster let's let's do this let's do this nothing was i think yeah okay then surname

46:21 all right and let's see if all of the buttons work so it is josh smith and he is 19. now we can reset that yes change it to afrikaans english spanish it works perfectly right but you know i once heard from someone who programmed that a good programmer is someone who does that extra effort so we're going to go back to reset and we are going to just

47:06 do this because the main language everyone knows or most people knows is english so if they say clear shouldn't it change back to english for them because let's say they're they didn't actually know they just want to go back to where they were see let's say they did that and they don't know like what okay which one of these was the one i actually chose because people are terrible with actually reading in english you know so then you just go reset and there so today we're going to be working on your basic output now first off let's start completely

47:53 from beginning make a new v-cell forms application all right i just like that and then file save all then we can go frm out put underscore u we can copy that then you can go f4 and underscore output p okay here we go

48:40 so we're going to start with the basics now we're going to add a button this button is going to do a lot of things this one particular button then we're going to add a label we're going to add a memo [Music] and that should be all for now oh yeah and probably a good thing to add would be a panel as well all right okay now let's just name all of these things lvl out you just call them last

49:28 all right now with memo you will see that you don't want that you don't want that in here so what you do is you go to lines you click on these three and you just delete and then say okay and there we go then there's panel there we go pnl out and we just yeah we can we can keep it locked okay so then we're just going to name the button to btn display and then we're going to make the caption

50:16 display now when i click on this button each one of these will be changing into something so let's start now we can start with label now when they click on the label they're going to get a basic output so [Music] lbl out and then as we all whoopsie as we all know by now the label has a caption now if we were to say dot caption then we can change its caption now we shall be going

51:02 the answer to five times 5 is all right okay now we're going to make this the on 35 times 5 is and this is going to be the answer so then we can go now this is where you might we'll change it a little bit now here's the memo now as you can see we deleted the lines first line see we deleted this part right here we don't have a caption as you can see here there's no caption but we do have lines so we go mem out dot

51:47 lines dot add and then we go five times five would be 25 now there is a string output all right but what if we don't want a string output since we have a panel we can just as well put that to use and go pnl out dot caption because the panel has a caption becomes and we can go because we're going to times five for five so we're going to go into string five times five

52:32 now if we're going to be running it now if i say display the answer to 5 here is a string and here is an integer so those are the basic outputs you can get but then you also have a show message now a show message is a basically a pop-up box that tells you things now let's go on sir is [Music] and then we plus it with an enter to string

53:18 five times five now display then the answer is 25 but if we were to not add this and we're just going to say that we would get an error because you can't have in string and an integer it may must both that this can only take in a string so you have to convert it from a string from integer to a string which is into string the same here i would want to if i would want to put it here i'd have to say

54:04 empty string first otherwise it won't work another way if you don't want it to actually times you can always just do that but then you won't get the answer already put together so display the answer is five times five that's just the equation so this was basic output guys so today we're going to be talking about adding subtracting and stuff like that so uh yeah let's get started so first off if you watched my previous video you

54:49 would have seen quite a few outputs you can get so we're just going to use a show message to do everything so first off let's begin with plus so we're going to be adding stuff together with plus so it should be easy we don't have variables yet so we're not going to be using that just yet uh i first want to teach you guys how to make sums so let's start by just creating a show message show message okay and in here we're going to be doing everything so let's go in to

55:34 string and then in here will be passing and stuff so plus it's easy it is just something like five plus six and you should get 11 yes 11 all right that's easy enough remember that's this and this and this is not the same so this will just display five and six unlike javascript you can't plus them

56:21 together if they're strings same goes for if you're going to make this one string it's just going to be a string it's not going to be adding or subtracting anything so now we have done plus now let's do minus minus is pretty easy just as plus it can be int to str okay and then just like five minus five that should give you zero see zero very easy now this is where it gets a little teeny bit different times

57:08 now let's times five by five now you watch my previous video you know times is a whatever that is now yeah you could go that but that doesn't work because x is a letter we don't want letters we want that um this is pretty basic it's mostly the same in every language not all of them of course for example brain you can't do that so yeah that is times show message 25 now then you also get divide divide now

57:55 let's divide 25 by five that should give you five right but that's times so a divide is a slash that's all it is a forward slash and then you divide oh but wait into string can't be called with this argument it's probably because it's a divide now in a type of divide where you would use it in a into string place like this you would use a div

58:41 and voila now dev is something a little bit different so we're going to be working with the div a little bit later but if you would want to have used it as slash the actual way people use it it's going to give you an error but that is because with a slash you get returned in real now in real is something that is like a number dot or comma and not more numbers now also another word for real could be float or even double if you work with java now to get a float you just go float

59:26 to string now this will change it from a double or a real or whatever you want to call it two string so remember a float is something like five point six seven that's a float just five is an integer five point anything like even five point zero that's not an integer that's a float so now if you go like that and you go like that you get five yeah so that is based the basics of dividing times plus and minus we'll be using this a lot more in the future

1:00:14 so today we're going to be practicing the basic input i was going to do variables but then i said or then i saw that the book was doing it in chapter 2 which i feel isn't really a good way of doing it but we're following the books we'll be doing it in chapter 2. so what we have here is three labels two just normal labels with captions of first name and certainly they have no actual name as you can see then an output which is lbl output which is also a label then two edits which is edt name and edt surname with one button called btn display so what's going to happen is we are going to

1:01:00 put in enter our name here insert our surname here and when we click on this button this should be the name and surname that we inserted basically being hello both the name and in the surname because we want to greet them so let's open up our button and let's start so we don't have variables it is going to be a little more effort than it has to be but when they click on the button lbl or it's actually a little bit less you think about it but anyways lb output dot caption becomes now

1:01:45 or let's first make it hello and then just remember the space needs to be here because we want the space between the hello and the name plus and this is where we get our first input so it was edit name as you would see as you remember this is called edt name so oh my gosh so we're going to go edt name but wait let's just first keep like that now if we run it you see we get an error because edt name is not a string

1:02:31 it is an object because this these are objects so we need to get the text inside of these objects because they return text so it's edt name dot text once you learn some javascript this will look really easy but it should look easy for it right now so you get the object and then you turn the text inside of the object so let's run it now now if you just insert some random things hello and in the name see it works perfectly now let's get the output of the surname so we're going to create a space there's a space between the name

1:03:16 and the surname and then go edt surname dot text now when we run it i will put in let's just go neon strike so hello neon strike this isn't completely central but i will be okay now as you can see that is the basic output that you get or input educate excuse me

1:04:06 okay so today we'll be looking at the calendar now let's just create a new v sales forms application let me resize this a little bit now what we'll need is one calendar to get it confused with one calendar get one calendar and then one edit and one button so let's get that all right so here we have a calendar a button animated now what we want to do is we want to put a date in this button then when they are in this edit

1:04:53 then when you click on this button wait you guys know what remove this edit we want a spin edit so here we have a spin at it because this will make the whole process of making sure it's only integers and stuff like that a lot easier um of course it's still easy if you even if you don't use them specifically but anyways so let's just do this so then let's rename the button to set date and then we give it a name of

1:05:39 btn set date there's no real specific name for calendars as far as i know so i'm just going to go calendar because there's no reason to not have a calendar so first thing we're going to do so we're going to limit this to only two numbers so you can go here to maximum value and minimum value and you can also change that if you want and max length so when you go to it will stay too so we're going to code this in where we don't want to do that

1:06:26 so first we go to events whoopsie first we get to events and then we go to on activate okay wait okay set date dot max length and then we're going to make it two because we don't want 10 to put in something like 100 you know 99 is a for the max then we're going to go sedate dot nope sedate dot max value

1:07:12 and we're going to put that at 31 and then yet again set date dot minimum value and we're going to make it one because we didn't want them to put in zero because there is no dates such as zero okay so then we can just save all so now we have set a minimum value a maximum value and a max length easy as power right so now we can here go to set date we're gonna write it up so now we go to

1:07:58 we should click on this and we should put the value up to one here as you can see your value we can make it one we can hard code that in if you want but we don't want to do that right now okay so then we go to calendar dot day becomes and then edt i mean scd date dot value these are both integers they taken so if we're going we're going to run this then we should get a right output so

1:08:43 let's make this the fifth you can see it went to five i can all just click there and do if you want but this is best to do so then we can go 15 sedate 15. all right but now we want to be changing the month and the year so let's go to the design but we don't want to get confused so we're going to be going here and saying label

1:09:41 month we can just change the name to a cd month ac acd here now it is actually a good practice to put them all in a way that you can read it so acd day now we should just go back to the code and edit it so now let's do the month now what we can do is we can do this we can do exactly this but do the month but we won't be doing that since we want

1:10:27 to try out more things so let to set the max length to 2 the maximum value to 12 and the minimum value to 1 because you can't have a month less than zero and then we're going to change the value to one see easy enough then we go to here we're going to give it a maximum minimum as well so max length is four because it shouldn't have more than four max value should be let's say 2050

1:11:15 so they shouldn't be able to go past that minimum value should be 1990. and then the value we can make that 2 000 but actually it's 1990 should be a good place certain is the minimum and you can just take it up if you had a drop down list it should have been a little bit better but we don't have that right now so then we can just code it and let's see that all of the restrictions work so here can we have more than two no we can't more than two no more than four no

1:12:00 okay and if i'm correct you should be able to go up to 13 yeah you can go up to the first thing you can even go up to 14 but as soon as you press any of these it won't accept it as well if you click away so you can put something higher but it will restrict you to those specific times so 32 isn't an option and 3000 is an option either okay so that's good to note right so then we can close that and now we can set date this should be easy we can actually just copy this and stuff yeah so let's copy this it should be of quite fast control c

1:12:45 b now calendar isn't canon day anymore it's calendar calendar month because we want to change the margin acd month the value then here is a cd year value and calendar.here pretty easy compared to most languages we can run it should be no errors and then we can change it to however we want so we make it day five of month free in the year 2000 sit date and there

1:13:31 we can always make it month eight sedate there you go now we can't see the month but there are ones where we can't see the month and you can put them on yourself if you go here to search for cat lender then you get money which does give you a few extra details but it's small and you can't really resize it you know so it's not really the best option to have that's why i told you guys to get the normal calendars and you can resize it even if you can't see the specific page right now

1:14:16 and hello everybody welcome back to a new video okay so today we're going to make a traffic light with delphi so we're going to be basically be changing up a bunch of properties of all of these things when um web code so yeah let's get right into it so let's create a nice gui for it because here in the book they give us a few they give us what we should do so we're going to be seeing what we should do and then we will be continuing so let's see the buttons height should be 100 that's mostly what i wanted okay so let's get the height the rest we will do

1:15:02 ourselves because i know how to do that so let me explain to you after i've changed the height okay now these we want to be as we want to have as circles because the traffic lights use circles and not squares or at least here they use circles so let's first change these to circles circle circle and circle so here we are completely leaving the book uh we'll just be completing command like um make sure the circles turns on and stuff

1:15:48 so first off we want to change this background of the form we want to make it black because you know they are black there so then we can just make the color black we can actually do that while in the code but let's try it or not because now if we're going to run it nothing special is going to happen but it will look more like in traffic light there we go so you can actually make it like the green goes on then yellow then red and you don't have to express the buttons but we're going to press a button then this light will come on and stuff like that so let's give them all names this will

1:16:35 be shp red for shape red then we have the buttons so first let's change their names before we change anything else so this one going to be btn red so now we can change their caption button that and there the design is actually ready somewhat so we want to see these we don't want to make them black just yet we want to still be able to see them in the design so we're going to click on

1:17:21 the form and go to events and then on activate we're going to change the color of the shapes so when the form activates we want btn green to be the color that we'll be showing so uh let's change everything inside the code here so then go shp green access okay cool shp green dot

1:18:08 wait let me quickly see so it's shp green f12 and click here what's the color change dot brush okay so this is a nice way for if you can't remember you can go look here you can click on it look at an object experience research dot brush and then dot color this is very useful thing to remember so i suggest you do remember it so it's dot dot brush dot color becomes cl green now that should be correct let's see if it works because if it does work wait let's first save the game because if we save the game we know we won't lose anything so let's go first save save all

1:18:57 all right so now that we saved everything let's run it and see if it's green then we're doing everything correctly it's green we're doing it right so now we can make the wrist black because we don't want them to be seen so what we can do is you can type all of this over but that's going to be everything let's be lazy and copy it so there we go shp yellow and then red then go with both of them we can go cl black and then here as well we can go cl black now they shouldn't be seeable from when we run it perfect so now you can only see this but clicking on buttons doesn't do anything

1:19:43 just yet which is not good because we want to them to work correctly so these are pretty simple stuff but i'm still going to do it with you guys just so you guys can see so let's take that away now first we're going to do green but green is actually already on so we want to see if we could actually work so we're going to go red first now i'm just going to copy this and paste it there now what we can do is we can't really type it or maybe put in specific parameters but that's a lot of effort and you don't really need to do it so we can just go cl

1:20:28 black and then here read we can goes cl red that saves us a lot of time and a lot of unnecessary coding so now if you press on red it works almost perfectly so let's just quickly fix the design here because that's really annoying looking at that the whole time there we go ah that's gonna look so much better you can put us more into the middle of everything instead of at the top you know and then we can bring then we can bring this up closer and there we go we have a beautiful traffic light but we are not done yet so we're

1:21:13 going to go here we're going to paste it again and we can even this is not good practice you first finish the code you're actually working with so don't follow this one but they make an open green as well first finish your code because otherwise you're going to get confused and it's not going to be nice damn it look at this copy this let's paste it here so this one is already actually done so we don't have to worry about this one and this one on the other hand is not done so we can just go cl black and then we can go here cl yellow now as far as i know this should do everything that is required so you have green if you click on it nothing happens yellow red yellow green

1:22:01 as you can see they all work perfectly now and that wasn't too hard now was it it's very basic code if you can understand this then i can guarantee you you'll understand what's coming on in the next video so we're finally starting with variables you guys don't understand how excited i am about this oh so then let's click on calculate to open a on click ok can you open an on click function please there all right so there are three types now the first two you don't have to really do work with just yet these are mostly

1:22:48 you know for you to later on okay so first you get private declarations now i'm not going to go through the nitty gritty things i'm just going to tell you guys for now and what these are what this one is mostly used for and but i'm not going to go into the very deep details and tell guys what specifically you'd use it for that we can do later on once we get to the bigger projects so first off you get private now to declare a variable um you get the different types of variable you get a string which is a word wait let's let's put this in a there so first you get a string which becomes a word

1:23:34 for example my name that's this is a string um hello that's a string a string can also be something like a sentence for example how are you this is a string they get a character or a char this is literally just take a character for example a or b or c you know there there's not really anything too special you know so these are the main types of things you'd work with when you talk about strings so not really that much but you do get

1:24:20 like once in a while you'll find that now note these are very important almost all programming languages you'd have this you'd have something that is a variable so keep this in mind you got to get this one underhand so then there's also an integer now integer is basically a number for example five or nine or even seven thousand all right but do not confuse it with this this is a string because it is in these quotes this is a number because it does not have quotes so

1:25:05 keep that in mind because selfie will see this is a string then you get a real or a double now in java you'd usually use a double but in delphi you have the option to use a real now these are basically also numbers but these numbers can be something like 5.79 or 9.0 or even 8765 point this is a real or a double but if you were to put something like this here it will give you an error because an integer is only whole numbers

1:25:52 while a double can beats things like this let's first do this so to declare variable you go underneath procedure or pro here private but we'll get to that later there's going to be in public but that's also for later time pretty fair to say you're going to start declaring variables here now let's go s word yeah it's word and then you go this this basically says becomes or is you know and you go string but since delphi isn't really capital sensitive you can do that or that it doesn't really matter because if

1:26:38 they press ctrl d it's not going to give you any problems okay so now let's just fix that because that's annoying okay so then we can go like this now how to declare a variable you can go like s word becomes and then in these quotation mark things you can go and make maybe hello now the reason why we say s word with the s and not just word is because when we work with this this basically tells us this is going to be a string because later on you will be doing things like is word

1:27:24 plus into a string i numb i'm yeah plus is word to maybe and things like that and let's just go like this remove that that and that now yes you can still read it but later on it's nothing it's not going to always take words it will change to things like name or even id number id num now id number can be a string guys just like phone number it's it's you can make it a string it's not impossible so it's usually good practice to do that you don't have to but it's good practice

1:28:10 now let's go and declare another string to do that you go copy i mean comma and it's word to now you can also do this is word free sorry about that f3 and go string and do it all one by one but delphi made it easy for you just made you have you set a comma now we can go yes word to becomes world world so now we can do this because we have an

1:28:57 edit sorry about that we have an edit here this is edited edit out now once we when you say calculate we're going to like display hello and world as one word so then we go edt out dot text becomes an s word plus and then a space in between plus s word two right now you might not see the point of all of this but once we get deeper into this guy you're really going to love it i'm telling you this is the variables makes everything easier there is a calculate hello world that's very nice right guys so basically this just says

1:29:42 um hello and then plus a space plus world that's all that basically says remember you can also put sentences in here so you could have gone like a sentence and say hello world and it's one sentence so yeah now let's remove that because it said calculate now we're going to declare an integer so now we're going to go i num 1 comma i num 2 and we're going to make that integer now let's also go b flag and go boolean

1:30:31 sorry about that boolean okay so now we have a boolean as well so now we make b flag equal to or it becomes excuse me false for now it's good to see what it should be at the beginning because you know so because sometimes it might be true or false randomly i don't know i might just do that at the beginning so in goo i num1 becomes five item two becomes and then let's also teach you something else let's add math here math

1:31:17 now math is something that you use to do math with now in javascript you'd go math.round and then insert whatever you want to round but in here you put math right on the top there and then you go round so it's kind of like math around and then you go like let's say 5.89 now round will round this up or down to the nearest integer for let's say if it's 5.8 it will go to 6. if it's 5.4 it will go to 4 or it will go to 5 excuse me not four so yeah and if it's five point five it will go to six as well there's already half

1:32:03 way you know so now we go if i num 2 is equal to it's going to be 6 then begin and then we go b flag b flag becomes true now this is a basic example we'll get to more of this later and then we can go if b flag equals yeah if b flat if it's if you want it to be true you can just go if b flag but if you want it to be false you have to say

1:32:49 false so if it's false but if it's true you can actually just go b flag or you can go b flat equals true you can go begin just make this a little bit nicer then you can go in one plus i num too boy there you go edt out dot text becomes now note guys an edit cannot take in an integer it is a string holder especially if it's the text then you have to go int to string

1:33:35 i just have to convert these two into strings now the reason why i put all of them in one entry string is because if you didn't do that it will basically say five plus six and then you'll just get 56 but if they're still numbers then you go basically five plus six which will equal to 11. so that is why you put all both of them in change string not into string this one plus into string item two okay good and then you say else so

1:34:21 so if b flag is true it will display that else out dot text becomes error so let's see if it works calculate and we get 11. this is because b flag is true so let's just tidy this up a bit very okay so if we were to say if i num equals 5 then b-flat equals true so b-flat will now become false and it will give us an error

1:35:07 so let's run again calculate see error so this is just the basics of variables we'll definitely get deeper into this as we go on because these are very important you're going to use them a lot later on so yeah now if you declare something here now let me show you something if we're going to let's open it and on forum create so if i'm going to try and use let's say i numb to here then it's not going to give me anything so for example let's show message

1:35:54 i numb into string i num 2. let's run this but oh we are getting an error now why is that this is because i numb is basically invisible to everything around it except for this procedure here because it only lasts for from begin to end now this is also very important because this also works a lot in other programming languages this includes javascript java um python almost it i think python i'm not sure it probably does yeah but these are very important to know so this is why you have a private section

1:36:42 right there so let's remove inum 2 and declare it here i num 2 integer now we have an eye now so let's declare inaudible becomes what was item 2 let's just copy this and then paste it here b now when we run it we get a six and then we can press calculate and we

1:37:27 get an error because remember b flag is false but if we were to make this one invisible and go here to variable i'm i num 2 integer we'd still have a bunch of errors because we didn't know what this is so that is why you have a private declaration place now the public one you will almost never use until you start doing projects so yeah we'll get to this one later you don't have to worry yourself about this one just yet because we're we didn't really we don't really work with those things just yet this either

1:38:13 so yeah that's all there is for the variables for today guys if statement in most programming languages is basically exactly the same thing so what we're going to do is we're just going to take in basic example now what an if statement does is if something is like something do this that's basically what you tell this team let's create another variable called b flag we'll get more into b flat later boolean now recap boolean is true slash false

1:38:59 now if you have an if statement it returns true yeah if the statement is true then it will do this if it is not true it will not do this all right but if the statement is false so if it is false then do this but we'll get more into how to make something if it's fox happen so for now let's do this let's say b flag becomes if 5 is bigger than 8 that's false because 5 is smaller than eight remember bigger ass sign the this is a mouth remember if you don't know

1:39:44 what a bigger sign is the big sign is basically a mouth it eats the biggest one so if it doesn't show to the biggest version it means that 5 is bigger as which is not so it will be false so this is false now this is an example now we can go b flag now if it is b flag show message hello well we let's make it actually true okay so we make it true because eight is bigger than 5 so you make it true now if you run this

1:40:31 and we click on this button we get hello now let's make this false again false now we're going to run this let's also get the code in here like i said okay can't move it all right so now we have b flat now when i click this button it's going to check if b flag is true now i should have actually started with something else but okay let's first go to this now if i'm going to click it it's not going to do anything because b flag is false good practice would be to just go b flag equals true so if b

1:41:17 true so if b flat is true then begin now this is a way to kind of validate if it's true or false so you can also go if b flag is false which it is right now because an if statement returns a boolean if the if statement returns true now let's just go if b flag or b tag is true all right so if b flag equals true then it should run this code all right

1:42:02 now we have b flag as true now you should be getting to this around right now v lag b flag equals false or true so if b flag is true do this else remember remember to always use begin in because otherwise that will later on get evers and stuff like that we could later go to how not to add begin and end but i highly highly recommend that you do now now we have a b flag that if it's true it should run this piece of code

1:42:49 else otherwise if it is not true it should say show message oopsie bye so if show message hello i mean excuse me if b flag is true which it is then run this piece of code run that but do not run this thing because it there it does doesn't have to be an hours then but if b flag is false so then it will not run this piece of sorry they will not run this piece of code because then it's false it doesn't go down they will go to else i'm like okay they got something else since your

…

Share

YouTube Video Summaries