Results 1 to 1 of 1

Thread: using byref + strptr

  1. #1

    using byref + strptr

    http://www.thinbasic.com/community/s...5317#post85317

    here's a little example for using "byref" + "strptr"

    ' Empty GUI script created on 11-16-2011 10:24:41 by largo_winch (ThinAIR)
    ' Empty GUI script created on 11-15-2011 23:44:20 by largo_winch (ThinAIR)
     
    Uses "console"
     
    Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _
        ByRef pDst As Any, _
        ByRef pSrc As Any, _
        ByVal ByteLen As Long)
     
    '---------------->
    Sub myexample()  
    '---------------->
        Const TEST_TEXT As String = "Hello Largo "
         
        Dim strString As String
        Dim lngCounter As Long, lngPosition As Long
         
        strString = $SPC(50 * Len(TEST_TEXT))
         
        For lngCounter = 1 To 50
             
            Call CopyMemory(ByVal StrPtr(strString) + lngPosition, _
                ByVal StrPtr(TEST_TEXT), Len(TEST_TEXT) )
             
            lngPosition = lngPosition + Len(TEST_TEXT)       
        Next
         
        PrintL strString
        PrintL test_text
         
    End Sub
     
    PrintL myexample()
    PrintL
    
    PrintL "push a key to exit example"
    WaitKey
    
    '-------------------------------------------->
    
    '-----------------> but take attention: new win api (winNT include file) using other declare statements ------------------------------>
    'Declare Sub CopyMemory Lib "KERNEL32.DLL" Alias "RtlMoveMemory" ( _
    '   ByVal Destination As DWord _                         ' __in PVOID Destination
    ' , ByVal Source As DWord _                              ' __in const VOID* Source
    ' , ByVal Length As DWord _                              ' __in SIZE_T Length
    ' )                                                      ' void
    '------------------------------------------------------------------------------------>
    
    bye, largo
    Attached Files Attached Files

Similar Threads

  1. byref parameter
    By largo_winch in forum thinBasic General
    Replies: 23
    Last Post: 16-11-2011, 22:33
  2. byref or not byref that is the question.
    By Michael Clease in forum Module SDK (Power Basic version)
    Replies: 2
    Last Post: 04-11-2010, 02:55
  3. Dim Byref
    By Charles Pegge in forum O2h Compiler
    Replies: 1
    Last Post: 22-07-2009, 12:27
  4. How to parse BYREF?
    By Michael Hartlef in forum Module SDK (IBasic version)
    Replies: 9
    Last Post: 07-10-2007, 10:26

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
  •