about Templot Club cookie information pre-print options:    

Templot club top logo looking for Templot? - (free)



 you are not logged in  - Login | Join


receive all messages by email: info


Recent Topics
  to bottom of page     Search  Image Gallery  Gallery Upload  My Account  Members  Help  
make a donation  
please click: important information for new members and first-time visitors Templot Companion - User Guide:  Beginner's Guide | Contents | A-Z Index
            messages archive on Yahoo
page trail:  Templot Club > Forums > Off track > Coding for beginners
main Templot web site

                                       Coding for beginners
     
 Start new topic   Reply blank   Printer friendly 
  Rate this topic  
AuthorMessage
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
1st message | this message only posted: 25 Dec 2016 13:28
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
As I've mentioned in the past, Templot is written in Delphi, which is a visual version of Pascal.

Nowadays it is expensive to buy Delphi -- gone are days of free cut-down versions on computer magazine cover disks.

But Lazarus is an open-source clone of Delphi, works well, and is entirely free:

 http://www.lazarus-ide.org

If anyone is looking to try program coding, Lazarus is an excellent choice and easy to use.

There is a free time-limited trial of Delphi, but it requires registration and you will get lots of nag screens to buy the full version.

Martin.

__________
message ref: 20976

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
2nd message | this message only posted: 26 Dec 2016 08:14
 PM  Reply with quote  Reply blank 
from:
Jim Guthrie
United Kingdom

 

view images in gallery
view images as slides
Well worth a look for anyone interested in programming, especially since it's free. :)

I used Delphi to write software to run the core of my business and it was so much easier to use than the competition - C++ at the time - and so much faster to compile. I could do almost interactive coding by writing a few lines, then compile and debug to see if they worked. With other compilers you could have a cup of tea while waiting for the compiled output. :)

Jim.
__________
message ref: 20981

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
3rd message | this message only posted: 13 May 2017 23:06
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
I've just had a look at sample code for it and it seems very similar in idea to MS VBA and the old Commodore basic that I used in nineteen hundred and dark.

Presumably this is far, far harder to 'get into' though, is it?
__________
message ref: 21506

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
4th message | this message only posted: 13 May 2017 23:24
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
DerekStuart wrote: I've just had a look at sample code for it and it seems very similar in idea to MS VBA and the old Commodore basic that I used in nineteen hundred and dark.

Presumably this is far, far harder to 'get into' though, is it?
Hi Derek,

Which software are you referring to? I suggest you start with Lazarus, which is a clone of Delphi, works well, and is entirely free:

 http://www.lazarus-ide.org

How hard it is to "get into" depends on what you want to do. It is very quick and easy to write simple programs to do calculations, print lists of numbers, draw coloured diagrams on the screen, and so forth.

If you want to develop a replacement operating system for the NHS, it might take a bit longer. :)

If you say something simple I will post some sample code showing how you might get started, and you could have a go at changing it or expanding it.

regards,

Martin.

__________
message ref: 21507

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
5th message | this message only posted: 14 May 2017 14:24
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
Hi Derek,

If you are starting Lazarus for the first time, you might find the screen confusing, even though it is really very simple, at least for Windows:

1. go to http://www.lazarus-ide.org

2. click the Download Now button.

After a few seconds you will be downloading the file: lazarus-1.6.4-fpc-3.0.2-win64.exe

That's all you need, don't click any of the other stuff on the Sourceforge pages which might flash up.

Download that file and run it to install the Lazarus program in the usual way. Being free, they aren't paying fees for a digital certificate, so you will need to click past the security warnings (same as for Templot).

During the install process you will probably find it convenient to tick the "create desktop icon" box.

When installation finishes, start Lazarus by clicking that desktop icon.

You will then probably see this:



Which strikes me as not at all helpful for a beginner. Don't change anything on there, just click the Start IDE button.

You won't see this again next time you start Lazarus.

If you have got that far and wondering what to do next, I can suggest some basic stuff to create and run a simple test program.

p.s. "IDE" means "Integated Development Environment" which is just a fancy name for the normal Lazarus desktop screen -- see:

 https://en.wikipedia.org/wiki/Integrated_development_environment

regards,

Martin.

__________
message ref: 21508

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
6th message | this message only posted: 20 May 2017 11:08
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Hello Martin
Many thanks for the info. Much appreciated.

"If you say something simple I will post some sample code showing how you might get started, and you could have a go at changing it or expanding it."

