1. Buat New Function dengan function name "f_hex_to_bin"
2. Isi Return Type dengan "string"
3. Isi Argument Type dengan "string" dan Argument Name dengan "as_param_hex"
4. Tuliskan powerscript dibawah ini
5. Selamat mencoba...
integer i,li_length
string ls_param_hex,ls_hex,ls_binary,ls_huruf
ls_param_hex = trim(as_param_hex)
li_length = len(ls_param_hex)
for i = 1 to li_length
ls_huruf = Mid(ls_param_hex, i,1)
choose case ls_huruf
case '0'
ls_binary = '0000'
case '1'
ls_binary = '0001'
case '2'
ls_binary = '0010'
case '3'
ls_binary = '0011'
case '4'
ls_binary = '0100'
case '5'
ls_binary = '0101'
case '6'
ls_binary = '0110'
case '7'
ls_binary = '0111'
case '8'
ls_binary = '1000'
case '9'
ls_binary = '1001'
case 'A'
ls_binary = '1010'
case 'B'
ls_binary = '1011'
case 'C'
ls_binary = '1100'
case 'D'
ls_binary = '1101'
case 'E'
ls_binary = '1110'
case 'F'
ls_binary = '1111'
end choose
ls_hex = ls_hex + ls_binary
next
return ls_hex
string ls_param_hex,ls_hex,ls_binary,ls_huruf
ls_param_hex = trim(as_param_hex)
li_length = len(ls_param_hex)
for i = 1 to li_length
ls_huruf = Mid(ls_param_hex, i,1)
choose case ls_huruf
case '0'
ls_binary = '0000'
case '1'
ls_binary = '0001'
case '2'
ls_binary = '0010'
case '3'
ls_binary = '0011'
case '4'
ls_binary = '0100'
case '5'
ls_binary = '0101'
case '6'
ls_binary = '0110'
case '7'
ls_binary = '0111'
case '8'
ls_binary = '1000'
case '9'
ls_binary = '1001'
case 'A'
ls_binary = '1010'
case 'B'
ls_binary = '1011'
case 'C'
ls_binary = '1100'
case 'D'
ls_binary = '1101'
case 'E'
ls_binary = '1110'
case 'F'
ls_binary = '1111'
end choose
ls_hex = ls_hex + ls_binary
next
return ls_hex
Lain kali saya akan coba untuk membuat function2 yang semoga bisa bermanfaat untuk para penggemar PB.
Tidak ada komentar:
Posting Komentar