click here for a list of all existing Templot documentation
Important Privacy Information cookie information pre-print options:    

click image to open Templot Club in a new tab
Templot club top logo
looking for Templot? - (free)



 you are not logged in  - Login | Join


receive all messages by email: info


Recent Topics
Front Page  Search  Image Gallery  Gallery Upload  My Account  Members  Open Source  TemplotMEC  Help  
make a donation  
please click: important information for new members and first-time visitors Templot Companion - User Guide
            messages archive on Yahoo
page trail:  Templot Club > Forums > TemplotMEC nuts and bolts > Getting started with TemplotMEC - coding for beginners
Templot web site

                                       Getting started with TemplotMEC - 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: 9 Jun 2018 19:42
 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.
This topic assumes you are using Windows.



Now that I have posted the open-source code for Templot, you might want to join in the developments. Or use Templot as a basis to learn some coding. If there is something in Templot which you have always wanted to change, now is your chance. :)

There is the OpenTemplot Project which might one day replace Templot2, see:

 https://sourceforge.net/projects/opentemplot/

Or alternatively you might like to try the TemplotMEC option so that you can dabble in coding on your own personal version of Templot.
 
If so, the first thing to do is to download and extract the open-source TemplotMEC files, see:

 http://85a.co.uk/forum/view_topic.php?id=3292&forum_id=26

They are in plain text, so you could open and read them in Windows Notepad (other text editors are available).

But to make any use of them you need a compiler. A compiler is a program which reads the statements which are written in the source code files, and converts them into a runnable computer program, called the object code.

The files are intended to be used with the Lazarus/FreePascal compiler system, which is free.

To download and install Lazarus:

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.8.4-fpc-3.0.4-win64.exe

That's all you need, don't click any of the other advertising 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 (it may take a while), start Lazarus by clicking that desktop icon.

3. you will then probably see this:



Don't change anything on there, just click the Start IDE button. "IDE" means "Integated Development Environment" which is just a fancy name for the normal Lazarus desktop screen.

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

4. click the File > Open... menu item, and navigate to the previously downloaded TemplotMEC files. Select and open the

  templotmec.lpi

file.

5. answer Yes or Open Project to any questions which come up.

6. you are likely to see a Missing Packages message like this:



7. click OK for now. But this will need to be fixed before the program can be compiled. See later.

8. You should then be seeing something like this (the windows may be arranged differently):



9. if the Project Inspector window is showing (not the Object Inspector), you can close it.

10. if the Source Editor window is missing or empty, click the Project > Units ... menu item, and select control_room.pas from the list.

More shortly.

Martin.

__________
message ref: 24920

 
 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: 10 Jun 2018 03:26
 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.
Lazarus scatters itself 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 part of the program which you are working on. 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. The data for a form is saved in a .lfm file.

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 is saved in a separate .pas file with the same name as the corresponding form file.

Each unit appears in a separate tab in the editor window. The current tab being edited is highlighted. An asterisk against the file name in the tab indicates that the contents have been changed and will need saving.

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.

The font used in the editor needs to be a fixed-width font if you value your sanity, so that the text appears in fixed columns. By default the font used is Courier New, but I find the Consolas font is easier on my eyes.

The editor changes the colours of the text according to its meaning to the compiler. This is called "syntax highlighting". This is very useful to avoid typing errors. The colours and formatting can be changed to whatever you find comfortable.

Chunks of text can be hidden from view by clicking the small + and - boxes on the left. This is called "folding" the text. It is very useful to reduce scrolling when working on a long unit.

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 Messages 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.

In the screenshot above I am editing the control_room unit. Users who were in at the first release of Templot in 1999 will recognise these names. This window is now called the program panel, but it was then called the "control room". I changed it on the visible window to avoid confusion with the control template, but the original names in the code haven't changed.

Likewise the storage box is in the keep_select unit. Stored templates were then called "keeps". I was persuaded to change the name by Brian Lewis (then of C&L), but I often regret it. You will find the term "keep" for a stored template is still used throughout the code.

The Object Inspector above is currently showing the settings for the recent files button object. You can see that I have clicked on it, and it has gained some corner handles which could be used to drag it around and resize it.

The form is shown at design-time with all objects visible. When the program is run they are not necessarily all visible at the same time. On this window the blue bar behind the buttons is not visible at the same time as the row of buttons.

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 settings:

Every object in Lazarus must have a name, so that it can be referred to in the code. For this button you can see that I have given it the name recent_button. 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 recent_button, RECENT_BUTTON, Recent_Button, reCenT_buTton, 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.

Next we need to set the text which appears on the button. 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 "&recent  files". I often use a double space for easier reading. The &ampersand causes the next letter to appear underlined on the button as a keyboard accelerator key.

You can see some of the other settings, all of which can be changed. The Height of the button is set to 29 pixels. Left means the left edge of the button is 91 pixels from the left edge of the form.

6. Before the TemplotMEC code can be compiled it is necessary to install the HtmlView package in Lazarus. This is used to display HTML text for the help notes. More about that next time.

Martin.

__________
message ref: 24923

 
 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: 10 Jun 2018 19:14
 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 mentioned, Lazarus won't be able to compile the TemplotMEC source files until you have installed an add-on component, called a "package".

