Just starting out? Need help? Post your questions and find answers here.
			
		
		
			
				
								blueznl 							 
						PureBasic Expert 			
		Posts:  6172 Joined:  Sat May 17, 2003 11:31 am
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by blueznl  Wed Oct 01, 2003 7:09 pm 
			
			
			
			
			question as to the internal workings of the countlist command, is it simply a counter (thus using countlist does not impose a slowdown and it can be used as an easy check to see if a list is empty) or does it actually count elements in there?
			
			
									
									
						 
		 
				
		
		 
	 
				
			
		
		
			
				
																			
								Fred 							 
						Administrator 			
		Posts:  18351 Joined:  Fri May 17, 2002 4:39 pmLocation:  France
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by Fred  Thu Oct 02, 2003 9:34 am 
			
			
			
			
			It does actually count..
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
								blueznl 							 
						PureBasic Expert 			
		Posts:  6172 Joined:  Sat May 17, 2003 11:31 am
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by blueznl  Thu Oct 02, 2003 10:47 am 
			
			
			
			
			besides keeping your own counter, is there another way to check if a list is empty?
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								Saboteur 							 
						Enthusiast 			
		Posts:  273 Joined:  Fri Apr 25, 2003 7:09 pmLocation:  (Madrid) Spain
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by Saboteur  Thu Oct 02, 2003 11:54 am 
			
			
			
			
			yes.
Code: Select all 
if LastElement(linkedlist())
  debug "List if full"
else
  debug "List is empty"
endif
[:: PB Registered ::]Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti 
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								freak 							 
						PureBasic Team 			
		Posts:  5948 Joined:  Fri Apr 25, 2003 5:21 pmLocation:  Germany 
		
						
						
						 
													
							
						
									
						Post 
					 
								by freak  Thu Oct 02, 2003 2:54 pm 
			
			
			
			
			I think LastElement() also loops through the elements, till the last one is reached.
			
			
									
									quidquid Latine dictum sit altum videtur
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								Fred 							 
						Administrator 			
		Posts:  18351 Joined:  Fri May 17, 2002 4:39 pmLocation:  France
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by Fred  Fri Oct 03, 2003 9:52 am 
			
			
			
			
			No the list structure get the point of the first and last element so LastElement() is an elegant solution for that.
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								Saboteur 							 
						Enthusiast 			
		Posts:  273 Joined:  Fri Apr 25, 2003 7:09 pmLocation:  (Madrid) Spain
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by Saboteur  Fri Oct 03, 2003 11:34 am 
			
			
			
			
			Of course, I am elegant 
[:: PB Registered ::]Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti 
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								Fred 							 
						Administrator 			
		Posts:  18351 Joined:  Fri May 17, 2002 4:39 pmLocation:  France
				Contact: 
				
			 
				
		 
		
						
						
						 
													
							
						
									
						Post 
					 
								by Fred  Fri Oct 03, 2003 4:02 pm