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?
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
Any other thoughts?
Put your code in a test proc (defining columnName) and see where the crash is - debug may be required at start to step thru.
Is this a specific record that crashes or all records?
Are you operating in UTF-8 mode?
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
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?
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.
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.
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.
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
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?
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.
Yes, that is a potential issue. 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.
So do I, still.
That did my head in:- (0 = done) 😁