Author Topic: ScriptLess Scripting  (Read 468 times)

0 Members and 1 Guest are viewing this topic.

John Spikowski

  • Administrator
  • *****
  • Posts: 54
ScriptLess Scripting
« on: June 12, 2021, 10:44:17 pm »
I wanted to get ScriptBasic to work as my scripting engine for Sage 100 when the Sage Custom Office scripting solution falls short of my needs. I'm still putting the pieces together but here is a few examples I've got working so far. I should be able to create any type of control to script and not just buttons. Sage development personal has cautioned me that my direction may cause issues with existing functionality. I think they also feel better about keeping development within their defined scope.

My focus with Sage 100 is extending it externally without having to be a Master Developer to offer custom solutions.  Sage supports 100 if modifications are done via scripting as they can be turned off and default functionality restored for support debugging if a problem surfaces.

The Test Button attachment calls ScriptBasic as a DLL and runs the messagebox script with whatever Sage 100 variables I chose to pass. (script object, current business object, ...) Since ScriptBasic is seen as a DLL call in the same Windows process as Sage 100, I'm able to pass pointers to object references and use them within a ScriptBasic script.

The Zip Code attachment shows handling a focus event when the user enters an already defined 100 control.

I plan on using this scripting method with projects I do for clients.

ScriptBasic is a great option for external scripting and as a web server getting your business connected to the cloud.

 
« Last Edit: June 13, 2021, 09:44:28 pm by John Spikowski »

John Spikowski

  • Administrator
  • *****
  • Posts: 54
Re: ScriptLess Scripting
« Reply #1 on: June 23, 2021, 01:23:32 am »
After a lot of digging trying to create iDispatch pointers I could pass to ScriptBasic in a DLL call, it gets pretty ugly and I'm not sure the value created by ProvideX is actually an iDispatch pointer.

Code: [Select]
DEF OBJECT oSession_Proxy, "*PROXY";ON EVENT FROM oSession_Proxy PROCESS %SYS_SS;DEF OBJECT oSession_Variant, "*VARIANT";oSession_Variant'Val.Put(*oSession_Proxy);MSGBOX STR(oSession_Variant'Val)

See attached for the MSGBOX value.

I'm able to create a Customer Maintenance screen in ScriptBasic using BOI as if it was created from the 100 launcher. At least in this environment I have iDispatch pointers to all the 100 objects to script the screen in anyway I wish.

Code: Script BASIC
  1. ' COM - AR_Customer
  2.  
  3. IMPORT COM.sbi
  4.  
  5. oscript = COM::CREATE(:SET, "ProvideX.Script")
  6. COM::CBN oScript, "Init", :CALL, "C:\\Sage\\Sage 100 Standard\\MAS90\\Home"
  7. osession = COM::CBN(oscript, "NewObject", :SET, "SY_Session")
  8. COM::CBN osession, "nSetUser", :CALL, "UserID", "Password"
  9. COM::CBN osession, "nsetcompany", :CALL, "ABC"
  10. COM::CBN osession, "nSetModule", :CALL, "A/R"
  11. mdate = COM::CBN(osession, "sModuleDate", :GET)
  12. COM::CBN osession, "nSetDate", :CALL, "A/R", mdate
  13. COM::CBN osession, "nSetProgram", :CALL, COM::CBN(osession, "nLookupTask", :CALL, "AR_Customer_ui")
  14. oui = COM::CBN(oscript, "NewObject", :SET, "AR_Customer_ui", osession)
  15. COM::CBN oui, "nProcess", :CALL, "01MAVRK"
  16.  
  17. COM::CBN oui,"DropObject", :CALL
  18. COM::RELEASE oui
  19. COM::CBN osession, "DropObject", :CALL
  20. COM::RELEASE osession
  21. COM::RELEASE oscript
  22.  

I don't give up easy but trying to use ScriptBasic as an internal scripting engine seems like a waste of my time.
« Last Edit: June 24, 2021, 12:27:47 am by John Spikowski »

John Spikowski

  • Administrator
  • *****
  • Posts: 54
Re: ScriptLess Scripting
« Reply #2 on: June 23, 2021, 02:28:39 pm »
Here is an example of creating the Sales Order entry screen in BOI.

Code: Script BASIC
  1. ' COM - BOI Sales Order
  2.  
  3. IMPORT COM.sbi
  4.  
  5. oscript = COM::CREATE(:SET, "ProvideX.Script")
  6. COM::CBN oScript, "Init", :CALL, "C:\\Sage\\Sage 100 Standard\\MAS90\\Home"
  7. osession = COM::CBN(oscript, "NewObject", :SET, "SY_Session")
  8. COM::CBN osession, "nSetUser", :CALL, "UserID", "Password"
  9. COM::CBN osession, "nsetcompany", :CALL, "ABC"
  10. COM::CBN osession, "nSetModule", :CALL, "S/O"
  11. mdate = COM::CBN(osession, "sModuleDate", :GET)
  12. COM::CBN osession, "nSetDate", :CALL, "S/O", mdate
  13. COM::CBN osession, "nSetProgram", :CALL, COM::CBN(osession, "nLookupTask", :CALL, "SO_SalesOrder_ui")
  14. oui = COM::CBN(oscript, "NewObject", :SET, "SO_SalesOrder_ui", osession)
  15. COM::CBN(oui, "nProcess", :CALL)
  16.  
  17. COM::CBN oui,"DropObject", :CALL
  18. COM::RELEASE oui
  19. COM::CBN osession, "DropObject", :CALL
  20. COM::RELEASE osession
  21. COM::RELEASE oscript
  22.