Thursday, May 10, 2007

Fungsi Terbilang (Powerbuilder)

//-----
num = truncate(num,0)
//------

double a, b
double c, d
boolean suff, done
string abjad[9]
string str_milyar, str_juta, str_ribu, str_satuan, str
double e1,e2,e3, tmp, tmp2, ix, jx

if num = 0 then
return('Nol')
end if

suff = true
str = ''
str_milyar = ''
str_juta = ''
str_ribu = ''
str_satuan = ''

abjad[1] = 'satu'
abjad[2] = 'dua'
abjad[3] = 'tiga'
abjad[4] = 'empat'
abjad[5] = 'lima'
abjad[6] = 'enam'
abjad[7] = 'tujuh'
abjad[8] = 'delapan'
abjad[9] = 'sembilan'


// ************************************* JUTAAN / MILLION*************************************
c = 100000000
d = 1000000

a = 100000
b = 1000000
ix = c * d
done = false
do while (not done)
// first
e1 = int(num / ix)
tmp = mod(num, ix)
num = num - (e1 * ix)

// second
e2 = int(tmp/ (ix/10) )
tmp2 = mod(tmp, (ix/10) )
num = num - (e2 * (ix/10))

// third
e3 = int(tmp2/ (ix/100) )
num = num - (e3 * (ix/100))

if e1=1 then
str = str + 'seratus '
else
if (e1 > 1 and e1 <= 9) then
str = str + abjad[e1] + ' ratus '
end if
end if

if (e2=1 and e3 = 0) then
str = str + 'sepuluh '
//suff = false
else
if (e2=1 and e3 = 1) then
str = str + 'sebelas '
//suff = false
else
if (e2=1 and e3 >= 2) then
str = str + abjad[e3] + ' belas '
else
if (e2>1 and e2<=9) then
str = str + abjad[e2] + ' puluh '
end if
end if
end if
end if

if (e3=1) and (ix=100000) and (e1=0) and (e2=0) then //RIBUAN => SERIBU
str = str + 'se'
else
if (e3>=1 and e3<=9 and e2<>1) then
str = str + abjad[e3] + ' '
end if
end if
// end if

if ( str<> '' ) then
choose case (ix)
case (c * d)
if str <> '' then
str = str + 'trilyun '
end if
case (a * b)
if str <> '' then
str = str + 'milyar '
end if
case 100000000
if str <> '' then
str = str + 'juta '
end if
case 100000
if str <> '' then
str = str + 'ribu '
end if
case 100
end choose

end if
e1=0
e2=0
e3=0
ix = ix/1000
if num<1>
done = true
end if

loop

// Decimal Handling
// See The Algorithm
integer num_koma

// Manipulate The Value
num_koma = num * 100

if num_koma > 0 then
if str = '' then
return gf_prop('Nol koma ' + gf_prop(gf_angka(num_koma)) +'Sen') // make it nice
else
return gf_prop(str + ' koma ' + gf_prop(gf_angka(num_koma)) + 'Sen') // make it nice
end if
else
return gf_prop(str) // make it nice
end if

1 comment:

SURYA354 said...

variable yang tidak ada :

1. num
2. gf_angka
3. gf_prop

jadi script gagal di jalankan.

tks.

eska354