Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: FreeBasic strings

  1. #11

    Re: FreeBasic strings

    To avoid duplicating huge Bstrings, for processing in FreeBasic, you can treat them like memory files. You can copy small chunks into FreeBasic Strings or patch FBstring content directly into the Bstring (as long as it fits into the same space).

    Here is a sort of mid$() for extracting FB substrings directly from the Bstring. It's basically the same code as above slightly tweaked.

    FreeBasic Source
    Function midBSTR_to_FBstr( byval srcBSTR as BSTR,byval mi as long, byval le as long ) as string
     dim as long i,v
     dim as any ptr j
     dim as string s
     asm
       mov eax,[srcBSTR]
       mov ecx,[eax-4]
       mov [i],ecx
     end asm
     v=i-mi+1 : if le>v then le=v
     if le>0 then
       s=space$(le) : j=strptr(s)
       asm
        mov esi,[srcBSTR]
        add esi,[mi]
        dec esi
        mov edi,[j]
        mov ecx,[le] 'length of data
        nexch:
         mov al,[esi] ' src
         mov [edi],al ' dest
         inc esi
         inc edi
         dec ecx
        jnz nexch
       end asm
     end if
     function=s
    end function
    

  2. #12

    Re: FreeBasic strings

    And this sub is for patching FBstrings into Bstrings like: mid$(bst,mi)=fbs....

    Again it is based on the previous code.

    FreeBasic Source
    Sub midBSTR( byval sBSTR as BSTR,byval mi as long, s as string )
     dim as long i,v,le
     dim as any ptr j
     asm
       mov eax,[sBSTR]
       mov ecx,[eax-4]
       mov [i],ecx
     end asm
     le=len(s)
     v=i-mi+1 : if le>v then le=v
     if le>0 then
       j=strptr(s)
       asm
        mov edi,[sBSTR]
        add edi,[mi]
        dec edi
        mov esi,[j]
        mov ecx,[le] 'length of data
        nexch:
         mov al,[esi] ' src
         mov [edi],al ' dest
         inc esi
         inc edi
         dec ecx
        jnz nexch
       end asm
     end if
    end sub
    

  3. #13

    Re: FreeBasic strings

    Edited... I think I got it...

    THAT is what I believe I need... because I do know the MID chunks that are edited, and yes, the CWAD data that I am processing like this, is fixed-length... rather... same length. (The length changes from string to string, but the edited portions inside the strings are all the same length. Treated as ASCIIZ, for the text-names, and the DOUBLE values are all the same size also. But one may have 40 and another may have 400... but not from string-in to string-out, just from string-a to string-b, which is not done in the module.)

    I will let you know if I get it to work, when I get back here again...

    Focusing on the FATE and mini-server at the moment.

    TY, Eros an Charles...

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Freebasic Strings again
    By Michael Clease in forum Module SDK (Freebasic version)
    Replies: 7
    Last Post: 20-05-2013, 03: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
  •