Results 1 to 3 of 3

Thread: byref or not byref that is the question.

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

    byref or not byref that is the question.

    When working with strings in PB does the ParseSTRING make a local copy or am I working from original data.

    simple example of what i mean.

    [code=thinbasic] '----------------------------------------------------------------------------
    FUNCTION Exec_TBZZ_String2String() AS LONG
    ' load a bitmap.
    ' Usage: n = TBZZ_String2String ( StringtoCopy, StringCOPY as STRING)
    '----------------------------------------------------------------------------

    LOCAL String1 AS STRING
    LOCAL String2 AS STRING

    IF thinBasic_CheckOpenParens() THEN
    thinBasic_ParseSTRING String1
    IF thinBasic_CheckComma() THEN
    thinBasic_ParseSTRING String2
    IF thinBasic_CheckCloseParens() THEN

    string2 = string1


    END IF
    END IF
    END IF

    END FUNCTION
    [/code]
    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

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

    Re: byref or not byref that is the question.

    Abraxas,

    in your example, all strings are local.
    [code=thinbasic]

    thinBasic_ParseSTRING String1

    [/code]
    Get a string from the script and make a local module copy.
    The same in
    [code=thinbasic]

    thinBasic_ParseSTRING String2

    [/code]

    To return a modified string you can use the function name. Declare function AS STRING, define in your LoadLocalSymbols something like:
    [code=thinbasic]

    thinBasic_LoadSymbol "TBZZ_String2String" , %thinBasic_ReturnString , CodePtr(Exec_TBZZ_String2String ), %thinBasic_ForceOverWrite

    [/code]
    and inside your function something like:
    [code=thinbasic]

    FUNCTION = String1

    [/code]
    or whatever you want to return.

    _________________________________________________
    Instead, if you want to have a parameter passed BYREF to your module function, please have a look at this post here: http://community.thinbasic.com/index...sg4452#msg4452

    If you need more info, let me know and I will give all the info you need. I'm going home from work right now so please excuse me if I will reply a bit later.

    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
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    160

    Re: byref or not byref that is the question.

    Is this information still valid or has it been replaced with something new?

    I was wanting to byref a string.

    Mike
    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

Similar Threads

  1. Dim Byref
    By Charles Pegge in forum O2h Compiler
    Replies: 1
    Last Post: 22-07-2009, 12:27

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
  •