Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Arraylist


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007, 09:09 PM
Knows the basics
 
Join Date: May 2007
Posts: 60
Default Arraylist

Help!,

How can i clear an Arraylist?

i use
Listbox3.Clear
FileSearch (al1, appPath, "*.csv")
For i = 0 to al1.Count - 1
ListBox3.Add(FileName(al1.Item(i)))
Next
End Sub


I need serveral times to reload above situations in an listbox, the listbox can be cleared but the Arraylist not?

Last edited by tvrman : 06-29-2007 at 09:45 PM.
Reply With Quote
  #2 (permalink)  
Old 06-29-2007, 09:47 PM
Knows the basics
 
Join Date: May 2007
Posts: 60
Default

i found it ,


al1.clear

Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 11:36 PM
Newbie
 
Join Date: May 2007
Posts: 4
Default Arraylist disposal

Hi Erel,

I take benefit of this new subject about Arraylists to ask if there is a way to dispose Arraylists objects added at runtime ?

In fact, if i add a button to a form with the AddButton method then dispose and add it again, there is no problem.

But doing the same with an arraylist raises an error.

eg.:

' working code

AddButton("Form1","myButton",10,10,50,20,"Test")
msgbox("button added")
control("myButton").dispose
msgbox("button disposed")
AddButton("Form1","myButton",10,10,50,20,"Test")
msgbox("button added again")

' not working code

AddArrayList("myList")
msgbox("arraylist added")
control("myList").dispose
msgbox("arraylist disposed but in fact not really ")
AddArrayList("myList")
msgbox("well error on above line")

Well it is still possible to clear the arraylist and add an error handler when trying to add one but i only wanted to know if this was a normal/wanted behaviour.

Thanks in advance.

ps: I attached some code example to illustrate
This example also shows how to use a hidden disposable listbox control to mimic the arraylist behaviour.
The drawbacks of this is we need a form to add the listbox to and the list cannot be sorted automatically with a 'sort method' :/
There may be other drawbacks not mentionned or just forgotten here
Attached Files
File Type: sbp test.sbp (2.5 KB, 10 views)
Reply With Quote
  #4 (permalink)  
Old 06-29-2007, 11:43 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I've tried myself and couldn't get it to work.
At first I thought that it might not work with the Control keyword and so attempted to Dispose it directly.
However a quick glance at the help-file and it appears that the Dispose Method is not available for an ArrayList - Sorry.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #5 (permalink)  
Old 06-29-2007, 11:58 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,314
Default

If you are going to use the same arraylist then try just to clear it...
You can check that an array list already exist by trapping the error generated upon trying to re-create it...
like this

errorlabel(error)
addarraylist(myarray) ' if myarray already exist it jumps to error
return ' stops the execution of the remaing code of the sub
error:
do whatever you like, possably create "myarray2"
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #6 (permalink)  
Old 06-30-2007, 12:38 PM
Newbie
 
Join Date: May 2007
Posts: 4
Default

To CableGuy, yep, we need to use errorlabel not to get the error message.

To RandomCoder, the dispose method does not appear in the help file but seems to exist anyway

If you add one arraylist manually with the form editor then in the code you tap "arraylist1." to see the possible methods you will notice the dispose one.

Is this only a method provided by a generic interface with no implementation behind or why in any other case does this method seem to be available ?

Thanks for your replies

Regards,
Sirnono
Reply With Quote
  #7 (permalink)  
Old 06-30-2007, 02:19 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
Awards Showcase
Beta Tester 
Total Awards: 1
Default

This would appear to be a bug and so I'll add it to the 'Bugs and Errors' section of the Forum.
It should either be made available as a Method or removed from the list.

Regards,
RandomCoder.
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 07-01-2007, 11:42 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,132
Default

The dispose method is not implemented for ArrayLists.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList bidimensional? serge Questions & Help Needed 3 07-18-2008 10:15 AM
ArrayList Bobbes German Forum 2 02-25-2008 09:36 PM
ControlType for ArrayList glook Bug Reports 2 02-18-2008 11:31 AM
ArrayList won't dispose? willisgt Questions & Help Needed 1 08-30-2007 08:56 PM
listbox = arraylist ? sloopa Questions & Help Needed 1 05-07-2007 01:38 PM


All times are GMT. The time now is 02:58 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0