click here for a list of all existing Templot documentation
about Templot Club 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  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 > I found a flaw > List index out of bounds (-1)
Templot web site

                                       List index out of bounds (-1)
     
 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: 27 Dec 2017 00:06
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Hello Martin

I am getting pop up boxes marked Templot2 at the top and the message 'List index out of bounds (-1)' (inverted commas added by me).

I just ignore it and it carries on. I did find it a little while back but the window appeared and disappeared so quickly that I couldn't read it and thus couldn't report it.

If it's any help it happens when there are quite a few templates on the trackpad. This laptop is fairly iffy since the Windows 10 update a while back so it may well just be down to that.

Best wishes
Derek

__________
message ref: 23184

 
 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: 27 Dec 2017 01:48
 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.
Hello Derek,

Thanks for reporting it.

Can you remember the last thing you clicked before it happened? Without that information I am looking for a needle in a haystack.  :(

You may be interested in this:

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

and this: 

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

and this:

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

cheers,

Martin.

__________
message ref: 23185

 
 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: 27 Dec 2017 13:09
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Hello Martin

I did find one of those examples you listed- apologies, I didn't think to look further in case there were any more.

If I'm being 100% honest I can't now recall whether it happened when I went to store the control template or when I tried to lay a new one- but either way control did return to the previous template.

The programme carried on, I repeated the action without issue. I will pay more attention in the future.

NB for my own understanding for my (very basic) programming, have I understood correctly that this message is due to searching for a specific line of data (presumably the Templot file in memory/cache/page/etc?) that isn't there?

Ie I'm searching for template XYZ123 but there isn't a template matching that description in the memory?

(If I'm pushing my luck by asking technical questions, please forgive me).

Many thanks
Derek
__________
message ref: 23186

 
 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: 27 Dec 2017 16:22
 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: NB for my own understanding for my (very basic) programming, have I understood correctly that this message is due to searching for a specific line of data (presumably the Templot file in memory/cache/page/etc?) that isn't there?

Ie I'm searching for template XYZ123 but there isn't a template matching that description in the memory?

(If I'm pushing my luck by asking technical questions, please forgive me).
Hi Derek,

Not at all, it's interesting.

In Delphi and Lazarus a list is a very common construct. There are a great many lists in Templot.

Such lists are indexed starting from zero. i.e. the first item in the list is indexed [0], the second item is indexed [1], etc.

Consequently if you have a list containing 10 items, valid index values are in the range 0-9 when accessing the list. If you request a data item from the list using an index outside that range, or try to put data into the list for an item outside that range, you get the message "List index out of bounds". 

If the list is empty, the current list Count value is 0, but the current index returns the value -1 because there is no current data for index [0].

If you create a list but forget to put any data in it, or delete all the data in it, or most likely delete the last item in the list without noticing that it was the last, any subsequent attempt to access data in the list returns the message "List index out of bounds (-1)".

It's a bit more complicated than that, because you could if you wish catch the exception yourself and handle it, like this:

try
  data:=my_list.Strings[next_index];
except
  data:='no data available';
end;


In which case if the list is empty, you still get a valid result, instead of the "out of bounds" message.

Generally I prefer to do a proper test:

if (my_list.Count>0) and (next_index>=0) and (next_index<my_list.Count)
   then data:=my_list.Strings[next_index]
   else data:='no data available';


Or more typically:

if (my_list.Count<1) or (next_index<0) or (next_index>=my_list.Count)
   then begin
          ShowMessage('Something has gone wrong');
          ...
          do_something_about_it;
          ...
        end
   else data:=my_list.Strings[next_index];


For more info, see:

 http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/vptworkingwithstringlists_xml.html

cheers,

Martin.

__________
message ref: 23187

 
 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: 29 Dec 2017 01:16
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Hello Martin

Thanks for that explanation. I have tried some internet examples of string lists. I didn't realise that's what it was referring to.

Normally I can pick things up fairly quickly, but I must admit to finding this fairly hard going.

I shall persevere.

Thanks
Derek
__________
message ref: 23208

 
 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: 29 Dec 2017 01:23
 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: Normally I can pick things up fairly quickly, but I must admit to finding this fairly hard going.

I shall persevere.
Hi Derek,

What are you actually trying to do?

If you post a bit of code here we might find an easier way.

Generally there is a IT professional way of doing things, shown in published examples, and a "Meccano" way.

The compiler doesn't mind how inelegant your code is, it all works just the same if it delivers the right answer.  :)

regards,

Martin.

__________
message ref: 23209

 
 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: 29 Dec 2017 01:55
 PM  Reply with quote  Reply blank 
from:
DerekStuart
United Kingdom

 

view images in gallery
view images as slides
Thanks Martin. You're a true Gent.

I'm not specifically trying to do anything at the moment- just taking sample pieces of code from the internet, seeing how they work- chopping bits out to see what stops working etc.

I did find another site after your previous reply as I tried to search what it all meant; I shall give that a go at the weekend on the desktop. I will get the hang of it. Eventually.

Thanks again not only for the info, but also the encouragement. It means a lot.
Derek
__________
message ref: 23211

 
 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: 29 Dec 2017 02:05
 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 may find Gary Darby's site worth a look:

 http://www.delphiforfun.org

cheers,

Martin.

__________
message ref: 23213

 
This is topic ID = 3161     Page created at 18:22 (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 > I found a flaw > List index out of bounds (-1)
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