Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

CharBufferString - Initialize from a WString

stmos
2020-11-12
2022-07-20
  • stmos

    stmos - 2020-11-12

    Hello,
    I can't find a way to initialize a CharBufferString from a WString.

    I've done something similar for a STRING:

    Declaration:

        astring     : STRING(1000);
        cbs         : Stu.CharBufferString(uiBufferSize:=2000, stringType:=__SYSTEM.TYPE_CLASS.TYPE_STRING);
        pst         : POINTER TO STRING;
    

    Code:

    astring:='... a very long string ...';
    cbs.FromString(astring);
    pst := cbs.m_cbpBuffer;
    

    But I can't find a "FromString" method that takes a WSTRING.
    Any idea?

    Thanks in advance.

     
  • sgronchi

    sgronchi - 2020-11-12

    You need to use the method Initialize passing the pointer to the WSTRING and the proper __SYSTEM.TYPE_CLASS, i.e __SYSTEM.TYPE_CLASS.TYPE_WSTRING.

     
  • johndoe67

    johndoe67 - 2022-07-20

    Hello stmos,
    I just start to work with the CharBufferString. Do you maybe have a simple example project to understand how it works?

     
  • stmos

    stmos - 2022-07-20

    Hi,
    I'm sorry, but no... I don't have a sample project at the moment. I'm not even really an expert with the CharBufferString... 😒

     
  • johndoe67

    johndoe67 - 2022-07-20

    Ok, thanks for the quick feedback

     

Log in to post a comment.