Está en la página 1de 27

Power Builder

Exportar e Importar Datawindow

Power Builder

Script Open de la Ventana


Dw_data.DataObject="Dw_Alumno"

Implemente la siguiente Base de datos Universidad

Dw_data.SetTransObject(Sqlca)
Dw_data.Retrieve()
Script Clicked Para Botn Cb_Exportar

Desarrollar la Siguiente aplicacin.


Objeto Datawindow:
Dw_Alumnos
Tabla : Alumno
Tipo:
Grid
Control Datawindow:
Dw_data
Command Button:
Cb_Registrar
Cb_Importar
Cb_Exportar
Cb_Guardar
Cb_Eliminar

Script En el Evento open de la Aplicacin:


// Profile Venta
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Connectstring='DSN=UNiversidad"
Connect using SQLCA;
If Sqlca.Sqlcode=0 then
open(W_Exportar)
else
Messagebox ("Error de Conexin",Sqlca.SqlErrText)
Halt
end if

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

string ls_nombre,ls_archivo
TRY
if
getfilesavename("Guardar
Archivo",ls_archivo,ls_nombre,"xls","Archivo
excel(*.xls),*.xls")= 1 then
dw_data.saveas(ls_archivo,excel! ,True)
MessageBox ("Mensaje","los datos exportados con exito")
else
MessageBox ("error","los datos no fueron exportados con exito")
dw_data.saveas()

de

end if
//dw_data.saveas("reporteenexcel.xls",excel! ,false)
//MessageBox ("error","datos exportados con exito")
CATCH (runtimeerror msg)
MessageBox ("error",msg.text)
END TRY
//
Script Clicked Para Botn Cb_Importar
string ls_nombre,ls_archivo
TRY
GetFileOpenName("Importar
(*.CSV),*.CSV")
dw_data.ImportFile(ls_archivo)

archivo",ls_archivo,

ls_nombre,"CSV","Archivos

CATCH (runtimeerror msg)


MessageBox ("error",msg.text)
END TRY
//dw_1.ImportFile("reporteenexcel1111.csv")

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

PRACTICA ESTRUCTURAS REPETITIVAS

Power Builder

else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()

Objeto SingleLineEdit:
Name:
Sle_numero

end if

Control StaticText:

BUCLE WHILE

Name:
St_numero

Script Clicked Para Botn Primeros N

Control CommandButton:
Name:
Cb_primero
Cb_suma
Ventana Bucles
BUCLE FOR
Script Clicked Para Botn Primeros N
integer i,numero
string m
numero=integer(sle_numero.text)
if isnumber(sle_numero.text) then
for i=1 to numero
m +=string(i)+ " "
next
st_numero.text=string(m)
Messagebox("Mostrar",string(m))
else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()
end if
Script Clicked Para Botn Suma N
integer i,numero
integer m
if isnumber(sle_numero.text) then
numero=integer(sle_numero.text)
for i=1 to numero
m+=i
next
st_numero.text=string(m)
Messagebox("Mostrar",string(M))

Lic. Vladimir Cotaquispe Gutirrez.

integer i,numero,n
string m
numero=integer(sle_numero.text)
if isnumber(sle_numero.text) then
i=1
do while i<=numero
m +=string(i)+ " "
n +=i
i+=1
loop
st_numero.text=string(m)
Messagebox("Mostrar",string(m))
else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()
end if
Script Clicked Para Botn Suma N
integer i,numero,n
numero=integer(sle_numero.text)
if isnumber(sle_numero.text) then
i=1
do while i<=numero
n +=i
i+=1
loop
st_numero.text=string(n)
Messagebox("Mostrar",string(n))
else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()
end if

Lic. Vladimir Cotaquispe Gutirrez.

Power Builder

BUCLE UNTIL

Power Builder

PRCTICA ESTRUCTURAS DE CONTROL - REPETITIVAS

Script Clicked Para Botn Primeros N


Objeto SingleLineEdit:
integer i,numero,n
string m
numero=integer(sle_numero.text)
if isnumber(sle_numero.text) then
i=1
do until i > numero
m +=string(i)+ " "
n +=i
i+=1
loop
st_numero.text=string(m)
Messagebox("Mostrar",string(m))
else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()
end if
Script Clicked Para Botn Suma N
integer i,numero,n
numero=integer(sle_numero.text)
if isnumber(sle_numero.text) then
i=1
do until i>numero
n +=i
i+=1
loop
st_numero.text=string(n)
Messagebox("Mostrar",string(n))
else
Messagebox("Error","ingrese un Valor Numerico")
sle_numero.text=""
sle_numero.setfocus()
end if

Lic. Vladimir Cotaquispe Gutirrez.

Name:
Sle_n
Control ListBox:
Name:
Lb_numeros
Control CommandButton:
Name:
Cb_Llenar
Cb_Primo
Ventana Numeros
Script Clicked Para Botn Llenar
integer i,n
n=integer(sle_n.text)
lb_numeros.reset()
if rb_par.checked=true then
for i=2 to n step 2
lb_numeros.additem(string(i))
next
elseif rb_impar.checked=true then
for i=1 to n step 2
lb_numeros.additem(string(i))
next
end if
Script Clicked Para Botn N primo
integer i,n,c
n=integer(sle_n.text)
lb_numeros.reset()
c=0
for i=1 to n
if mod(n,1)=0 then
c=c+1
lb_numeros.additem(string(i) + ' ' + "
end if
next
if c<=2 then
st_primo.text=" Es Primo"
else
st_primo.text="No Es Primo"
end if
Lic. Vladimir Cotaquispe Gutirrez.

" + string(mod(n,i)))

Power Builder

PRACTICA ESTRUCTURAS CONTROL MULTIPLE

Power Builder

Ventana Venta de Combustible

Objeto SingleLineEdit:

Objeto SingleLineEdit:

Name:
Sle_mes

Name:
Sle_total

Control StaticText:

Control StaticText:

Name:
St_esta

Name:
St_cantidad
Sle_precio

Control CommandButton:

Control ListBox:

Name:
Cb_visualizar
Ventana Estaciones
Script Clicked Para Botn Visualizar
integer mes
string msg
mes=integer(sle_mes.text)
choose case mes
case 1 to 3
msg="Verano"
case 4 to 6
msg="Otoo"
case 7 to 9
msg="Invierno"
case 10 to 12
msg="Primavera"
case else
messagebox("Error","El mes No existe")
st_esta.text=""
sle_mes.text=""
end choose
st_esta.text=string(msg)

Lic. Vladimir Cotaquispe Gutirrez.

Name:
Lb_combustible
Script Open Para la Ventana
lb_combustible.additem("Gasolina 97")
lb_combustible.additem("Gasolina 95")
lb_combustible.additem("Gasolina 90")
lb_combustible.additem("Gasolina 84")
lb_combustible.additem("Dissel 1")
lb_combustible.additem("Dissel 2")
Script Selectionchanged Para Listbox combustible
choose case lb_combustible.selectedindex()
case 1
sle_precio.text="15.00"
sle_cantidad.text=""
sle_cantidad.setfocus()
case 2
sle_precio.text="12.00"
sle_cantidad.text=""
sle_cantidad.setfocus()
case 3
sle_precio.text="10.00"
sle_cantidad.text=""
sle_cantidad.setfocus()
case 4
sle_precio.text="9.50"
sle_cantidad.text=""
sle_cantidad.setfocus()
case 5
sle_precio.text="10.20"
Lic. Vladimir Cotaquispe Gutirrez.

Power Builder

sle_cantidad.text=""
sle_cantidad.setfocus()
case 6
sle_precio.text="11.00"
sle_cantidad.text=""
sle_cantidad.setfocus()
end choose
Script Modified Para SingleLineEdit Cantidad
decimal precio, cantidad,total
precio=dec(sle_precio.text)
cantidad=dec(sle_cantidad.text)
total=precio * cantidad
st_total.text="S/. " + string(total,"###,###.00")

Lic. Vladimir Cotaquispe Gutirrez.

Power Builder

ESTRUCTURAS DE CONTROL
Objeto Datawindow:
Dw_producto
Tabla : Products
Tipo:

Freeform

Control Datawindow:
Dw_data
Script Open de la aplicacin
Open (W_Contrasea)
Ventana Contrasea
Declaracin de variables de
Instancia

Script Clicked Para Botn Aceptar


String clave
Clave = sle_clave.Text
t+= 1
If clave = "UAP" Then
Open (w_estructura)
Close (w_contrasea)
Else
If t< 3 Then
Messagebox ("Error","La contrasea es incorrecta"+ Char(13) + "N intentos "
+string( t))
sle_clave.Text = ""
sle_clave.setFocus()
End If
If t = 3 Then
Messagebox("Error","Se acabaron Tus Intentos")
close(w_contrasea)
End If
End If
Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Ventas Northwind
Disee la siguiente interfase
para realizar ventas con la
base de datos Northwind.
Al cargar no deber Mostrar
Nada en los Datawindow.
Al

pulsar

Cargaran

el
los

Respectivos
una

Botn

Nueva

nuevo

Datawindow

para

Registrar

venta.

Donde

tendr que agregar el cliente,


la fecha de venta, Luego se
activara el botn agregar.
Luego en el detalle agregar la cantidad y el producto, el precio deber
mostrar automticamente
En el detalle se agregar los productos seleccionados.
Luego al registrar la venta tendr que almacenarse la boleta, la tabla
respectiva y el detalle en la tabla respectiva.
Ala vez se deber descontar del stock los productos vendidos.

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Formularios Maestro Detalle


Objetos Datawindow:
Name: Dw_categoria
Tabla: Categories
Control Datawindow:

Power Builder

Declaracin de variables de Instancia

Dw_1

Name: Dw_producto
Tabla : Products
Control Datawindow:

Dw_2
Script Clicked del Dw_1
try

Script Open de la Ventana

fila=dw_1.getitemNumber(GetClickedRow(),1)

// Cargar Categorias

dw_2.setfilter("categoryid="+string(fila))

dw_1.settransobject(sqlca)

dw_2.filter()

dw_1.retrieve()

dw_2.setsort("productid asc")

// Cargar Productos

dw_2.sort()

dw_2.settransobject(sqlca)

catch (runtimeerror ex)

dw_2.retrieve()

fila=1

//llamar el evento Clicked de dw_1

dw_2.setfilter("categoryid="+ string(fila))

dw_1.triggerevent(clicked!)

dw_2.filter()
end try

Script Clicked Para Botn Nuevo


long n
n=dw_2.rowcount() +1
dw_2.insertrow(n)
Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

dw_2.scrolltorow(n)
dw_2.setfocus()
Script Clicked Para Botn Guardar
Dw_2.modify(categoryid.visible=0)
dw_2.setcolumn(5)
dw_2.settext(string(fila))
dw_2.accepttext()

if dw_2.update()<>-1 then
commit;
messagebox("Msg","Datos Guardados Con exito")
else
rollback;
messagebox("Msg","Datos no se Guardaron")
end if
Dw_2.modify(categoryid.visible=1)

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Utilizacin del Datawindow

Controles DataWindows (dw_1), como


se observa :
Objeto DataWindow Control (Caja
de Herramientas)
El Objeto DataWindow Control se
selecciona del listado de objetos que se
pueden insertar en una ventana,
simplemente haga un clic sobre el
siguiente icono.
Luego haga un
clic en la posicin de la ventana, donde
desea poner el DataWindow Control.

Pasos
1.Adjuntar
la
BD
NORTHWIND en el motor de Base
de dato SQL server, para este caso se
hace uso del SQL server.
Pasos 2.- Conecte la base de datos
con Power Builder y configure los
parmetros de inicializacin.

Paso
3.DataWindow
DataWindow)

Disear
el
(File-New-

Se
elige
el
estilo
de
Presentacin: (Elegir el Tipo Free)

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Modos de trabajo: (Seleccione


QUICK Select)
El modo de trabajo define como
se trabajara con el Origen de
Datos. Existen 5 tipos de
modos de trabajo.

Al seleccionar Quick SELECT mostrara la siguiente pantalla:

Paso 3.Products

Seleccione

la

Tabla

Luego Seleccione los campos de la


Tabla
como
se
muestra
a
continuacin:
Luego pulse ok hasta finalizar el
asistente.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Edite las etiquetas como se muestra en la imagen.

Proceda a grabar el objeto DataWindow (almacene en la biblioteca creada y asignarle un


comentario, (dw_productos)
Paso 4.- Se agregar un
Control Datawindow En
la ventana.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Paso 5.- Haga clic en la


propiedad
Dataobject
de
Control Datawindow Para
enlazarlo con el objeto
datawindow (dw_producto).

Paso 6.- Codificar en la ventana, evento open(), lo siguiente:


//enlazar el control con el objeto transaction
Dw_1.settransobject(sqlca)
//recuperar los registros
Dw_1.retrieve()

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Controles Avanzados en Datawindow


Para agregar Controles en un Datawindows (Controles avanzados)

Paso 1.- Deber entrar a editar el Datawindows.


En la Vista de Diseo Deber seleccionar el Campo que
desea modificar el tipo de control a Usar en el
dataWindows.

Paso 2.-Luego Seleccionemos el campo Stock en el Datawindow

En la ventana de propiedades busque la ficha EDIT.

Paso 3.- En la Ficha Edit Busque la Propiedad StyleType y despliegue la Lista y


seleccione Editmask, Luego en Mask determine la cantidad de caracteres que se
ingresaran en el campo, active la Propiedad Spin control.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Paso 4.-Luego Seleccionemos el campo Estado en el


Datawindow
Paso 5.- En la Ficha Edit Busque la Propiedad
StyleType y despliegue la Lista y seleccione
RadioButtons, Luego active la propiedad 3 D Look,
Columns Across
le asigna dos 2, luego en la
propiedad Code Table asigna los siguientes valores.

Paso 6.- Para Poder Mostrar la categora


de los productos y enlazarlo a al
datawindos Producto habr que crear un
datawindows tipo grid para la tabla
Categories. Proceda a agregar un data
Windows.
Paso 7.- Se elige el estilo de Presentacin:
(Elegir el Tipo Grid).
Paso 8.- Seleccione la Tabla Categories
Paso 9.- Luego Seleccione los campos de
la Tabla como se muestra a continuacin:
Paso 10.- Luego pulse ok hasta finalizar el
asistente.
Paso 11.- Proceda a grabar el objeto
DataWindow (almacene en la biblioteca
creada
y
asignarle
un
comentario,
(dw_categoria)

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Luego el datawindows
muestra la imagen.

quedara

como

Para Mejorar la presentacin del


datawindows (dw_categoria), se tendr
que eliminar las etiquetas de la cabecera
y corres un poco el espacio de la cabecera
hasta que quede como la figura, tambin
el espacio de cdigo de la categora.

Paso 2.-Luego Seleccionemos el campo Categoria en el


Datawindow(dw_producto)
Paso 3.- En la Ficha Edit Busque la Propiedad
StyleType y despliegue la Lista y seleccione
DropdownDW, en la la propiedad Datawindow
pulse
el
botn
y
seleccione
el
datawindows(dw_categoria).

Luego defina el Display Column (lo que mostrar al


desplegar) en este caso es el Nombre de categora,
luego el Data Column (loque almacenara al
seleccionar) en este caso es el cdigo de categora.
Para finalizar active la propiedad always Show
Arrow(para mostrar siempre la flecha).

para que muestre la


forma siguiente.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

Power Builder

Al concluir se mostrara como la imagen.

Agregue los botones respectivos en el pie de pgina guarde la aplicacin y esta lista para
manipularla.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET


Messagebox("Error","Seleccione un Registro")

Controles de Lista
Objeto Listbox:

else

Name:
Lb_producto
Lb_venta

lb_venta.additem(lb_producto.selecteditem())

Control DropdownListbox:

end if

Name:
Ddlb_producto

Script Clicked Para Botn Pasartodo

lb_producto.deleteitem(lb_producto.SELECTEDINDEX())

integer i
Control CommandButton:
for i=1 to lb_producto.totalitems()
Name:
Cb_agregar
Cb_borrar
Cb_borrartodo
Cb_pasar
Cb_regresar
Cb_pasartodo
Cb_regresartodo

lb_producto.selectitem(i)
lb_venta.additem(lb_producto.selecteditem())
next
lb_producto.reset()
Script Clicked Para Botn Borrar

Ventana Sistema de Almacen


Script Open de la Ventana

if lb_producto.selectedindex()>0 then

ddlb_producto.additem("Fideos")

lb_producto.deleteitem(lb_producto.selectedindex())

ddlb_producto.additem("Arroz")

elseif lb_venta.selectedindex()>0 then

ddlb_producto.additem("Aceite")

lb_venta.deleteitem(lb_venta.selectedindex())

ddlb_producto.additem("Harina")

elseif lb_producto.selectedindex()<0 or lb_venta.selectedindex()<0 then

ddlb_producto.additem("Azucar")

Messagebox("Error","Seleccione un Registro")

ddlb_producto.additem("Carne")

end if

Script Clicked Para Botn agregar

Script Clicked Para Botn Borrartodo

lb_producto.additem(ddlb_producto.text)

if lb_producto.selectedindex()=-1 and lb_venta.selectedindex()=-1 then

st_n.text=string(lb_producto.totalitems())
Script Clicked Para Botn Pasar

Messagebox("Error","seleccione La lista a eliminar")


Else

if lb_producto.selectedindex()<0 then
Lic. Vladimir Cotaquispe Gutirrez.

Lic. Vladimir Cotaquispe Gutirrez.

INSTITUTO SUPERIOR TECNOLOGICO JHALEBET


if lb_producto.selectedindex()>=1 then
lb_producto.reset()
end if
if lb_venta.selectedindex()>=1 then
lb_venta.Reset()
end if
end if

Lic. Vladimir Cotaquispe Gutirrez.

Power Builder

Power Builder

Llamados A Las Apis De Windows Desde Power Builder

ulong lParam

Power Builder al igual que otros lenguajes de programacin, provee la capacidad de


extender las posibilidades del lenguaje tomando funcionalidades que pertenecen al
sistema operativo o controles de terceras partes. Este proceso es lo que se llama API
(Application Programming Interface). Algunas personas incluyen DLLs que han realizado
en C o C++, para usarlos en Power Builder. Pero los mas comunes llamados son los que
se hacen a las API del sistema operativo, para que el programador acceda directamente a
funciones que desde power builder tocara desarrollarlas, y el sistema operativo ya las
tiene implementadas.
Declaracin de funciones externas en PowerBuilder para llamadas a API's de
32bit
Para declarar funciones externas en Power Builder se debe indicar el nombre de la
funcin, as como los parmetros que recibe y los tipos de datos equivalentes de cada
parmetro en Power Builder; adems de la librera DLL que contiene a la funcin a
declarar.
FUNCTION <Tipo_Dato_Devuelto_Funcin> <Nombre_Funcin>
(<Tipo_Acceso_Parmetro> <Tipo_Dato_Parmetro> <Parmetro>[,...]) LIBRARY
<Librera DLL>

Declaracin de funciones externas en PowerBuilders para llamadas a API's de 32bit


Funcin

_access

_lclose

_lopen

Arc

Devuelve

Parmetros que recibe

Librera

Ref string filename, int


mode

msvcrt.dll

long

Long hfile

Kernel32.dll

long

Ref string lsfile, long


fnmode

Boolean

ulong hwnd, long r1,


long r2, long r3, long r4,
Gdi32.dll
long a1, long a2, long
a3, long a4

Long

Beep

Boolean

BitBlt

Long

Lic. Vladimir Cotaquispe Gutirrez.

long freq,long dur


ulong hDC, long num,
long num, long num,
long num, ulong hDC,
long num, long num,
1

BringWindowToTop

Boolean

ulong w_handle

Chord

Boolean

Chord(ulong hwnd,long
x1,long y1,long x2,long
Gdi32.dll
y2,long r1, long r2, long
r3, long r4

ChooseColorA

boolean

REF str_ChooseColor
lpcc

comdlg32.dll

ChooseFontA

boolean

REF str_choosefont c

comdlg32.dll

CloseHandle

Boolean

Ulong h

Kernel32.dll

CloseHandle

Boolean

ulong w_handle

Kernel32.dll

CloseWindow

Boolean

ulong w_handle

User32.dll

CopyFileA

Boolean

Ref string cfrom, ref


string cto, boolean flag

kernel32.dll

Pb pointer, pb pointer

kernel32.dll

CopyMemory

User32.dll

RtlMoveMem
ory

Ver tambin
CreateCompatibleDC

Ulong

Ulong hDC

Gdi32.dll

CreateDirectoryA

Boolean

Ref string ls_newdir,


ulong lnull

kernel32.dll

CreateMutexA

Ulong

Ulong security,boolean
bowner, string lsname

Kernel32.dll

DeleteFileA

Boolean

Ref string filename

kernel32.dll

DeleteObject

boolean

ulong hgdiobj

Gdi32.dll

DestroyWindow

Boolean

ulong w_handle

User32.dll

DllRegisterServer

Long

Kernel32.dll

Kernel32.dll

c:\windows\
ocxname.ocx

Gdi32.dll

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Ellipse

Boolean

Lic. Vladimir Cotaquispe Gutirrez.

ulong hwnd,long x1,long


Gdi32.dll
y1,long x2,long y2
2

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

ExitWindowsEx

boolean

uint dwReserved, uint


uReserved

nbuf

User32.dll
GetCurrentDirectoryA ulong

REF String lpszSrc, REF


string lpszDest, long
cchDest

kernel32.dll

FatalExit

int exitcode

Kernel32.dll

FileTimeToLocalFileTi
boolean
me

Filetimetolocalfiletime(r
ef str_filedatetime
Kernel32.dll
lpfiletime,ref
str_filedatetime
lplocalfiletime)

ExpandEnvironmentSt
Long
ringsA

Power Builder

FileTimeToSystemTim
boolean
e

Str_filedatetime lpt, ref


Kernel32.dll
str_systemtime sts

FindClose

boolean

Long handle

kernel32.dll

FindFirstFileA

Long

Ref string filename, ref


str_filedata filedata

kernel32.dll

kernel32.dll

Ulong

Kernel32.dll

GetCursor

Ulong

User32.dll

GetCursorPos

Boolean

ref mousepos
mousepos2

User32.dll

GetDC

Ulong

Ulong hwnd

User32.dll

boolean

Ref string as_dir, ref


long
al_sectorspercluster, ref
Kernel32.dll
long al_bytespersector,
ref long al_freeclusters,
ref long al_totalclusters

GetDiskFreeSpaceExA boolean

Ref string as_dir, ref


str_ularge_long
ast_userfreebytes, ref
str_ularge_long
ast_totalbytes, ref
str_ularge_long
ast_totalfreebytes

GetFileTime

boolean

Long hfile, ref


str_filedatetime
lpcreate, ref
Kernel32.dll
str_filedatetime
lpaccess, ref
str_filedatetime lpwrite

Boolean

Ref string lpfilename,


ref ulong lpdwhandle,
ulong dwlen, ref string
lpdata

Version.dll

GetFileVersionInfoSiz
Ulong
eA

Ref string lpfilename,


ref ulong lpdwhandle

Version.dll

GetComputerNameA(ref User32.dll
string cname,ref long

GetKeyboardState

ref integer kbarray[256] User32.dll

Lic. Vladimir Cotaquispe Gutirrez.

FindNextFileA

Boolean

Long handle, ref


str_filedata filedata

FindWindowA

Ulong

Ref string c, ref string t User32.dll

FreeLibrary

Ulong h

kernel32.dll

FreeLibrary

ulong libhandle

Kernel32.dll

FtpRenameFile

boolean

ulong hConnect, ref


string lpszExisting, ref
string lpszNew

wininet.dll

GetBkColor

Ulong

ulong hwnd

Gdi32.dll
GetFileVersionInfoA

Ulong

GetClassNameA

Long

GetComputerNameA

Boolean

Lic. Vladimir Cotaquispe Gutirrez.

Kernel32.dll

GetCurrentThread

GetDiskFreeSpaceA

GetCapture

Ulong bufferlen, ref


string currentdir

User32.dll
ulong hwnd, ref string
cname, int buf

User32.dll

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Boolean

Kernel32.dll

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder
GetKeyState

Integer

Long al_vk

User32.dll

GetLastError

Long

GetMenu

ulong

Ulong w

long

Ulong h, ulong i, ref


User32.dll
string s, long m, ulong f

Power Builder
GetTextExtentPoint32
boolean
A

( Ulong h, string s, long


Gdi32.dll
l, ref str_point st

GetThreadPriority

ulong hthread

Kernel32.dll
Integer

Kernel32.dll

User32.dll
GetUserDefaultLangID Integer

GetMenuStringA

GetMinMaxInfo

GetModuleHandleA

long

GetModuleFileNameA long

Ref str_minmaxinfo d,
long s, long l

kernel32.dll

string modname

Kernel32dll

ulong hModule, ref


string lpFilename, long
nSize

Kernel32.dll

GetObjectBitmap

Ulong

ulong hgdiobj, int


cbBuffer, ref s_bitmap
bm

Gdi32.dll

GetParent

Ulong

ulong hwnd

User32.dll

GetPixel

Ulong

ulong hwnd, long xpos,


long ypos

Gdi32.dll

integer

string lpszLongPath,
REF string
lpszShortPath, integer
cchBuffer

GetShortPathNameA

Ulong

Ulong w, long p

GetSystemMenu

boolean

ulong mhandle, boolean


User32.dll
flag

Integer

boolean

RtlMoveMem
ory

GetTempPathA

long

Lic. Vladimir Cotaquispe Gutirrez.

GetWindow

ulong hwnd, uint fuRel

user32.dll

GetWindowsDirectory
Ulong
A

ref string wdir, ulong


buf

Kernel32.dll

GlobalAlloc

ulong

ulong uFlags, long


dwBytes

kernel32.dll

GlobalFree

ulong

ulong hMem

kernel32.dll

GlobalLock

ulong

ulong hMem

kernel32.dll

Ref str_memorystatus
lpbuffer

kernel32.dll

ulong

User32.dll

Integer indexnum

User32.dll

ref systemtime
systimeptr

Kernel32.dll

long nBufferLength, ref


string lpBuffer

Kernel32.dll

Advapi32.dll

GetVolumeInformatio
boolean
nA

GlobalMemoryStatus
GetSystemTime

ref string uname, ref


ulong slength

Ref string
lprootpathname,ref
string
lpvolumenamebuffer,lon
g nvolumenamesize,ref
uint
lpvolumeserialnumber[2
], ref long
kernel32.dll
lpmaximumcomponentle
ngth, ref long
lpfilesystemflags,ref
string
lpfilesystemnamebuffer,
long
nfilesystemnamesize

GetObjectA

Kernel32.dll

GetSubMenu

GetSystemMetrics

GetUserNameA

Kernel32.dll

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

GlobalUnlock

ulong

ulong hMem

kernel32.dll

LineTo

boolean

ulong hwnd,long wx,


long wy

Gdi32.dll

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

LoadImageA

LoadLibraryA

MciSendStringA

MessageBoxA

Ulong

ulong

MoveToEx

MoveWindow

String modname

Boolean

string p, string e, string


Rasapi32.dll
n, ref str_rasdialdlg s

RasEnumConnections
long
A

ref str_RasConn
lprasconn[], ref long
lpcb, ref long i

RasEnumEntriesA(string
r, string p, ref
Rasapi32.dll
str_rasentryname e[],
ref long lsize, ref long
lentries

Rasapi32.dll

string cmd, REF string


Winmm.dll
rtn, long size, long wnd

long

ulong hwnd, ref string


text, ref string title,
ulong style

User32.dll

RasEnumEntriesA

ulong dwflag,ulong
dx,ulong dy,ulong
cbutton,ulong dwextra

User32.dll

RasGetConnectStatus
Ulong
A

ulong hConn, ref


str_Rasstatus rs

Ref string fromfile, ref


string tofile

kernel32.dll

RasGetEntryDialPara
msA

Long

ulong hwnd,long wx,


long wy,ref prepos
prepos2

ref string
lpszPhonebook, ref
Rasapi32.dll
str_RasDialParms rdp,
ref boolean lbfPassword

Gdi32.dll
RasGetErrorStringA

Long

uint l, ref string s, long c Rasapi32.dll

ulong whand,int wx,int


wy,int ww,int
wh,boolean wflag

RasHangUpA

Ulong

ulong hConn

User32.dll
Rectangle

boolean

ulong hwnd,long x1,long


Gdi32.dll
y1,long x2,long y2

Boolean

Boolean

boolean

boolean

ulong hwnd,long x1,long


y1,long x2,long y2,long
Gdi32.dll
x3,long y3,long x4,long
y4

Polygon

Boolean

hdc, ref struct poly


poly2, int cnt

Gdi32.dll

ulong hwndle,UINT
wmsg,ulong
wParam,ulong lParam

User32.dll

RasDialA

RasDialDlgA

kernel32.dll

Pie

PostMessageA

hwnd, ref ulong hConn

long

Mouse_Event

MoveFileA

ulong hints, ref string


lpszName, UINT uType,
User32.dll
int cxDesired,int
cyDesired,UINT fuLoad

Power Builder

Boolean

Ulong

Lic. Vladimir Cotaquispe Gutirrez.

ref
str_RasDialExtensions
lstrExt, string
phonebook, ref
str_Rasdialparms rdp,
long notifier, ulong
7

long

RegisterWindowMessa
Ulong
geA

Rasapi32.dll

String lpsz

User32.dll

ReleaseCapture

Boolean

User32.dll

RemoveMenu

boolean

Ulong h, ulong p, ulong f User32.dll

SendMessageA

Long

ulong hwndle,UINT
wmsg,ulong
wParam,ulong lParam

User32.dll

SelectObject

ulong

ulong hDC, ulong


hGDIObj

Gdi32.dll

SetCapture

Ulong

Ulong a

User32.dll

Rasapi32.dll

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Rasapi32.dll

Lic. Vladimir Cotaquispe Gutirrez.

DeleteMenu

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Power Builder
SetComputerNameA

Boolean

ref string cname

Kernel32.dll

SetCurrentDirectoryA Boolean

Ref string cdir

kernel32.dll

SetCursorPos

int cx, int cy

User32.dll

long objhandle

User32.dll

Boolean

SetFocus
SetKeyboardState

boolean

SetPixel

Ulong

ulong hwnd, long xpos,


long ypos, ulong pcol

Gdi32.dkk

SetThreadPriority

Boolean

ulong hthread, int


npriority

Kernel32.dll

SHBrowseForFolder

Long

FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll"

ref integer kbarray[256] User32.dll


Long d, str_minmaxinfo
kernel32.dll
s, long l

SetMinMaxInfo

Ejemplo: En el script de una ventana la cual va utilizar la funcin de un DLL


existente. Elegimos Declare y seguidamente elegimos Local External Functions.
Luego

RtlMoveMem
ory

Usando API
Aqu se ha puesto una serie de llamadas a API's de 32 bits. en general se ha puesto sin
explicacin, puesto creo que no las necesitan. Estos ejemplos se obtuvieron de la pgina
web: http://lonestar.texas.net/~chakes y se ha traducido al castellano.
Ejemplo: Llamadas a API's del entorno de Windows

Ref str_browseinfo lpbi Shell32.dll

SHGetPathFromIDList Boolean

Ulong pidl, ref string


pszbuffer

ShowWindow

ulong hWind, int


nCmdShow

user32.dll

Sleep

Long m

kernel32.dll

Shell32.dll

//Nombre de Equipos
function long GetComputerNameA(ref string equipo, ref ulong
areatrabajo)library "kernel32.dll" alias for "GetComputerNameA;Ansi"
long ll_valor
sndPlaySoundA

boolean

String wavfile, uint flag Winmm.dll

SwapMouseButton

Boolean

boolean var

Boolean

Ref string lpblock, string


Version.dll
lpsubblock, ref long
lpbuffer, ref uint pulen

string ls_equipo , ls_usuario


User32.dll

ulong lul_at1=20
VerQueryValueA

//nombre equipo
ls_equipo=space(lul_at1)

waveOutGetNumDevs Ulong

Winmm.dll

ll_valor=GetComputerNameA(ls_equipo,lul_at1)
WinExec

uint

Lic. Vladimir Cotaquispe Gutirrez.

ref string filename, uint


Kernel32.dll
wstyle

st_1.text=ls_equipo

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

10

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

function long GetUserNameA(ref string usuario, ref ulong areatrabajo)library


"advapi32.dll" alias for "GetUserNameA;Ansi"
// usuario
ulong lul_at2=20
ls_usuario=space(lul_at2)
ll_valor=GetUserNameA(ls_usuario,lul_at2)
st_2.text=ls_usuario
//buscador de fichero
FUNCTION long SearchTreeForFile(String RootPath ,String InputPathName,ref
String OutputPathBuffer) LIBRARY "imagehlp.dll" alias for
"SearchTreeForFile;Ansi"
CONSTANT long MAX_PATH = 260
string tempStr,ls_buscar,ls_unidad
long Ret
ls_buscar=sle_buscar.text
ls_unidad=sle_unidad.text
tempStr = space(MAX_PATH)
//'retorna 1 si lo encuentra, 0 si falla en la busqueda
Ret = SearchTreeForFile(ls_unidad,ls_buscar,tempStr)
if ret=1 then
st_ruta.text = tempStr //muestra el path
else
messagebox("Error...","El fichero no encontrado.")
end if

Lic. Vladimir Cotaquispe Gutirrez.

11

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Power Builder

Conectarse a SQL Server desde PowerBuilder 10


Nos pasamos a la ficha PREVIEW, Probamos la
conexin y si es satisfactoria.

PowerBuilder desde la versin 10 ya no tiene la opcin de configuracin de drivers nativos


(MSS Microsoft SQL Server) en el DBProfile. Ahora para conectarse "Nativamente" debe
utilizar ADO.NET, JDBC, o OLE DB. O si lo prefiere por el tradicional ODBC con sus
limitantes de rendimiento conocidas. A continuacin le mostramos la manera de
conectarse:

Copiamos la lnea de conexin.


Normalmente el objeto transaccin (transaction)
se configura y se conecta cuando se inicia la
aplicacin, es decir en el open de la aplicacin.
Para hacer esto abra el objeto aplicacin
(file/open/aplication) en el evento open donde
est el cdigo de abrir la ventana inicial, borrelo
y remplace por este cdigo:

"Nativamente" por OLE DB a SQL Server.


Abra el Database Profiles:
All seleccione OLE Microsoft OLE DB y haga click en Nuevo:
Luego seleccione en la pestaa conexin:
Profile Name
Provider
DataSource
User ID
Password
Extended

--> nombre de la conexin


--> SQLOLEDB
--> Nombre del Servidor de Base de datos (nombre o IP)
--> Nombre del usuario de la base de datos
--> Clave del Usuario de la base de datos
--> Aqui se define la base de datos asi :
Database=NOMBRE_DE_LA_BASE_DE_DATOS

Para conectarse desde el PowerScript use la


siguiente sintaxis:

// Profile Coneccion
SQLCA.DBMS = "OLE DB"
SQLCA.LogId = "sa"
SQLCA.AutoCommit = False
SQLCA.DBParm =
"PROVIDER='SQLOLEDB',DATASOURCE='.',PROVIDERSTRING='Database=Northwind'"
Connect using SQLCA;
If Sqlca.Sqlcode=0 then
open(W_Buscar)
else
Messagebox ("Error de Conexin",Sqlca.SqlErrText)
Halt
end if

Tradicional ODBC con sus limitantes de rendimiento Por ODBC.


Si deseas utilizar la seguridad integrada de Windows.
En la Pestaa Security:
Persist Security Info: (activar la casilla)
Integrated: SSPI (digitar en la caja de texto)

Pasos 1.- La BD NORTHWIND se encuentra de forma predeterminada en el motor de


Base de dato SQL server, para este caso se hace uso del SQL server.
Pasos 2.- Acceder al panel de control \ Herramientas administrativas \ ODBC \
USUARIO.

DSN

Click en el Botn Agregar.


Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Power Builder

Seleccionamos el origen de Datos SQL Server

Power Builder

Agregamos una nueva conexin NEW PROFILE.

Activamos las Opciones:


Con la autentificacin de Windows NT, mediante el ID de autentificacin de Red.
Luego establecer la Base de datos Northwind.

Nos pasamos a la ficha PREVIEW, Probamos la conexin y si es satisfactoria.


Copiamos la lnea de conexin.
Normalmente el objeto transaccin (transaction) se configura y se conecta cuando se
inicia la aplicacin, es decir en el open de la aplicacin. Para hacer esto abra el objeto
aplicacin (file/open/aplication) en el evento open donde est el cdigo de abrir la
ventana inicial, borrelo y remplace por este cdigo:

Luego en adelante pulsar siguiente, probar la conexin de Base de datos y luego aceptar.
Para conectarse desde el PowerScript use la siguiente sintaxis:
Pasos 3.- Desde
PowerBuilder 10

el

Entorno

del

// Profile Venta
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Connectstring='DSN=venta"
Connect using SQLCA;
If Sqlca.Sqlcode=0 then
open(W_Buscar)
else
Messagebox ("Error de Conexin",Sqlca.SqlErrText)
Halt
end if

Ventana DATABASE. Luego obtenemos las


siguientes vistas

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

Lic. Vladimir Cotaquispe Gutirrez.

E.P. DE INGENIERIA DE SISTEMA E INFORMATICA

También podría gustarte