Professional Documents
Culture Documents
Ao de la
Diversificacin
NACIONAL
DEL SANTA
FACULTAD DE INGENIERIA
E.A.P. INGENIERA DE SISTEMAS E INFORMTICA
ALUMNA:
Sandoval Ramirez Jennifer
CODIGO:
0201314052
TEMA:
Funciones en Power Builder
CURSO:
Computacin II
PROFESOR:
Briones Pereyra Lizbeth
Ejemplo 1.
Escribir una funcin llamado max3 que reciba tres nmeros enteros
(A, B y C) y devuelva el mayor de ellos. (VER PAG. 40 DE SU SESION
04.)
PROCEDIMIENTO:
Primero se tiene que crear una funcin dentro del
Windows es decir de (w_funciones), nos vamos a
functions
y damos click en la opcin
classname() returns string nos va abrir un
max1=max(a,b)
maximo= max(max1, c)
return maximo
Luego compilamos y guardamos. Listo esta creada la funcin.
Posteriormente pasamos a codificar:
Numero1: sle_1.text
Numero2: sle_2.text
Numero3: sle_3.text
Numero mximo: sle_4.text, aqu saldr el resultado
cb_1 lo cual sabemos es un botn en la que hemos codificado
lo siguiente:
integer a,b,c
dec max
string mensaje
a= integer(sle_1.text)
b= integer(sle_2.text)
c= integer(sle_4.text)
// Llamamos a la funcin que habamos creado y los
datos con la cual ejecutar ser con los cuadro de texto
es decir los datos ingresados en numero1, numero2,
numero3.
max = maximo3(a,b,c)
sle_3.text = string (max)
Primero
creamos las funciones:
Funcin condicin:
string nCar
if nProm<=10 then
nCar = "desaprobado"
else
if nProm>=11 then
nCar = "Aprobado"
else
nCar = "asistencia"
end if
end if
return (nCar)
Funcin promedio:
dec nvar1, nvar2, nMin, nProm
nvar1=Min(nota1,nota2)
nvar2=Min(nota3,nota4)
nMin=Min(nota1,nota2)
nProm=((nota1+nota2+nota3+nota4)-nMin)/3
return (nProm)
Luego codificamos:
En el botn correcto:
integer nNota1, nNota2, nNota3, nNota4, nExa
dec nPromedioP, nPromedioG
string cMensaje
Evento Open
nNota1 = integer(sle_5.text)
nNota2 = integer(sle_6.text)
Sle_3.text = string(today())
nNota3 = integer(sle_7.text)
nNota4 = integer(sle_8.text)
nExa = integer(sle_9.text)
En el botn nuevo:
sle_1.text=""
sle_2.text=""
sle_4.text=""
sle_5.text=""
sle_6.text=""
sle_7.text=""
sle_8.text=""
sle_9.text=""
sle_10.text=""
sle_11.text=""
En el botn salir:
close(w_promedio)
Funcin Coseno:
real resul4
resul4 = cos(t)
return resul4
Funcin factorial:
integer resul
resul = Fact(l)
return resul
Funcin pi:
dec resulte
resulte = Pi(r)
return resulte
Funcin potencia:
dec wu
wu = Exp(e)
return wu
dec qe
qe = Sqrt
(w)
return qe
Funcin seno:
decimal
resut2
resut2 =
sin(k)
return
resut2
Funcin tangente:
dec po
po = tan (i)
return po
real resul2
resul2 = Abs (p)
return resul2
Luego codificamos:
Declaramos una variable global a
Botn tangente
a= integer (sle_1.text)
dec re
re =tangente(a)
Botn seno
a = dec(sle_1.text)
dec result
result =seno(a)
sle_2.text = String
(result)
Botn raz cuadrada
a= dec (sle_1.text)
dec resu
resu = raizcuadrada(a)
sle_2.text = string
(resu)
Botn coseno
a = integer (sle_1.text)
real resul5
resul5 = coseno(a)
sle_2.text = string
(resul5)
Botn logaritmo
a = integer (sle_1.text)
string mensaje
dec result
result = logaritmo(a)
sle_2.text = string (result)
Botn potencia
a= integer (sle_1.text)
dec wo
wo = potencia(a)
sle_2.text = string (wo)
Botn factorial
a = integer(sle_1.text)
integer resul1
resul1 =factorial(a)
sle_2.text = string (resul1)
Ejemplo 4.
Codificamos:
En el botn apply:
int dia,mes,ao,szodiaco
string z
date fec
dia=integer(sle_1.text)
mes=integer(sle_2.text)
ao=integer(sle_3.text)
fec=today()
szodiaco=integer(right(string(fec),4))
if dia>=21 and mes=3 or dia<=20 and mes=4 then
z="Aries"
pb_1.picturename="C:\Users\JENNIFER\Download
s\aries_1.gif"
end if
if dia>=21 and mes=4 or dia<=21 and mes=5 then
z="Tauro"
pb_1.picturename="C:\Users\JENNIFER\Download
s\tauro_1.gif"
end if
if dia>=22 and mes=5 or dia<=22 and mes=6 then
z="Gemenis"
pb_1.picturename="C:\Users\JENNIFER\Download
s\geminis_1.gif"
end if
if dia>=23 and mes=6 or dia<=22 and mes=7 then
z="Cancer"
pb_1.picturename="C:\Users\JENNIFER\Download
s\cancer_1.gif"
end if
if dia>=23 and mes=7 or dia<=22 and mes=8 then
z="Leo"
pb_1.picturename="C:\Users\JENNIFER\Download
s\leo_1.gif"
end if
if dia>=23 and mes=8 or dia<=22 and mes=9 then
z="Virgo"
pb_1.picturename="C:\Users\JENNIFER\Download
s\virgo_1.gif"
end if
if dia>=23 and mes=9 or dia<=22 and mes=10 then
z="Libra"
pb_1.picturename="C:\Users\JENNIFER\Download
s\libra_1.gif"
end if
if dia>=23 and mes=10 or dia<=21 and mes=11 then
z="Escorpio"
pb_1.picturename="C:\Users\JENNIFER\Download
s\escorpio_1.gif"
end if
if dia>=22 and mes=11 or dia<=21 and mes=12 then
z="Sagitario"
pb_1.picturename="C:\Users\JENNIFER\Download
s\sagitario_1.gif"
end if
if dia>=22 and mes=12 or dia<=20 and mes=1 then
z="Capricornio"
pb_1.picturename="C:\Users\JENNIFER\Download
s\capricornio_1.gif"
end if
if dia>=20 and mes=1 or dia<=18 and mes =2 then
z="Acuario"
pb_1.picturename="C:\Users\JENNIFER\Download
s\acuario_1.gif"
end if
if dia>=19 and mes=2 or dia<=20 and mes=3 then
z="Picis"
pb_1.picturename="C:\Users\JENNIFER\Download
s\picis_1.gif"
end if
st_4.text="Usted Tiene" +""+ string (szodiaco - ao)
+"Aos y su Signo es:" + string(z)
Ejemplo 5.
st_15.text=string(total
-tot)
Codificamos el botn
exit:
close(w_centroturistico)
Ejemplo 6.
if lb_2.selectedindex()<0 then
messagebox("error", "seleccione un pais")
else
//pasamos los datos a la lista 01
lb_1.additem(lb_2.selecteditem())
//borramos los datos de la lista 02
lb_2.deleteitem(lb_2.selectedindex())
end if
//total de elementos de la lista
sle_2.text = string (lb_1.totalitems())
sle_3.text=string (lb_2.totalitems())
Luego codificamos el botn <<:
integer i
//bucle para agregar todos los datos
for i=1 to lb_2.totalitems()
lb_2.selectitem(i)
lb_1.additem(lb_2.selecteditem())
next
//limpiamos la lista 01
lb_2.reset()
//total de elementos de la lista 01
sle_2.text=string (lb_1.totalitems())
sle_3.text=string(lb_2.totalitems())
Luego codificamos el botn delete
integer a,b
a = integer (lb_1.selectedindex())
b = integer (lb_2.selectedindex())
lb_1.deleteitem(a)
lb_2.deleteitem(b)