Results 1 to 10 of 10

Thread: How to parse BYREF?

  1. #1
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    How to parse BYREF?

    Hi folks,

    I know that you can set the value of parameter variables but I don't know how.
    Petr does this in the TBGL module. Can you show a little example?

    Thanks in advance
    Michael

  2. #2
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: How to parse BYREF?

    Here is the sub where I want to use this:

    [code=qbasic]'**************************************************************************************************
    SUB GetNodeXYZ(),DOUBLE
    '**************************************************************************************************
    DEF id,cid:INT
    DEF i:INT
    DEF posx,posy,posz : DOUBLE
    IF thinBasic_CheckOpenParens(FALSE, FALSE)
    id = thinBasic_ParseDword()
    IF thinBasic_CheckComma()
    posX = thinBasic_ParseDouble()
    IF thinBasic_CheckComma()
    posY = thinBasic_ParseDouble()
    IF thinBasic_CheckComma()
    posZ = thinBasic_ParseDouble()
    IF thinBasic_CheckCloseParens(FALSE, FALSE)
    i = id
    FOR tempData = EACH nodeList
    IF #<NodePoint>tempData.ID = i
    posx = #<NodePoint>tempData.xpos
    posy = #<NodePoint>tempData.ypos
    posz = #<NodePoint>tempData.zpos
    GOTO lFinish232
    ENDIF
    NEXT
    ENDIF
    endif
    endif
    endif
    ENDIF
    RETURN thinbasic_TRUE
    ENDSUB
    [/code]

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    160

    Re: How to parse BYREF?

    are you saying that you want to directly access the memory locations of posx,posy,posz because I dont see any way that thinbasic can pass pointers for IBASIC.

    I dont use IB so this is a quick observation so I could be wrong.

    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: How to parse BYREF?

    Mike,

    I'm sorry but there is no direct interface for IBasic at the moment. Under IBasic SDK we just exposes a little subset of the many interfaces we have developed and usable under PowerBasic. But if you are interested, I think we can quite easily develop them in a short time.

    In details, there are some functions do achieve the job. Those are the templates under Power Basic that we can release also under IBasic. One of the most important is thinBasic_VariableParse function that will perform all the checks and return a pointer to the variable internal descriptor plus the element number in case of an array.

    [code=thinbasic] '----------------------------------------------------------------------------
    'thinBasic_VariableParse
    '----------------------------------------------------------------------------
    ' Instruct parser to get next token, check if variable, check if array and
    ' return all info needed to subsequent change variable value
    '----------------------------------------------------------------------------
    DECLARE FUNCTION thinBasic_VariableParse _
    LIB "thinCore.DLL" _
    ALIAS "thinBasic_VariableParse" _
    ( _
    BYREF VariablePtr AS LONG , _ '---ATTENTION: parameter passed BYREF will return info
    BYREF VariableAbsPos AS LONG _ '---ATTENTION: parameter passed BYREF will return info
    ) AS LONG
    [/code]

    After that you will be able to call thinBasic_ChangeVariableStringDirect or thinBasic_ChangeVariableNumberDirect to change value inside the variable passing back the above parameters and the value you need to assign to the variable:
    [code=thinbasic]
    '----------------------------------------------------------------------------
    'thinBasic_ChangeVariableStringDirect
    '----------------------------------------------------------------------------
    ' See also thinBasic_VariableParse
    '
    ' Change a variable using direct variable pointer's data returned by
    ' thinBasic_VariableParse. This will ensure to work also with arrays
    '----------------------------------------------------------------------------
    DECLARE FUNCTION thinBasic_ChangeVariableStringDirect _
    LIB "thinCore.DLL" _
    ALIAS "thinBasic_ChangeVariableStringDirect" _
    ( _
    BYVAL VariablePtr AS LONG , _
    BYVAL VariableAbsPos AS LONG , _
    BYVAL lValString AS STRING _
    ) AS LONG
    [/code]
    [code=thinbasic]
    '----------------------------------------------------------------------------
    'thinBasic_ChangeVariableNumberDirect
    '----------------------------------------------------------------------------
    ' See also thinBasic_VariableParse
    '
    ' Change a variable using direct variable pointer's data returned by
    ' thinBasic_VariableParse. This will ensure to work also with arrays
    '----------------------------------------------------------------------------
    DECLARE FUNCTION thinBasic_ChangeVariableNumberDirect _
    LIB "thinCore.DLL" _
    ALIAS "thinBasic_ChangeVariableNumberDirect" _
    ( _
    BYVAL VariablePtr AS LONG , _
    BYVAL VariableAbsPos AS LONG , _
    BYVAL lValNumber AS EXT _
    ) AS LONG
    [/code]

    But if you are in hurry, the only possible way to pass a BYREF value in IBASIC is to get its data address (using VARPTR in the script) and change data directly using pointers. It should be possible to do it in IBasic but I do not know how. In PowerBasic you just need to define a variable pointer and than use it.

    I will talk with Roberto about this. He did the IBasic interface.

    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

  5. #5
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: How to parse BYREF?

    Thanks for the info Eros.

  6. #6
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: How to parse BYREF?

    Quote Originally Posted by Abraxas
    are you saying that you want to directly access the memory locations of posx,posy,posz because I dont see any way that thinbasic can pass pointers for IBASIC.

    I dont use IB so this is a quick observation so I could be wrong.

    Yes Abraxas, and like Eros said, with the PowerBasic SDK it is possible. The TBGL module does it quite often. But it isn't a big problem for me that this is not possible with IBasic Pro.

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

    Re: How to parse BYREF?

    Mike,

    in any case we will improve IBasic interface. If you are using IBasic for a new module it is worth for us to support you.
    Just give us some days due to high workload at "real life work"

    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

  8. #8
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: How to parse BYREF?

    Eros, it isn't really needed. Work on it only if you have nothing else better to do.

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

    Re: How to parse BYREF?

    No problem Mike.
    We just need to add a new function interface called something like "thinBasic_ChangeVariableDWORDDirect" because "thinBasic_ChangeVariableNumberDirect" accepts EXTENTED data type while IBasic has no EXT number support.

    While "thinBasic_VariableParse" function interface can be used also for IBasic because it just needs two LONGs passed BYREF

    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

  10. #10
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: How to parse BYREF?

    Another thing why I might not need is that I bumped into a serious speed problem with my module. So I'm not sure if IBP is the problem or the algorythm itself. Could be that I will port it to a different language.

Similar Threads

  1. parse$ or parse direction
    By kryton9 in forum thinBasic General
    Replies: 10
    Last Post: 27-04-2007, 08:29

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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