Oct 24, 2003 #1 bms1 Programmer Dec 26, 2002 8 US Does anyone have code or a utlilty to convert a string to a BSTRING.
Oct 25, 2003 1 #2 ShankarJ Programmer Aug 9, 2003 856 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. Upvote 0 Downvote
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.
Oct 25, 2003 #3 ShankarJ Programmer Aug 9, 2003 856 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) Upvote 0 Downvote
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)