Program crashes with 'result'

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Program crashes with 'result'

#1 Post by arco » 27 Sep 2018 17:26

If I use this (pic24fj256ga108):

Code: Select all

Sub Function Func_A () As Byte
  ...
  Result = 1
End Sub

Sub Function Func_B () As Byte
  ...
  Result = 1
End Sub

Sub Function Func_C () As Byte
  ...
  Result = 1
  ...
  If Result Then
    If Func_A() Then Result = Func_B() Else Result = 0 End If
  End If
End Sub
the program crashes at this point. I then have to use a temp variable to keep result.

Code: Select all

Sub Function Func_A () As Byte
  ...
  Result = 1
End Sub

Sub Function Func_B () As Byte
  ...
  Result = 1
End Sub

Sub Function Func_C () As Byte
  ...
  Result = 1
  ...
  If Result Then
    If Func_A() Then Temp = Func_B() Else Temp = 0 End If
  End If
  Result = Temp
End Sub
It seems something goes wrong with the result of one or more subs/compiler gets confused?...
(took me a day to find that out... :evil: )
Regards,

Peter.

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Program crashes with 'result'

#2 Post by petar.suknjaja » 28 Sep 2018 09:58

Hi Peter,
I'll try to reproduce this, in meanwhile post the whole project so we could review it.
Kind regards,
Petar

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: Program crashes with 'result'

#3 Post by arco » 28 Sep 2018 13:39

I cannot post complete code, it's proprietary...
I discovered that this also solves the problem: (same as failing code but written slightly different)

Code: Select all

  ...
  ...
  If Result Then Result = Func_A() 
  If Result Then Result = Func_B()
  End If
Regards,

Peter.

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Program crashes with 'result'

#4 Post by petar.suknjaja » 01 Oct 2018 08:41

Hi Peter,
I understand, however, I'm glad that you have found the solution for your issue.
Kind regards,
Petar

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”