From the examples I've looked at, it seems fairly intuitive. Using Templot's purpose as an example: It seems a programme to allow the plotting of 2 curves of X dia. Y length and intersecting at Z would be fairly straight forward (from what I've seen). But the one bit I was never any good at was GUIs- ie, click on the curve and move it to "over there", but that would be well beyond what I could expect anyone to explain on a discussion forum.

I will let you know how I get on. Thanks.
__________
message ref: 21529

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
7th message | this message only posted: 20 May 2017 14:36
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
DerekStuart wrote: But the one bit I was never any good at was GUIs- ie, click on the curve and move it to "over there", but that would be well beyond what I could expect anyone to explain on a discussion forum.Hi Derek,

I will see what I can do. :)

regards,

Martin.

__________
message ref: 21530

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
8th message | this message only posted: 20 May 2017 22:35
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
So let's try something.

The first thing to do is create a folder in a known place to contain your files. There will be quite a few of them. I much prefer to do this rather than rely on the default Windows behaviour of using virtual folders from which it is always a pain to find what you are looking for. You will need to access the folder directly, because in there will be the final executable program file.

I created a folder called C:\DEREK_TRIAL\ for this example program.

This is what you will see when you run Lazarus:



Lazarus (and Delphi) scatter themselves across the screen in 5 basic windows. Each one can be moved around and re-sized in the usual way, to suit yourself.

1. is the main command window. Closing this closes Lazarus. Minimizing this minimizes everything.

2. is the window representing the program which you are creating. This is where you drag and drop the buttons and boxes which make up your program. The dots are a grid to which they can be aligned for a neater result. The dots don't show when the program runs. Program windows are called Forms.

3. is the editor window. This where you write the code which makes things happen when the buttons and boxes are clicked. Each form has its own corresponding chunk of code, called a Unit. Each unit appears in a separate tab in the editor window. Small programs often have only one form and one corresponding unit. The editor and form windows can be toggled to and fro in front of each other by pressing F12 on the keyboard -- which is handy if you are working with large forms on a small screen.

4. is called the Object Inspector window. This is where you make the settings for each Object in the program by entering them in the right-hand column. For example if you add a button to a form, this is where you set the text which appears on the button. Almost everything in Lazarus is an object, so this Object Inspector window is used a lot. It is typically arranged as a tall column window. Most programmers seem to like it on the left of the screen, but I prefer it on the right.

5. is the message window. This is where Lazarus reports what's happening -- hopefully on a green background to indicate a successful operation. You can close this window when not needed and it will re-appear when there is something to report.

Other smaller dialog windows appear in the usual way as needed.

The Object Inspector is currently showing the settings for the form object. Lazarus makes some default settings when an object is created. Most of them can be left on the defaults, but you will always need to change a few of them. As you can see I have made some initial changes:

Every object in Lazarus must have a name, so that it can be referred to in the code. For this form you can see that I have given it the name derek_form. Spaces are not allowed in names. It could be called anything (beans_on_toast ?) but it is handy to use a sensible name and include a reference to the type of object. Otherwise when you come to read the code again in a few years time (or in my case 5 minutes later) it will be meaningless.

Lazarus is case-insensitive, so derek, DEREK, Derek, DERek, dEreK, all mean exactly the same thing and refer to the same object. Lazarus itself uses camel-case, so that objects and functions have names such as ToggleBox or SaveToFile.

You can do the same if you wish for names, but I prefer to use all lower case separated by underscores: toggle_box, save_to_file. This has the useful result when reading code that I can see immediately which names were created by me, and which were created by Lazarus. So this form is called derek_form.

Next we need to set the text which appears in the title bar at the top of the form. This text is called an object's Caption. Generally the text which appears on the screen on a button, next to tickbox, etc., is called its caption. As you can see I have set this to "Trial Program For Derek". As it is typed in the Object Inspector it appears on the form.

I then saved the project so far, such as it is, by clicking File > Save As... on the top window.

This is a bit tedious, but gives you a chance to set up the file names for this project. You need only do this once. There are several files to be saved in our new folder, each one will appear in turn in the Save dialog:

The project file has the extension .lpr and contains the code for the main executable startup program. I called it derek_project.lpr       

The same name will be used for several other files, such as the final executable program, derek_project.exe

