Recent Posts

Pages: [1] 2 3 ... 10
1
Scripting Languages / Re: Script BASIC COM
« Last post by Mike Lobanovsky on December 12, 2017, 03:50:43 PM »
I think we just need to do what VBScript is doing when it calls the ProvideX.Script NewObject method.

No big deal, you think? :D

Quote
The only thing I think is outstanding is getting values returned in method call arguments to update the SB passed argument acting as a place holder for it.

I think these particulars would be easier to resolve with a full-fledged installation of both client and server and a matching test suite to work with. We can discuss it in a greater detail via email if you don't mind. 
2
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 03:18:22 PM »
I agree!

I would still like to fix the issue of GetByName returning the successful GetValue argument to SB's passed initialized variable. Special type?

ProvideX COM has a CleanUp routine I think cleans up any reference count issues on the release side. I call ReleaseObject method calls to ProvideX as well. I think we just need to do what VBScript is doing when it calls the ProvideX.Script NewObject method.

The only thing I think is outstanding is getting values returned in method call arguments to update the SB passed argument acting as a place holder for it.

3
Scripting Languages / Re: Script BASIC COM
« Last post by Mike Lobanovsky on December 12, 2017, 03:00:03 PM »
Hehe, no wonder ..._bus method calls now work as expected.

Jose's response is absolutely correct.

Dave's implementation is "half baked". It creates COM objects but it neither increments their initial ref count nor does it keep track of it later in sync with the client's garbage collection rules. Which means Sage is short of 1 ref count when VARIANTARG va goes out of scope and Sage's garbage collector kills the instance as soon as whichever assignments have been made on the receiving end of the very first method call all go out of scope too. Which, in its turn, means by the time we want to make a second call to the instance's methods it is already dead and non-existent!

Dave's code ought to be augmented with a meticulous ref count mechanism to match the Sage garbage collector's expectations. Else I'm afraid there won't be any chance for SB on Sage's scene.
4
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 02:30:14 PM »
Quote from:  Josť Roca
Forget my remark about increasing the reference count of the dispatch pointer because Dave's code for CallByName is not following the COM rules and it is not clearing the passed variants. It is just deleting the array of variants without calling VariantClear.

I'm confused as using AR_Customer_bus now works with the methods that failed before.

The problem I have now is I don't think Dave's CallByName knows how to return a value to one of its passed arguments. GetValue() method remains a "". (empty string)

5
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 02:22:42 PM »
That seemed to fix the GetIDsOfNames failed problem. (surprised!)

Code: Script BASIC
  1. ' Script BASIC PVXCOM Code Challenge
  2.  
  3. IMPORT NT.sbi
  4. IMPORT COM.sbi
  5.  
  6. oscript = COM::CreateObject("ProvideX.Script")
  7. COM::CallByName(oScript,"Init",vbMethod,"C:\\Sage\\Sage 100 Advanced ERP\\MAS90\\HOME")
  8. osession = COM::CallByName(oscript, "NewObject", vbMethod, "SY_Session")
  9. UserOK = COM::CallByName(osession, "nSetUser", vbMethod, "JRS", "northstar")
  10. CompanyOK = COM::CallByName(osession, "nsetcompany", vbMethod, "ABC")
  11. DateOK = COM::CallByName(osession, "nSetDate", vbMethod, "A/R", "20171119")
  12. ModuleOK = COM::CallByName(osession, "nSetModule", vbMethod, "A/R")
  13. osec = COM::CallByName(osession, "nSetProgram", vbMethod, COM::CallByName(osession, "nLookupTask", vbMethod, "AR_Customer_ui"))
  14. ocust = COM::CallByName(oscript, "NewObject", vbMethod, "AR_Customer_bus", "VT_DISPATCH:" & osession)
  15.  
  16. retval = 0
  17. sCustomerNo = ""
  18. sCustomerName = ""
  19. sCity = ""
  20. sState = ""
  21. sTelephoneNo = ""
  22.  
  23. retval = COM::CallByName(ocust, "nSetIndex", vbMethod, "KNAME")
  24. retval = COM::CallByName(ocust, "nFind", vbMethod,"")
  25. retval = COM::CallByName(ocust, "nMoveNext", vbMethod)
  26. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerNo$", sCustomerNo)
  27. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerName$", sCustomerName)
  28. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "City$", sCity)
  29. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "State$", sState)
  30. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "TelephoneNo$", sTelephoneNo)
  31.  
  32. retval = NT::MsgBox("Customer:  " & sCustomerNo & "  " & sCustomerName & "  " & sCity & "  " & sState & "  " & sTelephoneNo, "PVXCOM Code Challenge", "OK")
  33. COM::CallByName(osession,"DropObject")
  34. COM::ReleaseObject(oscript)
  35.  


