Aparijata,
To further this discussion. I've found more called 4D methods that take a
C_STRING input and return a C_LONGINT. This usage has been in places for
years and does not crash 4D, but as you note is causing a memory leak.
One method is a Sequence Number generator that is also used extensively in
many 4D methods. I don't want to modify that method.
mySequence(sequencePoolName: alpha10) -> longint
Is it safe to simply wrap this in 4D as
`myA4DSequence
`
`Wrapper for mySequence. Uses supported parameter types.
C_TEXT($1;$inName)
C_REAL($0;$outNumber)
$inName := substring($1;1;10) `mySequence $1 is C_STRING(10)
$outNumber := mySequence($inName) `returns a Longint
$0 := $outNumber
Then change all the A4D code as follows?
`$intValue := mySequence("People") - existing code becomes
$intValue := Int(myA4DSequence("People"))
Thanks,
Brad Perkins
On 9/10/12 3:02 PM, "Aparajita Fishman" <[email protected]>
wrote:
>That is correct.
>
>On Sep 10, 2012, at 10:39 PM, "Perkins, Bradley D" <[email protected]>
>wrote:
>
>> I don't think my original question ever made it to the list but this
>>would
>> appear to be the solution:
>>
>> C_REAL ($1) `From Active4D
>> C_LONGINT($tableID) `Same type as [TABLE]id
>> $tableID := Int($1) `Convert Real to Integer
>>
>>
>> -- Brad Perkins
>>
>>
>> On 9/10/12 10:40 AM, "Perkins, Bradley D" <[email protected]> wrote:
>>
>>> Despite using Active4D since V1 I only recently learned that when
>>>calling
>>> 4D Methods, numeric and textual parameters in the 4D method must be
>>>typed
>>> C_REAL and C_TEXT. This is clearly documented but I somehow missed it
>>>and
>>> in our case it hadn't been causing clearly noticeable problems.
>>>Recently
>>> (thanks to Aparajita) we discovered that it was contributing to a
>>>memory
>>> leak that would eventually crash 4D. In my case I had a lot of methods
>>> with C_STRING parameters that needed to be replaced with C_TEXT. Easy
>>> enough to fix.
>>>
>>> `Example Method called by Active4D
>>>
>>> C_TEXT($1; $inString) `replaces C_STRING($1;$inString;20)
>>> $inString := Substring($1;1;20)
>>>
>>>
>>>
>>> We've long run a structure that serves both Active4D and legacy
>>> (Netlink/WS4D style) pages. I am in the process of rewriting the
>>>latter in
>>> A4D and am encountering more called 4D methods that have illegal
>>>parameter
>>> types.
>>>
>>> My question involves having to now use C_REAL instead of C_LONGINT.
>>> Most of the cases where I'll need to replace C_REAL parameters are
>>>methods
>>> where I currently use C_LONGINT to reference a primary key for a QUERY.
>>>
>>> `Example Method 2 called by Active4D
>>> C_REAL ($1; $tableID) ` replaces C_LONGINT($1; $tableID)
>>> $tableID := $1
>>> QUERY([TABLE];[TABLE]id = $tableID) `[Table]id is a long integer,
>>>$tableID
>>> is a real
>>> ...
>>>
>>> I have always run 4D compiled in production. I always compile with "All
>>> variables are typed". From my CS studies and Numerical Analysis
>>>classes I
>>> know that a floating point number that "looks equal" to a similar
>>>integer
>>> isn't always equal.
>>>
>>> In re-typing existing method C_LONGINT parameters to C_REAL, do I need
>>>to
>>> worry that about this?
>>>
>>> Should I do something like this?
>>>
>>> C_REAL ($1) ` replaces C_LONGINT($1; $tableID)
>>> C_LONGINT($tableID)
>>> $tableID := Round($1;0)
>>>
>>> QUERY([TABLE];[TABLE]id = $tableID) `[Table]id is a long integer,
>>>$tableID
>>> is a real
>>>
>>> Thanks,
>>>
>>> Brad Perkins
>>>
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> Active4D-dev mailing list
>> [email protected]
>> http://list.aparajitaworld.com/listinfo/active4d-dev
>> Archives: http://active4d-nabble.aparajitaworld.com/
>
>Regards,
>
> Aparajita
>
>_______________________________________________
>Active4D-dev mailing list
>[email protected]
>http://list.aparajitaworld.com/listinfo/active4d-dev
>Archives: http://active4d-nabble.aparajitaworld.com/
_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/