Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Arraylist

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007, 08:09 PM
Knows the basics
 
Join Date: May 2007
Posts: 63
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 08:45 PM.
Reply With Quote
  #2 (permalink)  
Old 06-29-2007, 08:47 PM
Knows the basics
 
Join Date: May 2007
Posts: 63
Default

i found it ,


al1.clear

Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 10: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, 14 views)
Reply With Quote
  #4 (permalink)  
Old 06-29-2007, 10:43 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
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
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #5 (permalink)  
Old 06-29-2007, 10:58 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
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 - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #6 (permalink)  
Old 06-30-2007, 11:38 AM
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, 01:19 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
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.
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 07-01-2007, 10:42 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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 Off
Pingbacks are Off
Refbacks are On

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


All times are GMT. The time now is 10:24 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0