Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BSTRING Conversion 1

Status
Not open for further replies.

bms1

Programmer
Dec 26, 2002
8
US
Does anyone have code or a utlilty to convert a string to a BSTRING.
 
I think there is an inbuilt clarion function for it and is documented in the ABDST.clw in the \c55\libsrc directory.

MODULE('CLA')
BString2String(LONG, LONG, BOOL),NAME('Cla$BString2String')
END

BSTRING's are equated as LONG integers in Clarion.
 
Since I could not find any more info on the inbuilt function, I have written a function to do it using 2 API functions.

EMBED : Inside the GLOBAL Map

MODULE('api')
lstrlenW(long lpWString),signed,proc,pascal
WideCharToMultibyte(ulong,ulong,Long,long,long,Long,long,long),bool,pascal,raw,proc
END

If inpBSTR is the BSTRING and outCSTR is the CSTRING to be returned :

ConvertBSTRINGtoCSTRING(LONG inpBSTR, *CSTRING outCSTR),BYTE

ReqLen LONG,AUTO
CharWritten LONG,AUTO

CODE

CLEAR(outCSTR)

ReqLen = lstrlenw(inpBSTR)
IF ~ReqLen THEN RETURN(False).
IF SIZE(outCSTR)-1 < ReqLen THEN RETURN(False).

CharWritten = WideCharToMultiByte(0, 0, inpBSTR, ReqLen, ADDRESS(outCSTR), SIZE(outCSTR)-1, 0, 0)
IF ~CharWritten THEN RETURN(False).

outCSTR[Charwritten+1] = '<0>'

RETURN(True)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top