iOS Question Call B4i sub from inline OBJC and return value

Discussion in 'iOS Questions' started by CaptKronos, Apr 28, 2019.

  1. CaptKronos

    CaptKronos Active Member Licensed User

    How would I call from inline OBJC a B4i sub such as the following and have the inline code receive the sub's return value:
    Code:
    sub test as int
       
    return 1
    end sub
    Thanks.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. CaptKronos

    CaptKronos Active Member Licensed User

    Do you mean like this:
    Code:
    sub test as int
       
    return 1
    end sub

    #If OBJC 

    -(NSInteger)testGettingVal
    {
        NSInteger aNum;
        aNum=[self.bi raiseEvent:nil event:@"test:" params:@[]];
        return aNum;
    }

    #end if
    I always get a value of 0 returned. I thought raising an event returned immediately (hence 0 rather than 1 being returned).
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Your objective C code is wrong. What are you using inline code for?
     
  5. CaptKronos

    CaptKronos Active Member Licensed User

    At the moment it is just to see whether it was possible to get a value from a b4i sub.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There is an extra colon in the in the sub name. There are other problems with this code (you will probably see a warning about unexpected synchronous event in the logs).
     
  7. CaptKronos

    CaptKronos Active Member Licensed User

    Yes, sorry, you are correct. I rewrote my code on the fly to simplify it for the post and I missed the ":". My original code was passing a parameter. I also get the unexpected synchronous event message in the logs. However, I can't use raiseUIEvent because I believe that doesn't return a value.
     
  8. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    I know nothing about Objective C. But, as I understand, inline OBJC allows direct calls like in other languages. For example, I added some statements in Erel's sample (see test.zip).
     

    Attached Files:

    CaptKronos likes this.
  9. CaptKronos

    CaptKronos Active Member Licensed User

    Hi Semen, that's exactly what I was looking for.

    Thanks.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice