BAM BAM - Request for support to remove need of Execute and Eval

Last edited:
I have found external scripts to be more trouble than they are worth. They work fine but end users always seem to be confused with them and they question the need to create a folder named scripts for them. They find it odd they have to create it when all the other folders they need are already created. You will be addressing an endless set of user complaints caused by not saving them correctly. You're better off just saving everything to the script. You might add it to a Notepad file and save it to a folder of other snippets that you can grab when you need them.
 
Last edited:
I have found external scripts to be more trouble than they are worth. They work fine but end users always seem to be confused with them and they question the need to create a folder named scripts for them. They find it odd they have to create it when all the other folders they need are already created. You will be addressing an endless set of user complaints caused by not saving them correctly. You're better off just saving everything to the script. You might add it to a Notepad file and save it to a folder of other snippets that you can grab when you need them.
Yup. People can use the class in the script and add it to their own table's script if they want! I love external scripts when development to better encapsulate work. Scripts for these tables starts to get overwhelming.
 
Yup. People can use the class in the script and add it to their own table's script if they want! I love external scripts when development to better encapsulate work. Scripts for these tables starts to get overwhelming.
You could include the scripts in the table download for people to use if they wish but add them to the table script.
 
Ok, just to understand, that is an "xbam" code that I should insert to avoid giving problems to "those" of eval/execute?
I use eval a lot, and in some cases execute, I have never had problems, as far as I remember I have not had error requests for these commands.
I read a bit, it seems to me that they create slow execution of fp? I read it right?
 
Ok, just to understand, that is an "xbam" code that I should insert to avoid giving problems to "those" of eval/execute?
I use eval a lot, and in some cases execute, I have never had problems, as far as I remember I have not had error requests for these commands.
I read a bit, it seems to me that they create slow execution of fp? I read it right?
Yup. When used a lot or with heavy script tables the calls to Execute can cause a frame or two to be removed/affected. Maybe not an issue on standalone Virtual Pin Machine that perhaps isn't attached to the network. On machines that have Windows Defender you'll still get some impacts, sometimes regardless of "exclusions" that you might do. On a machine not on the network I'd be fine with full Defender disablement.

Rav was showing other ways to avoid Eval on a regular basis.
 
It's probably not possible, but is there any way BAM could be used to extend VBScript to support creating an object by class name?

In a pinball framework I'm constructing, I have to use the ExecuteGlobal to perform a "new" function for an object, which then requires me to have these global objects around for no reason, when I was just trying to dynamically create an instance of a class.

One example you can see below:
C#:
    private function CreateAndRegisterTable(psNameOfTableClass)
        ' create and register the user's table model class
       
        AddDebugText "Creating Table:" & psNameOfTableClass
       
        on error resume next
        Err.Clear
       
        ExecuteGlobal("Set TheGlobalTableName = New "& psNameOfTableClass)
        set moPFTable = TheGlobalTableName
       
        If Err.Number <> 0 Then
         ... <ERROR HANDLING>
        Else

            Err.Clear
            AddDebugText "Registering Table: "
                       
            call moPFTable.RegisterTable(moBaseOptions)
            ... more
 
The ExecuteGlobal command is usually OK. Problems happen when an exe or eval command runs when a ball is in play. ExecuteGlobal usually runs before the ball is released so there is no problem. In fact, it is OK to run any exe or eval command when a ball is not in play.

I am not familiar with your code but it looks like it probably runs when a ball is not in play.
 
...

I am not familiar with your code but it looks like it probably runs when a ball is not in play.
Yup that's correct! Sounds good then. I'll keep with this approach for now.
 
