Author Topic: wstring vs string  (Read 161 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 229
    • PluriBASIC
wstring vs string
« on: January 27, 2019, 05:03:06 AM »

 I still haven't found a definitive way to make it. I have these functions:

Code: [Select]
FUNCTION MSGBOX(string aText) AS LONG
   string aCaption = "PluriBASIC"
   dword mOptions = 0
   FUNCTION = ¤MessageBoxa(0, aText, aCaption, mOptions)   
END FUNCTION

FUNCTION MSGBOX(wstring wText) AS LONG
   wString wCaption = "PluriBASIC"
   dword mOptions = 0 
   FUNCTION = ¤MessageBoxw(0, wText, wCaption, mOptions)   
END FUNCTION

FUNCTION MSGBOX(string aText, dword mOptions) AS LONG
   string aCaption = "PluriBASIC a"
   FUNCTION = ¤MessageBoxa(0, aText, aCaption, mOptions)   
END FUNCTION

FUNCTION MSGBOX(wstring wText, dword mOptions) AS LONG
   wString wCaption = "PluriBASIC w"
   FUNCTION = ¤MessageBoxw(0, wText, wCaption, mOptions)   
END FUNCTION

Invoking this code:

Code: [Select]
   MSGBOX (EXE.wsz(@tv, 0, 30))
   MSGBOX (EXE.chr(@tv, 60, 30))
   MSGBOX (EXE.wsz(@tv, 0, 30), 1)
   MSGBOX (EXE.chr(@tv, 60, 30), 1)

 The first 3 work fine, it picks and displays the text correctly. The fourth one picks unicode and displays nothing. It should pick the ANSI one. But it doesnt match "1" with dword, and ends up (wrongly) picking the unicode one (caption displays "PluriBASIC w").

 Attached is an image of the code being converted.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 229
    • PluriBASIC
Re: wstring vs string
« Reply #1 on: January 27, 2019, 05:36:00 AM »

In the above code, using int instead of dword, works fine. :)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3971
    • Oxygen Basic
Re: wstring vs string
« Reply #2 on: January 27, 2019, 07:00:21 PM »
Hi Brian,

This function will support all string combos. Ascii strings are automatically converted to wide.

Code: [Select]
FUNCTION MSGBOX(wstring wText, dword mOptions=0) AS LONG
   wString wCaption = "PluriBASIC w"
   FUNCTION = MessageBoxw(0, wText, wCaption, mOptions)   
END FUNCTION

Brian Alvarez

  • Full Member
  • ***
  • Posts: 229
    • PluriBASIC
Re: wstring vs string
« Reply #3 on: January 27, 2019, 08:01:12 PM »
Thanks charles, i will download latest version to check it out. :)

The one i have displays nothing for ANSI strings when using them
in an unicode function.