Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Attach_Table() plus Calculate() symbolic field = crash ?

I'm writing some code to pull some data from an OI table that is external to my app.

If I try to pull a symbolic field using Calculate(), my code crashes inside the formula code for the symbolic field.

I've had success pulling some symbolic fields by ensuring that I attach any tables that are referenced inside the formula. But then other field's formulas will cause an error.

If I run the same code inside the app that contains the data (without the attach_table call since the tables are already part of it's database), then I can call Calculate() on symbolic fields with no problem.

My code looks like this, is there something I'm missing?

Attach_Table(inputDir, tableName, database, "") open tableName To myTable Then Open "DICT." : tableName To @DICT Then Select myTable Loop Readnext @ID Else done = 1 While (0 = done) ReadO RECORD From myTable, @ID Then columnValue = Calculate(columnName) End Else End Repeat End Else End End Else End

Comments

  • Change RECORD to @RECORD.
  • edited November 1
    Hi Don. Thanks for the suggestion, my code is actually is already @RECORD . I must have mis-copied the sample.

    Any other thoughts?
  • Is the tableName getting attached - look in dbmanager

    Put your code in a test proc (defining columnName) and see where the crash is - debug may be required at start to step thru.
  • that does not look like it is the full code for your symbolic as there are obvious places it would crash, but, you say it does work in the setup you described, so....
  • It would be helpful to know what kind of crash you are seeing. Is this a Windows crash or a runtime error? If a runtime error, what error are you seeing?
  • Walter,

    Is this a specific record that crashes or all records?

    Are you operating in UTF-8 mode?
  • > It would be helpful to know what kind of crash you are seeing.

    It's a runtime error. I get something like "ENG0010: FIELDCOUNT, line 1. Variable has not been assigned a value." . But the actual error changes depending on which symbolic field I pass to Calculate()

    > Is the tableName getting attached - look in dbmanager
    Yes, I see it there in dbmanager. My code sample was abbreviated, my full code performs get_status() checks to ensure the table is being attached.

    > Is this a specific record that crashes or all records?
    It fails for every record that I've tried.

    > Are you operating in UTF-8 mode?
    Yes

  • I'm writing some code to pull some data from an OI table that is external to my app.

    What does this actually mean? Are you running code within an OI application, but not the "app that contains the data", or are you calling code from an interface like NetOI?
  • Also, you should call Set_Status(0) before calling Attach_Table and then check Get_Status() to make sure there are no problems.
  • > What does this actually mean? Are you running code within an OI application, but not the "app that contains the data"

    I've got two separate OI apps.

    App-A has the data that I want to read.
    App-B has the code that attaches tables from App-A and tries to read them.

  • is the database you are attaching in the calling app's inheritance chain?
  • edited November 4
    > Is the tableName getting attached - look in dbmanager
    Yes, I see it there in dbmanager. My code sample was abbreviated, my full code performs get_status() checks to ensure the table is being attached.


    If you then do a LIST tablename [failing (columnName)] - what happens?

    Where is columnName in 'columnValue = Calculate(columnName)' coming from?

    is the failing columnName a symbolic?

    Seeing the code of the failing symbolic would be useful to us sleuths.
  • I assume you confirmed that Get_Status() and @FILE.ERROR return nothing of significance. I am a bit stumped but I think this is mostly due to some missing information. I recommend Barry's previous suggestion to move the symbolic code into a stored procedure so you can debug it and get more information about the crash.
  • > is the database you are attaching in the calling app's inheritance chain?
    No

    > If you then do a LIST tablename [failing 'columnValue = Calculate(columnName)')

    Are you talking about the Currently Attached Tables report? For the table containing columnName, the Location field reports the path that I passed into Attach_Table() .

    > Where is columnName in 'columnValue = Calculate(columnName)' coming from?
    It's omitted from my code sample, but it's just a string containing the column name defined DBManager.

    > is the failing columnName a symbolic?
    Yes. Calculate() only fails for symbolic columns.
  • edited November 4
    I dont suppose you have an xlate in the symbolic do you?

    Seeing the symbolic code will help as there are a lot of things that might not line-up seeing you are referencing a different application - xlate , function call etc etc
  • > I dont suppose you have an xlate in the symbolic do you?

    One of the failing symbolics does have a xlate in it.

    This is the CUSTOMER_NAME symbolic on the ORDERS record.

    CUST_ID = {CUSTOMER_ID} @ANS = XLATE("CUSTOMERS", CUST_ID, "FULL_NAME", "X")}

    Does this mean OI can't resolve XLATE calls on attached tables?
  • No, XLATES work just fine as long as all dependencies are available. Is CUSTOMERS being attached as well?
  • Thanks for the hint Don. After I attached CUSTOMERS, the CUSTOMER_NAME symbolic worked.

    But for another symbolic, the formula is calling a subroutine on App-A. My code is executing in App-B and attaching tables from App-A.

    I think my two app plan isn't going to work. It seems that App-B is unable to access subroutines on App-A. That probably explains why my calls to Calculate work when run from App-A.


  • I think my two app plan isn't going to work. It seems that App-B is unable to access subroutines on App-A. That probably explains why my calls to Calculate work when run from App-A.

    Yes, that is a potential issue. Is your app from a different copy of OI than the other one?
  • what I said 😜
    Seeing the symbolic code will help as there are a lot of things that might not line-up seeing you are referencing a different application - xlate , function call etc etc
  • > Is your app from a different copy of OI than the other one?

    No, they're the same version of OI. I just wanted to try to keep this code separated from the main app.

    > what I said 😜

    Ha, yes you were correct. I still have much to learn in the ways of OI.
  • edited November 5
    I still have much to learn in the ways of OI.

    So do I, still.
    That did my head in:- (0 = done) 😁
Sign In or Register to comment.