![Avatar of Amrit Samtani](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
Amrit Samtani
asked on
FastReport / Report Query Help - How do i convert a integer value into a string ?
I am using FastReport to create my reports right now, and i have an issue.
I have an one data attribute named "ProductMaster.ITEMBUYINGP RICE".
The output of this data is a 6 digit value showing the cost price. Let us say, for example its 205,450 .
However since this report needs to be printed . I need to encrypt the costs into an alphabetical value so only certain staffs who know the encryption would be able to know the cost . Therefore i need the report to automatically convert the data stored in ITEMBUYINGPRICE into a string value
My formula is as follows :
V = 1
G = 2
O = 3
B = 4
I = 5
N = 6
D = 7
R = 8
A = 9
M = 0
Therefore the cost above would read as "GMIBIM"
Could you guide me as to how/what function i should use to code this into the report?
Thanks
I have an one data attribute named "ProductMaster.ITEMBUYINGP
The output of this data is a 6 digit value showing the cost price. Let us say, for example its 205,450 .
However since this report needs to be printed . I need to encrypt the costs into an alphabetical value so only certain staffs who know the encryption would be able to know the cost . Therefore i need the report to automatically convert the data stored in ITEMBUYINGPRICE into a string value
My formula is as follows :
V = 1
G = 2
O = 3
B = 4
I = 5
N = 6
D = 7
R = 8
A = 9
M = 0
Therefore the cost above would read as "GMIBIM"
Could you guide me as to how/what function i should use to code this into the report?
Thanks
![Avatar of PortletPaul](https://filedb.experts-exchange.com/files/public/2021/3/25/63be102b-64fe-48d6-992b-e28b09bac9a2.png)
what is the dbms type & version you are using?
![Avatar of Ryan Chong](https://filedb.experts-exchange.com/files/public/2021/2/28/d39a9608-d1c4-436f-9ad6-5b7ce32e1884.png)
what's the database you're using? perhaps you can have a custom function to do the conversion of field: ProductMaster.ITEMBUYINGPR ICE before passing the query to fast report? does it make sense to you?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of Geert G](https://filedb.experts-exchange.com/files/public/2014/1/14/c032cb16-4dd7-48a7-a3fe-029a3278158d.png)
delphi code is similar
a little bit compacter with a for than sinisa's code
a little bit compacter with a for than sinisa's code
function PriceCrypto(price: string): string;
const ch = 'MVGOBINDRA';
var I: Integer;
begin
Result := Price;
for I := 0 to 9 do
Result := StringReplace(Result, IntToStr(I), Copy(ch, I+1, 1), [rfReplaceAll]);
end;
There was mention of a scripting tool, Fast Scripts, that might be able to do what you want.
mlmcc