Page 1 of 1
AppendElement()
Posted: Thu Jun 30, 2016 5:50 am
by IdeasVacuum
AddElement() Adds a new empty element after the
current element (or create the first element if none exist).
I propose AppendElement() to add an element at the end of the List (or create the first element if none exist).
This would eliminate testing the size of a List before applying LastElement(), which will crash if there are no elements.
Edit: AppendList() replaced by AppendElement(), better name as proposed by DontTalkToMe; I'm currently unable to reproduce the crash which led to this Wish. Not sure that's a good thing

Re: AppendList()
Posted: Thu Jun 30, 2016 7:15 am
by Thunder93
There is no crash with PB 5.42 LTS
Code: Select all
NewList Numbers.b()
LastElement(Numbers())
If it crashes it would be a PB bug. You suppose to be-able to have a return value on LastElement() to know if it has an element or none.
PB Help: Return Value "... and zero if there if there are no elements in the list." ... not sure why PB help repeats
if there 
Re: AppendList()
Posted: Thu Jun 30, 2016 3:43 pm
by Little John
Thunder93 wrote:There is no crash with PB 5.42 LTS
Code: Select all
NewList Numbers.b()
LastElement(Numbers())
If it crashes it would be a PB bug.
I agree.
Also
no crash when running the above code snippet here, tested with PB 5.42 LTS x86 and x64 on Windows 10.
Re: AppendList()
Posted: Thu Jun 30, 2016 7:55 pm
by IdeasVacuum
...strange. I'm seeing a crash with a structured list, maybe that makes a difference though I don't see why it should.
AppendList() would nonetheless be usefull.
Re: AppendList()
Posted: Thu Jun 30, 2016 8:04 pm
by Thunder93
It doesn't appear to make a difference for my test.
Code: Select all
Structure BasicStructure
Field1.b
Field2.w
Field3.l
EndStructure
NewList TestList.BasicStructure()
Debug LastElement(TestList())
Re: AppendList()
Posted: Thu Jun 30, 2016 8:06 pm
by Little John
IdeasVacuum wrote:...strange. I'm seeing a crash with a structured list, maybe that makes a difference though I don't see why it should.
Maybe you can post a bug report with a short code snippet that demonstrates the issue?
IdeasVacuum wrote:AppendList() would nonetheless be usefull.
I agree.
Re: AppendList()
Posted: Thu Jun 30, 2016 11:21 pm
by DontTalkToMe
... as long as it is called AppendElement() and not AppendList() since we have AddElement(), InsertElement() and what's being appended is not a list.

Re: AppendList()
Posted: Fri Jul 01, 2016 1:10 am
by IdeasVacuum
....good point (element)