There is iCom plugin for BAM (check plugins dir). It allows to create objects. But first user have to select Security Level:
1741279286816.png
4 levels are available:
- Paranoic (no extension) - there is no way to create objects (lets say it is FP default)
- Very Safe (only whitelisted) - only few classes are allowed: PinUpPlayer & Vpinmame
- Safe (disable blacklisted) - (this is default) some objects types are not allowed, like WScript
- Same as VPX (don't care)

Simple usage:

Code:
dim shell : Set shell = xBAM.Get("iCom").CreateObject("WScript.Shell")
shell.run "cmd.exe rmdir /s /q ""c:\games\future pinball"" "

As you can see this is powerful and dangerous.
 
Thanks
There is iCom plugin for BAM (check plugins dir). It allows to create objects. But first user have to select Security Level:
View attachment 46276
4 levels are available:
- Paranoic (no extension) - there is no way to create objects (lets say it is FP default)
- Very Safe (only whitelisted) - only few classes are allowed: PinUpPlayer & Vpinmame
- Safe (disable blacklisted) - (this is default) some objects types are not allowed, like WScript
- Same as VPX (don't care)

Simple usage:

Code:
dim shell : Set shell = xBAM.Get("iCom").CreateObject("WScript.Shell")
shell.run "cmd.exe rmdir /s /q ""c:\games\future pinball"" "

As you can see this is powerful and dangerous.
Thanks Rav. My objects are simple classes. Just to demonstrate :

in VBScript

Class myClass
End Class

Dim c : c = new myClass


The ability to create an instance of a class with the class name coming from a string.

What I ended up doing was creating a function:

C#:
function createClassInstance(classname)
    On error resume next
    ExecuteGlobal("set pfTempClassInstance = New " & classname)

    Err.Clear : On error goto 0
    set createClassInstance = pfTempClassInstance   
    set pfTempClassInstance = nothing
end function
 
There is iCom plugin for BAM (check plugins dir). It allows to create objects. But first user have to select Security Level:
View attachment 46276
4 levels are available:
- Paranoic (no extension) - there is no way to create objects (lets say it is FP default)
- Very Safe (only whitelisted) - only few classes are allowed: PinUpPlayer & Vpinmame
- Safe (disable blacklisted) - (this is default) some objects types are not allowed, like WScript
- Same as VPX (don't care)

Simple usage:

Code:
dim shell : Set shell = xBAM.Get("iCom").CreateObject("WScript.Shell")
shell.run "cmd.exe rmdir /s /q ""c:\games\future pinball"" "

As you can see this is powerful and dangerous.
As you can see, very safe option is for PinUpPlayet and VPinMAME
Maybe it's time to create a link to VPinMAME, isn't it?
Just my opinion, but as I helped GeorgeH for different tables, struggle with the script in order to have about the same things that the real table is a little bit tedious.
 
@madmrmax
Here is example how to create factory function:
Code:
' lets say we have 2 classes:
Class ClassA
    Dim var1
    Public Property Get Name()
      Name = "A"
   End Property
End Class

Class ClassB
    Dim var1
    Public Property Get Name()
      Name = "B"
   End Property
End Class

' we need 2 functions: class creators
Function makeA
   Set makeA = New ClassA
End Function

Function makeB
   Set makeB = New ClassB
End Function

' create dictionary where string with name is key to "creator" functions 
Dim classDict : Set classDict = xBAM.NewDict

classDict.Add "ClassA", GetRef("makeA")
classDict.Add "ClassB", GetRef("makeB")

' object factory function
Function factory(name)
    Set factory = classDict.Item(name)()
End Function

' tests: create few objects
Dim ca : Set ca = factory("ClassA")
Dim ca2 : Set ca2 = factory("ClassA")
Dim ca3 : Set ca3 = factory("ClassA")
Dim cb : Set cb = factory("ClassB")

' lets set different values for field to be sure, that they are different instances of class, not references to same
ca.var1 = "1st"
ca2.var1 = "2nd"
ca3.var1 = "3rd"
cb.var1 = "is instance of ClassB"

' check: print name of class and field value
AddDebugText ca.Name & " " & ca.var1
AddDebugText ca2.Name & " " & ca2.var1
AddDebugText ca3.Name & " " & ca3.var1

AddDebugText cb.Name & " " & cb.var1

I tested it and it works.


So, limitations:
- you need to know all class names
- you need to create creator function for each class
- you need to add each creator function to dictionary under string key
Creator of each object should be relatively fast.
 
Thanks @ravarcade! Yup good input and it would work in the cases where I know the class names ahead of time definitely.
 
As you can see, very safe option is for PinUpPlayet and VPinMAME
Maybe it's time to create a link to VPinMAME, isn't it?
Just my opinion, but as I helped GeorgeH for different tables, struggle with the script in order to have about the same things that the real table is a little bit tedious.

VPinMAME is a COM class app (no different than PUP, DOF, B2S Server, FlexDMD). That is the only reason its shown as an example of what can be launched if iCOM is set to that level.

Anyone can launch VPinMAME with FP today, but that doesn't mean it can just "work" with FP as it is. You would need to create support for translation from VPinMAME calls to FP functions and also two way communication, etc. There may be custom functions that would need to be added to FP for certain aspects of VPinMAME to be usable as well.

It's not something that would simply work automatically with FP. You guys would need to make it work for each table, and need to know what you are doing (and how vpinmame works, and how the roms work, and how each pinball system works)... and even then it may not be completely possible (without updates to FP being required).

It's much more complex to make work (and keep updated) than most think... not to mention that VP uses it as well and its constantly being updated by others in the VP community... and like it is with VP... compatibility can be broken easily with any new update (happens on VP.... alot)... and that would effect any app using it.
 
As I wrote, it's not simple, this involves a lot of work, but if I can help, why not.
 
General chit-chat
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
  • Quote
  • xenonph @ xenonph:
    I sent you message with pic showing where to make visible adjustment.
    Quote
  • Chat Bot Mibs Chat Bot Mibs:
    Pinped has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    daleks12 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Stephen has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    docdoc has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Exnihilo_Mundus has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    angmarg52 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    tully619 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    smorndb has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Tech49 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Topsi Klaus has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Forsaken43 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    duduky72 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gerge has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    nunolilo has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    DavidT2025 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gary-7 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Thunderbird has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    alug has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    bluebird has left the room.
  • HZR @ HZR:
    It’s nice to go all see a place I can play actual machines!!!!
    Quote
  • Chat Bot Mibs Chat Bot Mibs:
    Sunrise74 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Rai has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    liebowa has left the room.
      Chat Bot Mibs Chat Bot Mibs: liebowa has left the room.
      Back
      Top