Then the file containing the unit must be named and saved. The file has the extension .pas and contains the code text from the editor window. I called it derek_main_unit.pas and you can see that Lazarus updated the unit name on the first line in the editor accordingly.

Lazarus will then automatically create the linked file derek_main_unit.lfm which contains details of the corresponding form window, such as the size and position of each button.

Having done all that the project can be opened and saved in future simply by opening the project file.

So we are now ready next time to make the program actually do something. :) 
 
regards,

Martin.

__________
message ref: 21532

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
9th message | this message only posted: 30 May 2017 22:44
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Hello Martin
Thanks for the further info. I must admit that at first I came close to testing the flight characteristics of HP laptops.

But I have downloaded it to the work desktop- faster and with a bigger screen- I have been able to "play" with the interface and get to understand it a bit. I have found example codes on the internet and will try to reverse engineer little bits of it and see what it does.

Thanks for the encouragement. I shall let you know how I get on, but don't expect miracles as it's taken 3 years to be able to solder track properly.
__________
message ref: 21562

 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
10th message | this message only posted: 31 May 2017 13:20
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
DerekStuart wrote: I must admit that at first I came close to testing the flight characteristics of HP laptops.Hi Derek,

Yes, I've been there many times. I suspect many Templot users too. :)

Sorry about the delay in getting back to you. I have created a small program which you might like to try making and modifying. You specifically asked about drawing on the screen.

The executable is attached below.

It is unsigned, so you will need to click through the security warnings.

I will post the code later. Unlike web examples, you can ask me what each bit means. :)

regards,

Martin.

__________
message ref: 21564
Attachment: derek_project.exe (Downloaded 18 times)
 
 Clicked a link? Wrong message? Wait until the page has finished loading, click in the address bar and then press the Enter key. This is a timing bug in some browsers.
11th message | this message only posted: 31 May 2017 13:59
 PM  Reply with quote  Reply blank 
from:
Martin Wynne
West Of The Severn, United Kingdom



view images in gallery
view images as slides

Please do not send requests for help direct to me via email or PM.

Post your questions on the forum where everyone can see them and add helpful replies.
Hi Derek,

You need to put 4 objects on the form:



1. From the Standard tab, select a TButton (they describe themselves if hovered over), click and drag a rectangle for it on the form.

On the Object Inspector window , give it the Name colour_button, and the Caption choose background colour.

2. Add another one on the form. Give it the Name go_button, and the Caption GO.


Those are the visible controls. Now you need two "designers". These objects appear on the form at design time, but not when the program runs.

3. From the Dialogs tab, select a TColorDialog, add it on the form.

On the Object Inspector, give it the Name derek_colour_dialog.


4. From the System tab, select a TTimer, add it on the form.

On the Object Inspector, give it the Name derek_timer, set Enabled to False, and set the Interval to 20 (milliseconds).


Here is a zip file containing all that and the code. Extract it to a folder somewhere.

Code to follow.

regards,

Martin.
__________
message ref: 21565
Attachment: derek_lazarus_zip.zip (Downloaded 17 times)
 
This is topic ID = 2956     Page created at 18:31 (local time)  
You can type a quick reply to this topic here.

Click in the box to begin.


But to reply to an individual message, or to include images, attachments and formatted text, use the reply buttons on each message above.

To start a new topic in this forum, click the Start new topic button below.
To start a new topic in a different forum, click the Forum Jump drop-down list below.

             Start new topic 

 click to jump to a different forum:     Back to top of page

Templot Club > Forums > Off track > Coding for beginners
about Templot Club

list recently active topics Templot Companion - User Guide - A-Z Index Old Templot Companion Please click: important information for new members and first-time visitors.
indexing link for search engines only

back to top of page


Please read this important note about copyright: Unless stated otherwise, all the files submitted to this web site are copyright and the property of the respective contributor. You are welcome to use them for your own personal non-commercial purposes, and in your messages on this web site. If you want to publish any of this material elsewhere or use it commercially, you must first obtain the owner's permission to do so.

The small print: All material submitted to this web site is the responsibility of the respective contributor. By submitting material to this web site you acknowledge that you accept full responsibility for the material submitted. The owner of this web site is not responsible for any content displayed here other than his own contributions. The owner of this web site may edit, modify or remove any content at any time without giving notice or reason.
Problems with this web site? Contact webmaster@templot.com.   This web site uses cookies: click for information.  
© 2017  

Powered by UltraBB - © 2009 Data 1 Systems