It is the HtmlViewer component (a mini-browser) which is used in TemplotMEC to display the Help notes.

If you begin writing other programs it is a very useful component to have available in Lazarus.

Installing packages is not for the faint-hearted, so I have prepared a step-by-step sequence.

The easy way is to use the Online Package Manager. Unfortunately even that isn't installed from scratch, so the first task is to install it.



1. click the Package > Install/Uninstall Packages... menu item:



2. this dialog will appear. Scroll down the right-hand list and select onlinepackagemanager. Then click the Install selection button:



3. then click the Save and rebuild IDE button:



4. click Continue to confirm:



5. the process will take a while, after which Lazarus will restart, and you will see this message again. Click OK:



6. but now there is a new item on the Package menu. Click the Online Package Manager menu item:



7. an internet connection is needed to search for online packages.

After a while this dialog will appear. Scroll down the list and tick the box next to HtmlViewer, then click the Install button:



Note in passing some of the other useful packages that you might one day want to install. :)  There are 140 of them listed at present.

8. click Yes to confirm:



9. the process will take a while, after which Lazarus will restart again. But this time you shouldn't see any error message, and if you look in the component bar you will see that the HtmlViewer is now installed:




10. which means you are now ready to try compiling the TemplotMEC program. More next time.

cheers,

Martin.

__________
message ref: 24933

 
 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: 10 Jun 2018 20:49
 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 you are now finally ready to try compiling TemplotMEC. :)

1. as this is a first try, it's best to do a full build to check for errors before running. Click the Run > Build menu item:




2. it will take a while -- the Messages window will appear and fill with messages.

There will be several Warning messages, but hopefully no red Error messages. The warnings will need to be fixed in due course, especially if you want to port TemplotMEC to some other platform such as Linux or Mac. But for now they are not serious on Windows and can be ignored.

The word which you are looking for is "Success" on a green background. :)

It should appear eventually:




3. assuming you get a green, it's finally time to try running it. Click the Run > Run menu item:




4. it will again take a while, and the Messages window will appear again. But eventually you should see the familiar Templot start-up:




5. and if you click GO, you should have TemplotMEC running. :)

Note (debugging...) shown in the Lazarus top bar. This means that TemplotMEC is currently running inside Lazarus, and you should get meaningful error messages if there are any. But TemplotMEC will be fully functional and usable in that condition.

N.B. note that you won't be able to load any of your existing Templot2 .box files. But you should be able to create TemplotMEC track plans, save them, and reload them, in .otbox format. And print them.

Likewise your existing .bgs files, and printer calibration files.

The file conversion functions will be available in the next Templot2 program update shortly.

More about all that next time.

cheers,

Martin.

__________
message ref: 24935

 
 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: 13 Jun 2018 00: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.
Next up, it is necessary to modify the HtmlViewer code which was just installed. That is to allow clickable links to other parts of the program, which is needed to make the save preferences dialog work for example.

First navigate to the folder where it was installed - by the time you get there you may have lost the will to live:

 C:\Users\martin\AppData\Local\lazarus\onlinepackagemanager\packages\HtmlViewer\source

Select the file  htmlview.pas  and then click the Rename button:



Rename the file as  htmlview_original.pas  (or whatever you want).

Now download this replacement file attached below and save it in that folder (copy and paste from your download folder).

More next time.

Martin.

__________
message ref: 24993
Attachment: htmlview.pas (Downloaded 13 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.
6th message | this message only posted: 13 Jun 2018 01:37
 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.
If you try compiling the program now you will get a "help_sheet not found" error message.

So now it is necessary to tell the package where to find it. Another tedious sequence:



1. Package > Open Loaded Package... menu item:





2. scroll the list and select FrameViewer09.  Then click Open:





3. click Options:





4. select Paths under Compiler Options, and then click the top ... selector button:





5. in the Path Editor click the file selector button:





6. the usual Windows file selector dialog will open. Navigate to the folder in which you saved your TemplotMEC files, and select it. It will then appear in the bar. Click the Add button:





7. it will transfer to the list. Click OK:





8. that's it. Click OK on any windows remaining open, and then try compiling the program again. It should be successful this time.

You are now finally ready to start adding your own ideas and code to TemplotMEC. :)

cheers,

Martin.

__________
message ref: 24994

 
 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: 19 Jun 2018 18:32
 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.
I have updated the previous message in this topic:

 http://85a.co.uk/forum/view_topic.php?id=3283&forum_id=26&jump_to=24994#p24994

If you have previously been using the OpenTemplot files and have changed over to TemplotMEC, you need to update the path setting for the HtmlView component, as shown. This is important.

I strongly recommend that if you still have the path to the OpenTemplot files showing, that you remove it. Click on it and then click the Delete button.

Otherwise Lazarus is very likely to get in a muddle when compiling, and mix up the files from both projects (because they both have the same file names).

I'm sure in Lazarus there must be an easier way than this of arranging a call-back from an installed package to the calling project, but I haven't been able to find it. But this method works anyway.

Martin.

__________
message ref: 25072

 
This is topic ID = 3283     Page created at 09:37 (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 > TemplotMEC nuts and bolts > Getting started with TemplotMEC - 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.  
© 2018  

Powered by UltraBB - © 2009 Data 1 Systems