C:\ScriptBASIC\examples>sbwin comcustcc.sb
The number of arguments is: 1
CreateObject(ProvideX.Script)
CallByName 4 args
CallByName(obj=c50bc, method='Init', calltype=1 , comArgs=1)
CallByName 4 args
CallByName(obj=c50bc, method='NewObject', calltype=1 , comArgs=1)
return value from COM function was numeric: 807388
CallByName 5 args
CallByName(obj=c51dc, method='nSetUser', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=c51dc, method='nsetcompany', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c51dc, method='nSetDate', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=c51dc, method='nSetModule', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=c51dc, method='nLookupTask', calltype=1 , comArgs=1)
return value from COM function was numeric: 40000001
CallByName 4 args
CallByName(obj=c51dc, method='nSetProgram', calltype=1 , comArgs=1)
return value from COM function was numeric: 100006
CallByName 5 args
CallByName(obj=c50bc, method='NewObject', calltype=1 , comArgs=2)
return value from COM function was numeric: 807532
CallByName 4 args
CallByName(obj=c526c, method='nSetIndex', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=c526c, method='nFind', calltype=1 , comArgs=1)
return value from COM function was numeric: 0
CallByName 3 args
CallByName(obj=c526c, method='nMoveNext', calltype=1 , comArgs=0)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=c526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 2 args
CallByName(obj=c51dc, method='DropObject', calltype=1 , comArgs=0)

C:\ScriptBASIC\examples>
6
Scripting Languages / Re: Script BASIC COM
« Last post by Mike Lobanovsky on December 12, 2017, 02:07:00 PM »
No no John,

Please run it with the ..._bus object as you did before to see if the three red errors persist with this artificial manual AddRef() call!

COM languages usually do ref counting transparently under the hood. Both the server and client are COM languages while we, with our sb_engine.dll, are just a proxy -- a means to inform the client that the object of such and such type has been created at such and such address with an initial ref count of 1. The ref count is initially incremented by the COM server when the object is created and then modified (+/-) by the COM client as it consumes its methods and properties making occasional temporary assignments here and there in the process. When both server and client's references to that object all go out of scope and the ref count falls to 0, the object is destroyed automatically by the corresponding garbage collector.

If we try to add one more ref count manually, then when and where are we supposed to decrement it accordingly? Our proxy is a one-way pipe that passes the pointer value to but not fro!
7
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 01:35:36 PM »
Mike,

Sage has three business objects for AR_Customer.

AR_Customer_ui
AR_Customer_bus
AR_Customer_svc

There is a lot of inheriting going on under the Sage 100 covers. The routines for declare INDEX, StartingKey and then a MoveNext are all in the SY_Service object which doesn't seem to be inherited in the AR_Customer_bus object. Why it works with VBScript still has me puzzled. In this example I include both AR_Customer_bus and AR_Customer_svc which doesn't cause any errors but I'm still not getting data from the customer record yet.

I recompiled with your latest change and no errors reported. I think ProvideX.Script takes care of object ref counting. I have never seen in the VBScript code anything about object count references.,

