Results 1 to 7 of 7

Thread: Suggestion for enhancing thinBasic_LoadSymbol

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733

    Suggestion for enhancing thinBasic_LoadSymbol

    Hi guys,

    I have one mad idea, which could solve 2 problems at the same time:

    * problem #1, some errors at run time occur, because functions have wrong number of parameters, but currently thinBasic engine has no chance to detect it
    * problem #2, where to take description for code tips?

    The possible solution -> adding one more (optional) parameter to the thinBasic_LoadSymbol function, which would be string, specifying some kind of mask for the parameters function can use.

    Simple example:
    thinBasic_LoadSymbol "TBGL_Vertex", _
    %thinBasic_ReturnNone, _
    CODEPTR( Exec_TBGL_Vertex ), _
    %thinBasic_ForceOverWrite, _
    "(x,y,z)"
    The last parameter as a whole can directly serve as help for code tips.

    For checking, you can easily recognize the parameters should start with (, then 2 commas, then ).

    In case of optional parameters, they would be indicated like in help file:
    thinBasic_LoadSymbol "SomeFunction", _
    %thinBasic_ReturnNone, _
    CODEPTR( Exec_SomeFunction ), _
    %thinBasic_ForceOverWrite, _
    "(x,y[,z])"
    This can again be used both by code tips and for syntax check at the time before parsing.

    This is just idea for future, I don't need it currently, but wanted to let you know about it, and possibly discuss the problems of this solution.

    Regarding the parameter description, instead of just "x" in above example, some special characters could be added to add more info for use with code tips:
    thinBasic_LoadSymbol "SomeFunction", _
    %thinBasic_ReturnNone, _
    CODEPTR( Exec_SomeFunction ), _
    %thinBasic_ForceOverWrite, _
    "(x?X coordinate,y?Y coordinate[,z?Z coordinate])"
    or to not bloat module, just command TB to seek for more info in help files automatically:

    thinBasic_LoadSymbol "SomeFunction", _
    %thinBasic_ReturnNone, _
    CODEPTR( Exec_SomeFunction ), _
    %thinBasic_ForceOverWrite, _
    "(x,y[,z])@HELPFILE:thinbasic_tbgl.chm@"

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    Petr,

    I'm checking you suggestion. I think we already discussed something similar in the past.

    It is quite simple to implement it, at least for storing passed data (and I've already done it).
    The problem is that we have to recompile all modules because an additional parameter, even if optional, must be known by all modules.
    So, ... modules developed by me there is no problem.
    Modules developed by you and others like Michael and Charles must be recompiled with the new thinCore.inc file I will distribute.

    Regarding the syntax, I would prefer full syntax like "BYVAL X AS LONG [, BYVAL Y AS NUMBER]" or something like that because it would be better for help and for parsing instead to invent a new syntax.

    If this is acceptable I can start working on it.
    This would create a sort of self documented language.

    Ciao
    Eros

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    Hi Eros,

    for me it is 100% acceptable

    Another alternative would be adding new:
    thinBasic_DefSymbolParams(sName, sParams)
    -> I am not sure how much it is suitable for non-PB SDK languages to have optional string parameter in thinBasic_LoadSymbol.
    If OK, I would go the way you proposed.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    Petr,

    I will add a new SDK function:
    [code=thinbasic] Declare Function thinBasic_LoadSymbolEX _
    Lib "thinCore.DLL" _
    Alias "thinBasic_LoadSymbolEX" _
    ( _
    ByVal SymbolName As String , _
    ByVal ReturnCode As Long , _
    ByVal FunctionOrSubPointer As Dword , _
    Optional _
    ByVal ForceOverWrite As Long , _
    ByVal sSyntax As String , _
    ByVal sHelp As String _
    ) As Long[/code]
    In this way it will not be necessary to recompile any module.
    Those willing to add syntax and/or help instructions to keywords will just need to change from
    "thinBasic_LoadSymbol"
    to
    "thinBasic_LoadSymbolEX"
    and add relevant informations.

    I will post soon a new thinCore.dll and thinCore.inc files so you can test it. New core will have a new function called "APP_ListKeywordsAndSyntax[(KeySep [, SynSep])]" able to return keywords plus additional info.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    Perfect,

    thanks a lot!
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    Petr,

    in current beta 1.7.10.2 I've already developed what you suggested.
    Check \thinBasic\SDK\SDK.ZIP and get PB version.
    You will find new Core interface function "thinBasic_LoadSymbolEX" you can use to pass additional syntax and help to keywords of your modules.

    To get back info from engine inside scripts you can use a new APP_... function called "APP_ListKeywordsAndSyntax" like in the following example:
    [code=thinbasic]
    Uses "console"
    Uses "file"

    DIM sKeys AS STRING
    DIM aKeys() AS STRING
    DIM nKeys AS LONG
    DIM Count AS LONG
    DIM sOut AS STRING
    Dim sFileOut As String Value APP_ScriptPath & "KeywordsAndHelp.txt"

    PrintL "Exporting keywords and syntax"
    '---Get a string with keywords, syntax and help'
    '---Each keyword is separated by $CRLF
    '---Syntax and help is separated by $TAB
    sKeys = APP_ListKeywordsAndSyntax
    '---Is is possible to indicate keys and help separators like the following:
    'sKeys = APP_ListKeywordsAndSyntax($CRLF, ";")

    '---Parse string into an array
    Parse sKeys, aKeys, $CRLF

    '---Creates output buffer
    nKeys = UBOUND(aKeys(1))
    FOR Count = 1 TO nKeys
    if aKeys(Count) = "" then iterate for
    IF aKeys(Count) = "REM" then iterate for
    IF aKeys(Count) = "|" then iterate for

    sOut += aKeys(Count) & $CRLF
    Console_ProgressBar(1, 35, 1, 45, 24, 1, nKeys, Count)

    Next


    PrintL "Saving file ", sFileOut

    '---Save buffer into .txt file
    FILE_Save(sFileOut, sOut)

    PrintL "Done"
    WaitKey
    [/code]

    Let mw know.
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733

    Re: Suggestion for enhancing thinBasic_LoadSymbol

    It works as expected, so I will prepare TBGL with this new SDK.


    Thanks!,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Members who have read this thread: 1

Posting Permissions

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