Change in Function operation?
#1
The following worked several versions back:

Function CountUnmarked% (KSorCC$)
    CountUnmarked% = 0
    If KSorCC$ = "KS" Then
        For x = 1 To TotKSrecs%
            If KSdata$(Assigned%, x) = "N" Then CountUnmarked% = CountUnmarked% + 1
        Next x
    Else
        For x = 1 To TotCCrecs%
            If CCdata$(Assigned%, x) = "N" Then CountUnmarked% = CountUnmarked% + 1
        Next x
    End If
End Function



With PE edition, you cannot use the variable CountUnmarked% the same as you would any other variable (within the function). It appears that QB64 thinks that you are calling the function again.  Instead you have to use a temp variable and then assign that value to CountUnmarked% before exiting the function:


Function CountUnmarked% (KSorCC$)
    tCountUnmarked% = 0
    If KSorCC$ = "KS" Then
        For x = 1 To TotKSrecs%
            If KSdata$(Assigned%, x) = "N" Then tCountUnmarked% = tCountUnmarked% + 1
        Next x
    Else
        For x = 1 To TotCCrecs%
            If CCdata$(Assigned%, x) = "N" Then tCountUnmarked% = tCountUnmarked% + 1
        Next x
    End If
    CountUnmarked% = tCountUnmarked%
End Function



Is this because recursion code changed ?  I can make adjustments if this is proper operation, no biggie.  I just wanted to mention this in case is this is a bug...<ahem>...errr...an 'undocumented feature'.

Thanks to all,
Dano
Reply


Messages In This Thread
Change in Function operation? - by dano - 09-17-2022, 11:59 AM
RE: Change in Function operation? - by bplus - 09-17-2022, 12:04 PM
RE: Change in Function operation? - by RhoSigma - 09-17-2022, 12:28 PM
RE: Change in Function operation? - by mnrvovrfc - 09-17-2022, 02:09 PM
RE: Change in Function operation? - by dano - 09-18-2022, 06:59 PM



Users browsing this thread: 1 Guest(s)