Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A bit tricky math problem
Message
From
26/04/2010 12:55:06
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01462028
Message ID:
01462062
Views:
51
This message has been marked as a message which has helped to the initial question of the thread.
>>>>If in the range, the 'rangepart' then becomes - zero offset from tnStart
>>>>
>>>>The StartPos-EndPos can span more than one 'rangepart'
>>>>
>>>>rangepartLow =  int( (StartPos - tnStart)/tnIncrement)
>>>>rangepartHigh =  int( (EndPos - tnStart)/tnIncrement)
>>>>
>>>
>>>Sorry, something is wrong here. I got 1 and 0 and I used 10000 as starting point and 50000 as increment.
>>>
>>>UPDATE. I changed it to
>>>
>>>rangepartLow = ceiling( (StartPos - tnStart)/tnIncrement) * m.tnIncrement
>>>rangepartHigh = ceiling( (EndPos - tnStart)/tnIncrement) * m.tnIncrement
>>
>>
>>You may have to re- examine your where clause
>>
>>
>>
>>	create cursor xx ;
>>	(	StartPos	I, ;
>>		EndPos		I ;
>>	)
>>	
>>	insert into xx values (100, 1000)
>>	
>>	
>>	local tnStart, tnEnd, tnIncrement
>>	tnStart = 20
>>	tnEnd = 2000
>>	tnIncrement = 200
>>	
>>	select 	StartPos, ;
>>			EndPos, ;
>>			int( (StartPos - m.tnStart)/m.tnIncrement) as PartLo, ;
>>			int( (EndPos - m.tnStart)/m.tnIncrement)	as	PartHi ;
>>		from xx ;
>>		where	( StartPos >= m.tnStart) ;
>>			 and ( EndPos <=  m.tnEnd)
>>	
>>	
>>	&& 100, 1000, 0, 4
>>	&& 0: 100 >= 20 + 200 * 0, 100 < 20 + 200 * 1
>>	&& 4: 1000 >= 20 + 200 * 4, 1000 < 20 + 200 * 5
>>
>
>It should show 20 as RangeLow and 1020 as RangeHigh. Something is wrong again.


Change the select statement
	create cursor xx ;
	(	StartPos	I, ;
		EndPos		I ;
	)
	
	insert into xx values (100, 1000)
	
	
	local tnStart, tnEnd, tnIncrement
	tnStart = 20
	tnEnd = 2000
	tnIncrement = 200
	
	select 	StartPos, ;
			EndPos, ;
			m.tnStart as PartLo, ;
			m.tnStart + ceiling( (EndPos - m.tnStart)/m.tnIncrement) * m.tnIncrement	as	PartHi ;
		from xx ;
		where	( StartPos >= m.tnStart) ;
			 and ( EndPos <=  m.tnEnd)
	
	
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform