New scripting engine - testers wanted!

Everything else that doesn't fall into one of the other PB categories.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: New scripting engine - testers wanted!

Post by Kwai chang caine »

@SROD
INCREDIBLE, never i imagine it's a also big project :shock:
After your COMATE, i say to me, never a project can be also strong than him.

You have wonderfully explain to me, and never you believe, :shock: but i have all understand the goal 8)

When i have say "SCRIPT", i believe it's another project like when several code send PB order in txt and the serveur execute, another PBSCRIPT what.
But no, like usually, you shoot really really more top, like the COMATE class, a SCRIPT like several professionals already use :shock:

I'm really surprising by your and Bitblazer explanations :shock:
I know they are several Script program, but i believe the script one and same part, included in the program, and not a program where after, a Script motor can to be connected :shock:
Anyway, i don't know several program have planned, like say Bitblazer :wink: to accept the connection of a Script motor if we want this function :shock:

Really, how you want that my admiration not increase in the same time you had a line to all your extraordinary projects 8)
I wish you all the courage for terminate it, (the knowledge no need to wish something)
Thanks you in advance, and i follow you the most far possible, for not disturb you another time...
You do not need a ball more, the task is already enough hard :oops:

Image

Again thanks for sent your precious time, again another time, for explain to me :oops:

@Bitblazer
Thanks for your explanation 8) , after reading SROD great explanations and yours, i see it's again a giant professionnal option that SROD try to offer to PB community 8)
Apparently, a more value also big than OLE, and i never believe it's another time possible :shock:

@KIFFY
Really thanks for recognize your unknowledge 8) , if someone like you not understand...i had no chance to understand 8)

@HEXOR
You are a big master of the WEB and network, i have admired several of your codes about this subject 8) i'm not surprising it's you who begin the challenge 8)
Even if the code is for KIFFY, thanks a lot for sharing it 8)
ImageThe happiness is a road...
Not a destination
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: New scripting engine - testers wanted!

Post by HeX0R »

I just had a quite annoying effect, where the exe didn't handle any scripts, while in debugging mode anything worked fine.
Needed to dive into the code and finally found this here in minScriptMAIN.pbi:

Code: Select all

CompilerIf  #PB_Compiler_OS = #PB_OS_Windows 
  If InitScintilla() = 0
    ProcedureReturn 1
  EndIf
CompilerEndIf
This is somewhat misplaced, no?

btw.:
How is the documentation progress going?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

Ah yes I threw that in when I was about to add a Scintilla based code editor type component into the mix, but subsequently changed my mind. That needs to be removed.

Documentation... yea, about that... struggling to find the time right now.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: New scripting engine - testers wanted!

Post by QuimV »

Could someone tell me how I could solve the following code with minScript:

Code: Select all

var1 = 5
var2 = 10
var3 = 0
rel$ = InputRequester("Relation", "New relation betweeen var1 and var2 ", "AND")
;For example: the user enters "AND"
;Now I need to evaluate var3 = var1 rel$ var2, this is  "var3 = var1 AND var2"
;
debug (var3) ;var3 should have the value 1
;
rel$ = InputRequester("Relation", "New relation betweeen var1 and var2 ", "+")
;now the user defines another relationship between v1 and var2, and enters "+"
;So I need to evaluate "var3 = var1 + var2"
;
debug (var3); var3 should have the value 15
:D Thanks in advanced
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

The following lets you type in any expression of the form "result = ..." involving variables var1 and var2. Easily adapted for your uses.
This approach is probably the simplest way to pass some PB variables (by value) to a simple script. If a 'by-reference' mechanism was required then you could pass the addresses of suitable Purebasic variables and use our pointer class etc.

Code: Select all

#minScript_HOME = "c:/PurebasicCode/minScript/Source/"  

;Include the minScript source and check that it initialized ok.
  XIncludeFile #minScript_HOME + "minScript.pbi"
  If minScriptINIT <> #minScript_OKAY
    Debug "minScript failed to initialize correctly."
    End
  EndIf

;Create a minScriptCode object and check the return value.
  Define myCode.minScriptCode
  myCode = minScript_NewCodeObject()
  If myCode = 0 ;Typically a memory allocation issue.
    Debug "Could not create a code object!"
    End
  EndIf

;Create variables.
  var1 = 5
  var2 = 10
  ;Return variable.
    *returnVar.minScriptVariant = myCode\GetReturnVariantPtr()

;Request expression.
  expression$ = InputRequester("", "Expression involving var1 and var2. Must be of the form 'result = ...'", "result = var1 + var2")

