Just starting out? Need help? Post your questions and find answers here.
			
		
		
			
				
																			
								ivega718 							 
						User 			
		Posts:  15  		Joined:  Mon Feb 25, 2013 9:29 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by ivega718   »  Fri Mar 01, 2013 4:01 am 
			
			
			
			
			How I can do that variable incr in decimal values?
Code: Select all 
Define X.d
For X.d=1 To 2 Step .5
  MessageRequester ("",Str(X.d))  
Next X.d
 
Code: Select all 
Define x.d
x.d=0
Repeat
  x.d=x.d + .5
  MessageRequester("",Str(x.d)) 
Until x.d=3
This not compile...somebody know of other alternative?
sorry...I am new in PureBasic...
 
			
			
									
									
						 
		 
				
		
		 
	 
				
			
		
		
			
				
																			
								jassing 							 
						Addict 			
		Posts:  1885  		Joined:  Wed Feb 17, 2010 12:00 am 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by jassing   »  Fri Mar 01, 2013 4:13 am 
			
			
			
			
			Use strf()...
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
								STARGÅTE 							 
						Addict 			
		Posts:  2261  		Joined:  Thu Jan 10, 2008 1:30 pm 		
		
																Location:  Germany, Glienicke 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by STARGÅTE   »  Fri Mar 01, 2013 4:15 am 
			
			
			
			
			For  : 
Next : 
Step  is only for 
integers !
if you need a loop with 
floats /
doubles  you can use a 
While  : 
Wend  loop:
if you debug a 
float /
double , you have to use StrF/StrD() instead of Str()
Code: Select all 
Define X.d = 1.0
While X <= 2.0
  MessageRequester("", StrD(X))
  X + 0.5
Wend
 
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								IdeasVacuum 							 
						Always Here 			
		Posts:  6426  		Joined:  Fri Oct 23, 2009 2:33 am 		
		
																Location:  Wales, UK 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by IdeasVacuum   »  Fri Mar 01, 2013 4:20 am 
			
			
			
			
			Code: Select all 
Define X.d = 0
While(X < 2.4)
     MessageRequester ("",StrD(X))
     X = X + 0.5
 
Wend
End
For loops can only use integer steps.
 
			
			
									
									IdeasVacuum 
If it sounds simple, you have not grasped the complexity.
						 
		 
				
		
		 
	 
	
						
		
		
			
				
								ts-soft 							 
						Always Here 			
		Posts:  5756  		Joined:  Thu Jun 24, 2004 2:44 pm 		
		
											Location:  Berlin - Germany 
							
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by ts-soft   »  Fri Mar 01, 2013 4:37 am 
			
			
			
			
			Code: Select all 
Define x.d = 0
Repeat
  x + 0.5
  MessageRequester("", StrD(x))
Until x = 3
 
			
			
									
									PureBasic 5.73  | 
SpiderBasic 2.30  |
 Windows 10 Pro (x64)  | 
Linux Mint 20.1 (x64) 
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
 
						 
		 
				
		
		 
	 
	
						
		
		
			
				
																			
								ivega718 							 
						User 			
		Posts:  15  		Joined:  Mon Feb 25, 2013 9:29 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by ivega718   »  Fri Mar 01, 2013 7:20 am 
			
			
			
			
			This forum is wonderful...I am learning and more I know I like this compiler... 
 
Now is working fine... 
 
Thanks
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			
				
								GWS 							 
						User 			
		Posts:  23  		Joined:  Tue Sep 27, 2005 9:51 pm 		
		
											Location:  Staffs. UK 
							
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by GWS   »  Fri Mar 01, 2013 10:46 am 
			
			
			
			
			In the FOR loop, work in tenths, hundreths or whatever you require ..  
  
This example runs between 1.0 and 2.0 in tenths:
Code: Select all 
OpenConsole()
ClearConsole()
For i = 10 To 20
  PrintN(StrF((i/10),1))
Next i
PrintN("Press any key to exit")
Input()
PrintN("Done")
Delay(2000)
End
best wishes, 
  
Graham
 
			
			
									
									Tomorrow may be too late ..