clases...

clases...

Postby goosfancito » Thu Mar 25, 2021 9:19 am

hola

necesito completar estos datos y acceder a ellos desde varias clases (para no usar variables globales)

Code: Select all  Expand view
class TDatos
   data nId
   data cDomicilio
   data cPais
end class


Estando dentro de la clase TPrimera poder hacer esto
Code: Select all  Expand view
o:= TDatos():new()
o:nId:= 1
o:cDomicilio:= "aaaa"
o:cPais:= "Argentina"


y desde la clase TSegunda poder acceder a esos datos e incluso poder cambiarlos
Code: Select all  Expand view
msginfo(nId)
msginfo(cDomicilio)
cPais:= "nuevo pais"
 



Como lo hago? para no usar variables globales.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: clases...

Postby goosfancito » Thu Mar 25, 2021 9:29 am

FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: clases...

Postby Antonio Linares » Thu Mar 25, 2021 10:08 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42059
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: clases...

Postby artu01 » Thu Mar 25, 2021 7:07 pm

password.prg
Code: Select all  Expand view

#INCLUDE "FiveWin.ch"
#INCLUDE "Objects.ch"

create class PassWord
   data cFile
   data cRuta
   data nIntento
   data cMsje

   method new() CONSTRUCTOR

endclass

/* --------------------------------------------------------- */
method new() CLASS PassWord


   ::cPath    := "ruta default"


return self
 


main.prg
Code: Select all  Expand view


 oPassWord := PassWord():new()
oPassWord:cPath:="c:\turuta"

 
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 59 guests