Results 1 to 9 of 9

Thread: "Scripting" language

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    How about using PascalScript by RemoteObjects (might mess up name)? You'd be able to expose procedures, types and variables to scripts and scripts would be coded with Pascal with which you are familiar with?

    Granted, they are VCL/LCL-based, but you can create them in code or if you prefer visual approach, place them visually on data module and then create this data module (from my understanding all are non-visual).

  2. #2
    I actually used this for some of my previous projects. Works great but for what I need for this project its a bit to heavy.

  3. #3
    Ah, okay. If that's the case... I just thought you don't know about PascalScript.

  4. #4
    I redid the parsing of the commands:

    - 60% faster parsing
    - Better syntax checking
    - Less and cleaner code
    - Fix a load of small bugs

    Regards,
    Luuk
    Attached Files Attached Files

  5. #5
    Hi Luuk, nice work

    I just looked at your code, rather neat.

    I have coded an extra Params() function for a variable amount of params that you could use instead of using the multiple functions if you wish...

    Code:
    function Params(const p: array of TParam): TParams; overload;
    
    
    implementation
    
    {...}
    
    
    function Params(const p: array of TParam): TParams; overload;var
      i: Integer;
    begin
      setLength(Result,Length(p));
      for i := 0 to High(p) do
        result[i] := p[i];
    end;
    You would use it like so (adding any amount of params to the 'list' between the '[' and ']'):

    Code:
    Command('SetValues', @SetValues, Params([p(PT_BOOL), p(PT_INT), p(PT_FLOAT), p(PT_STR)]));
    cheers,
    Paul

  6. #6
    Thank paul Made the following changes.

    - Unlimited parameters (Thanks to Pauls suggestion.)
    - Again less and cleaner code
    - Streamlined the error messaging

    I think the code is as streamlined and optimised as can be now so this is probably the final version

    Regards,
    Luuk
    Attached Files Attached Files

  7. #7
    There are some little things you could clean, that compiler still tells

    ignore? - scripting.pas(81,27) Hint: Local variable "c" does not seem to be initialized
    *see below 1) - scripting.pas(212,16) Warning: Local variable "str" does not seem to be initialized
    ignore? - scripting.pas(238,36) Hint: Local variable "c" does not seem to be initialized
    remove - scripting.pas(133,3) Note: Local variable "com" not used
    remove - Unit1.pas(36,23) Hint: Parameter "params" not used
    remove - Unit1.pas(41,29) Hint: Parameter "params" not used
    ignore? - Unit1.pas(63,33) Hint: Local variable "freq" does not seem to be initialized
    ignore? - Unit1.pas(64,32) Hint: Local variable "start" does not seem to be initialized
    ignore? - Unit1.pas(66,31) Hint: Local variable "stop" does not seem to be initialized
    remove - Unit1.pas(6,12) Hint: Unit "messages" not used in Unit1
    remove - ScriptingTest.lpr(12,15) Warning: Symbol "MainFormOnTaskBar" is not portable

    1) Line is str := str + script[i]; where str was not initialized (meaning str := ''; ). It could be that compiler nulls dynamic arrays and strings, but i'm not sure if it does on all possible fpc compilers and their settings.

    Lots of 'Local variable X does not seem to be initialized' could be rid of by changing "var" to "out", but i just recently read that fpc might allocate that parameter for itself, instead of using the parameter reference... That might slow down performance slightly if so.
    edit: In my test app var, out and pointer perform pretty much the same. I had 1 parameter record with 1kb data.
    Last edited by User137; 24-07-2013 at 08:46 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •