Re: Where is the error - Solved

2017-02-15 Thread Tim Nevels via 4D_Tech

On Feb 15, 2017, at 2:56 PM, Peter Mew wrote:

> APPEND TO ARRAY(StartSampleArray;($Start*<>SampleRate/75))
> 
> This does not always evaluate correctly when compiled
> it shoud read
> 
> APPEND TO ARRAY(StartSampleArray;$Start*(<>SampleRate/75))
> this fixes the problem

On Feb 15, 2017, at 4:11 PM, Chuck Miller wrote:

> Actually you are correct only form a mathematical basis from 4D basis 
> evaluation occurs from left to right with not parens. It does not follow 
> mathematical constructs

In the case that Peter is referring to, the difference in operation order that 
4D uses and the standard order of operations has nothing to do with his 
problem. He is doing 2 operations: multiplication and division. Both 4D and the 
“standard" order for these 2 operators is left to right. The issue is that he 
is doing operations on longints values and the intermediate values of the 
formula calculation are also stored in a longint and he is overflowing what can 
be stored in a longint. 

4D is calculating the formula value from left to right so the first operation 
is the multiplication — $Start * <>SampleRate. This causes a longint overflow 
sometimes and results in a negative number. Then the division operation is 
done. 

By adding parenthesis to the formula he forces the division — <>SampleRate / 75 
— to occur first. The result of this operation is then multiplied by $Start; 
thus eliminating the possible overflow condition. 

Tim


Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Where is the error?

2017-02-14 Thread Chip Scheide via 4D_Tech
not sure what you are doing..
26655216 is more then 7400 hours

If $Duration is negative then <>StartSampleArray{$i} is larger then the 
next array element value (<>StartSampleArray{$i+1})

Since 26655216 seconds is 7400 hours, or if the the value 26+ million 
is milliseconds is still over 7.4 hours; I suspect that there is a 
data/ data collection problem.


On Tue, 14 Feb 2017 21:30:54 +, Peter Mew via 4D_Tech wrote:
> Hi
> This snippet of code is in a loop, of typically 10 to 20 items.
> The Array <>StartsampleArray holds the start time, in samples, of the
> tracks on a CD.
> It all works fine interpreted, but when compiled, when
> <>StartSampleArray{$i} exceeds around 26655216 or thereabouts $Duration
> turns negative, and it all falls over
> <>StartSampleArray is copied from a Process array earlier in the code,
> which itself is declared as a longint array
> 
> $start and $duration are part of a LEP call to Sox to split the individual
> tracks from a complete CD
> It looks so simple, but why wont it work compiled?
> 
> Thanks for any guidance
> -pm
> 
> 
> 
> $Start:=String(<>StartSampleArray{$i})+"s"
> If ($iStartSampleArray))
> $trackDur:=<>StartSampleArray{$i+1}-<>startSampleArray{$i}
> $Duration:=String($trackDur)+"s"
> Else
> $lastTrackDur:=<>EndofFileSamples-<>StartSampleArray{$i}
> $duration:=String($lastTrackDur)+"s"
> End if
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Where is the error?

2017-02-14 Thread Peter Mew via 4D_Tech
Hi
This snippet of code is in a loop, of typically 10 to 20 items.
The Array <>StartsampleArray holds the start time, in samples, of the
tracks on a CD.
It all works fine interpreted, but when compiled, when
<>StartSampleArray{$i} exceeds around 26655216 or thereabouts $Duration
turns negative, and it all falls over
<>StartSampleArray is copied from a Process array earlier in the code,
which itself is declared as a longint array

$start and $duration are part of a LEP call to Sox to split the individual
tracks from a complete CD
It looks so simple, but why wont it work compiled?

Thanks for any guidance
-pm



$Start:=String(<>StartSampleArray{$i})+"s"
If ($iStartSampleArray))
$trackDur:=<>StartSampleArray{$i+1}-<>startSampleArray{$i}
$Duration:=String($trackDur)+"s"
Else
$lastTrackDur:=<>EndofFileSamples-<>StartSampleArray{$i}
$duration:=String($lastTrackDur)+"s"
End if
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**