;Set up a simple script.
  script$ = "DIM var1, var2, result AS INTEGER" + #CRLF$
  script$ + "var1 = " + Str(var1) + #CRLF$
  script$ + "var2 = " + Str(var2) + #CRLF$
  script$ + expression$ + #CRLF$
  script$ + "RETURN result"
  
  result = myCode\Execute(script$)

  If result <> #minScript_OKAY
    Debug "Execution error info : "
    Debug "  Error code : " + Str(myCode\GetLastErrorCode())
    Debug "  Error source line number : " + Str(myCode\GetLastErrorLineNumber())
  Else
    var3 = *returnVar\i
    Debug "Result = " + Str(var3)
  EndIf

;Release the minScriptCode object.
  myCode\Destroy()
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: New scripting engine - testers wanted!

Post by QuimV »

:D Thank You @srod

If I need decimals. How should I declare the types of the variables?
In the case of the following code, the result is always 0 (without decimals),
Why?

Code: Select all

DIM a as VARIANT
DIM b as VARIANT
DIM c as VARIANT
a=5
b=10
c=a/b
debug(c)
Regards
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

I wouldn't really recommend the use of variants unless you have a good reason for using them.

There are plenty of ways of doing what you want. The simplest way is to define the c variable as a REAL type (or simply define all the variables as REALs).

Code: Select all

DIM a, b as INTEGER
DIM c as REAL
a=5
b=10
c=a/b
DEBUG c
In this case, because c has been declared as a REAL type, the minScript compiler automatically 'promotes' the division to a 'decimal division' which will then yield the correct decimal result 0.5. This is not the case if the variable c is an INTEGER or VARIANT type.

An alternative, if you must use variants, is the use of the % type modifier operator as follows.

Code: Select all

DIM a, b, c as VARIANT
a=5
b=10
c=a%r/b
DEBUG c
In this case, the use of %r (modify type to REAL) has the effect of casting a copy of the a variable to a type REAL. This then forces a decimal division and because the variable c is a VARIANT type, it can then hold the decimal value 0.5.

There is also the following use of the a similar type modifier to actually force one of the two variables to hold a REAL value (even though it is VARIANT type) :

Code: Select all

DIM a, b, c as VARIANT
a=5%r   ;Could use a=5.0 instead although in this case 5.0 is regarded as a CURRENCY type!
b=10
c=a/b
DEBUG c
As I say, I wouldn't recommend the use of VARIANTs when dealing with simple native types. They are really intended for holding class objects and the like.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: New scripting engine - testers wanted!

Post by QuimV »

:D Thank You @srod,

Where can I find the different types of variables, INTEGER, REAL, VARIANT ... and what else? (and its abbreviations, REAL =% r)

Thanks in advanced
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

All there is at the moment are some text files in the /Specifications subfolder.

The expressions.txt file gives some details on expressions although it is a little out of date.

A help manual? Well, I started one, but have no time right now to work on it as it is a very big job! There are only a couple of users of minScript right now and so the effort to create a manual is far more than I can justify right now. :)

NOTE that %r is NOT an abbreviation for REAL; it is a modifier. Do not confuse them.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: New scripting engine - testers wanted!

Post by QuimV »

:D Thanks @srod for your information and for your kind help.
QuimV
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: New scripting engine - testers wanted!

Post by HeX0R »

srod wrote:A help manual? Well, I started one, but have no time right now to work on it as it is a very big job! There are only a couple of users of minScript right now and so the effort to create a manual is far more than I can justify right now. :)
Is there at least something finished showing the coding rules?
I wouldn't be interested in explanations how to integrate it into your host, but if my app goes final some day, I need some raw instructions for end customers to be able to use scripts.

If there is nothing finished and you don't think something like this will be released anytime soon, then please let me know, I have to pull something together then on my own.
I would share it of course, although my version will have some more "special" commands included.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

There will be a point when I need such a manual myself, but there is nothing which would be of any use right now I'm afraid. Sorry. My efforts thus far concentrated on integrating minScript into a host app.
I may look like a mule, but I'm not a complete ass.
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: New scripting engine - testers wanted!

Post by HeX0R »

Seems I found a bug, the script engine dies in following script (I thought hexadecimal numbers are prefixed with $, my fault, anyway, it should never die)

Code: Select all

function main()
  Dim j, k as integer

  k = 2500
  j   = k & $0F
endfunction
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: New scripting engine - testers wanted!

Post by srod »

Fixed. :)

Hex numbers should be prefixed with 0x.
I may look like a mule, but I'm not a complete ass.
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: New scripting engine - testers wanted!

Post by HeX0R »

srod wrote:Hex numbers should be prefixed with 0x.
Yes... yes... I knew this in the past, but I had to extend one of my scripts which I didn't touch for some weeks and just didn't think while extending (as usual) :mrgreen:

Thanks for the fix fix :)

btw.:
You still have this InitScintilla() thing in minScriptMain.pbi
Post Reply