Results 1 to 7 of 7

Thread: [LAPE] memCopy ? Move ?

  1. #1
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default [LAPE] memCopy ? Move ?

    I see there are functions in Lape for memory management, like allocMem, FreeMem, CompareMem, but is there a function to copy memory ?


    @nielsie95 said that you can use Move to copy data ,although this function is on function list but Simba doesn't seem to recognize it:
    Code:
    Error: Unknown declaration "Move" at line 27
    So, how to do it ?

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by bg5 View Post
    I see there are functions in Lape for memory management, like allocMem, FreeMem, CompareMem, but is there a function to copy memory ?


    @nielsie95 said that you can use Move to copy data ,although this function is on function list but Simba doesn't seem to recognize it:
    Code:
    Error: Unknown declaration "Move" at line 27
    So, how to do it ?
    MemMove() iirc

  3. #3
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

  4. #4
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Yeah as he said, it's renamed to MemMove in Simba (for no apparent reason). In lape itself it's named Move, same goes for FPC/Lazarus and Delphi.
    Edit: If you are dealing with actual array's, you can use the Copy function builtin to lape.
    Last edited by slacky; 10-15-2017 at 12:57 PM.
    !No priv. messages please

  5. #5
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Yeah as he said, it's renamed to MemMove in Simba (for no apparent reason). In lape itself it's named Move, same goes for FPC/Lazarus and Delphi.
    And it doesn't appear on function list. How do you actually know such functions (and other hidden ones) exist ? ;-)

    Edit: If you are dealing with actual array's, you can use the Copy function builtin to lape.
    I have only such thing, definition without parameters, so I guess it doesn't work. Maybe there is another name for it too ?

  6. #6
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by bg5 View Post
    And it doesn't appear on function list. How do you actually know such functions (and other hidden ones) exist ? ;-)


    I have only such thing, definition without parameters, so I guess it doesn't work. Maybe there is another name for it too ?
    It's the same parameters as the string copy (arr, start, count). It has to parameters in the function list because it's not declared like a regular method (it's magic!).

    Simba Code:
    aItems.addStrings(['procedure Write(Args: Anything); begin end;',
                         'procedure WriteLn(Args: Anything); begin end;',
                         'procedure SetLength(var A: array of Anything; Length: Int32); overload; begin end;',
                         'procedure SetLength(var S: String; Length: Int32); overload; begin end;',
                         'function Length(A: array of Anything): Int32; overload; begin end;',
                         'function Length(S: String): Int32; overload; begin end;',
                         'function High(A: array of Anything): Int32; overload; begin end;',
                         'function High(E: Enum): Int32; overload; begin end;',
                         'function Low(A: array of Anything): Int32; overload; begin end;',
                         'function Low(E: Enum): Int32; overload; begin end;',
                         'procedure Insert(Source: Anything; var Dest: array of Source; Index: Int32 = 0); overload; begin end;',
                         'procedure Insert(Source: String; var Dest: String; Index: Int32 = 1); overload; begin end;',
                         'procedure Delete(var Source: array of Anything; Index, Count: Int32); overload; begin end;',
                         'procedure Delete(var Source: String; Index, Count: Int32); overload; begin end;',
                         'function Copy(Source: array of Anything; Index: Int32 = 0; Count: Int32 = High(Int32)): array of Source; overload; begin end;',
                         'function Copy(Source: String; Index: Int32 = 1; Count: Int32 = High(Int32)): String; overload; begin end;',
                         'procedure Swap(var A, B: Anything); begin end;',
                         'function Inc(var i: Ordinal; Amount: Int32 = 1): Int32; begin end;',
                         'function Dec(var i: Ordinal; Amount: Int32 = 1): Int32; begin end;']);
    Last edited by Olly; 10-16-2017 at 04:21 AM.

  7. #7
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by bg5 View Post
    And it doesn't appear on function list. How do you actually know such functions (and other hidden ones) exist ? ;-)

    I have only such thing, definition without parameters, so I guess it doesn't work. Maybe there is another name for it too ?
    Builtin special function aren't fully defined in the func list - due to them not taking any specific parameters, they are "dynamically" created when you use it in a script for those specific parameters you have supplied it. How do you know SetLength, Low/High, Inc/Dec, WriteLn etc exist? You just learn it one way or another over time, I'd assume most people who use Simba a bit knows about mose these builtin methods.

    How I know they exist is because I involved myself somewhat in Lape and Simba as soon as I came around these parts of the internet. And they are mentioned in various threads on the forum, they are easy to find in the lape source code, and have a clear commit message (Copy, Delete, Insert) explaining them.
    Last edited by slacky; 10-16-2017 at 03:01 PM.
    !No priv. messages please

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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