Code: Script BASIC
  1. ' Script BASIC PVXCOM Code Challenge
  2.  
  3. IMPORT NT.sbi
  4. IMPORT COM.sbi
  5.  
  6. oscript = COM::CreateObject("ProvideX.Script")
  7. ' HomeDirOK = COM::CallByName(oscript, "Init", vbMethod, NT::RegRead("HKEY_CURRENT_USER\\Software\\ODBC\\ODBC.INI\\SOTAMAS90\\Directory") & "\\HOME")
  8. COM::CallByName(oScript,"Init",vbMethod,"C:\\Sage\\Sage 100 Advanced ERP\\MAS90\\HOME")
  9. osession = COM::CallByName(oscript, "NewObject", vbMethod, "SY_Session")
  10. UserOK = COM::CallByName(osession, "nSetUser", vbMethod, "JRS", "northstar")
  11. CompanyOK = COM::CallByName(osession, "nsetcompany", vbMethod, "ABC")
  12. DateOK = COM::CallByName(osession, "nSetDate", vbMethod, "A/R", "20171119")
  13. ModuleOK = COM::CallByName(osession, "nSetModule", vbMethod, "A/R")
  14. osec = COM::CallByName(osession, "nSetProgram", vbMethod, COM::CallByName(osession, "nLookupTask", vbMethod, "AR_Customer_ui"))
  15. ocust = COM::CallByName(oscript, "NewObject", vbMethod, "AR_Customer_bus", "VT_DISPATCH:" & osession)
  16. ocustkey = COM::CallByName(oscript, "NewObject", vbMethod, "AR_Customer_svc", "VT_DISPATCH:" & osession)
  17. retval = 0
  18. CustomerNo = ""
  19. CustomerName = ""
  20. City = ""
  21. State = ""
  22. TelephoneNo = ""
  23.  
  24. retval = COM::CallByName(ocustkey, "nSetIndex", vbMethod, "KNAME")
  25. retval = COM::CallByName(ocustkey, "nFind", vbMethod, "00ABC")
  26. retval = COM::CallByName(ocustkey, "nMoveNext", vbMethod)
  27. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerNo$", CustomerNo)
  28. retval = NT::MsgBox("CustomerNo: |" & CustomerNo & "|","DEBUG", "OK")
  29. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerName$", CustomerName)
  30. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "City$", City)
  31. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "State$", State)
  32. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "TelephoneNo$", TelephoneNo)
  33.  
  34. retval = NT::MsgBox("Customer:  " & CustomerNo & "  " & CustomerName & "  " & City & "  " & State & "  " & TelephoneNo, "PVXCOM Code Challenge", "OK")
  35. COM::CallByName(osession,"DropObject")
  36. COM::ReleaseObject(oscript)
  37.  


C:\ScriptBASIC\examples>sbwin comcustcc.sb
The number of arguments is: 1
CreateObject(ProvideX.Script)
CallByName 4 args
CallByName(obj=2950bc, method='Init', calltype=1 , comArgs=1)
CallByName 4 args
CallByName(obj=2950bc, method='NewObject', calltype=1 , comArgs=1)
return value from COM function was numeric: 2707932
CallByName 5 args
CallByName(obj=2951dc, method='nSetUser', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=2951dc, method='nsetcompany', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=2951dc, method='nSetDate', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=2951dc, method='nSetModule', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=2951dc, method='nLookupTask', calltype=1 , comArgs=1)
return value from COM function was numeric: 40000001
CallByName 4 args
CallByName(obj=2951dc, method='nSetProgram', calltype=1 , comArgs=1)
return value from COM function was numeric: 100006
CallByName 5 args
CallByName(obj=2950bc, method='NewObject', calltype=1 , comArgs=2)
return value from COM function was numeric: 2708076
CallByName 5 args
CallByName(obj=2950bc, method='NewObject', calltype=1 , comArgs=2)
return value from COM function was numeric: 2708220
CallByName 4 args
CallByName(obj=2952fc, method='nSetIndex', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=2952fc, method='nFind', calltype=1 , comArgs=1)
return value from COM function was numeric: 0
CallByName 3 args
CallByName(obj=2952fc, method='nMoveNext', calltype=1 , comArgs=0)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=29526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=29526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=29526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=29526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=29526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 2 args
CallByName(obj=2951dc, method='DropObject', calltype=1 , comArgs=0)

