Bin2String It's possible

 

We were often told that there is no way to convert a binary field to a character field (or any other field) from within Omnis. This however is not correct - it can be done. This is not my fastest one, however it is plain and neat - so instead of a file I place the algorithm here:

 

(C) 1997 by T H E  O M N I S  L /\ B - Mischa Klement

Parameter pBin (Field name) ; binfield to convert
Local variable mString (Character 10000000) Local variable mLen (Long integer) Local variable mCount (Long integer) Local variable mStr (Character 1) Optimize procedure Calculate mLen as ENV002D(pBin) For mCount from 1 to mLen step 1
Calculate mStr as chr(mod(ENV002C(ENV002A(pBin,mCount,1)),256)) Calculate mStr as chr(mod(ENV002C(chr(mod(ENV002C(mStr),256))),256)) Calculate mStr as chr(mod(ENV002C(chr(mod(ENV002C(mStr),256))),256)) Calculate mStr as chr(mod(ENV002C(chr(mod(ENV002C(mStr),256))),256)) Calculate mString as con(mString,chr(mod(ENV002C(mStr),256))) End For Calculate pBin as mString

 

Note that this algorithm requires the ENV002 external, that comes with your OMNIS 7 installation. You might want to pass pBin as value und return the calculated mString field to the calling procedure instead of passing and receiving as reference as it is pointed out here.

Go to top
JSN Boot template designed by JoomlaShine.com