C:\ScriptBASIC\examples>

8
Scripting Languages / Re: Script BASIC COM
« Last post by Mike Lobanovsky on December 12, 2017, 01:19:51 PM »
Re: Jose Roca

No problem, John. Compile this and see what happens: (actually it contains a question to Jose)
Code: C
  1. bool HandleSpecial(VARIANTARG* va, char* str) {
  2.  
  3.     if (str == 0) return false;
  4.  
  5.     std::string s = str;
  6.     //std::string s(str);
  7.  
  8.     if (s.length() < 3) return false;
  9.     if (s.substr(0, 3) != "VT_") return false;
  10.  
  11.     int pos = s.find(":", 0);
  12.     if (pos < 1) return false;
  13.  
  14.     std::string cmd = s.substr(0, pos);
  15.     if (s.length() < pos + 2) return false;
  16.  
  17.     s = s.substr(pos + 1);
  18.  
  19.     //todo implement handling of these types (there are many more than this)
  20.     if (cmd == "VT_I1") {
  21.     } else if (cmd == "VT_I2") {
  22.     } else if (cmd == "VT_I8") {
  23.     } else if (cmd == "VT_BOOL") {
  24.     } else if (cmd == "VT_DISPATCH") {
  25.         // HACK: va->lVal and va->pdispVal are a union, so ...
  26.         va->vt = VT_DISPATCH; // ... we tag this variant as an IDispatch* ...
  27.         va->lVal = atol(s.c_str()); // ... but write its ptr value as an ordinary long to avoid compiler type mismatches
  28.         // @Jose Roca: But where do you suggest I put a matching Release() call?
  29.         // I am NOT A CLIENT, I am JUST A PROXY passing the pointer value but not using it in any way.
  30.         // It's ProvideX.Script which is the IDispatch's client that's supposed to manage its references.
  31.         va->pdispVal->AddRef();
  32.     }
  33.  
  34.     return true;
  35. }

Re: _bus vs. _svc

John, you're mostly talking to yourself here (and evidently dropping out words at times because I can't grasp the meaning of very first sentence). I am not yet in the subject of this project, far from it.

WHICH METHOD CALLS EXACTLY generated the red errors before? Did and do any other method calls OF THE SAME OBJECT INSTANCE work correctly, before and now? What is the meaning of COM numeric returns (retvals) in each method call? Are they successes or failures? Have you ever gotten that message box before in any other contexts? I'm sorry but this isn't at all obvious from the listings you submit.
9
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 11:55:30 AM »
Mike,

Based on the documentation for the AR_Customer_bus object, I don't see where the SY_Service object which contains the methods that are currently generating an error. Why the VBScript version works, I haven't a clue. I substituted the AR_Customer_bus for AR_Customer_svc object which does have the SY_Service object inherited and the calls work without error. I'm still not getting my message box to show a customer record yet but at least the COM interface isn't generating errors Invoking the methods.

Code: Script BASIC
  1. ' Script BASIC PVXCOM Code Challenge
  2.  
  3. IMPORT NT.sbi
  4. IMPORT COM.sbi
  5.  
  6. oscript = COM::CreateObject("ProvideX.Script")
  7. ' HomeDirOK = COM::CallByName(oscript, "Init", vbMethod, NT::RegRead("HKEY_CURRENT_USER\\Software\\ODBC\\ODBC.INI\\SOTAMAS90\\Directory") & "\\HOME")
  8. COM::CallByName(oScript,"Init",vbMethod,"C:\\Sage\\Sage 100 Advanced ERP\\MAS90\\HOME")
  9. osession = COM::CallByName(oscript, "NewObject", vbMethod, "SY_Session")
  10. UserOK = COM::CallByName(osession, "nSetUser", vbMethod, "JRS", "northstar")
  11. CompanyOK = COM::CallByName(osession, "nsetcompany", vbMethod, "ABC")
  12. DateOK = COM::CallByName(osession, "nSetDate", vbMethod, "A/R", "20171119")
  13. ModuleOK = COM::CallByName(osession, "nSetModule", vbMethod, "A/R")
  14. osec = COM::CallByName(osession, "nSetProgram", vbMethod, COM::CallByName(osession, "nLookupTask", vbMethod, "AR_Customer_ui"))
  15. ' ocust = COM::CallByName(oscript, "NewObject", vbMethod, "AR_Customer_ui", "VT_DISPATCH:" & osession)
  16. ocust = COM::CallByName(oscript, "NewObject", vbMethod, "AR_Customer_svc", "VT_DISPATCH:" & osession)
  17. retval = 0
  18. CustomerNo = ""
  19. CustomerName = ""
  20. City = ""
  21. State = ""
  22. TelephoneNo = ""
  23.  
  24. retval = COM::CallByName(ocust, "nSetIndex", vbMethod, "KNAME")
  25. retval = COM::CallByName(ocust, "nFind", vbMethod, "00ABC")
  26. retval = COM::CallByName(ocust, "nMoveNext", vbMethod)
  27. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerNo$", CustomerNo)
  28. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "CustomerName$", CustomerName)
  29. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "City$", City)
  30. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "State$", State)
  31. retval = COM::CallByName(ocust, "nGetValue", vbMethod, "TelephoneNo$", TelephoneNo)
  32.  
  33. retval = NT::MsgBox("Customer:  " & CustomerNo & "  " & CustomerName & "  " & City & "  " & State & "  " & TelephoneNo, "PVXCOM Code Challenge", "OK")
  34. COM::CallByName(osession,"DropObject")
  35. COM::ReleaseObject(oscript)
  36.  


C:\ScriptBASIC\examples>sbwin comcustcc.sb
The number of arguments is: 1
CreateObject(ProvideX.Script)
CallByName 4 args
CallByName(obj=4650bc, method='Init', calltype=1 , comArgs=1)
CallByName 4 args
CallByName(obj=4650bc, method='NewObject', calltype=1 , comArgs=1)
return value from COM function was numeric: 4608476
CallByName 5 args
CallByName(obj=4651dc, method='nSetUser', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=4651dc, method='nsetcompany', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=4651dc, method='nSetDate', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=4651dc, method='nSetModule', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=4651dc, method='nLookupTask', calltype=1 , comArgs=1)
return value from COM function was numeric: 40000001
CallByName 4 args
CallByName(obj=4651dc, method='nSetProgram', calltype=1 , comArgs=1)
return value from COM function was numeric: 100006
CallByName 5 args
CallByName(obj=4650bc, method='NewObject', calltype=1 , comArgs=2)
return value from COM function was numeric: 4608620
CallByName 4 args
CallByName(obj=46526c, method='nSetIndex', calltype=1 , comArgs=1)
return value from COM function was numeric: 1
CallByName 4 args
CallByName(obj=46526c, method='nFind', calltype=1 , comArgs=1)
return value from COM function was numeric: 0
CallByName 3 args
CallByName(obj=46526c, method='nMoveNext', calltype=1 , comArgs=0)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=46526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=46526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=46526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=46526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 5 args
CallByName(obj=46526c, method='nGetValue', calltype=1 , comArgs=2)
return value from COM function was numeric: 1
CallByName 2 args
CallByName(obj=4651dc, method='DropObject', calltype=1 , comArgs=0)

C:\ScriptBASIC\examples>
10
Scripting Languages / Re: Script BASIC COM
« Last post by John on December 12, 2017, 11:13:14 AM »
Mike,

I received an e-mail from Josť Roca with a comment about your fix for the HandleSpecial() routine.

Quote
In his posted workaround it is missing to increase the reference count of the dispatch pointer.

I'm not sure if this is causing the GetIDsOfNames failed errors or not.

I have asked Josť Roca to join us here on the forum. I hope he accepts my invitation,


John
Pages: [1] 2 3 ... 10